Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Remoting / ScreenMirroring / ScreenMirroringVideoInfo.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using static Tizen.Multimedia.InteropHelper;
19 using Native = Interop.ScreenMirroring;
20
21 namespace Tizen.Multimedia
22 {
23     /// <summary>
24     /// Provides a means to retrieve the video information which is negotiated with the source device.
25     /// </summary>
26     public class ScreenMirroringVideoInfo
27     {
28         private readonly ScreenMirroring _owner;
29
30         internal ScreenMirroringVideoInfo(ScreenMirroring owner)
31         {
32             _owner = owner;
33         }
34
35         /// <summary>
36         /// Gets the negotiated video codec.
37         /// </summary>
38         /// <exception cref="InvalidOperationException">An internal error occurs.</exception>
39         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
40         public ScreenMirroringVideoCodec Codec
41         {
42             get
43             {
44                 GetValue(Native.GetNegotiatedVideoCodec, _owner.Handle, out ScreenMirroringVideoCodec value).
45                     ThrowIfError("Failed to get video codec.");
46
47                 return value;
48             }
49         }
50
51         /// <summary>
52         /// Gets the negotiated video resolution.
53         /// </summary>
54         /// <exception cref="InvalidOperationException">An internal error occurs.</exception>
55         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
56         public Size Resolution
57         {
58             get
59             {
60                 var handle = _owner.Handle;
61                 Native.GetNegotiatedVideoResolution(ref handle, out var width, out var height).
62                     ThrowIfError("Failed to get resolution.");
63
64                 return new Size(width, height);
65             }
66         }
67
68         /// <summary>
69         /// Gets the negotiated video frame rate.
70         /// </summary>
71         /// <exception cref="InvalidOperationException">An internal error occurs.</exception>
72         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
73         public int FrameRate
74         {
75             get
76             {
77                 GetValue(Native.GetNegotiatedVideoFrameRate, _owner.Handle, out int value).
78                     ThrowIfError("Failed to get video frame rate.");
79
80                 return value;
81             }
82         }
83     }
84 }