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.Diagnostics;
19 using NativeWebRTC = Interop.NativeWebRTC;
21 namespace Tizen.Multimedia.Remoting
24 /// Represents a screen source.
26 /// <seealso cref="WebRTC.AddSource"/>
27 /// <seealso cref="WebRTC.AddSources"/>
28 /// <since_tizen> 9 </since_tizen>
29 public sealed class MediaScreenSource : MediaSource
32 /// Initializes a new instance of the <see cref="MediaScreenSource"/> class.
34 /// <since_tizen> 9 </since_tizen>
35 public MediaScreenSource() : base(MediaType.Video) {}
37 internal override void OnAttached(WebRTC webRtc)
39 Debug.Assert(webRtc != null);
43 throw new InvalidOperationException("The source is has already been assigned to another WebRTC.");
46 NativeWebRTC.AddMediaSource(webRtc.Handle, MediaSourceType.Screen, out uint sourceId).
47 ThrowIfFailed("Failed to add MediaScreenSource.");
53 internal override void OnDetached(WebRTC webRtc)
55 NativeWebRTC.RemoveMediaSource(webRtc.Handle, SourceId.Value).
56 ThrowIfFailed("Failed to remove MediaScreenSource.");