diff options
| -rw-r--r-- | MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs | 38 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dto/MediaSourceInfo.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Entities/MediaAttachment.cs | 44 |
3 files changed, 84 insertions, 0 deletions
diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs index 54d02fc9f..2c001d775 100644 --- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs +++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs @@ -49,6 +49,10 @@ namespace MediaBrowser.MediaEncoding.Probing .Where(i => i.Type != MediaStreamType.Subtitle || !string.IsNullOrWhiteSpace(i.Codec)) .ToList(); + info.MediaAttachments = internalStreams.Select(s => GetMediaAttachment(s)) + .Where(i => i != null) + .ToList(); + if (data.format != null) { info.Container = NormalizeFormat(data.format.format_name); @@ -514,6 +518,40 @@ namespace MediaBrowser.MediaEncoding.Probing } /// <summary> + /// Converts ffprobe stream info to our MediaAttachment class + /// </summary> + /// <param name="streamInfo">The stream info.</param> + /// <returns>MediaAttachments.</returns> + private MediaAttachment GetMediaAttachment(MediaStreamInfo streamInfo) + { + if (!string.Equals(streamInfo.codec_type, "attachment", StringComparison.OrdinalIgnoreCase)) + { + return null; + } + + var attachment = new MediaAttachment + { + Codec = streamInfo.codec_name, + Index = streamInfo.index + }; + + // Filter out junk + if (!string.IsNullOrWhiteSpace(streamInfo.codec_tag_string) && streamInfo.codec_tag_string.IndexOf("[0]", StringComparison.OrdinalIgnoreCase) == -1) + { + attachment.CodecTag = streamInfo.codec_tag_string; + } + + if (streamInfo.tags != null) + { + attachment.Filename = GetDictionaryValue(streamInfo.tags, "filename"); + attachment.MIMEType = GetDictionaryValue(streamInfo.tags, "mimetype"); + attachment.Comment = GetDictionaryValue(streamInfo.tags, "comment"); + } + + return attachment; + } + + /// <summary> /// Converts ffprobe stream info to our MediaStream class /// </summary> /// <param name="isAudio">if set to <c>true</c> [is info].</param> diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 5bdc4809a..8a1aa55b6 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -57,6 +57,8 @@ namespace MediaBrowser.Model.Dto public List<MediaStream> MediaStreams { get; set; } + public List<MediaAttachment> MediaAttachments { get; set; } + public string[] Formats { get; set; } public int? Bitrate { get; set; } diff --git a/MediaBrowser.Model/Entities/MediaAttachment.cs b/MediaBrowser.Model/Entities/MediaAttachment.cs new file mode 100644 index 000000000..daabbe91d --- /dev/null +++ b/MediaBrowser.Model/Entities/MediaAttachment.cs @@ -0,0 +1,44 @@ +namespace MediaBrowser.Model.Entities +{ + /// <summary> + /// Class MediaAttachment + /// </summary> + public class MediaAttachment + { + /// <summary> + /// Gets or sets the codec. + /// </summary> + /// <value>The codec.</value> + public string Codec { get; set; } + + /// <summary> + /// Gets or sets the codec tag. + /// </summary> + /// <value>The codec tag.</value> + public string CodecTag { get; set; } + + /// <summary> + /// Gets or sets the comment. + /// </summary> + /// <value>The comment.</value> + public string Comment { get; set; } + + /// <summary> + /// Gets or sets the index. + /// </summary> + /// <value>The index.</value> + public int Index { get; set; } + + /// <summary> + /// Gets or sets the filename. + /// </summary> + /// <value>The filename.</value> + public string Filename { get; set; } + + /// <summary> + /// Gets or sets the MIME type. + /// </summary> + /// <value>The MIME type.</value> + public string MIMEType { get; set; } + } +} |
