Release 4.0.0-preview1-00051
[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.InteropHelper;
19 using Native = Interop.ScreenMirroring;
20
21 namespace Tizen.Multimedia
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">An internal error occurs.</exception>
40         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
41         public ScreenMirroringAudioCodec Codec
42         {
43             get
44             {
45                 GetValue(Native.GetNegotiatedAudioCodec, _owner.Handle, out ScreenMirroringAudioCodec value).
46                     ThrowIfError("Failed to get audio codec.");
47
48                 return value;
49             }
50         }
51
52         /// <summary>
53         /// Gets the negotiated audio channels.
54         /// </summary>
55         /// <exception cref="InvalidOperationException">An internal error occurs.</exception>
56         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
57         public int Channels
58         {
59             get
60             {
61                 GetValue(Native.GetNegotiatedAudioChannel, _owner.Handle, out int value).
62                     ThrowIfError("Failed to get audio channels.");
63
64                 return value;
65             }
66         }
67
68         /// <summary>
69         /// Gets the negotiated audio sample 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 SampleRate
74         {
75             get
76             {
77                 GetValue(Native.GetNegotiatedAudioSampleRate, _owner.Handle, out int value).
78                     ThrowIfError("Failed to get audio sample rate.");
79
80                 return value;
81             }
82         }
83
84         /// <summary>
85         /// Gets the negotiated audio bit width.
86         /// </summary>
87         /// <exception cref="InvalidOperationException">An internal error occurs.</exception>
88         /// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
89         public int BitWidth
90         {
91             get
92             {
93                 GetValue(Native.GetNegotiatedAudioBitwidth, _owner.Handle, out int value).
94                     ThrowIfError("Failed to get audio bit width.");
95
96                 return value;
97             }
98         }
99     }
100 }