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;
20 namespace Tizen.Multimedia
23 /// Represents the video metadata information.
25 /// <since_tizen> 4 </since_tizen>
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> 4 </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> 4 </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> 4 </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> 4 </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> 4 </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> 4 </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 /// <since_tizen> 4 </since_tizen>
98 public override string ToString() => _description.Value;
102 /// Represents the audio metadata information.
104 /// <since_tizen> 4 </since_tizen>
105 public class AudioMetadata
107 private AudioMetadata(int streamCount, MetadataExtractor extractor)
109 Debug.Assert(streamCount > 0);
111 StreamCount = streamCount;
112 BitRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitrate));
113 Channels = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioChannels));
114 SampleRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioSamplerate));
115 BitPerSample = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitPerSample));
116 Codec = extractor.GetMetadata(MetadataExtractorAttr.AudioCodec);
118 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
121 internal static AudioMetadata From(MetadataExtractor extractor)
123 var streamCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.AudioStreamCount));
125 return streamCount > 0 ? new AudioMetadata(streamCount, extractor) : null;
129 /// Gets the audio bitrate.
131 /// <since_tizen> 4 </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> 4 </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> 4 </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> 4 </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> 4 </since_tizen>
160 /// <value>The number of audio streams.</value>
161 public int StreamCount { get; }
164 /// Gets the audio codec type.
166 /// <since_tizen> 4 </since_tizen>
167 public string Codec { get; }
169 private Lazy<string> _description;
172 /// Returns a string that represents the current object.
174 /// <returns>A string that represents the current object.</returns>
175 /// <since_tizen> 4 </since_tizen>
176 public override string ToString() => _description.Value;
180 /// Represents the metadata information of a media.
182 /// <since_tizen> 3 </since_tizen>
183 public class Metadata
185 internal Metadata(MetadataExtractor extractor)
187 Debug.Assert(extractor != null);
189 Video = VideoMetadata.From(extractor);
190 Audio = AudioMetadata.From(extractor);
192 Duration = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.Duration));
193 Artist = extractor.GetMetadata(MetadataExtractorAttr.Artist);
194 Title = extractor.GetMetadata(MetadataExtractorAttr.Title);
195 Album = extractor.GetMetadata(MetadataExtractorAttr.Album);
196 AlbumArtist = extractor.GetMetadata(MetadataExtractorAttr.AlbumArtist);
197 Genre = extractor.GetMetadata(MetadataExtractorAttr.Genre);
198 #pragma warning disable CS0618 // Type or member is obsolete
199 Author = extractor.GetMetadata(MetadataExtractorAttr.Composer);
200 #pragma warning restore CS0618 // Type or member is obsolete
201 Composer = extractor.GetMetadata(MetadataExtractorAttr.Composer);
202 Copyright = extractor.GetMetadata(MetadataExtractorAttr.Copyright);
203 DateReleased = extractor.GetMetadata(MetadataExtractorAttr.ReleaseDate);
204 Description = extractor.GetMetadata(MetadataExtractorAttr.Description);
205 Comment = extractor.GetMetadata(MetadataExtractorAttr.Comment);
206 TrackNumber = extractor.GetMetadata(MetadataExtractorAttr.TrackNum);
207 Classification = extractor.GetMetadata(MetadataExtractorAttr.Classification);
208 Rating = extractor.GetMetadata(MetadataExtractorAttr.Rating);
209 Longitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Longitude));
210 Latitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Latitude));
211 Altitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Altitude));
212 Conductor = extractor.GetMetadata(MetadataExtractorAttr.Conductor);
213 UnsyncLyrics = extractor.GetMetadata(MetadataExtractorAttr.UnSyncLyrics);
214 SyncLyricsCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.SyncLyricsNum));
215 DateRecorded = extractor.GetMetadata(MetadataExtractorAttr.RecordingDate);
216 Rotation = extractor.GetMetadata(MetadataExtractorAttr.Rotate);
217 Content360 = extractor.GetMetadata(MetadataExtractorAttr.ContentFor360);
219 _description = new Lazy<string>(() => ObjectDescriptionBuilder.BuildWithProperties(this));
223 /// Gets the duration of the media.
225 /// <since_tizen> 4 </since_tizen>
226 /// <value>The duration value, or null if the information does not exist.</value>
227 public int? Duration { get; }
230 /// Gets the video metadata.
232 /// <since_tizen> 4 </since_tizen>
233 /// <value>The video metadata, or null if the information does not exist.</value>
234 public VideoMetadata Video { get; }
237 /// Gets the audio metadata.
239 /// <since_tizen> 4 </since_tizen>
240 /// <value>The audio metadata, or null if the information does not exist.</value>
241 public AudioMetadata Audio { get; }
244 /// Gets the artist of the media.
246 /// <since_tizen> 3 </since_tizen>
247 /// <value>A string representing the artist, or null if the information does not exist.</value>
248 public string Artist { get; }
251 /// Gets the title of the media.
253 /// <since_tizen> 3 </since_tizen>
254 /// <value>A string representing the title, or null if the information does not exist.</value>
255 public string Title { get; }
258 /// Gets the album name of the media.
260 /// <since_tizen> 3 </since_tizen>
261 /// <value>A string representing the album name, or null if the information does not exist.</value>
262 public string Album { get; }
265 /// Gets the album artist of the media.
267 /// <since_tizen> 3 </since_tizen>
268 /// <value>A string representing the album artist, or null if the information does not exist.</value>
269 public string AlbumArtist { get; }
272 /// Gets the genre of the media.
274 /// <since_tizen> 3 </since_tizen>
275 /// <value>A string representing the genre, or null if the information does not exist.</value>
276 public string Genre { get; }
279 /// Gets the author of the media.
281 /// <since_tizen> 3 </since_tizen>
282 /// <value>A string representing the author, or null if the information does not exist.</value>
283 [Obsolete("Please do not use! This will be deprecated. Please use Composer instead.")]
284 public string Author { get; }
287 /// Gets the composer of the media.
289 /// <since_tizen> 6 </since_tizen>
290 /// <value>A string representing the composer, or null if the information does not exist.</value>
291 public string Composer { get; }
294 /// Gets the copyright of the media.
296 /// <since_tizen> 3 </since_tizen>
297 /// <value>A string representing the copyright, or null if the information does not exist.</value>
298 public string Copyright { get; }
301 /// Gets the release date of the media.
303 /// <since_tizen> 4 </since_tizen>
304 /// <value>A string representing the release date, or null if the information does not exist.</value>
305 public string DateReleased { get; }
308 /// Gets the description of the media.
310 /// <since_tizen> 3 </since_tizen>
311 /// <value>A string representing the description, or null if the information does not exist.</value>
312 public string Description { get; }
315 /// Gets the comment of the media.
317 /// <since_tizen> 3 </since_tizen>
318 /// <value>A string representing the comment, or null if the information does not exist.</value>
319 public string Comment { get; }
322 /// Gets the track number of the media.
324 /// <since_tizen> 3 </since_tizen>
325 /// <value>A string representing the track number, or null if the information does not exist.</value>
326 public string TrackNumber { get; }
329 /// Gets the classification of the media.
331 /// <since_tizen> 3 </since_tizen>
332 /// <value>A string representing the classification, or null if the information does not exist.</value>
333 public string Classification { get; }
336 /// Gets the rating of the media.
338 /// <since_tizen> 3 </since_tizen>
339 /// <value>A string representing the rating, or null if the information does not exist.</value>
340 public string Rating { get; }
343 /// Gets the longitude of the media.
345 /// <since_tizen> 4 </since_tizen>
346 /// <value>The longitude value, or null if the information does not exist.</value>
347 public double? Longitude { get; }
350 /// Gets the latitude of the media.
352 /// <since_tizen> 4 </since_tizen>
353 /// <value>The latitude value, or null if the information does not exist.</value>
354 public double? Latitude { get; }
357 /// Gets the altitude of the media.
359 /// <since_tizen> 4 </since_tizen>
360 /// <value>The altitude value, or null if the information does not exist.</value>
361 public double? Altitude { get; }
364 /// Gets the conductor of the media.
366 /// <since_tizen> 3 </since_tizen>
367 /// <value>A string representing the conductor, or null if the information does not exist.</value>
368 public string Conductor { get; }
371 /// Gets the unsynchronized lyrics of the media.
373 /// <since_tizen> 4 </since_tizen>
374 /// <value>A string representing the unsynchronized lyrics, or null if the information does not exist.</value>
375 public string UnsyncLyrics { get; }
378 /// Gets the number of synchronized lyrics of the media.
380 /// <since_tizen> 4 </since_tizen>
381 /// <value>The number of the synchronized lyrics.</value>
382 public int SyncLyricsCount { get; }
385 /// Gets the recording date of the media.
387 /// <since_tizen> 4 </since_tizen>
388 /// <value>A string representing the recording date, or null if the information does not exist.</value>
389 public string DateRecorded { get; }
392 /// Gets the rotate(orientation) information of the media.
394 /// <since_tizen> 4 </since_tizen>
395 /// <value>A string representing the rotation information, or null if the information does not exist.</value>
396 public string Rotation { get; }
399 /// Gets the information for 360 content of the media.
401 /// <since_tizen> 3 </since_tizen>
402 /// <value>A string representing the information for 360 content, or null if the information does not exist.</value>
403 public string Content360 { get; }
405 private Lazy<string> _description;
408 /// Returns a string that represents the current object.
410 /// <returns>A string that represents the current object.</returns>
411 /// <since_tizen> 3 </since_tizen>
412 public override string ToString() => _description.Value;