Release 4.0.0-preview1-00253
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Remoting / ScreenMirroring / ScreenMirroringAudioInfo.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.Remoting.InteropHelper;
19 using Native = Interop.ScreenMirroring;
20
21 namespace Tizen.Multimedia.Remoting
22 {
23     /// <summary>
24     /// Provides a means to retrieve the audio information which is negotiated with the source device.
25     /// </summary>
26     /// <seealso cref="ScreenMirroring"/>
27     public class ScreenMirroringAudioInfo
28     {
29         private readonly ScreenMirroring _owner;
30
31         internal ScreenMirroringAudioInfo(ScreenMirroring owner)
32         {
33             _owner = owner;
34         }
35
36         /// <summary>
37         /// Gets the negotiated audio codec.
38         /// </summary>
39         /// <exception cref="InvalidOperationException">
40         ///     Not connected to a source.\n
41         ///     \n
42         ///     An internal error occurs.
43         /// </exception>
44         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
45         public ScreenMirroringAudioCodec Codec
46         {
47             get
48             {
49                 _owner.ThrowIfNotConnected();
50
51                 GetValue(Native.GetNegotiatedAudioCodec, _owner.Handle, out ScreenMirroringAudioCodec value).
52                     ThrowIfError("Failed to get audio codec.");
53
54                 return value;
55             }
56         }
57
58         /// <summary>
59         /// Gets the negotiated audio channels.
60         /// </summary>
61         /// <exception cref="InvalidOperationException">
62         ///     Not connected to a source.\n
63         ///     \n
64         ///     An internal error occurs.
65         /// </exception>
66         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
67         public int Channels
68         {
69             get
70             {
71                 _owner.ThrowIfNotConnected();
72
73                 GetValue(Native.GetNegotiatedAudioChannel, _owner.Handle, out int value).
74                     ThrowIfError("Failed to get audio channels.");
75
76                 return value;
77             }
78         }
79
80         /// <summary>
81         /// Gets the negotiated audio sample rate.
82         /// </summary>
83         /// <exception cref="InvalidOperationException">
84         ///     Not connected to a source.\n
85         ///     \n
86         ///     An internal error occurs.
87         /// </exception>
88         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
89         public int SampleRate
90         {
91             get
92             {
93                 _owner.ThrowIfNotConnected();
94
95                 GetValue(Native.GetNegotiatedAudioSampleRate, _owner.Handle, out int value).
96                     ThrowIfError("Failed to get audio sample rate.");
97
98                 return value;
99             }
100         }
101
102         /// <summary>
103         /// Gets the negotiated audio bit width.
104         /// </summary>
105         /// <exception cref="InvalidOperationException">
106         ///     Not connected to a source.\n
107         ///     \n
108         ///     An internal error occurs.
109         /// </exception>
110         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
111         public int BitWidth
112         {
113             get
114             {
115                 _owner.ThrowIfNotConnected();
116
117                 GetValue(Native.GetNegotiatedAudioBitwidth, _owner.Handle, out int value).
118                     ThrowIfError("Failed to get audio bit width.");
119
120                 return value;
121             }
122         }
123     }
124 }