浏览代码

Add json parser for DOVI side_data

nyanmisaka 3 年之前
父节点
当前提交
3f37ef70e1

+ 7 - 0
MediaBrowser.MediaEncoding/Probing/MediaStreamInfo.cs

@@ -310,5 +310,12 @@ namespace MediaBrowser.MediaEncoding.Probing
         /// <value>The color primaries.</value>
         [JsonPropertyName("color_primaries")]
         public string ColorPrimaries { get; set; }
+
+        /// <summary>
+        /// Gets or sets the side_data_list.
+        /// </summary>
+        /// <value>The side_data_list.</value>
+        [JsonPropertyName("side_data_list")]
+        public IReadOnlyList<MediaStreamInfoSideData> SideDataList { get; set; }
     }
 }

+ 74 - 0
MediaBrowser.MediaEncoding/Probing/MediaStreamInfoSideData.cs

@@ -0,0 +1,74 @@
+using System.Collections.Generic;
+using System.Text.Json.Serialization;
+
+namespace MediaBrowser.MediaEncoding.Probing
+{
+    /// <summary>
+    /// Class MediaStreamInfoSideData.
+    /// </summary>
+    public class MediaStreamInfoSideData
+    {
+        /// <summary>
+        /// Gets or sets the SideDataType.
+        /// </summary>
+        /// <value>The SideDataType.</value>
+        [JsonPropertyName("side_data_type")]
+        public string? SideDataType { get; set; }
+
+        /// <summary>
+        /// Gets or sets the DvVersionMajor.
+        /// </summary>
+        /// <value>The DvVersionMajor.</value>
+        [JsonPropertyName("dv_version_major")]
+        public int? DvVersionMajor { get; set; }
+
+        /// <summary>
+        /// Gets or sets the DvVersionMinor.
+        /// </summary>
+        /// <value>The DvVersionMinor.</value>
+        [JsonPropertyName("dv_version_minor")]
+        public int? DvVersionMinor { get; set; }
+
+        /// <summary>
+        /// Gets or sets the DvProfile.
+        /// </summary>
+        /// <value>The DvProfile.</value>
+        [JsonPropertyName("dv_profile")]
+        public int? DvProfile { get; set; }
+
+        /// <summary>
+        /// Gets or sets the DvLevel.
+        /// </summary>
+        /// <value>The DvLevel.</value>
+        [JsonPropertyName("dv_level")]
+        public int? DvLevel { get; set; }
+
+        /// <summary>
+        /// Gets or sets the RpuPresentFlag.
+        /// </summary>
+        /// <value>The RpuPresentFlag.</value>
+        [JsonPropertyName("rpu_present_flag")]
+        public int? RpuPresentFlag { get; set; }
+
+        /// <summary>
+        /// Gets or sets the ElPresentFlag.
+        /// </summary>
+        /// <value>The ElPresentFlag.</value>
+        [JsonPropertyName("el_present_flag")]
+        public int? ElPresentFlag { get; set; }
+
+        /// <summary>
+        /// Gets or sets the BlPresentFlag.
+        /// </summary>
+        /// <value>The BlPresentFlag.</value>
+        [JsonPropertyName("bl_present_flag")]
+        public int? BlPresentFlag { get; set; }
+
+        /// <summary>
+        /// Gets or sets the DvBlSignalCompatibilityId.
+        /// </summary>
+        /// <value>The DvBlSignalCompatibilityId.</value>
+        [JsonPropertyName("dv_bl_signal_compatibility_id")]
+        public int? DvBlSignalCompatibilityId { get; set; }
+    }
+}

+ 21 - 0
MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs

@@ -841,6 +841,27 @@ namespace MediaBrowser.MediaEncoding.Probing
                 {
                     stream.ColorPrimaries = streamInfo.ColorPrimaries;
                 }
+
+                if (streamInfo.SideDataList != null)
+                {
+                    foreach (var data in streamInfo.SideDataList)
+                    {
+                        // Parse Dolby Vision metadata from side_data
+                        if (string.Equals(data.SideDataType, "DOVI configuration record", StringComparison.OrdinalIgnoreCase))
+                        {
+                            stream.DvVersionMajor = data.DvVersionMajor;
+                            stream.DvVersionMinor = data.DvVersionMinor;
+                            stream.DvProfile = data.DvProfile;
+                            stream.DvLevel = data.DvLevel;
+                            stream.RpuPresentFlag = data.RpuPresentFlag;
+                            stream.ElPresentFlag = data.ElPresentFlag;
+                            stream.BlPresentFlag = data.BlPresentFlag;
+                            stream.DvBlSignalCompatibilityId = data.DvBlSignalCompatibilityId;
+
+                            break;
+                        }
+                    }
+                }
             }
             else
             {

+ 48 - 0
MediaBrowser.Model/Entities/MediaStream.cs

@@ -72,6 +72,54 @@ namespace MediaBrowser.Model.Entities
         /// <value>The color primaries.</value>
         public string ColorPrimaries { get; set; }
 
+        /// <summary>
+        /// Gets or sets the Dolby Vision version major.
+        /// </summary>
+        /// <value>The Dolby Vision version major.</value>
+        public int? DvVersionMajor { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Dolby Vision version minor.
+        /// </summary>
+        /// <value>The Dolby Vision version minor.</value>
+        public int? DvVersionMinor { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Dolby Vision profile.
+        /// </summary>
+        /// <value>The Dolby Vision profile.</value>
+        public int? DvProfile { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Dolby Vision level.
+        /// </summary>
+        /// <value>The Dolby Vision level.</value>
+        public int? DvLevel { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Dolby Vision rpu present flag.
+        /// </summary>
+        /// <value>The Dolby Vision rpu present flag.</value>
+        public int? RpuPresentFlag { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Dolby Vision el present flag.
+        /// </summary>
+        /// <value>The Dolby Vision el present flag.</value>
+        public int? ElPresentFlag { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Dolby Vision bl present flag.
+        /// </summary>
+        /// <value>The Dolby Vision bl present flag.</value>
+        public int? BlPresentFlag { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Dolby Vision bl signal compatibility id.
+        /// </summary>
+        /// <value>The Dolby Vision bl signal compatibility id.</value>
+        public int? DvBlSignalCompatibilityId { get; set; }
+
         /// <summary>
         /// Gets or sets the comment.
         /// </summary>