diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-02-05 00:29:37 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-02-05 00:29:37 -0500 |
| commit | 7d415fc2fd8c76ba25c2bdb40347d1e0d17ad99f (patch) | |
| tree | 448ecc653015896c5237f54b82072ce77956bf20 /MediaBrowser.Model/Dlna | |
| parent | 1f1852f3cbe2a7899aea0d306a77d2eedb0434fc (diff) | |
some initial work on cloud sync
Diffstat (limited to 'MediaBrowser.Model/Dlna')
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamBuilder.cs | 37 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dlna/StreamInfo.cs | 17 |
2 files changed, 22 insertions, 32 deletions
diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 84c0839976..8b929425a1 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -108,7 +108,8 @@ namespace MediaBrowser.Model.Dlna MediaType = DlnaProfileType.Audio, MediaSource = item, RunTimeTicks = item.RunTimeTicks, - Context = options.Context + Context = options.Context, + DeviceProfile = options.Profile }; int? maxBitrateSetting = options.GetMaxBitrate(); @@ -240,7 +241,8 @@ namespace MediaBrowser.Model.Dlna MediaType = DlnaProfileType.Video, MediaSource = item, RunTimeTicks = item.RunTimeTicks, - Context = options.Context + Context = options.Context, + DeviceProfile = options.Profile }; int? audioStreamIndex = options.AudioStreamIndex ?? item.DefaultAudioStreamIndex; @@ -265,7 +267,7 @@ namespace MediaBrowser.Model.Dlna if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options); + SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile); playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method; playlistItem.SubtitleFormat = subtitleProfile.Format; @@ -290,7 +292,7 @@ namespace MediaBrowser.Model.Dlna { if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options); + SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile); playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method; playlistItem.SubtitleFormat = subtitleProfile.Format; @@ -524,7 +526,7 @@ namespace MediaBrowser.Model.Dlna { if (subtitleStream != null) { - SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options); + SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile); if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed) { @@ -535,10 +537,10 @@ namespace MediaBrowser.Model.Dlna return IsAudioEligibleForDirectPlay(item, maxBitrate); } - private SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, VideoOptions options) + public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, DeviceProfile deviceProfile) { // Look for an external profile that matches the stream type (text/graphical) - foreach (SubtitleProfile profile in options.Profile.SubtitleProfiles) + foreach (SubtitleProfile profile in deviceProfile.SubtitleProfiles) { if (profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format)) { @@ -546,13 +548,11 @@ namespace MediaBrowser.Model.Dlna } } - if (subtitleStream.IsTextSubtitleStream) + foreach (SubtitleProfile profile in deviceProfile.SubtitleProfiles) { - SubtitleProfile embedProfile = GetSubtitleProfile(options.Profile.SubtitleProfiles, SubtitleDeliveryMethod.Embed); - - if (embedProfile != null) + if (profile.Method == SubtitleDeliveryMethod.Embed && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format)) { - return embedProfile; + return profile; } } @@ -563,19 +563,6 @@ namespace MediaBrowser.Model.Dlna }; } - private SubtitleProfile GetSubtitleProfile(SubtitleProfile[] profiles, SubtitleDeliveryMethod method) - { - foreach (SubtitleProfile profile in profiles) - { - if (method == profile.Method) - { - return profile; - } - } - - return null; - } - private bool IsAudioEligibleForDirectPlay(MediaSourceInfo item, int? maxBitrate) { // Honor the max bitrate setting diff --git a/MediaBrowser.Model/Dlna/StreamInfo.cs b/MediaBrowser.Model/Dlna/StreamInfo.cs index acd2658a8c..3c2f39b745 100644 --- a/MediaBrowser.Model/Dlna/StreamInfo.cs +++ b/MediaBrowser.Model/Dlna/StreamInfo.cs @@ -54,6 +54,7 @@ namespace MediaBrowser.Model.Dlna public float? MaxFramerate { get; set; } + public DeviceProfile DeviceProfile { get; set; } public string DeviceProfileId { get; set; } public string DeviceId { get; set; } @@ -160,11 +161,6 @@ namespace MediaBrowser.Model.Dlna List<SubtitleStreamInfo> list = new List<SubtitleStreamInfo>(); - if (SubtitleDeliveryMethod != SubtitleDeliveryMethod.External) - { - return list; - } - // HLS will preserve timestamps so we can just grab the full subtitle stream long startPositionTicks = StringHelper.EqualsIgnoreCase(Protocol, "hls") ? 0 @@ -175,7 +171,7 @@ namespace MediaBrowser.Model.Dlna { foreach (MediaStream stream in MediaSource.MediaStreams) { - if (stream.Type == MediaStreamType.Subtitle && stream.IsTextSubtitleStream && stream.Index == SubtitleStreamIndex.Value) + if (stream.Type == MediaStreamType.Subtitle && stream.Index == SubtitleStreamIndex.Value) { AddSubtitle(list, stream, baseUrl, startPositionTicks); } @@ -186,7 +182,7 @@ namespace MediaBrowser.Model.Dlna { foreach (MediaStream stream in MediaSource.MediaStreams) { - if (stream.Type == MediaStreamType.Subtitle && stream.IsTextSubtitleStream && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value)) + if (stream.Type == MediaStreamType.Subtitle && (!SubtitleStreamIndex.HasValue || stream.Index != SubtitleStreamIndex.Value)) { AddSubtitle(list, stream, baseUrl, startPositionTicks); } @@ -198,6 +194,13 @@ namespace MediaBrowser.Model.Dlna private void AddSubtitle(List<SubtitleStreamInfo> list, MediaStream stream, string baseUrl, long startPositionTicks) { + var subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile); + + if (subtitleProfile.Method != SubtitleDeliveryMethod.External) + { + return; + } + string url = string.Format("{0}/Videos/{1}/{2}/Subtitles/{3}/{4}/Stream.{5}", baseUrl, ItemId, |
