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 file source.
28 /// The media storage privilege(http://tizen.org/privilege/mediastorage) is required.<br/>
29 /// The external storage privilege(http://tizen.org/privilege/externalstorage) is required.
31 /// <seealso cref="WebRTC.AddSource"/>
32 /// <seealso cref="WebRTC.AddSources"/>
33 /// <since_tizen> 9 </since_tizen>
34 [EditorBrowsable(EditorBrowsableState.Never)]
35 public sealed class MediaFileSource : MediaSource
40 /// Initializes a new instance of the <see cref="MediaFileSource"/> class.
42 /// <param name="type">The <see cref="MediaType"/> of file source.</param>
43 /// <param name="path">The file path.</param>
44 /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
45 /// <since_tizen> 9 </since_tizen>
46 [EditorBrowsable(EditorBrowsableState.Never)]
47 public MediaFileSource(MediaType type, string path) : base(type)
49 _path = path ?? throw new ArgumentNullException(nameof(path), "path is null");
52 internal override void OnAttached(WebRTC webRtc)
54 Debug.Assert(webRtc != null);
58 throw new InvalidOperationException("The source is has already been assigned to another WebRTC.");
61 NativeWebRTC.AddMediaSource(webRtc.Handle, MediaSourceType.File, out uint sourceId).
62 ThrowIfFailed("Failed to add MediaFileSource.");
64 NativeWebRTC.SetFileSourcePath(webRtc.Handle, sourceId, _path).
65 ThrowIfFailed("Failed to set path for MediaFileSource.");
71 internal override void OnDetached(WebRTC webRtc)
73 NativeWebRTC.RemoveMediaSource(webRtc.Handle, SourceId.Value).
74 ThrowIfFailed("Failed to remove MediaFileSource.");