87f0d629fa296ff5d517f61b5755790304fb10fe
[platform/core/csapi/tizenfx.git] / src / Tizen.Content.MediaContent / Tizen.Content.MediaContent / AudioInfo.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 System.Diagnostics;
19
20 namespace Tizen.Content.MediaContent
21 {
22     /// <summary>
23     /// Represents the audio media information.
24     /// </summary>
25     /// <since_tizen> 4 </since_tizen>
26     public class AudioInfo : MediaInfo
27     {
28         internal AudioInfo(Interop.MediaInfoHandle handle) : base(handle)
29         {
30             IntPtr audioHandle = IntPtr.Zero;
31
32             try
33             {
34                 Interop.MediaInfo.GetAudio(handle, out audioHandle).ThrowIfError("Failed to retrieve data");
35
36                 Debug.Assert(audioHandle != IntPtr.Zero);
37
38                 Album = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetAlbum);
39                 Artist = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetArtist);
40                 AlbumArtist = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetAlbumArtist);
41                 Genre = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetGenre);
42                 Composer = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetComposer);  // Deprecated since API12
43                 Year = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetYear);
44                 DateRecorded = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetRecordedDate); // Deprecated since API12
45                 Copyright = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetCopyright); // Deprecated since API12
46                 TrackNumber = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetTrackNum);
47
48                 BitRate = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetBitRate); // Deprecated since API12
49                 BitPerSample = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetBitPerSample); // Deprecated since API12
50                 SampleRate = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetSampleRate); // Deprecated since API12
51                 Channels = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetChannel); // Deprecated since API12
52
53                 Duration = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetDuration); // Deprecated since API12
54             }
55             finally
56             {
57                 Interop.AudioInfo.Destroy(audioHandle);
58             }
59         }
60
61         /// <summary>
62         /// Gets the album name.
63         /// </summary>
64         /// <value>The album from the metadata.</value>
65         /// <since_tizen> 4 </since_tizen>
66         public string Album { get; }
67
68         /// <summary>
69         /// Gets the artist name.
70         /// </summary>
71         /// <value>The artist from the metadata.</value>
72         /// <since_tizen> 4 </since_tizen>
73         public string Artist { get; }
74
75         /// <summary>
76         /// Gets the album artist name.
77         /// </summary>
78         /// <value>The album artist from the metadata.</value>
79         /// <since_tizen> 4 </since_tizen>
80         public string AlbumArtist { get; }
81
82         /// <summary>
83         /// Gets the genre.
84         /// </summary>
85         /// <value>The genre from the metadata.</value>
86         /// <since_tizen> 4 </since_tizen>
87         public string Genre { get; }
88
89         /// <summary>
90         /// Gets the composer.
91         /// </summary>
92         /// <value>The composer from the metadata.</value>
93         /// <since_tizen> 4 </since_tizen>
94         [Obsolete("Deprecated since API12; Will be removed in API14.")]
95         public string Composer { get; }
96
97         /// <summary>
98         /// Gets the year.
99         /// </summary>
100         /// <value>The year from the metadata.</value>
101         /// <since_tizen> 4 </since_tizen>
102         public string Year { get; }
103
104         /// <summary>
105         /// Gets the recorded date.
106         /// </summary>
107         /// <value>The recorded date from the metadata.</value>
108         /// <since_tizen> 4 </since_tizen>
109         [Obsolete("Deprecated since API12; Will be removed in API14.")]
110         public string DateRecorded { get; }
111
112         /// <summary>
113         /// Gets the copyright.
114         /// </summary>
115         /// <value>The copyright from the metadata.</value>
116         /// <since_tizen> 4 </since_tizen>
117         [Obsolete("Deprecated since API12; Will be removed in API14.")]
118         public string Copyright { get; }
119
120         /// <summary>
121         /// Gets the track number.
122         /// </summary>
123         /// <value>The track number from the metadata.</value>
124         /// <since_tizen> 4 </since_tizen>
125         public string TrackNumber { get; }
126
127         /// <summary>
128         /// Gets the bit rate in bit per second.
129         /// </summary>
130         /// <value>The bit rate in bit per second.</value>
131         /// <since_tizen> 4 </since_tizen>
132         [Obsolete("Deprecated since API12; Will be removed in API14.")]
133         public int BitRate { get; }
134
135         /// <summary>
136         /// Gets the bit per sample.
137         /// </summary>
138         /// <value>The bit per sample.</value>
139         /// <since_tizen> 4 </since_tizen>
140         [Obsolete("Deprecated since API12; Will be removed in API14.")]
141         public int BitPerSample { get; }
142
143         /// <summary>
144         /// Gets the sample rate in hertz.
145         /// </summary>
146         /// <value>The sample rate in hertz.</value>
147         /// <since_tizen> 4 </since_tizen>
148         [Obsolete("Deprecated since API12; Will be removed in API14.")]
149         public int SampleRate { get; }
150
151         /// <summary>
152         /// Gets the number of channels.
153         /// </summary>
154         /// <value>The number of channels.</value>
155         /// <since_tizen> 4 </since_tizen>
156         [Obsolete("Deprecated since API12; Will be removed in API14.")]
157         public int Channels { get; }
158
159         /// <summary>
160         /// Gets the track duration in milliseconds.
161         /// </summary>
162         /// <value>The track duration in milliseconds.</value>
163         /// <since_tizen> 4 </since_tizen>
164         [Obsolete("Deprecated since API12; Will be removed in API14.")]
165         public int Duration { get; }
166     }
167 }