diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 4f56f828b4..2e61ed89cb 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -356,12 +356,18 @@ Dlna\HttpHeaderInfo.cs + + Dlna\ILocalPlayer.cs + Dlna\MediaFormatProfile.cs Dlna\MediaFormatProfileResolver.cs + + Dlna\NullLocalPlayer.cs + Dlna\PlaybackErrorCode.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index b49cef7405..ba4ac22e7c 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -288,6 +288,9 @@ Dlna\ContentFeatureBuilder.cs + + Dlna\DefaultLocalPlayer.cs + Dlna\DeviceIdentification.cs @@ -321,12 +324,18 @@ Dlna\HttpHeaderInfo.cs + + Dlna\ILocalPlayer.cs + Dlna\MediaFormatProfile.cs Dlna\MediaFormatProfileResolver.cs + + Dlna\NullLocalPlayer.cs + Dlna\PlaybackErrorCode.cs diff --git a/MediaBrowser.Model/Dlna/AudioOptions.cs b/MediaBrowser.Model/Dlna/AudioOptions.cs index cddfd89559..6ad4fa2659 100644 --- a/MediaBrowser.Model/Dlna/AudioOptions.cs +++ b/MediaBrowser.Model/Dlna/AudioOptions.cs @@ -46,17 +46,6 @@ namespace MediaBrowser.Model.Dlna /// /// The audio transcoding bitrate. public int? AudioTranscodingBitrate { get; set; } - - /// - /// Gets or sets a value indicating whether [supports direct remote content]. - /// - /// true if [supports direct remote content]; otherwise, false. - public bool SupportsDirectRemoteContent { get; set; } - /// - /// Gets or sets a value indicating whether [supports custom HTTP headers]. - /// - /// true if [supports custom HTTP headers]; otherwise, false. - public bool SupportsCustomHttpHeaders { get; set; } /// /// Gets the maximum bitrate. diff --git a/MediaBrowser.Model/Dlna/DefaultLocalPlayer.cs b/MediaBrowser.Model/Dlna/DefaultLocalPlayer.cs new file mode 100644 index 0000000000..fc15a55a09 --- /dev/null +++ b/MediaBrowser.Model/Dlna/DefaultLocalPlayer.cs @@ -0,0 +1,22 @@ +using System.IO; + +namespace MediaBrowser.Model.Dlna +{ + public class DefaultLocalPlayer : ILocalPlayer + { + public bool CanAccessFile(string path) + { + return File.Exists(path); + } + + public bool CanAccessDirectory(string path) + { + return Directory.Exists(path); + } + + public virtual bool CanAccessUrl(string url, bool requiresCustomRequestHeaders) + { + return false; + } + } +} diff --git a/MediaBrowser.Model/Dlna/ILocalPlayer.cs b/MediaBrowser.Model/Dlna/ILocalPlayer.cs new file mode 100644 index 0000000000..55e11ec4b7 --- /dev/null +++ b/MediaBrowser.Model/Dlna/ILocalPlayer.cs @@ -0,0 +1,26 @@ + +namespace MediaBrowser.Model.Dlna +{ + public interface ILocalPlayer + { + /// + /// Determines whether this instance [can access file] the specified path. + /// + /// The path. + /// true if this instance [can access file] the specified path; otherwise, false. + bool CanAccessFile(string path); + /// + /// Determines whether this instance [can access directory] the specified path. + /// + /// The path. + /// true if this instance [can access directory] the specified path; otherwise, false. + bool CanAccessDirectory(string path); + /// + /// Determines whether this instance [can access URL] the specified URL. + /// + /// The URL. + /// if set to true [requires custom request headers]. + /// true if this instance [can access URL] the specified URL; otherwise, false. + bool CanAccessUrl(string url, bool requiresCustomRequestHeaders); + } +} diff --git a/MediaBrowser.Model/Dlna/NullLocalPlayer.cs b/MediaBrowser.Model/Dlna/NullLocalPlayer.cs new file mode 100644 index 0000000000..c34b638871 --- /dev/null +++ b/MediaBrowser.Model/Dlna/NullLocalPlayer.cs @@ -0,0 +1,21 @@ + +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 559a543f2d..126b218e82 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -10,6 +10,17 @@ namespace MediaBrowser.Model.Dlna { public class StreamBuilder { + private readonly ILocalPlayer _localPlayer; + + public StreamBuilder(ILocalPlayer localPlayer) + { + _localPlayer = localPlayer; + } + public StreamBuilder() + : this(new NullLocalPlayer()) + { + } + public StreamInfo BuildAudioItem(AudioOptions options) { ValidateAudioInput(options); @@ -73,7 +84,7 @@ namespace MediaBrowser.Model.Dlna StreamInfo streamInfo = BuildVideoItem(i, options); if (streamInfo != null) { - streams.Add(streamInfo); + streams.Add(streamInfo); } } @@ -180,7 +191,15 @@ namespace MediaBrowser.Model.Dlna if (all) { - playlistItem.PlayMethod = PlayMethod.DirectStream; + if (item.Protocol == MediaProtocol.File && _localPlayer.CanAccessFile(item.Path)) + { + playlistItem.PlayMethod = PlayMethod.DirectPlay; + } + else + { + playlistItem.PlayMethod = PlayMethod.DirectStream; + } + playlistItem.Container = item.Container; return playlistItem; @@ -530,18 +549,17 @@ namespace MediaBrowser.Model.Dlna if (mediaSource.Protocol == MediaProtocol.Http) { - if (!options.SupportsDirectRemoteContent) + if (_localPlayer.CanAccessUrl(mediaSource.Path, mediaSource.RequiredHttpHeaders.Count > 0)) { - return null; + return PlayMethod.DirectPlay; } - - if (mediaSource.RequiredHttpHeaders.Count > 0 && !options.SupportsCustomHttpHeaders) - { - return null; - } - return PlayMethod.DirectPlay; } + else if (mediaSource.Protocol == MediaProtocol.File && _localPlayer.CanAccessFile(mediaSource.Path)) + { + return PlayMethod.DirectPlay; + } + return PlayMethod.DirectStream; } @@ -574,7 +592,7 @@ namespace MediaBrowser.Model.Dlna { return profile; } - + // For sync we can handle the longer extraction times if (context == EncodingContext.Static && subtitleStream.IsTextSubtitleStream) { diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 662b760022..14ec093ec6 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -124,7 +124,10 @@ + + + diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 05c2807c0a..fc506e8221 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.582 + 3.0.583 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 8d6ecd1a1e..c459513836 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.582 + 3.0.583 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index c907f9c513..c38bf5ffb6 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.582 + 3.0.583 MediaBrowser.Model - Signed Edition Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 31064cfe0a..b78c8e3aa5 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.582 + 3.0.583 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +