2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Diagnostics;
19 using static Interop.MetadataExtractor;
21 namespace Tizen.Multimedia
24 /// Represents the video metadata information.
26 public class VideoMetadata
28 private VideoMetadata(int streamCount, IntPtr handle)
30 Debug.Assert(streamCount > 0);
31 Debug.Assert(handle != IntPtr.Zero);
33 StreamCount = streamCount;
34 BitRate = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.VideoBitrate));
35 Fps = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.VideoFps));
36 Width = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.VideoWidth));
37 Height = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.VideoHeight));
38 Codec = GetMetadata(handle, MetadataExtractorAttr.VideoCodec);
40 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
43 internal static VideoMetadata From(IntPtr handle)
45 var streamCount = ValueConverter.ToInt(GetMetadata(handle, MetadataExtractorAttr.VideoStreamCount));
47 return streamCount > 0 ? new VideoMetadata(streamCount, handle) : null;
53 /// <since_tizen> 3 </since_tizen>
54 /// <value>The bitrate value, or null if the information does not exist.</value>
55 public int? BitRate { get; }
58 /// Gets the video fps.
60 /// <since_tizen> 3 </since_tizen>
61 /// <value>The fps value, or null if the information does not exist.</value>
62 public int? Fps { get; }
65 /// Gets the width of the video.
67 /// <since_tizen> 3 </since_tizen>
68 /// <value>The width value, or null if the information does not exist.</value>
69 public int? Width { get; }
72 /// Gets the height of the video.
74 /// <since_tizen> 3 </since_tizen>
75 /// <value>The height value, or null if the information does not exist.</value>
76 public int? Height { get; }
79 /// Gets the codec type of the video.
81 /// <since_tizen> 3 </since_tizen>
82 /// <value>A string representing the codec type, or null if the information does not exist.</value>
83 public string Codec { get; }
86 /// Gets the video stream count.
88 /// <since_tizen> 3 </since_tizen>
89 /// <value>The number of video streams.</value>
90 public int StreamCount { get; }
92 private Lazy<string> _description;
94 public override string ToString()
96 return _description.Value;
102 /// Represents the audio metadata information.
104 public class AudioMetadata
106 private AudioMetadata(int streamCount, IntPtr handle)
108 Debug.Assert(streamCount > 0);
109 Debug.Assert(handle != IntPtr.Zero);
111 StreamCount = streamCount;
112 BitRate = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.AudioBitrate));
113 Channels = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.AudioChannels));
114 SampleRate = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.AudioSamplerate));
115 BitPerSample = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.AudioBitPerSample));
116 Codec = GetMetadata(handle, MetadataExtractorAttr.AudioCodec);
118 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
121 internal static AudioMetadata From(IntPtr handle)
123 var streamCount = ValueConverter.ToInt(GetMetadata(handle, MetadataExtractorAttr.AudioStreamCount));
125 return streamCount > 0 ? new AudioMetadata(streamCount, handle) : null;
129 /// Gets the audio bitrate.
131 /// <since_tizen> 3 </since_tizen>
132 /// <value>The bit rate value, or null if the information does not exist.</value>
133 public int? BitRate { get; }
136 /// Gets the audio channels.
138 /// <since_tizen> 3 </since_tizen>
139 /// <value>The number of the audio channels, or null if the information does not exist.</value>
140 public int? Channels { get; }
143 /// Gets the audio sample rate.
145 /// <since_tizen> 3 </since_tizen>
146 /// <value>The sample rate, or null if the information does not exist.</value>
147 public int? SampleRate { get; }
150 /// Gets the bit per sample of the audio.
152 /// <since_tizen> 3 </since_tizen>
153 /// <value>The bit per sample, or null if the information does not exist.</value>
154 public int? BitPerSample { get; }
157 /// Gets the audio stream count.
159 /// <since_tizen> 3 </since_tizen>
160 /// <value>The number of audio streams.</value>
161 public int StreamCount { get; }
164 /// Gets the audio codec type.
166 /// <since_tizen> 3 </since_tizen>
167 public string Codec { get; }
169 private Lazy<string> _description;
171 public override string ToString()
173 return _description.Value;
178 /// Represents the metadata information of a media.
180 public class Metadata
182 internal Metadata(IntPtr handle)
184 Debug.Assert(handle != IntPtr.Zero);
186 Video = VideoMetadata.From(handle);
187 Audio = AudioMetadata.From(handle);
189 Duration = ValueConverter.ToNullableInt(GetMetadata(handle, MetadataExtractorAttr.Duration));
190 Artist = GetMetadata(handle, MetadataExtractorAttr.Artist);
191 Title = GetMetadata(handle, MetadataExtractorAttr.Title);
192 Album = GetMetadata(handle, MetadataExtractorAttr.Album);
193 AlbumArtist = GetMetadata(handle, MetadataExtractorAttr.AlbumArtist);
194 Genre = GetMetadata(handle, MetadataExtractorAttr.Genre);
195 Author = GetMetadata(handle, MetadataExtractorAttr.Author);
196 Copyright = GetMetadata(handle, MetadataExtractorAttr.Copyright);
197 DateReleased = GetMetadata(handle, MetadataExtractorAttr.ReleaseDate);
198 Description = GetMetadata(handle, MetadataExtractorAttr.Description);
199 Comment = GetMetadata(handle, MetadataExtractorAttr.Comment);
200 TrackNumber = GetMetadata(handle, MetadataExtractorAttr.TrackNum);
201 Classification = GetMetadata(handle, MetadataExtractorAttr.Classification);
202 Rating = GetMetadata(handle, MetadataExtractorAttr.Rating);
203 Longitude = ValueConverter.ToNullableDouble(GetMetadata(handle, MetadataExtractorAttr.Longitude));
204 Latitude = ValueConverter.ToNullableDouble(GetMetadata(handle, MetadataExtractorAttr.Latitude));
205 Altitude = ValueConverter.ToNullableDouble(GetMetadata(handle, MetadataExtractorAttr.Altitude));
206 Conductor = GetMetadata(handle, MetadataExtractorAttr.Conductor);
207 UnsyncLyrics = GetMetadata(handle, MetadataExtractorAttr.UnSyncLyrics);
208 SyncLyricsCount = ValueConverter.ToInt(GetMetadata(handle, MetadataExtractorAttr.SyncLyricsNum));
209 DateRecorded = GetMetadata(handle, MetadataExtractorAttr.RecordingDate);
210 Rotation = GetMetadata(handle, MetadataExtractorAttr.Rotate);
211 Content360 = GetMetadata(handle, MetadataExtractorAttr.ContentFor360);
213 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
217 /// Gets the duration of the media.
219 /// <since_tizen> 3 </since_tizen>
220 /// <value>The duration value, or null if the information does not exist.</value>
221 public int? Duration { get; }
224 /// Gets the video metadata.
226 /// <since_tizen> 3 </since_tizen>
227 /// <value>The video metadata, or null if the information does not exist.</value>
228 public VideoMetadata Video { get; }
231 /// Gets the audio metadata.
233 /// <since_tizen> 3 </since_tizen>
234 /// <value>The audio metadata, or null if the information does not exist.</value>
235 public AudioMetadata Audio { get; }
238 /// Gets the artist of the media.
240 /// <since_tizen> 3 </since_tizen>
241 /// <value>A string representing the artist, or null if the information does not exist.</value>
242 public string Artist { get; }
245 /// Gets the title of the media.
247 /// <since_tizen> 3 </since_tizen>
248 /// <value>A string representing the title, or null if the information does not exist.</value>
249 public string Title { get; }
252 /// Gets the album name of the media.
254 /// <since_tizen> 3 </since_tizen>
255 /// <value>A string representing the album name, or null if the information does not exist.</value>
256 public string Album { get; }
259 /// Gets the album artist of the media.
261 /// <since_tizen> 3 </since_tizen>
262 /// <value>A string representing the album artist, or null if the information does not exist.</value>
263 public string AlbumArtist { get; }
266 /// Gets the genre of the media.
268 /// <since_tizen> 3 </since_tizen>
269 /// <value>A string representing the genre, or null if the information does not exist.</value>
270 public string Genre { get; }
273 /// Gets the author of the media.
275 /// <since_tizen> 3 </since_tizen>
276 /// <value>A string representing the author, or null if the information does not exist.</value>
277 public string Author { get; }
280 /// Gets the copyright of the media.
282 /// <since_tizen> 3 </since_tizen>
283 /// <value>A string representing the copyright, or null if the information does not exist.</value>
284 public string Copyright { get; }
287 /// Gets the release date of the media.
289 /// <since_tizen> 3 </since_tizen>
290 /// <value>A string representing the release date, or null if the information does not exist.</value>
291 public string DateReleased { get; }
294 /// Gets the description of the media.
296 /// <since_tizen> 3 </since_tizen>
297 /// <value>A string representing the description, or null if the information does not exist.</value>
298 public string Description { get; }
301 /// Gets the comment of the media.
303 /// <since_tizen> 3 </since_tizen>
304 /// <value>A string representing the comment, or null if the information does not exist.</value>
305 public string Comment { get; }
308 /// Gets the track number of the media.
310 /// <since_tizen> 3 </since_tizen>
311 /// <value>A string representing the track number, or null if the information does not exist.</value>
312 public string TrackNumber { get; }
315 /// Gets the classification of the media.
317 /// <since_tizen> 3 </since_tizen>
318 /// <value>A string representing the classification, or null if the information does not exist.</value>
319 public string Classification { get; }
322 /// Gets the rating of the media.
324 /// <since_tizen> 3 </since_tizen>
325 /// <value>A string representing the rating, or null if the information does not exist.</value>
326 public string Rating { get; }
329 /// Gets the longitude of the media.
331 /// <since_tizen> 3 </since_tizen>
332 /// <value>The longitude value, or null if the information does not exist.</value>
333 public double? Longitude { get; }
336 /// Gets the latitude of the media.
338 /// <since_tizen> 3 </since_tizen>
339 /// <value>The latitude value, or null if the information does not exist.</value>
340 public double? Latitude { get; }
343 /// Gets the altitude of the media.
345 /// <since_tizen> 3 </since_tizen>
346 /// <value>The altitude value, or null if the information does not exist.</value>
347 public double? Altitude { get; }
350 /// Gets the conductor of the media.
352 /// <since_tizen> 3 </since_tizen>
353 /// <value>A string representing the conductor, or null if the information does not exist.</value>
354 public string Conductor { get; }
357 /// Gets the unsynchronized lyrics of the media.
359 /// <since_tizen> 3 </since_tizen>
360 /// <value>A string representing the unsynchronized lyrics, or null if the information does not exist.</value>
361 public string UnsyncLyrics { get; }
364 /// Gets the number of synchronized lyrics of the media.
366 /// <since_tizen> 3 </since_tizen>
367 /// <value>The number of the synchronized lyrics.</value>
368 public int SyncLyricsCount { get; }
371 /// Gets the recording date of the media.
373 /// <since_tizen> 3 </since_tizen>
374 /// <value>A string representing the recording date, or null if the information does not exist.</value>
375 public string DateRecorded { get; }
378 /// Gets the rotate(orientation) information of the media.
380 /// <since_tizen> 3 </since_tizen>
381 /// <value>A string representing the rotation information, or null if the information does not exist.</value>
382 public string Rotation { get; }
385 /// Gets the information for 360 content of the media.
387 /// <since_tizen> 3 </since_tizen>
388 /// <value>A string representing the information for 360 content, or null if the information does not exist.</value>
389 public string Content360 { get; }
391 private Lazy<string> _description;
393 public override string ToString()
395 return _description.Value;