/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Diagnostics;
namespace Tizen.Multimedia
{
///
/// Represents the video metadata information.
///
/// 4
public class VideoMetadata
{
private VideoMetadata(int streamCount, MetadataExtractor extractor)
{
Debug.Assert(streamCount > 0);
StreamCount = streamCount;
BitRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoBitrate));
Fps = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoFps));
Width = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoWidth));
Height = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.VideoHeight));
Codec = extractor.GetMetadata(MetadataExtractorAttr.VideoCodec);
_description = new Lazy(() => ObjectDescriptionBuilder.BuildWithProperties(this));
}
internal static VideoMetadata From(MetadataExtractor extractor)
{
var streamCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.VideoStreamCount));
return streamCount > 0 ? new VideoMetadata(streamCount, extractor) : null;
}
///
/// Gets the bitrate.
///
/// 4
/// The bitrate value, or null if the information does not exist.
public int? BitRate { get; }
///
/// Gets the video fps.
///
/// 4
/// The fps value, or null if the information does not exist.
public int? Fps { get; }
///
/// Gets the width of the video.
///
/// 4
/// The width value, or null if the information does not exist.
public int? Width { get; }
///
/// Gets the height of the video.
///
/// 4
/// The height value, or null if the information does not exist.
public int? Height { get; }
///
/// Gets the codec type of the video.
///
/// 4
/// A string representing the codec type, or null if the information does not exist.
public string Codec { get; }
///
/// Gets the video stream count.
///
/// 4
/// The number of video streams.
public int StreamCount { get; }
private Lazy _description;
///
/// Returns a string that represents the current object.
///
/// A string that represents the current object.
/// 4
public override string ToString() => _description.Value;
}
///
/// Represents the audio metadata information.
///
/// 4
public class AudioMetadata
{
private AudioMetadata(int streamCount, MetadataExtractor extractor)
{
Debug.Assert(streamCount > 0);
StreamCount = streamCount;
BitRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitrate));
Channels = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioChannels));
SampleRate = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioSamplerate));
BitPerSample = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.AudioBitPerSample));
Codec = extractor.GetMetadata(MetadataExtractorAttr.AudioCodec);
_description = new Lazy(() => ObjectDescriptionBuilder.BuildWithProperties(this));
}
internal static AudioMetadata From(MetadataExtractor extractor)
{
var streamCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.AudioStreamCount));
return streamCount > 0 ? new AudioMetadata(streamCount, extractor) : null;
}
///
/// Gets the audio bitrate.
///
/// 4
/// The bit rate value, or null if the information does not exist.
public int? BitRate { get; }
///
/// Gets the audio channels.
///
/// 4
/// The number of the audio channels, or null if the information does not exist.
public int? Channels { get; }
///
/// Gets the audio sample rate.
///
/// 4
/// The sample rate, or null if the information does not exist.
public int? SampleRate { get; }
///
/// Gets the bit per sample of the audio.
///
/// 4
/// The bit per sample, or null if the information does not exist.
public int? BitPerSample { get; }
///
/// Gets the audio stream count.
///
/// 4
/// The number of audio streams.
public int StreamCount { get; }
///
/// Gets the audio codec type.
///
/// 4
public string Codec { get; }
private Lazy _description;
///
/// Returns a string that represents the current object.
///
/// A string that represents the current object.
/// 4
public override string ToString() => _description.Value;
}
///
/// Represents the metadata information of a media.
///
/// 3
public class Metadata
{
internal Metadata(MetadataExtractor extractor)
{
Debug.Assert(extractor != null);
Video = VideoMetadata.From(extractor);
Audio = AudioMetadata.From(extractor);
Duration = ValueConverter.ToNullableInt(extractor.GetMetadata(MetadataExtractorAttr.Duration));
Artist = extractor.GetMetadata(MetadataExtractorAttr.Artist);
Title = extractor.GetMetadata(MetadataExtractorAttr.Title);
Album = extractor.GetMetadata(MetadataExtractorAttr.Album);
AlbumArtist = extractor.GetMetadata(MetadataExtractorAttr.AlbumArtist);
Genre = extractor.GetMetadata(MetadataExtractorAttr.Genre);
#pragma warning disable CS0618 // Type or member is obsolete
Author = extractor.GetMetadata(MetadataExtractorAttr.Composer);
#pragma warning restore CS0618 // Type or member is obsolete
Composer = extractor.GetMetadata(MetadataExtractorAttr.Composer);
Copyright = extractor.GetMetadata(MetadataExtractorAttr.Copyright);
DateReleased = extractor.GetMetadata(MetadataExtractorAttr.ReleaseDate);
Description = extractor.GetMetadata(MetadataExtractorAttr.Description);
Comment = extractor.GetMetadata(MetadataExtractorAttr.Comment);
TrackNumber = extractor.GetMetadata(MetadataExtractorAttr.TrackNum);
Classification = extractor.GetMetadata(MetadataExtractorAttr.Classification);
Rating = extractor.GetMetadata(MetadataExtractorAttr.Rating);
Longitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Longitude));
Latitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Latitude));
Altitude = ValueConverter.ToNullableDouble(extractor.GetMetadata(MetadataExtractorAttr.Altitude));
Conductor = extractor.GetMetadata(MetadataExtractorAttr.Conductor);
UnsyncLyrics = extractor.GetMetadata(MetadataExtractorAttr.UnSyncLyrics);
SyncLyricsCount = ValueConverter.ToInt(extractor.GetMetadata(MetadataExtractorAttr.SyncLyricsNum));
DateRecorded = extractor.GetMetadata(MetadataExtractorAttr.RecordingDate);
Rotation = extractor.GetMetadata(MetadataExtractorAttr.Rotate);
Content360 = extractor.GetMetadata(MetadataExtractorAttr.ContentFor360);
_description = new Lazy(() => ObjectDescriptionBuilder.BuildWithProperties(this));
}
///
/// Gets the duration of the media.
///
/// 4
/// The duration value, or null if the information does not exist.
public int? Duration { get; }
///
/// Gets the video metadata.
///
/// 4
/// The video metadata, or null if the information does not exist.
public VideoMetadata Video { get; }
///
/// Gets the audio metadata.
///
/// 4
/// The audio metadata, or null if the information does not exist.
public AudioMetadata Audio { get; }
///
/// Gets the artist of the media.
///
/// 3
/// A string representing the artist, or null if the information does not exist.
public string Artist { get; }
///
/// Gets the title of the media.
///
/// 3
/// A string representing the title, or null if the information does not exist.
public string Title { get; }
///
/// Gets the album name of the media.
///
/// 3
/// A string representing the album name, or null if the information does not exist.
public string Album { get; }
///
/// Gets the album artist of the media.
///
/// 3
/// A string representing the album artist, or null if the information does not exist.
public string AlbumArtist { get; }
///
/// Gets the genre of the media.
///
/// 3
/// A string representing the genre, or null if the information does not exist.
public string Genre { get; }
///
/// Gets the author of the media.
///
/// 3
/// A string representing the author, or null if the information does not exist.
[Obsolete("Please do not use! This will be deprecated. Please use Composer instead.")]
public string Author { get; }
///
/// Gets the composer of the media.
///
/// 6
/// A string representing the composer, or null if the information does not exist.
public string Composer { get; }
///
/// Gets the copyright of the media.
///
/// 3
/// A string representing the copyright, or null if the information does not exist.
public string Copyright { get; }
///
/// Gets the release date of the media.
///
/// 4
/// A string representing the release date, or null if the information does not exist.
public string DateReleased { get; }
///
/// Gets the description of the media.
///
/// 3
/// A string representing the description, or null if the information does not exist.
public string Description { get; }
///
/// Gets the comment of the media.
///
/// 3
/// A string representing the comment, or null if the information does not exist.
public string Comment { get; }
///
/// Gets the track number of the media.
///
/// 3
/// A string representing the track number, or null if the information does not exist.
public string TrackNumber { get; }
///
/// Gets the classification of the media.
///
/// 3
/// A string representing the classification, or null if the information does not exist.
public string Classification { get; }
///
/// Gets the rating of the media.
///
/// 3
/// A string representing the rating, or null if the information does not exist.
public string Rating { get; }
///
/// Gets the longitude of the media.
///
/// 4
/// The longitude value, or null if the information does not exist.
public double? Longitude { get; }
///
/// Gets the latitude of the media.
///
/// 4
/// The latitude value, or null if the information does not exist.
public double? Latitude { get; }
///
/// Gets the altitude of the media.
///
/// 4
/// The altitude value, or null if the information does not exist.
public double? Altitude { get; }
///
/// Gets the conductor of the media.
///
/// 3
/// A string representing the conductor, or null if the information does not exist.
public string Conductor { get; }
///
/// Gets the unsynchronized lyrics of the media.
///
/// 4
/// A string representing the unsynchronized lyrics, or null if the information does not exist.
public string UnsyncLyrics { get; }
///
/// Gets the number of synchronized lyrics of the media.
///
/// 4
/// The number of the synchronized lyrics.
public int SyncLyricsCount { get; }
///
/// Gets the recording date of the media.
///
/// 4
/// A string representing the recording date, or null if the information does not exist.
public string DateRecorded { get; }
///
/// Gets the rotate(orientation) information of the media.
///
/// 4
/// A string representing the rotation information, or null if the information does not exist.
public string Rotation { get; }
///
/// Gets the information for 360 content of the media.
///
/// 3
/// A string representing the information for 360 content, or null if the information does not exist.
public string Content360 { get; }
private Lazy _description;
///
/// Returns a string that represents the current object.
///
/// A string that represents the current object.
/// 3
public override string ToString() => _description.Value;
}
}