فهرست منبع

Return more precise transcoding reasons

Using the first profile's reason is somewhat arbitrary, as many clients' first profile may not be the most compatible one. For instance, browsers often set WebM as the first profile, which doesn’t support common codecs like H.264 and AAC by design. This causes `VideoCodecNotSupported` and `AudioCodecNotSupported` to be returned, even if the browser supports those codecs. Only use those reasons when all profiles indicate that the codec is not supported.

Signed-off-by: gnattu <gnattuoc@me.com>
gnattu 9 ماه پیش
والد
کامیت
de8bb15c78
1فایلهای تغییر یافته به همراه37 افزوده شده و 4 حذف شده
  1. 37 4
      MediaBrowser.Model/Dlna/StreamBuilder.cs

+ 37 - 4
MediaBrowser.Model/Dlna/StreamBuilder.cs

@@ -1415,16 +1415,49 @@ namespace MediaBrowser.Model.Dlna
                 return profileMatch;
             }
 
+            TranscodeReason inferredReason = 0;
+
             var failureReasons = analyzedProfiles[false]
                 .Select(analysis => analysis.Result)
                 .Where(result => !containerSupported || (result.TranscodeReason & TranscodeReason.ContainerNotSupported) == 0)
-                .FirstOrDefault().TranscodeReason;
-            if (failureReasons == 0)
+                .Select(result => result.TranscodeReason)
+                .ToList();
+
+            if (failureReasons.FirstOrDefault() == 0)
+            {
+                inferredReason = TranscodeReason.DirectPlayError;
+            }
+            else
             {
-                failureReasons = TranscodeReason.DirectPlayError;
+                var videoCodecNotSupportedCount = failureReasons.Count(r => (r & TranscodeReason.VideoCodecNotSupported) != 0);
+                var audioCodecNotSupportedCount = failureReasons.Count(r => (r & TranscodeReason.AudioCodecNotSupported) != 0);
+
+                if (!containerSupported)
+                {
+                    inferredReason |= TranscodeReason.ContainerNotSupported;
+                }
+
+                if (videoCodecNotSupportedCount == failureReasons.Count)
+                {
+                    inferredReason |= TranscodeReason.VideoCodecNotSupported;
+                }
+
+                if (audioCodecNotSupportedCount == failureReasons.Count)
+                {
+                    inferredReason |= TranscodeReason.AudioCodecNotSupported;
+                }
+
+                foreach (var transcodeReason in failureReasons)
+                {
+                    var temp = transcodeReason;
+                    temp &= ~TranscodeReason.ContainerNotSupported;
+                    temp &= ~TranscodeReason.VideoCodecNotSupported;
+                    temp &= ~TranscodeReason.AudioCodecNotSupported;
+                    inferredReason |= temp;
+                }
             }
 
-            return (Profile: null, PlayMethod: null, AudioStreamIndex: null, TranscodeReasons: failureReasons);
+            return (Profile: null, PlayMethod: null, AudioStreamIndex: null, TranscodeReasons: inferredReason);
         }
 
         private TranscodeReason CheckVideoAudioStreamDirectPlay(MediaOptions options, MediaSourceInfo mediaSource, string container, MediaStream audioStream)