Release 4.0.0-preview1-00172
[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     public class AudioInfo : MediaInfo
26     {
27         internal AudioInfo(Interop.MediaInfoHandle handle) : base(handle)
28         {
29             IntPtr audioHandle = IntPtr.Zero;
30
31             try
32             {
33                 Interop.MediaInfo.GetAudio(handle, out audioHandle).ThrowIfError("Failed to retrieve data");
34
35                 Debug.Assert(audioHandle != IntPtr.Zero);
36
37                 Album = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetAlbum);
38                 Artist = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetArtist);
39                 AlbumArtist = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetAlbumArtist);
40                 Genre = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetGenre);
41                 Composer = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetComposer);
42                 Year = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetYear);
43                 DateRecorded = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetRecordedDate);
44                 Copyright = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetCopyright);
45                 TrackNumber = InteropHelper.GetString(audioHandle, Interop.AudioInfo.GetTrackNum);
46
47                 BitRate = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetBitRate);
48                 BitPerSample = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetBitPerSample);
49                 SampleRate = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetSampleRate);
50                 Channels = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetChannel);
51
52                 Duration = InteropHelper.GetValue<int>(audioHandle, Interop.AudioInfo.GetDuration);
53             }
54             finally
55             {
56                 Interop.AudioInfo.Destroy(audioHandle);
57             }
58         }
59
60         /// <summary>
61         /// Gets the album name.
62         /// </summary>
63         /// <value>The album from the metadata.</value>
64         public string Album { get; }
65
66         /// <summary>
67         /// Gets the artist name.
68         /// </summary>
69         /// <value>The artist from the metadata.</value>
70         public string Artist { get; }
71
72         /// <summary>
73         /// Gets the album artist name.
74         /// </summary>
75         /// <value>The album artist from the metadata.</value>
76         public string AlbumArtist { get; }
77
78         /// <summary>
79         /// Gets the genre.
80         /// </summary>
81         /// <value>The genre from the metadata.</value>
82         public string Genre { get; }
83
84         /// <summary>
85         /// Gets the composer.
86         /// </summary>
87         /// <value>The composer from the metadata.</value>
88         public string Composer { get; }
89
90         /// <summary>
91         /// Gets the year.
92         /// </summary>
93         /// <value>The year from the metadata.</value>
94         public string Year { get; }
95
96         /// <summary>
97         /// Gets the recorded date.
98         /// </summary>
99         /// <value>The recorded date from the metadata.</value>
100         public string DateRecorded { get; }
101
102         /// <summary>
103         /// Gets the copyright.
104         /// </summary>
105         /// <value>The copyright from the metadata.</value>
106         public string Copyright { get; }
107
108         /// <summary>
109         /// Gets the track number.
110         /// </summary>
111         /// <value>The track number from the metadata.</value>
112         public string TrackNumber { get; }
113
114         /// <summary>
115         /// Gets the bit rate in bit per second.
116         /// </summary>
117         /// <value>The bit rate in bit per second.</value>
118         public int BitRate { get; }
119
120         /// <summary>
121         /// Gets the bit per sample.
122         /// </summary>
123         /// <value>The bit per sample.</value>
124         public int BitPerSample { get; }
125
126         /// <summary>
127         /// Gets the sample rate in hertz.
128         /// </summary>
129         /// <value>The sample rate in hertz.</value>
130         public int SampleRate { get; }
131
132         /// <summary>
133         /// Gets the number of channels.
134         /// </summary>
135         /// <value>The number of channels.</value>
136         public int Channels { get; }
137
138         /// <summary>
139         /// Gets the track duration in milliseconds.
140         /// </summary>
141         /// <value>The track duration in milliseconds.</value>
142         public int Duration { get; }
143     }
144 }