aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Dlna
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-04-09 22:32:27 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-04-09 22:32:27 -0400
commit6ea48d1e7c32f159c2e8c92f73f84b09bb78ec3f (patch)
treefd907ec9c752b7c760ab764f74a15b35f6ff660d /MediaBrowser.Model/Dlna
parentbe4f301198fa0d1d455478eebfc960a6e61c33e9 (diff)
parent638dba51ec75f9180c44ec4e75b67f7cea774910 (diff)
Merge branch 'beta'
Diffstat (limited to 'MediaBrowser.Model/Dlna')
-rw-r--r--MediaBrowser.Model/Dlna/ConditionProcessor.cs3
-rw-r--r--MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs2
-rw-r--r--MediaBrowser.Model/Dlna/DeviceProfile.cs13
-rw-r--r--MediaBrowser.Model/Dlna/DlnaFlags.cs24
-rw-r--r--MediaBrowser.Model/Dlna/ProfileConditionValue.cs1
-rw-r--r--MediaBrowser.Model/Dlna/StreamBuilder.cs73
-rw-r--r--MediaBrowser.Model/Dlna/StreamInfo.cs29
-rw-r--r--MediaBrowser.Model/Dlna/TranscodingProfile.cs3
8 files changed, 68 insertions, 80 deletions
diff --git a/MediaBrowser.Model/Dlna/ConditionProcessor.cs b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
index fef04647a4..69f1369dc0 100644
--- a/MediaBrowser.Model/Dlna/ConditionProcessor.cs
+++ b/MediaBrowser.Model/Dlna/ConditionProcessor.cs
@@ -17,7 +17,6 @@ namespace MediaBrowser.Model.Dlna
int? packetLength,
TransportStreamTimestamp? timestamp,
bool? isAnamorphic,
- bool? isCabac,
int? refFrames,
int? numVideoStreams,
int? numAudioStreams,
@@ -27,8 +26,6 @@ namespace MediaBrowser.Model.Dlna
{
case ProfileConditionValue.IsAnamorphic:
return IsConditionSatisfied(condition, isAnamorphic);
- case ProfileConditionValue.IsCabac:
- return IsConditionSatisfied(condition, isCabac);
case ProfileConditionValue.VideoFramerate:
return IsConditionSatisfied(condition, videoFramerate);
case ProfileConditionValue.VideoLevel:
diff --git a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs
index 58d669c220..c4b3383a2b 100644
--- a/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs
+++ b/MediaBrowser.Model/Dlna/ContentFeatureBuilder.cs
@@ -115,7 +115,6 @@ namespace MediaBrowser.Model.Dlna
int? packetLength,
TranscodeSeekInfo transcodeSeekInfo,
bool? isAnamorphic,
- bool? isCabac,
int? refFrames,
int? numVideoStreams,
int? numAudioStreams,
@@ -157,7 +156,6 @@ namespace MediaBrowser.Model.Dlna
packetLength,
timestamp,
isAnamorphic,
- isCabac,
refFrames,
numVideoStreams,
numAudioStreams,
diff --git a/MediaBrowser.Model/Dlna/DeviceProfile.cs b/MediaBrowser.Model/Dlna/DeviceProfile.cs
index 778db8fb54..423928f620 100644
--- a/MediaBrowser.Model/Dlna/DeviceProfile.cs
+++ b/MediaBrowser.Model/Dlna/DeviceProfile.cs
@@ -131,7 +131,7 @@ namespace MediaBrowser.Model.Dlna
public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec)
{
- container = StringHelper.TrimStart((container ?? string.Empty), '.');
+ container = StringHelper.TrimStart(container ?? string.Empty, '.');
foreach (var i in TranscodingProfiles)
{
@@ -157,7 +157,7 @@ namespace MediaBrowser.Model.Dlna
public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec)
{
- container = StringHelper.TrimStart((container ?? string.Empty), '.');
+ container = StringHelper.TrimStart(container ?? string.Empty, '.');
foreach (var i in TranscodingProfiles)
{
@@ -188,7 +188,7 @@ namespace MediaBrowser.Model.Dlna
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate)
{
- container = StringHelper.TrimStart((container ?? string.Empty), '.');
+ container = StringHelper.TrimStart(container ?? string.Empty, '.');
foreach (var i in ResponseProfiles)
{
@@ -233,7 +233,7 @@ namespace MediaBrowser.Model.Dlna
public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
{
- container = StringHelper.TrimStart((container ?? string.Empty), '.');
+ container = StringHelper.TrimStart(container ?? string.Empty, '.');
foreach (var i in ResponseProfiles)
{
@@ -283,13 +283,12 @@ namespace MediaBrowser.Model.Dlna
int? packetLength,
TransportStreamTimestamp timestamp,
bool? isAnamorphic,
- bool? isCabac,
int? refFrames,
int? numVideoStreams,
int? numAudioStreams,
string videoCodecTag)
{
- container = StringHelper.TrimStart((container ?? string.Empty), '.');
+ container = StringHelper.TrimStart(container ?? string.Empty, '.');
foreach (var i in ResponseProfiles)
{
@@ -321,7 +320,7 @@ namespace MediaBrowser.Model.Dlna
var anyOff = false;
foreach (ProfileCondition c in i.Conditions)
{
- if (!conditionProcessor.IsVideoConditionSatisfied(c, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isCabac, refFrames, numVideoStreams, numAudioStreams, videoCodecTag))
+ if (!conditionProcessor.IsVideoConditionSatisfied(c, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag))
{
anyOff = true;
break;
diff --git a/MediaBrowser.Model/Dlna/DlnaFlags.cs b/MediaBrowser.Model/Dlna/DlnaFlags.cs
index 7c7fe8d8f5..b981e8455c 100644
--- a/MediaBrowser.Model/Dlna/DlnaFlags.cs
+++ b/MediaBrowser.Model/Dlna/DlnaFlags.cs
@@ -13,12 +13,12 @@ namespace MediaBrowser.Model.Dlna
and there are no issues with causing a buffer overflow if the
receiver uses TCP flow control to reduce total throughput.
*/
- BackgroundTransferMode = (1 << 22),
+ BackgroundTransferMode = 1 << 22,
- ByteBasedSeek = (1 << 29),
- ConnectionStall = (1 << 21),
+ ByteBasedSeek = 1 << 29,
+ ConnectionStall = 1 << 21,
- DlnaV15 = (1 << 20),
+ DlnaV15 = 1 << 20,
/*! <i>Interactive</i> transfer mode.
For best effort transfer of images and non-real-time transfers.
@@ -27,13 +27,13 @@ namespace MediaBrowser.Model.Dlna
\ref DH_TransferMode_Bulk is that the former assumes that the
transfer is intended for immediate rendering.
*/
- InteractiveTransferMode = (1 << 23),
+ InteractiveTransferMode = 1 << 23,
- PlayContainer = (1 << 28),
- RtspPause = (1 << 25),
- S0Increase = (1 << 27),
- SenderPaced = (1L << 31),
- SnIncrease = (1 << 26),
+ PlayContainer = 1 << 28,
+ RtspPause = 1 << 25,
+ S0Increase = 1 << 27,
+ SenderPaced = 1L << 31,
+ SnIncrease = 1 << 26,
/*! <i>Streaming</i> transfer mode.
The server transmits at a throughput sufficient for real-time playback of
@@ -41,8 +41,8 @@ namespace MediaBrowser.Model.Dlna
\ref DH_TransferMode_Interactive and \ref DH_TransferMode_Bulk transfer modes.
The most well-known exception to this general claim is for live streams.
*/
- StreamingTransferMode = (1 << 24),
+ StreamingTransferMode = 1 << 24,
- TimeBasedSeek = (1 << 30)
+ TimeBasedSeek = 1 << 30
}
} \ No newline at end of file
diff --git a/MediaBrowser.Model/Dlna/ProfileConditionValue.cs b/MediaBrowser.Model/Dlna/ProfileConditionValue.cs
index 4ad326e519..c17a09c3fb 100644
--- a/MediaBrowser.Model/Dlna/ProfileConditionValue.cs
+++ b/MediaBrowser.Model/Dlna/ProfileConditionValue.cs
@@ -17,7 +17,6 @@
VideoTimestamp = 12,
IsAnamorphic = 13,
RefFrames = 14,
- IsCabac = 15,
NumAudioStreams = 16,
NumVideoStreams = 17,
IsSecondaryAudio = 18,
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index b04f1b0fb4..d28e21bf25 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -383,7 +383,7 @@ namespace MediaBrowser.Model.Dlna
if (subtitleStream != null)
{
- SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, options.Context, directPlay.Value);
+ SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, directPlay.Value);
playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method;
playlistItem.SubtitleFormat = subtitleProfile.Format;
@@ -413,7 +413,7 @@ namespace MediaBrowser.Model.Dlna
if (subtitleStream != null)
{
- SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, options.Context, PlayMethod.Transcode);
+ SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, PlayMethod.Transcode);
playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method;
playlistItem.SubtitleFormat = subtitleProfile.Format;
@@ -443,6 +443,7 @@ namespace MediaBrowser.Model.Dlna
playlistItem.VideoCodec = transcodingProfile.VideoCodec;
playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps;
+ playlistItem.ForceLiveStream = transcodingProfile.ForceLiveStream;
playlistItem.SubProtocol = transcodingProfile.Protocol;
playlistItem.AudioStreamIndex = audioStreamIndex;
@@ -513,7 +514,14 @@ namespace MediaBrowser.Model.Dlna
{
if (targetAudioChannels.Value >= 5 && (maxTotalBitrate ?? 0) >= 2000000)
{
- defaultBitrate = 320000;
+ if (StringHelper.EqualsIgnoreCase(targetAudioCodec, "ac3"))
+ {
+ defaultBitrate = 384000;
+ }
+ else
+ {
+ defaultBitrate = 320000;
+ }
}
}
@@ -597,7 +605,6 @@ namespace MediaBrowser.Model.Dlna
string videoProfile = videoStream == null ? null : videoStream.Profile;
float? videoFramerate = videoStream == null ? null : videoStream.AverageFrameRate ?? videoStream.AverageFrameRate;
bool? isAnamorphic = videoStream == null ? null : videoStream.IsAnamorphic;
- bool? isCabac = videoStream == null ? null : videoStream.IsCabac;
string videoCodecTag = videoStream == null ? null : videoStream.CodecTag;
int? audioBitrate = audioStream == null ? null : audioStream.BitRate;
@@ -614,7 +621,7 @@ namespace MediaBrowser.Model.Dlna
// Check container conditions
foreach (ProfileCondition i in conditions)
{
- if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isCabac, refFrames, numVideoStreams, numAudioStreams, videoCodecTag))
+ if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag))
{
LogConditionFailure(profile, "VideoContainerProfile", i, mediaSource);
@@ -647,7 +654,7 @@ namespace MediaBrowser.Model.Dlna
foreach (ProfileCondition i in conditions)
{
- if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, isCabac, refFrames, numVideoStreams, numAudioStreams, videoCodecTag))
+ if (!conditionProcessor.IsVideoConditionSatisfied(i, width, height, bitDepth, videoBitrate, videoProfile, videoLevel, videoFramerate, packetLength, timestamp, isAnamorphic, refFrames, numVideoStreams, numAudioStreams, videoCodecTag))
{
LogConditionFailure(profile, "VideoCodecProfile", i, mediaSource);
@@ -739,7 +746,7 @@ namespace MediaBrowser.Model.Dlna
{
if (subtitleStream != null)
{
- SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, options.Context, playMethod);
+ SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, playMethod);
if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed)
{
@@ -751,7 +758,7 @@ namespace MediaBrowser.Model.Dlna
return IsAudioEligibleForDirectPlay(item, maxBitrate);
}
- public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, EncodingContext context, PlayMethod playMethod)
+ public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, PlayMethod playMethod)
{
if (playMethod != PlayMethod.Transcode && !subtitleStream.IsExternal)
{
@@ -775,7 +782,16 @@ namespace MediaBrowser.Model.Dlna
}
}
- // Look for an external profile that matches the stream type (text/graphical)
+ // Look for an external or hls profile that matches the stream type (text/graphical) and doesn't require conversion
+ return GetExternalSubtitleProfile(subtitleStream, subtitleProfiles, playMethod, false) ?? GetExternalSubtitleProfile(subtitleStream, subtitleProfiles, playMethod, true) ?? new SubtitleProfile
+ {
+ Method = SubtitleDeliveryMethod.Encode,
+ Format = subtitleStream.Codec
+ };
+ }
+
+ private static SubtitleProfile GetExternalSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, PlayMethod playMethod, bool allowConversion)
+ {
foreach (SubtitleProfile profile in subtitleProfiles)
{
if (profile.Method != SubtitleDeliveryMethod.External && profile.Method != SubtitleDeliveryMethod.Hls)
@@ -798,21 +814,24 @@ namespace MediaBrowser.Model.Dlna
{
bool requiresConversion = !StringHelper.EqualsIgnoreCase(subtitleStream.Codec, profile.Format);
- if (subtitleStream.IsTextSubtitleStream || !requiresConversion)
+ if (requiresConversion && !allowConversion)
{
- if (subtitleStream.SupportsExternalStream)
- {
- return profile;
- }
+ continue;
+ }
+
+ if (!requiresConversion)
+ {
+ return profile;
+ }
+
+ if (subtitleStream.IsTextSubtitleStream && subtitleStream.SupportsExternalStream)
+ {
+ return profile;
}
}
}
- return new SubtitleProfile
- {
- Method = SubtitleDeliveryMethod.Encode,
- Format = subtitleStream.Codec
- };
+ return null;
}
private bool IsAudioEligibleForDirectPlay(MediaSourceInfo item, int? maxBitrate)
@@ -898,22 +917,6 @@ namespace MediaBrowser.Model.Dlna
}
break;
}
- case ProfileConditionValue.IsCabac:
- {
- bool val;
- if (BoolHelper.TryParseCultureInvariant(value, out val))
- {
- if (condition.Condition == ProfileConditionType.Equals)
- {
- item.Cabac = val;
- }
- else if (condition.Condition == ProfileConditionType.NotEquals)
- {
- item.Cabac = !val;
- }
- }
- break;
- }
case ProfileConditionValue.IsAnamorphic:
case ProfileConditionValue.AudioProfile:
case ProfileConditionValue.Has64BitOffsets:
diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs
index 9118efb35c..644f732a74 100644
--- a/MediaBrowser.Model/Dlna/StreamInfo.cs
+++ b/MediaBrowser.Model/Dlna/StreamInfo.cs
@@ -6,7 +6,6 @@ using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Session;
using System;
using System.Collections.Generic;
-using System.Globalization;
namespace MediaBrowser.Model.Dlna
{
@@ -31,8 +30,8 @@ namespace MediaBrowser.Model.Dlna
public string VideoCodec { get; set; }
public string VideoProfile { get; set; }
- public bool? Cabac { get; set; }
public bool CopyTimestamps { get; set; }
+ public bool ForceLiveStream { get; set; }
public string AudioCodec { get; set; }
public int? AudioStreamIndex { get; set; }
@@ -194,7 +193,7 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("DeviceProfileId", item.DeviceProfileId ?? string.Empty));
list.Add(new NameValuePair("DeviceId", item.DeviceId ?? string.Empty));
list.Add(new NameValuePair("MediaSourceId", item.MediaSourceId ?? string.Empty));
- list.Add(new NameValuePair("Static", (item.IsDirectStream).ToString().ToLower()));
+ list.Add(new NameValuePair("Static", item.IsDirectStream.ToString().ToLower()));
list.Add(new NameValuePair("VideoCodec", item.VideoCodec ?? string.Empty));
list.Add(new NameValuePair("AudioCodec", item.AudioCodec ?? string.Empty));
list.Add(new NameValuePair("AudioStreamIndex", item.AudioStreamIndex.HasValue ? StringHelper.ToStringCultureInvariant(item.AudioStreamIndex.Value) : string.Empty));
@@ -206,7 +205,7 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("MaxWidth", item.MaxWidth.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxWidth.Value) : string.Empty));
list.Add(new NameValuePair("MaxHeight", item.MaxHeight.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxHeight.Value) : string.Empty));
- if (StringHelper.EqualsIgnoreCase(item.SubProtocol, "hls"))
+ if (StringHelper.EqualsIgnoreCase(item.SubProtocol, "hls") && !item.ForceLiveStream)
{
list.Add(new NameValuePair("StartTimeTicks", string.Empty));
}
@@ -220,7 +219,9 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("MaxRefFrames", item.MaxRefFrames.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxRefFrames.Value) : string.Empty));
list.Add(new NameValuePair("MaxVideoBitDepth", item.MaxVideoBitDepth.HasValue ? StringHelper.ToStringCultureInvariant(item.MaxVideoBitDepth.Value) : string.Empty));
list.Add(new NameValuePair("Profile", item.VideoProfile ?? string.Empty));
- list.Add(new NameValuePair("Cabac", item.Cabac.HasValue ? item.Cabac.Value.ToString() : string.Empty));
+
+ // no longer used
+ list.Add(new NameValuePair("Cabac", string.Empty));
list.Add(new NameValuePair("PlaySessionId", item.PlaySessionId ?? string.Empty));
list.Add(new NameValuePair("api_key", accessToken ?? string.Empty));
@@ -233,7 +234,8 @@ namespace MediaBrowser.Model.Dlna
list.Add(new NameValuePair("ItemId", item.ItemId));
}
- list.Add(new NameValuePair("CopyTimestamps", (item.CopyTimestamps).ToString().ToLower()));
+ list.Add(new NameValuePair("CopyTimestamps", item.CopyTimestamps.ToString().ToLower()));
+ list.Add(new NameValuePair("ForceLiveStream", item.ForceLiveStream.ToString().ToLower()));
list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty));
return list;
@@ -322,7 +324,7 @@ namespace MediaBrowser.Model.Dlna
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream, string baseUrl, string accessToken, long startPositionTicks, SubtitleProfile[] subtitleProfiles)
{
- SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, subtitleProfiles, Context, PlayMethod);
+ SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, subtitleProfiles, PlayMethod);
SubtitleStreamInfo info = new SubtitleStreamInfo
{
IsForced = stream.IsForced,
@@ -633,19 +635,6 @@ namespace MediaBrowser.Model.Dlna
}
}
- public bool? IsTargetCabac
- {
- get
- {
- if (IsDirectStream)
- {
- return TargetVideoStream == null ? null : TargetVideoStream.IsCabac;
- }
-
- return true;
- }
- }
-
public int? TargetWidth
{
get
diff --git a/MediaBrowser.Model/Dlna/TranscodingProfile.cs b/MediaBrowser.Model/Dlna/TranscodingProfile.cs
index e59ee6d634..bf6bf092f3 100644
--- a/MediaBrowser.Model/Dlna/TranscodingProfile.cs
+++ b/MediaBrowser.Model/Dlna/TranscodingProfile.cs
@@ -35,6 +35,9 @@ namespace MediaBrowser.Model.Dlna
[XmlAttribute("context")]
public EncodingContext Context { get; set; }
+ [XmlAttribute("forceLiveStream")]
+ public bool ForceLiveStream { get; set; }
+
public List<string> GetAudioCodecs()
{
List<string> list = new List<string>();