2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
19 using System.Diagnostics;
20 using NativeWebRTC = Interop.NativeWebRTC;
22 namespace Tizen.Multimedia.Remoting
25 /// Represents a audio, video custom source.
27 /// <seealso cref="WebRTC.AddSource"/>
28 /// <seealso cref="WebRTC.AddSources"/>
29 /// <since_tizen> 9 </since_tizen>
30 [EditorBrowsable(EditorBrowsableState.Never)]
31 public sealed class MediaCustomSource : MediaSource
34 /// Initializes a new instance of the <see cref="MediaCustomSource"/> class.
36 /// <since_tizen> 9 </since_tizen>
37 [EditorBrowsable(EditorBrowsableState.Never)]
38 public MediaCustomSource(MediaType type) : base(type) {}
40 internal override void OnAttached(WebRTC webRtc)
42 Debug.Assert(webRtc != null);
46 throw new InvalidOperationException("The source is has already been assigned to another WebRTC.");
49 var type = MediaType == MediaType.Video ? CustomMediaSourceType.Video : CustomMediaSourceType.Audio;
51 NativeWebRTC.AddCustomMediaSource(webRtc.Handle, type, out uint sourceId).
52 ThrowIfFailed($"Failed to add {MediaType.ToString()} MediaCustomSource.");
58 internal override void OnDetached(WebRTC webRtc)
60 NativeWebRTC.RemoveMediaSource(webRtc.Handle, SourceId.Value).
61 ThrowIfFailed($"Failed to remove {MediaType.ToString()} MediaCustomSource.");