@ -7,6 +7,7 @@ using MediaBrowser.Model.Session;
using System ;
using System.Collections.Generic ;
using System.Globalization ;
using System.Linq ;
namespace MediaBrowser.Model.Dlna
{
@ -409,6 +410,9 @@ namespace MediaBrowser.Model.Dlna
audioStreamIndex = audioStream . Index ;
}
var allMediaStreams = item . MediaStreams ;
var allAudioCodecs = allMediaStreams . Where ( i = > i . Type = = MediaStreamType . Audio ) . Select ( i = > i . Codec ) . Where ( i = > ! string . IsNullOrWhiteSpace ( i ) ) . ToList ( ) ;
MediaStream videoStream = item . VideoStream ;
// TODO: This doesn't accout for situation of device being able to handle media bitrate, but wifi connection not fast enough
@ -424,7 +428,7 @@ namespace MediaBrowser.Model.Dlna
if ( isEligibleForDirectPlay | | isEligibleForDirectStream )
{
// See if it can be direct played
PlayMethod ? directPlay = GetVideoDirectPlayProfile ( options , item , videoStream , audioStream , isEligibleForDirectPlay , isEligibleForDirectStream );
PlayMethod ? directPlay = GetVideoDirectPlayProfile ( options , item , videoStream , audioStream , isEligibleForDirectPlay , isEligibleForDirectStream , allMediaStreams );
if ( directPlay ! = null )
{
@ -552,7 +556,7 @@ namespace MediaBrowser.Model.Dlna
int? numAudioStreams = item . GetStreamCount ( MediaStreamType . Audio ) ;
int? numVideoStreams = item . GetStreamCount ( MediaStreamType . Video ) ;
if ( ! conditionProcessor . IsVideoConditionSatisfied ( applyCondition , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc ))
if ( ! conditionProcessor . IsVideoConditionSatisfied ( applyCondition , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc , allAudioCodecs ))
{
LogConditionFailure ( options . Profile , "VideoCodecProfile" , applyCondition , item ) ;
applyConditions = false ;
@ -653,7 +657,8 @@ namespace MediaBrowser.Model.Dlna
MediaStream videoStream ,
MediaStream audioStream ,
bool isEligibleForDirectPlay ,
bool isEligibleForDirectStream )
bool isEligibleForDirectStream ,
List < MediaStream > allMediaStreams )
{
DeviceProfile profile = options . Profile ;
@ -701,7 +706,7 @@ namespace MediaBrowser.Model.Dlna
foreach ( ContainerProfile i in profile . ContainerProfiles )
{
if ( i . Type = = DlnaProfileType . Video & &
L istHelper . Contains IgnoreCase( i . Get Containers ( ) , container ) )
i. Contains Container( container ) )
{
foreach ( ProfileCondition c in i . Conditions )
{
@ -734,10 +739,12 @@ namespace MediaBrowser.Model.Dlna
int? numAudioStreams = mediaSource . GetStreamCount ( MediaStreamType . Audio ) ;
int? numVideoStreams = mediaSource . GetStreamCount ( MediaStreamType . Video ) ;
var allAudioCodecs = allMediaStreams . Where ( i = > i . Type = = MediaStreamType . Audio ) . Select ( i = > i . Codec ) . Where ( i = > ! string . IsNullOrWhiteSpace ( i ) ) . ToList ( ) ;
// Check container conditions
foreach ( ProfileCondition i in conditions )
{
if ( ! conditionProcessor . IsVideoConditionSatisfied ( i , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc ))
if ( ! conditionProcessor . IsVideoConditionSatisfied ( i , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc , allAudioCodecs ))
{
LogConditionFailure ( profile , "VideoContainerProfile" , i , mediaSource ) ;
@ -764,7 +771,7 @@ namespace MediaBrowser.Model.Dlna
bool applyConditions = true ;
foreach ( ProfileCondition applyCondition in i . ApplyConditions )
{
if ( ! conditionProcessor . IsVideoConditionSatisfied ( applyCondition , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc ))
if ( ! conditionProcessor . IsVideoConditionSatisfied ( applyCondition , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc , allAudioCodecs ))
{
LogConditionFailure ( profile , "VideoCodecProfile" , applyCondition , mediaSource ) ;
applyConditions = false ;
@ -784,7 +791,7 @@ namespace MediaBrowser.Model.Dlna
foreach ( ProfileCondition i in conditions )
{
if ( ! conditionProcessor . IsVideoConditionSatisfied ( i , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc ))
if ( ! conditionProcessor . IsVideoConditionSatisfied ( i , width , height , bitDepth , videoBitrate , videoProfile , videoLevel , videoFramerate , packetLength , timestamp , isAnamorphic , refFrames , numVideoStreams , numAudioStreams , videoCodecTag , isAvc , allAudioCodecs ))
{
LogConditionFailure ( profile , "VideoCodecProfile" , i , mediaSource ) ;