aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Model')
-rw-r--r--MediaBrowser.Model/Dlna/AudioOptions.cs2
-rw-r--r--MediaBrowser.Model/Dlna/ILocalPlayer.cs39
-rw-r--r--MediaBrowser.Model/Dlna/ITranscoderSupport.cs15
-rw-r--r--MediaBrowser.Model/Dlna/NullLocalPlayer.cs21
-rw-r--r--MediaBrowser.Model/Dlna/StreamBuilder.cs82
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj3
6 files changed, 50 insertions, 112 deletions
diff --git a/MediaBrowser.Model/Dlna/AudioOptions.cs b/MediaBrowser.Model/Dlna/AudioOptions.cs
index 162b88c98..c208e8ab0 100644
--- a/MediaBrowser.Model/Dlna/AudioOptions.cs
+++ b/MediaBrowser.Model/Dlna/AudioOptions.cs
@@ -18,6 +18,8 @@ namespace MediaBrowser.Model.Dlna
public bool EnableDirectPlay { get; set; }
public bool EnableDirectStream { get; set; }
+ public bool ForceDirectPlay { get; set; }
+ public bool ForceDirectStream { get; set; }
public string ItemId { get; set; }
public List<MediaSourceInfo> MediaSources { get; set; }
diff --git a/MediaBrowser.Model/Dlna/ILocalPlayer.cs b/MediaBrowser.Model/Dlna/ILocalPlayer.cs
deleted file mode 100644
index 9de360023..000000000
--- a/MediaBrowser.Model/Dlna/ILocalPlayer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-
-namespace MediaBrowser.Model.Dlna
-{
- public interface ILocalPlayer
- {
- /// <summary>
- /// Determines whether this instance [can access file] the specified path.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns><c>true</c> if this instance [can access file] the specified path; otherwise, <c>false</c>.</returns>
- bool CanAccessFile(string path);
- /// <summary>
- /// Determines whether this instance [can access directory] the specified path.
- /// </summary>
- /// <param name="path">The path.</param>
- /// <returns><c>true</c> if this instance [can access directory] the specified path; otherwise, <c>false</c>.</returns>
- bool CanAccessDirectory(string path);
- /// <summary>
- /// Determines whether this instance [can access URL] the specified URL.
- /// </summary>
- /// <param name="url">The URL.</param>
- /// <param name="requiresCustomRequestHeaders">if set to <c>true</c> [requires custom request headers].</param>
- /// <returns><c>true</c> if this instance [can access URL] the specified URL; otherwise, <c>false</c>.</returns>
- bool CanAccessUrl(string url, bool requiresCustomRequestHeaders);
- }
-
- public interface ITranscoderSupport
- {
- bool CanEncodeToAudioCodec(string codec);
- }
-
- public class FullTranscoderSupport : ITranscoderSupport
- {
- public bool CanEncodeToAudioCodec(string codec)
- {
- return true;
- }
- }
-}
diff --git a/MediaBrowser.Model/Dlna/ITranscoderSupport.cs b/MediaBrowser.Model/Dlna/ITranscoderSupport.cs
new file mode 100644
index 000000000..0dac23403
--- /dev/null
+++ b/MediaBrowser.Model/Dlna/ITranscoderSupport.cs
@@ -0,0 +1,15 @@
+namespace MediaBrowser.Model.Dlna
+{
+ public interface ITranscoderSupport
+ {
+ bool CanEncodeToAudioCodec(string codec);
+ }
+
+ public class FullTranscoderSupport : ITranscoderSupport
+ {
+ public bool CanEncodeToAudioCodec(string codec)
+ {
+ return true;
+ }
+ }
+}
diff --git a/MediaBrowser.Model/Dlna/NullLocalPlayer.cs b/MediaBrowser.Model/Dlna/NullLocalPlayer.cs
deleted file mode 100644
index c34b63887..000000000
--- a/MediaBrowser.Model/Dlna/NullLocalPlayer.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-
-namespace MediaBrowser.Model.Dlna
-{
- public class NullLocalPlayer : ILocalPlayer
- {
- public bool CanAccessFile(string path)
- {
- return false;
- }
-
- public bool CanAccessDirectory(string path)
- {
- return false;
- }
-
- public bool CanAccessUrl(string url, bool requiresCustomRequestHeaders)
- {
- return false;
- }
- }
-}
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs
index 2863eba2e..c05ca4187 100644
--- a/MediaBrowser.Model/Dlna/StreamBuilder.cs
+++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs
@@ -11,29 +11,17 @@ namespace MediaBrowser.Model.Dlna
{
public class StreamBuilder
{
- private readonly ILocalPlayer _localPlayer;
private readonly ILogger _logger;
private readonly ITranscoderSupport _transcoderSupport;
- public StreamBuilder(ILocalPlayer localPlayer, ITranscoderSupport transcoderSupport, ILogger logger)
+ public StreamBuilder(ITranscoderSupport transcoderSupport, ILogger logger)
{
_transcoderSupport = transcoderSupport;
- _localPlayer = localPlayer;
_logger = logger;
}
- public StreamBuilder(ITranscoderSupport transcoderSupport, ILogger logger)
- : this(new NullLocalPlayer(), transcoderSupport, logger)
- {
- }
-
- public StreamBuilder(ILocalPlayer localPlayer, ILogger logger)
- : this(localPlayer, new FullTranscoderSupport(), logger)
- {
- }
-
public StreamBuilder(ILogger logger)
- : this(new NullLocalPlayer(), new FullTranscoderSupport(), logger)
+ : this(new FullTranscoderSupport(), logger)
{
}
@@ -127,6 +115,20 @@ namespace MediaBrowser.Model.Dlna
DeviceProfile = options.Profile
};
+ if (options.ForceDirectPlay)
+ {
+ playlistItem.PlayMethod = PlayMethod.DirectPlay;
+ playlistItem.Container = item.Container;
+ return playlistItem;
+ }
+
+ if (options.ForceDirectStream)
+ {
+ playlistItem.PlayMethod = PlayMethod.DirectStream;
+ playlistItem.Container = item.Container;
+ return playlistItem;
+ }
+
MediaStream audioStream = item.GetDefaultAudioStream(null);
List<PlayMethod> directPlayMethods = GetAudioDirectPlayMethods(item, audioStream, options);
@@ -182,19 +184,7 @@ namespace MediaBrowser.Model.Dlna
if (all)
{
- if (item.Protocol == MediaProtocol.File &&
- directPlayMethods.Contains(PlayMethod.DirectPlay) &&
- _localPlayer.CanAccessFile(item.Path))
- {
- playlistItem.PlayMethod = PlayMethod.DirectPlay;
- }
- else if (item.Protocol == MediaProtocol.Http &&
- directPlayMethods.Contains(PlayMethod.DirectPlay) &&
- _localPlayer.CanAccessUrl(item.Path, item.RequiredHttpHeaders.Count > 0))
- {
- playlistItem.PlayMethod = PlayMethod.DirectPlay;
- }
- else if (directPlayMethods.Contains(PlayMethod.DirectStream))
+ if (directPlayMethods.Contains(PlayMethod.DirectStream))
{
playlistItem.PlayMethod = PlayMethod.DirectStream;
}
@@ -413,8 +403,8 @@ namespace MediaBrowser.Model.Dlna
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
- bool isEligibleForDirectPlay = options.EnableDirectPlay && IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options), subtitleStream, options, PlayMethod.DirectPlay);
- bool isEligibleForDirectStream = options.EnableDirectStream && IsEligibleForDirectPlay(item, options.GetMaxBitrate(), subtitleStream, options, PlayMethod.DirectStream);
+ bool isEligibleForDirectPlay = options.EnableDirectPlay && (options.ForceDirectPlay || IsEligibleForDirectPlay(item, GetBitrateForDirectPlayCheck(item, options), subtitleStream, options, PlayMethod.DirectPlay));
+ bool isEligibleForDirectStream = options.EnableDirectStream && (options.ForceDirectStream || IsEligibleForDirectPlay(item, options.GetMaxBitrate(), subtitleStream, options, PlayMethod.DirectStream));
_logger.Info("Profile: {0}, Path: {1}, isEligibleForDirectPlay: {2}, isEligibleForDirectStream: {3}",
options.Profile.Name ?? "Unknown Profile",
@@ -425,7 +415,7 @@ namespace MediaBrowser.Model.Dlna
if (isEligibleForDirectPlay || isEligibleForDirectStream)
{
// See if it can be direct played
- PlayMethod? directPlay = GetVideoDirectPlayProfile(options.Profile, item, videoStream, audioStream, isEligibleForDirectPlay, isEligibleForDirectStream);
+ PlayMethod? directPlay = GetVideoDirectPlayProfile(options, item, videoStream, audioStream, isEligibleForDirectPlay, isEligibleForDirectStream);
if (directPlay != null)
{
@@ -645,13 +635,24 @@ namespace MediaBrowser.Model.Dlna
return Math.Min(defaultBitrate, encoderAudioBitrateLimit);
}
- private PlayMethod? GetVideoDirectPlayProfile(DeviceProfile profile,
+ private PlayMethod? GetVideoDirectPlayProfile(VideoOptions options,
MediaSourceInfo mediaSource,
MediaStream videoStream,
MediaStream audioStream,
bool isEligibleForDirectPlay,
bool isEligibleForDirectStream)
{
+ DeviceProfile profile = options.Profile;
+
+ if (options.ForceDirectPlay)
+ {
+ return PlayMethod.DirectPlay;
+ }
+ if (options.ForceDirectStream)
+ {
+ return PlayMethod.DirectStream;
+ }
+
if (videoStream == null)
{
_logger.Info("Profile: {0}, Cannot direct stream with no known video stream. Path: {1}",
@@ -829,25 +830,6 @@ namespace MediaBrowser.Model.Dlna
}
}
- if (isEligibleForDirectPlay && mediaSource.SupportsDirectPlay)
- {
- if (mediaSource.Protocol == MediaProtocol.Http)
- {
- if (_localPlayer.CanAccessUrl(mediaSource.Path, mediaSource.RequiredHttpHeaders.Count > 0))
- {
- return PlayMethod.DirectPlay;
- }
- }
-
- else if (mediaSource.Protocol == MediaProtocol.File)
- {
- if (_localPlayer.CanAccessFile(mediaSource.Path))
- {
- return PlayMethod.DirectPlay;
- }
- }
- }
-
if (isEligibleForDirectStream && mediaSource.SupportsDirectStream)
{
return PlayMethod.DirectStream;
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 931b2ebcb..e3c1e52a5 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -118,9 +118,8 @@
<Compile Include="Devices\DeviceInfo.cs" />
<Compile Include="Devices\DevicesOptions.cs" />
<Compile Include="Dlna\EncodingContext.cs" />
- <Compile Include="Dlna\ILocalPlayer.cs" />
+ <Compile Include="Dlna\ITranscoderSupport.cs" />
<Compile Include="Dlna\StreamInfoSorter.cs" />
- <Compile Include="Dlna\NullLocalPlayer.cs" />
<Compile Include="Dlna\PlaybackErrorCode.cs" />
<Compile Include="Dlna\PlaybackException.cs" />
<Compile Include="Dlna\ResolutionConfiguration.cs" />