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, MetadataExtractor extractor)
30 Debug.Assert(streamCount > 0);
32 StreamCount = streamCount;
33 BitRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoBitrate));
34 Fps = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoFps));
35 Width = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoWidth));
36 Height = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoHeight));
37 Codec = extractor.GetMetadata(MetadataExtractorAttr.VideoCodec);
39 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
42 internal static VideoMetadata From(MetadataExtractor extractor)
44 var streamCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.VideoStreamCount));
46 return streamCount > 0 ? new VideoMetadata(streamCount, extractor) : null;
52 /// <since_tizen> 3 </since_tizen>
53 /// <value>The bitrate value, or null if the information does not exist.</value>
54 public int? BitRate { get; }
57 /// Gets the video fps.
59 /// <since_tizen> 3 </since_tizen>
60 /// <value>The fps value, or null if the information does not exist.</value>
61 public int? Fps { get; }
64 /// Gets the width of the video.
66 /// <since_tizen> 3 </since_tizen>
67 /// <value>The width value, or null if the information does not exist.</value>
68 public int? Width { get; }
71 /// Gets the height of the video.
73 /// <since_tizen> 3 </since_tizen>
74 /// <value>The height value, or null if the information does not exist.</value>
75 public int? Height { get; }
78 /// Gets the codec type of the video.
80 /// <since_tizen> 3 </since_tizen>
81 /// <value>A string representing the codec type, or null if the information does not exist.</value>
82 public string Codec { get; }
85 /// Gets the video stream count.
87 /// <since_tizen> 3 </since_tizen>
88 /// <value>The number of video streams.</value>
89 public int StreamCount { get; }
91 private Lazy<string> _description;
94 /// Returns a string that represents the current object.
96 /// <returns>A string that represents the current object.</returns>
97 public override string ToString() => _description.Value;
101 /// Represents the audio metadata information.
103 public class AudioMetadata
105 private AudioMetadata(int streamCount, MetadataExtractor extractor)
107 Debug.Assert(streamCount > 0);
109 StreamCount = streamCount;
110 BitRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitrate));
111 Channels = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioChannels));
112 SampleRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioSamplerate));
113 BitPerSample = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitPerSample));
114 Codec = extractor.GetMetadata(MetadataExtractorAttr.AudioCodec);
116 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
119 internal static AudioMetadata From(MetadataExtractor extractor)
121 var streamCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.AudioStreamCount));
123 return streamCount > 0 ? new AudioMetadata(streamCount, extractor) : null;
127 /// Gets the audio bitrate.
129 /// <since_tizen> 3 </since_tizen>
130 /// <value>The bit rate value, or null if the information does not exist.</value>
131 public int? BitRate { get; }
134 /// Gets the audio channels.
136 /// <since_tizen> 3 </since_tizen>
137 /// <value>The number of the audio channels, or null if the information does not exist.</value>
138 public int? Channels { get; }
141 /// Gets the audio sample rate.
143 /// <since_tizen> 3 </since_tizen>
144 /// <value>The sample rate, or null if the information does not exist.</value>
145 public int? SampleRate { get; }
148 /// Gets the bit per sample of the audio.
150 /// <since_tizen> 3 </since_tizen>
151 /// <value>The bit per sample, or null if the information does not exist.</value>
152 public int? BitPerSample { get; }
155 /// Gets the audio stream count.
157 /// <since_tizen> 3 </since_tizen>
158 /// <value>The number of audio streams.</value>
159 public int StreamCount { get; }
162 /// Gets the audio codec type.
164 /// <since_tizen> 3 </since_tizen>
165 public string Codec { get; }
167 private Lazy<string> _description;
170 /// Returns a string that represents the current object.
172 /// <returns>A string that represents the current object.</returns>
173 public override string ToString() => _description.Value;
177 /// Represents the metadata information of a media.
179 public class Metadata
181 internal Metadata(MetadataExtractor extractor)
183 Debug.Assert(extractor != null);
185 Video = VideoMetadata.From(extractor);
186 Audio = AudioMetadata.From(extractor);
188 Duration = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.Duration));
189 Artist = extractor.GetMetadata(MetadataExtractorAttr.Artist);
190 Title = extractor.GetMetadata(MetadataExtractorAttr.Title);
191 Album = extractor.GetMetadata(MetadataExtractorAttr.Album);
192 AlbumArtist = extractor.GetMetadata(MetadataExtractorAttr.AlbumArtist);
193 Genre = extractor.GetMetadata(MetadataExtractorAttr.Genre);
194 Author = extractor.GetMetadata(MetadataExtractorAttr.Author);
195 Copyright = extractor.GetMetadata(MetadataExtractorAttr.Copyright);
196 DateReleased = extractor.GetMetadata(MetadataExtractorAttr.ReleaseDate);
197 Description = extractor.GetMetadata(MetadataExtractorAttr.Description);
198 Comment = extractor.GetMetadata(MetadataExtractorAttr.Comment);
199 TrackNumber = extractor.GetMetadata(MetadataExtractorAttr.TrackNum);
200 Classification = extractor.GetMetadata(MetadataExtractorAttr.Classification);
201 Rating = extractor.GetMetadata(MetadataExtractorAttr.Rating);
202 Longitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Longitude));
203 Latitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Latitude));
204 Altitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Altitude));
205 Conductor = extractor.GetMetadata(MetadataExtractorAttr.Conductor);
206 UnsyncLyrics = extractor.GetMetadata(MetadataExtractorAttr.UnSyncLyrics);
207 SyncLyricsCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.SyncLyricsNum));
208 DateRecorded = extractor.GetMetadata(MetadataExtractorAttr.RecordingDate);
209 Rotation = extractor.GetMetadata(MetadataExtractorAttr.Rotate);
210 Content360 = extractor.GetMetadata(MetadataExtractorAttr.ContentFor360);
212 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
216 /// Gets the duration of the media.
218 /// <since_tizen> 3 </since_tizen>
219 /// <value>The duration value, or null if the information does not exist.</value>
220 public int? Duration { get; }
223 /// Gets the video metadata.
225 /// <since_tizen> 3 </since_tizen>
226 /// <value>The video metadata, or null if the information does not exist.</value>
227 public VideoMetadata Video { get; }
230 /// Gets the audio metadata.
232 /// <since_tizen> 3 </since_tizen>
233 /// <value>The audio metadata, or null if the information does not exist.</value>
234 public AudioMetadata Audio { get; }
237 /// Gets the artist of the media.
239 /// <since_tizen> 3 </since_tizen>
240 /// <value>A string representing the artist, or null if the information does not exist.</value>
241 public string Artist { get; }
244 /// Gets the title of the media.
246 /// <since_tizen> 3 </since_tizen>
247 /// <value>A string representing the title, or null if the information does not exist.</value>
248 public string Title { get; }
251 /// Gets the album name of the media.
253 /// <since_tizen> 3 </since_tizen>
254 /// <value>A string representing the album name, or null if the information does not exist.</value>
255 public string Album { get; }
258 /// Gets the album artist of the media.
260 /// <since_tizen> 3 </since_tizen>
261 /// <value>A string representing the album artist, or null if the information does not exist.</value>
262 public string AlbumArtist { get; }
265 /// Gets the genre of the media.
267 /// <since_tizen> 3 </since_tizen>
268 /// <value>A string representing the genre, or null if the information does not exist.</value>
269 public string Genre { get; }
272 /// Gets the author of the media.
274 /// <since_tizen> 3 </since_tizen>
275 /// <value>A string representing the author, or null if the information does not exist.</value>
276 public string Author { get; }
279 /// Gets the copyright of the media.
281 /// <since_tizen> 3 </since_tizen>
282 /// <value>A string representing the copyright, or null if the information does not exist.</value>
283 public string Copyright { get; }
286 /// Gets the release date of the media.
288 /// <since_tizen> 3 </since_tizen>
289 /// <value>A string representing the release date, or null if the information does not exist.</value>
290 public string DateReleased { get; }
293 /// Gets the description of the media.
295 /// <since_tizen> 3 </since_tizen>
296 /// <value>A string representing the description, or null if the information does not exist.</value>
297 public string Description { get; }
300 /// Gets the comment of the media.
302 /// <since_tizen> 3 </since_tizen>
303 /// <value>A string representing the comment, or null if the information does not exist.</value>
304 public string Comment { get; }
307 /// Gets the track number of the media.
309 /// <since_tizen> 3 </since_tizen>
310 /// <value>A string representing the track number, or null if the information does not exist.</value>
311 public string TrackNumber { get; }
314 /// Gets the classification of the media.
316 /// <since_tizen> 3 </since_tizen>
317 /// <value>A string representing the classification, or null if the information does not exist.</value>
318 public string Classification { get; }
321 /// Gets the rating of the media.
323 /// <since_tizen> 3 </since_tizen>
324 /// <value>A string representing the rating, or null if the information does not exist.</value>
325 public string Rating { get; }
328 /// Gets the longitude of the media.
330 /// <since_tizen> 3 </since_tizen>
331 /// <value>The longitude value, or null if the information does not exist.</value>
332 public double? Longitude { get; }
335 /// Gets the latitude of the media.
337 /// <since_tizen> 3 </since_tizen>
338 /// <value>The latitude value, or null if the information does not exist.</value>
339 public double? Latitude { get; }
342 /// Gets the altitude of the media.
344 /// <since_tizen> 3 </since_tizen>
345 /// <value>The altitude value, or null if the information does not exist.</value>
346 public double? Altitude { get; }
349 /// Gets the conductor of the media.
351 /// <since_tizen> 3 </since_tizen>
352 /// <value>A string representing the conductor, or null if the information does not exist.</value>
353 public string Conductor { get; }
356 /// Gets the unsynchronized lyrics of the media.
358 /// <since_tizen> 3 </since_tizen>
359 /// <value>A string representing the unsynchronized lyrics, or null if the information does not exist.</value>
360 public string UnsyncLyrics { get; }
363 /// Gets the number of synchronized lyrics of the media.
365 /// <since_tizen> 3 </since_tizen>
366 /// <value>The number of the synchronized lyrics.</value>
367 public int SyncLyricsCount { get; }
370 /// Gets the recording date of the media.
372 /// <since_tizen> 3 </since_tizen>
373 /// <value>A string representing the recording date, or null if the information does not exist.</value>
374 public string DateRecorded { get; }
377 /// Gets the rotate(orientation) information of the media.
379 /// <since_tizen> 3 </since_tizen>
380 /// <value>A string representing the rotation information, or null if the information does not exist.</value>
381 public string Rotation { get; }
384 /// Gets the information for 360 content of the media.
386 /// <since_tizen> 3 </since_tizen>
387 /// <value>A string representing the information for 360 content, or null if the information does not exist.</value>
388 public string Content360 { get; }
390 private Lazy<string> _description;
393 /// Returns a string that represents the current object.
395 /// <returns>A string that represents the current object.</returns>
396 public override string ToString() => _description.Value;