[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_remove_media_source")]
internal static extern WebRTCErrorCode RemoveMediaSource(IntPtr handle, uint sourceId);
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_camera_source_set_device_id")]
+ internal static extern WebRTCErrorCode SetCameraDeviceId(IntPtr handle, uint sourceId, uint deviceId);
+
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_camera_source_get_device_id")]
+ internal static extern WebRTCErrorCode GetCameraDeviceId(IntPtr handle, uint sourceId, out uint deviceId);
+
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_packet_source_set_format")]
internal static extern WebRTCErrorCode SetMediaPacketSourceInfo(IntPtr handle, uint sourceId, IntPtr packet);
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_get_mute")]
internal static extern WebRTCErrorCode GetMute(IntPtr handle, uint sourceId, MediaType type, out bool mute);
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_set_encoder_bitrate")]
+ internal static extern WebRTCErrorCode SetEncoderBitrate(IntPtr handle, uint sourceId, MediaType type, int bitrate);
+
+ [DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_get_encoder_bitrate")]
+ internal static extern WebRTCErrorCode GetEncoderBitrate(IntPtr handle, uint sourceId, MediaType type, out int bitrate);
+
[DllImport(Libraries.WebRTC, EntryPoint = "webrtc_media_source_set_video_resolution")]
internal static extern WebRTCErrorCode SetVideoResolution(IntPtr handle, uint sourceId, int width, int height);
/// <since_tizen> 9 </since_tizen>
public MediaCameraSource() : base(MediaType.Video) {}
+ /// <summary>
+ /// Gets or sets the camera device id.
+ /// </summary>
+ /// <value>A value that specifies the camera device id.</value>
+ /// <exception cref="InvalidOperationException">MediaSource is not attached yet.</exception>
+ /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+ /// <since_tizen> 10 </since_tizen>
+ public uint CameraDeviceId
+ {
+ get
+ {
+ if (!SourceId.HasValue)
+ {
+ throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+ }
+
+ NativeWebRTC.GetCameraDeviceId(WebRtc.Handle, SourceId.Value, out uint deviceId).
+ ThrowIfFailed("Failed to get camera device id");
+
+ return deviceId;
+ }
+ set
+ {
+ if (!SourceId.HasValue)
+ {
+ throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+ }
+
+ NativeWebRTC.SetCameraDeviceId(WebRtc.Handle, SourceId.Value, value).
+ ThrowIfFailed("Failed to set camera device id");
+ }
+ }
+
internal override void OnAttached(WebRTC webRtc)
{
Debug.Assert(webRtc != null);
}
/// <summary>
+ /// Gets or sets the encoder bitrate of the current media source.
+ /// </summary>
+ /// <remarks>
+ /// This API is not supported in <see cref="MediaFileSource"/>, <see cref="MediaPacketSource"/>.<br/>
+ /// </remarks>
+ /// <value>A value that specifies the encoder bitrate.</value>
+ /// <exception cref="ArgumentException">EncoderBitrate is less than or equal to zero.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// MediaSource is not attached yet.<br/>
+ /// -or-<br/>
+ /// This MediaSource is not Video.
+ /// -or-<br/>
+ /// This MediaSource is not supported type of MediaSource.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The WebRTC has already been disposed.</exception>
+ /// <since_tizen> 10 </since_tizen>
+ public int EncoderBitrate
+ {
+ get
+ {
+ if (!SourceId.HasValue)
+ {
+ throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+ }
+ if (this is MediaFileSource || this is MediaPacketSource)
+ {
+ throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+ }
+
+ NativeWebRTC.GetEncoderBitrate(WebRtc.Handle, SourceId.Value, MediaType, out int bitrate).
+ ThrowIfFailed("Failed to get encoder bitrate");
+
+ return bitrate;
+ }
+ set
+ {
+ if (value <= 0)
+ {
+ throw new ArgumentException($"EncoderBitrate should be greater than zero.");
+ }
+ if (!SourceId.HasValue)
+ {
+ throw new InvalidOperationException("MediaSource is not attached yet. Call AddSource() first.");
+ }
+ if (this is MediaFileSource || this is MediaPacketSource)
+ {
+ throw new InvalidOperationException($"This property is not supported in {this.GetType()}.");
+ }
+
+ NativeWebRTC.SetEncoderBitrate(WebRtc.Handle, SourceId.Value, MediaType, value).
+ ThrowIfFailed("Failed to set encoder bitrate");
+ }
+ }
+
+ /// <summary>
/// Enables the audio loopback. The local audio will be played with <paramref name="policy"/>.
/// </summary>
/// <param name="policy">The <see cref="AudioStreamPolicy"/> to apply.</param>