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 /// <since_tizen> 4 </since_tizen>
27 public class VideoMetadata
29 private VideoMetadata(int streamCount, MetadataExtractor extractor)
31 Debug.Assert(streamCount > 0);
33 StreamCount = streamCount;
34 BitRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoBitrate));
35 Fps = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoFps));
36 Width = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoWidth));
37 Height = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoHeight));
38 Codec = extractor.GetMetadata(MetadataExtractorAttr.VideoCodec);
40 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
43 internal static VideoMetadata From(MetadataExtractor extractor)
45 var streamCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.VideoStreamCount));
47 return streamCount > 0 ? new VideoMetadata(streamCount, extractor) : null;
53 /// <since_tizen> 4 </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> 4 </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> 4 </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> 4 </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> 4 </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> 4 </since_tizen>
89 /// <value>The number of video streams.</value>
90 public int StreamCount { get; }
92 private Lazy<string> _description;
95 /// Returns a string that represents the current object.
97 /// <returns>A string that represents the current object.</returns>
98 /// <since_tizen> 4 </since_tizen>
99 public override string ToString() => _description.Value;
103 /// Represents the audio metadata information.
105 /// <since_tizen> 4 </since_tizen>
106 public class AudioMetadata
108 private AudioMetadata(int streamCount, MetadataExtractor extractor)
110 Debug.Assert(streamCount > 0);
112 StreamCount = streamCount;
113 BitRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitrate));
114 Channels = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioChannels));
115 SampleRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioSamplerate));
116 BitPerSample = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitPerSample));
117 Codec = extractor.GetMetadata(MetadataExtractorAttr.AudioCodec);
119 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
122 internal static AudioMetadata From(MetadataExtractor extractor)
124 var streamCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.AudioStreamCount));
126 return streamCount > 0 ? new AudioMetadata(streamCount, extractor) : null;
130 /// Gets the audio bitrate.
132 /// <since_tizen> 4 </since_tizen>
133 /// <value>The bit rate value, or null if the information does not exist.</value>
134 public int? BitRate { get; }
137 /// Gets the audio channels.
139 /// <since_tizen> 4 </since_tizen>
140 /// <value>The number of the audio channels, or null if the information does not exist.</value>
141 public int? Channels { get; }
144 /// Gets the audio sample rate.
146 /// <since_tizen> 4 </since_tizen>
147 /// <value>The sample rate, or null if the information does not exist.</value>
148 public int? SampleRate { get; }
151 /// Gets the bit per sample of the audio.
153 /// <since_tizen> 4 </since_tizen>
154 /// <value>The bit per sample, or null if the information does not exist.</value>
155 public int? BitPerSample { get; }
158 /// Gets the audio stream count.
160 /// <since_tizen> 4 </since_tizen>
161 /// <value>The number of audio streams.</value>
162 public int StreamCount { get; }
165 /// Gets the audio codec type.
167 /// <since_tizen> 4 </since_tizen>
168 public string Codec { get; }
170 private Lazy<string> _description;
173 /// Returns a string that represents the current object.
175 /// <returns>A string that represents the current object.</returns>
176 /// <since_tizen> 4 </since_tizen>
177 public override string ToString() => _description.Value;
181 /// Represents the metadata information of a media.
183 /// <since_tizen> 3 </since_tizen>
184 public class Metadata
186 internal Metadata(MetadataExtractor extractor)
188 Debug.Assert(extractor != null);
190 Video = VideoMetadata.From(extractor);
191 Audio = AudioMetadata.From(extractor);
193 Duration = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.Duration));
194 Artist = extractor.GetMetadata(MetadataExtractorAttr.Artist);
195 Title = extractor.GetMetadata(MetadataExtractorAttr.Title);
196 Album = extractor.GetMetadata(MetadataExtractorAttr.Album);
197 AlbumArtist = extractor.GetMetadata(MetadataExtractorAttr.AlbumArtist);
198 Genre = extractor.GetMetadata(MetadataExtractorAttr.Genre);
199 #pragma warning disable CS0618 // Type or member is obsolete
200 Author = extractor.GetMetadata(MetadataExtractorAttr.Composer);
201 #pragma warning restore CS0618 // Type or member is obsolete
202 Composer = extractor.GetMetadata(MetadataExtractorAttr.Composer);
203 Copyright = extractor.GetMetadata(MetadataExtractorAttr.Copyright);
204 DateReleased = extractor.GetMetadata(MetadataExtractorAttr.ReleaseDate);
205 Description = extractor.GetMetadata(MetadataExtractorAttr.Description);
206 Comment = extractor.GetMetadata(MetadataExtractorAttr.Comment);
207 TrackNumber = extractor.GetMetadata(MetadataExtractorAttr.TrackNum);
208 Classification = extractor.GetMetadata(MetadataExtractorAttr.Classification);
209 Rating = extractor.GetMetadata(MetadataExtractorAttr.Rating);
210 Longitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Longitude));
211 Latitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Latitude));
212 Altitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Altitude));
213 Conductor = extractor.GetMetadata(MetadataExtractorAttr.Conductor);
214 UnsyncLyrics = extractor.GetMetadata(MetadataExtractorAttr.UnSyncLyrics);
215 SyncLyricsCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.SyncLyricsNum));
216 DateRecorded = extractor.GetMetadata(MetadataExtractorAttr.RecordingDate);
217 Rotation = extractor.GetMetadata(MetadataExtractorAttr.Rotate);
218 Content360 = extractor.GetMetadata(MetadataExtractorAttr.ContentFor360);
220 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
224 /// Gets the duration of the media.
226 /// <since_tizen> 4 </since_tizen>
227 /// <value>The duration value, or null if the information does not exist.</value>
228 public int? Duration { get; }
231 /// Gets the video metadata.
233 /// <since_tizen> 4 </since_tizen>
234 /// <value>The video metadata, or null if the information does not exist.</value>
235 public VideoMetadata Video { get; }
238 /// Gets the audio metadata.
240 /// <since_tizen> 4 </since_tizen>
241 /// <value>The audio metadata, or null if the information does not exist.</value>
242 public AudioMetadata Audio { get; }
245 /// Gets the artist of the media.
247 /// <since_tizen> 3 </since_tizen>
248 /// <value>A string representing the artist, or null if the information does not exist.</value>
249 public string Artist { get; }
252 /// Gets the title of the media.
254 /// <since_tizen> 3 </since_tizen>
255 /// <value>A string representing the title, or null if the information does not exist.</value>
256 public string Title { get; }
259 /// Gets the album name of the media.
261 /// <since_tizen> 3 </since_tizen>
262 /// <value>A string representing the album name, or null if the information does not exist.</value>
263 public string Album { get; }
266 /// Gets the album artist of the media.
268 /// <since_tizen> 3 </since_tizen>
269 /// <value>A string representing the album artist, or null if the information does not exist.</value>
270 public string AlbumArtist { get; }
273 /// Gets the genre of the media.
275 /// <since_tizen> 3 </since_tizen>
276 /// <value>A string representing the genre, or null if the information does not exist.</value>
277 public string Genre { get; }
280 /// Gets the author of the media.
282 /// <since_tizen> 3 </since_tizen>
283 /// <value>A string representing the author, or null if the information does not exist.</value>
284 [Obsolete("Please do not use! This will be deprecated. Please use Composer instead.")]
285 public string Author { get; }
288 /// Gets the composer of the media.
290 /// <since_tizen> 6 </since_tizen>
291 /// <value>A string representing the composer, or null if the information does not exist.</value>
292 public string Composer { get; }
295 /// Gets the copyright of the media.
297 /// <since_tizen> 3 </since_tizen>
298 /// <value>A string representing the copyright, or null if the information does not exist.</value>
299 public string Copyright { get; }
302 /// Gets the release date of the media.
304 /// <since_tizen> 4 </since_tizen>
305 /// <value>A string representing the release date, or null if the information does not exist.</value>
306 public string DateReleased { get; }
309 /// Gets the description of the media.
311 /// <since_tizen> 3 </since_tizen>
312 /// <value>A string representing the description, or null if the information does not exist.</value>
313 public string Description { get; }
316 /// Gets the comment of the media.
318 /// <since_tizen> 3 </since_tizen>
319 /// <value>A string representing the comment, or null if the information does not exist.</value>
320 public string Comment { get; }
323 /// Gets the track number of the media.
325 /// <since_tizen> 3 </since_tizen>
326 /// <value>A string representing the track number, or null if the information does not exist.</value>
327 public string TrackNumber { get; }
330 /// Gets the classification of the media.
332 /// <since_tizen> 3 </since_tizen>
333 /// <value>A string representing the classification, or null if the information does not exist.</value>
334 public string Classification { get; }
337 /// Gets the rating of the media.
339 /// <since_tizen> 3 </since_tizen>
340 /// <value>A string representing the rating, or null if the information does not exist.</value>
341 public string Rating { get; }
344 /// Gets the longitude of the media.
346 /// <since_tizen> 4 </since_tizen>
347 /// <value>The longitude value, or null if the information does not exist.</value>
348 public double? Longitude { get; }
351 /// Gets the latitude of the media.
353 /// <since_tizen> 4 </since_tizen>
354 /// <value>The latitude value, or null if the information does not exist.</value>
355 public double? Latitude { get; }
358 /// Gets the altitude of the media.
360 /// <since_tizen> 4 </since_tizen>
361 /// <value>The altitude value, or null if the information does not exist.</value>
362 public double? Altitude { get; }
365 /// Gets the conductor of the media.
367 /// <since_tizen> 3 </since_tizen>
368 /// <value>A string representing the conductor, or null if the information does not exist.</value>
369 public string Conductor { get; }
372 /// Gets the unsynchronized lyrics of the media.
374 /// <since_tizen> 4 </since_tizen>
375 /// <value>A string representing the unsynchronized lyrics, or null if the information does not exist.</value>
376 public string UnsyncLyrics { get; }
379 /// Gets the number of synchronized lyrics of the media.
381 /// <since_tizen> 4 </since_tizen>
382 /// <value>The number of the synchronized lyrics.</value>
383 public int SyncLyricsCount { get; }
386 /// Gets the recording date of the media.
388 /// <since_tizen> 4 </since_tizen>
389 /// <value>A string representing the recording date, or null if the information does not exist.</value>
390 public string DateRecorded { get; }
393 /// Gets the rotate(orientation) information of the media.
395 /// <since_tizen> 4 </since_tizen>
396 /// <value>A string representing the rotation information, or null if the information does not exist.</value>
397 public string Rotation { get; }
400 /// Gets the information for 360 content of the media.
402 /// <since_tizen> 3 </since_tizen>
403 /// <value>A string representing the information for 360 content, or null if the information does not exist.</value>
404 public string Content360 { get; }
406 private Lazy<string> _description;
409 /// Returns a string that represents the current object.
411 /// <returns>A string that represents the current object.</returns>
412 /// <since_tizen> 3 </since_tizen>
413 public override string ToString() => _description.Value;