update stream closing

This commit is contained in:
Luke Pulverenti 2015-03-23 13:19:21 -04:00
parent 30a507eca8
commit e3a573ea97
8 changed files with 65 additions and 65 deletions

View File

@ -134,7 +134,8 @@ namespace MediaBrowser.Api.Playback
var data = GetCommandLineArguments("dummy\\dummy", "dummyTranscodingId", state, false);
data += "-" + (state.Request.DeviceId ?? string.Empty);
data += "-" + (state.Request.StreamId ?? state.Request.ClientTime ?? string.Empty);
data += "-" + (state.Request.StreamId ?? string.Empty);
data += "-" + (state.Request.ClientTime ?? string.Empty);
var dataHash = data.GetMD5().ToString("N");
@ -1054,7 +1055,7 @@ namespace MediaBrowser.Api.Playback
}
var transcodingJob = ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath,
state.Request.StreamId ?? state.Request.ClientTime,
state.Request.StreamId,
transcodingId,
TranscodingJobType,
process,
@ -1524,7 +1525,7 @@ namespace MediaBrowser.Api.Playback
}
else if (i == 16)
{
request.StreamId = val;
request.ClientTime = val;
}
else if (i == 17)
{
@ -1554,6 +1555,10 @@ namespace MediaBrowser.Api.Playback
videoRequest.Cabac = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
}
}
else if (i == 21)
{
request.StreamId = val;
}
}
}

View File

@ -136,7 +136,7 @@ namespace MediaBrowser.Api.Playback.Hls
// If the playlist doesn't already exist, startup ffmpeg
try
{
ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.StreamId ?? request.ClientTime, p => false);
ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.StreamId, p => false);
if (currentTranscodingIndex.HasValue)
{

View File

@ -1,10 +1,10 @@
using System;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.MediaInfo;
using ServiceStack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@ -68,6 +68,7 @@ namespace MediaBrowser.Api.Playback
}
result.MediaSources = mediaSources.ToList();
result.StreamId = Guid.NewGuid().ToString("N");
return ToOptimizedResult(result);
}

View File

@ -37,11 +37,6 @@ namespace MediaBrowser.Model.ApiClient
/// </summary>
event EventHandler<GenericEventArgs<RemoteLogoutReason>> RemoteLoggedOut;
/// <summary>
/// Occurs when [authenticated].
/// </summary>
event EventHandler<GenericEventArgs<AuthenticationResult>> Authenticated;
/// <summary>
/// Gets the API URL.
/// </summary>

View File

@ -92,6 +92,13 @@ namespace MediaBrowser.Model.Dlna
// Grab the first one that can be direct streamed
// If that doesn't produce anything, just take the first
foreach (StreamInfo i in streams)
{
if (i.PlayMethod == PlayMethod.DirectPlay && i.MediaSource.Protocol == MediaProtocol.File)
{
return i;
}
}
foreach (StreamInfo i in streams)
{
if (i.PlayMethod == PlayMethod.DirectPlay)
{
@ -128,12 +135,12 @@ namespace MediaBrowser.Model.Dlna
DeviceProfile = options.Profile
};
List<PlayMethod> directPlayMethods = GetAudioDirectPlayMethods(item, options);
MediaStream audioStream = item.GetDefaultAudioStream(null);
List<PlayMethod> directPlayMethods = GetAudioDirectPlayMethods(item, audioStream, options);
if (directPlayMethods.Count > 0)
{
MediaStream audioStream = item.DefaultAudioStream;
string audioCodec = audioStream == null ? null : audioStream.Codec;
// Make sure audio codec profiles are satisfied
@ -256,10 +263,8 @@ namespace MediaBrowser.Model.Dlna
return playlistItem;
}
private List<PlayMethod> GetAudioDirectPlayMethods(MediaSourceInfo item, AudioOptions options)
private List<PlayMethod> GetAudioDirectPlayMethods(MediaSourceInfo item, MediaStream audioStream, AudioOptions options)
{
MediaStream audioStream = item.DefaultAudioStream;
DirectPlayProfile directPlayProfile = null;
foreach (DirectPlayProfile i in options.Profile.DirectPlayProfiles)
{
@ -303,12 +308,12 @@ namespace MediaBrowser.Model.Dlna
DeviceProfile = options.Profile
};
int? audioStreamIndex = options.AudioStreamIndex ?? item.DefaultAudioStreamIndex;
playlistItem.SubtitleStreamIndex = options.SubtitleStreamIndex ?? item.DefaultSubtitleStreamIndex;
MediaStream audioStream = audioStreamIndex.HasValue ? item.GetMediaStream(MediaStreamType.Audio, audioStreamIndex.Value) : null;
MediaStream subtitleStream = playlistItem.SubtitleStreamIndex.HasValue ? item.GetMediaStream(MediaStreamType.Subtitle, playlistItem.SubtitleStreamIndex.Value) : null;
MediaStream audioStream = item.GetDefaultAudioStream(options.AudioStreamIndex ?? item.DefaultAudioStreamIndex);
int? audioStreamIndex = audioStream == null ? (int?)null : audioStream.Index;
MediaStream videoStream = item.VideoStream;
int? maxBitrateSetting = options.GetMaxBitrate();
@ -325,7 +330,7 @@ namespace MediaBrowser.Model.Dlna
if (subtitleStream != null)
{
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile, options.Context);
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, options.Context);
playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method;
playlistItem.SubtitleFormat = subtitleProfile.Format;
@ -355,7 +360,7 @@ namespace MediaBrowser.Model.Dlna
if (subtitleStream != null)
{
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile, options.Context);
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, options.Context);
playlistItem.SubtitleDeliveryMethod = subtitleProfile.Method;
playlistItem.SubtitleFormat = subtitleProfile.Format;
@ -597,7 +602,7 @@ namespace MediaBrowser.Model.Dlna
{
if (subtitleStream != null)
{
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile, options.Context);
SubtitleProfile subtitleProfile = GetSubtitleProfile(subtitleStream, options.Profile.SubtitleProfiles, options.Context);
if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed)
{
@ -608,10 +613,10 @@ namespace MediaBrowser.Model.Dlna
return IsAudioEligibleForDirectPlay(item, maxBitrate);
}
public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, DeviceProfile deviceProfile, EncodingContext context)
public static SubtitleProfile GetSubtitleProfile(MediaStream subtitleStream, SubtitleProfile[] subtitleProfiles, EncodingContext context)
{
// Look for an external profile that matches the stream type (text/graphical)
foreach (SubtitleProfile profile in deviceProfile.SubtitleProfiles)
foreach (SubtitleProfile profile in subtitleProfiles)
{
if (profile.Method == SubtitleDeliveryMethod.External && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
{
@ -628,7 +633,7 @@ namespace MediaBrowser.Model.Dlna
}
}
foreach (SubtitleProfile profile in deviceProfile.SubtitleProfiles)
foreach (SubtitleProfile profile in subtitleProfiles)
{
if (profile.Method == SubtitleDeliveryMethod.Embed && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format))
{

View File

@ -69,6 +69,8 @@ namespace MediaBrowser.Model.Dlna
public SubtitleDeliveryMethod SubtitleDeliveryMethod { get; set; }
public string SubtitleFormat { get; set; }
public LiveMediaInfoResult PlaybackInfo { get; set; }
public string MediaSourceId
{
get
@ -262,7 +264,7 @@ namespace MediaBrowser.Model.Dlna
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream)
{
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile, Context);
SubtitleProfile subtitleProfile = StreamBuilder.GetSubtitleProfile(stream, DeviceProfile.SubtitleProfiles, Context);
if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
{
@ -288,17 +290,7 @@ namespace MediaBrowser.Model.Dlna
{
if (MediaSource != null)
{
if (AudioStreamIndex.HasValue)
{
foreach (MediaStream i in MediaSource.MediaStreams)
{
if (i.Index == AudioStreamIndex.Value && i.Type == MediaStreamType.Audio)
return i;
}
return null;
}
return MediaSource.DefaultAudioStream;
return MediaSource.GetDefaultAudioStream(AudioStreamIndex);
}
return null;

View File

@ -57,11 +57,14 @@ namespace MediaBrowser.Model.Dto
[IgnoreDataMember]
public MediaStream DefaultAudioStream
{
get
get { return GetDefaultAudioStream(DefaultAudioStreamIndex); }
}
public MediaStream GetDefaultAudioStream(int? defaultIndex)
{
if (DefaultAudioStreamIndex.HasValue)
if (defaultIndex.HasValue)
{
var val = DefaultAudioStreamIndex.Value;
var val = defaultIndex.Value;
foreach (MediaStream i in MediaStreams)
{
@ -90,7 +93,6 @@ namespace MediaBrowser.Model.Dto
return null;
}
}
[IgnoreDataMember]
public MediaStream VideoStream

View File

@ -13,10 +13,10 @@ namespace MediaBrowser.Model.MediaInfo
public List<MediaSourceInfo> MediaSources { get; set; }
/// <summary>
/// Gets or sets the live stream identifier.
/// Gets or sets the stream identifier.
/// </summary>
/// <value>The live stream identifier.</value>
public string LiveStreamId { get; set; }
/// <value>The stream identifier.</value>
public string StreamId { get; set; }
/// <summary>
/// Gets or sets the error code.