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); var data = GetCommandLineArguments("dummy\\dummy", "dummyTranscodingId", state, false);
data += "-" + (state.Request.DeviceId ?? string.Empty); 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"); var dataHash = data.GetMD5().ToString("N");
@ -1054,7 +1055,7 @@ namespace MediaBrowser.Api.Playback
} }
var transcodingJob = ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath, var transcodingJob = ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath,
state.Request.StreamId ?? state.Request.ClientTime, state.Request.StreamId,
transcodingId, transcodingId,
TranscodingJobType, TranscodingJobType,
process, process,
@ -1524,7 +1525,7 @@ namespace MediaBrowser.Api.Playback
} }
else if (i == 16) else if (i == 16)
{ {
request.StreamId = val; request.ClientTime = val;
} }
else if (i == 17) else if (i == 17)
{ {
@ -1554,6 +1555,10 @@ namespace MediaBrowser.Api.Playback
videoRequest.Cabac = string.Equals("true", val, StringComparison.OrdinalIgnoreCase); 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 // If the playlist doesn't already exist, startup ffmpeg
try try
{ {
ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.StreamId ?? request.ClientTime, p => false); ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.StreamId, p => false);
if (currentTranscodingIndex.HasValue) 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.Controller.Net;
using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.MediaInfo;
using ServiceStack; using ServiceStack;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
@ -68,6 +68,7 @@ namespace MediaBrowser.Api.Playback
} }
result.MediaSources = mediaSources.ToList(); result.MediaSources = mediaSources.ToList();
result.StreamId = Guid.NewGuid().ToString("N");
return ToOptimizedResult(result); return ToOptimizedResult(result);
} }

View File

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

View File

@ -92,6 +92,13 @@ namespace MediaBrowser.Model.Dlna
// Grab the first one that can be direct streamed // Grab the first one that can be direct streamed
// If that doesn't produce anything, just take the first // If that doesn't produce anything, just take the first
foreach (StreamInfo i in streams) 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) if (i.PlayMethod == PlayMethod.DirectPlay)
{ {
@ -128,12 +135,12 @@ namespace MediaBrowser.Model.Dlna
DeviceProfile = options.Profile 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) if (directPlayMethods.Count > 0)
{ {
MediaStream audioStream = item.DefaultAudioStream;
string audioCodec = audioStream == null ? null : audioStream.Codec; string audioCodec = audioStream == null ? null : audioStream.Codec;
// Make sure audio codec profiles are satisfied // Make sure audio codec profiles are satisfied
@ -256,10 +263,8 @@ namespace MediaBrowser.Model.Dlna
return playlistItem; 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; DirectPlayProfile directPlayProfile = null;
foreach (DirectPlayProfile i in options.Profile.DirectPlayProfiles) foreach (DirectPlayProfile i in options.Profile.DirectPlayProfiles)
{ {
@ -303,12 +308,12 @@ namespace MediaBrowser.Model.Dlna
DeviceProfile = options.Profile DeviceProfile = options.Profile
}; };
int? audioStreamIndex = options.AudioStreamIndex ?? item.DefaultAudioStreamIndex;
playlistItem.SubtitleStreamIndex = options.SubtitleStreamIndex ?? item.DefaultSubtitleStreamIndex; 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 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; MediaStream videoStream = item.VideoStream;
int? maxBitrateSetting = options.GetMaxBitrate(); int? maxBitrateSetting = options.GetMaxBitrate();
@ -325,7 +330,7 @@ namespace MediaBrowser.Model.Dlna
if (subtitleStream != null) 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.SubtitleDeliveryMethod = subtitleProfile.Method;
playlistItem.SubtitleFormat = subtitleProfile.Format; playlistItem.SubtitleFormat = subtitleProfile.Format;
@ -355,7 +360,7 @@ namespace MediaBrowser.Model.Dlna
if (subtitleStream != null) 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.SubtitleDeliveryMethod = subtitleProfile.Method;
playlistItem.SubtitleFormat = subtitleProfile.Format; playlistItem.SubtitleFormat = subtitleProfile.Format;
@ -597,7 +602,7 @@ namespace MediaBrowser.Model.Dlna
{ {
if (subtitleStream != null) 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) if (subtitleProfile.Method != SubtitleDeliveryMethod.External && subtitleProfile.Method != SubtitleDeliveryMethod.Embed)
{ {
@ -608,10 +613,10 @@ namespace MediaBrowser.Model.Dlna
return IsAudioEligibleForDirectPlay(item, maxBitrate); 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) // 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)) 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)) 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 SubtitleDeliveryMethod SubtitleDeliveryMethod { get; set; }
public string SubtitleFormat { get; set; } public string SubtitleFormat { get; set; }
public LiveMediaInfoResult PlaybackInfo { get; set; }
public string MediaSourceId public string MediaSourceId
{ {
get get
@ -262,7 +264,7 @@ namespace MediaBrowser.Model.Dlna
private SubtitleStreamInfo GetSubtitleStreamInfo(MediaStream stream) 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) if (subtitleProfile.Method != SubtitleDeliveryMethod.External)
{ {
@ -288,17 +290,7 @@ namespace MediaBrowser.Model.Dlna
{ {
if (MediaSource != null) if (MediaSource != null)
{ {
if (AudioStreamIndex.HasValue) return MediaSource.GetDefaultAudioStream(AudioStreamIndex);
{
foreach (MediaStream i in MediaSource.MediaStreams)
{
if (i.Index == AudioStreamIndex.Value && i.Type == MediaStreamType.Audio)
return i;
}
return null;
}
return MediaSource.DefaultAudioStream;
} }
return null; return null;

View File

@ -57,39 +57,41 @@ namespace MediaBrowser.Model.Dto
[IgnoreDataMember] [IgnoreDataMember]
public MediaStream DefaultAudioStream public MediaStream DefaultAudioStream
{ {
get get { return GetDefaultAudioStream(DefaultAudioStreamIndex); }
}
public MediaStream GetDefaultAudioStream(int? defaultIndex)
{
if (defaultIndex.HasValue)
{ {
if (DefaultAudioStreamIndex.HasValue) var val = defaultIndex.Value;
{
var val = DefaultAudioStreamIndex.Value;
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio && i.Index == val)
{
return i;
}
}
}
foreach (MediaStream i in MediaStreams) foreach (MediaStream i in MediaStreams)
{ {
if (i.Type == MediaStreamType.Audio && i.IsDefault) if (i.Type == MediaStreamType.Audio && i.Index == val)
{ {
return i; return i;
} }
} }
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio)
{
return i;
}
}
return null;
} }
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio && i.IsDefault)
{
return i;
}
}
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio)
{
return i;
}
}
return null;
} }
[IgnoreDataMember] [IgnoreDataMember]

View File

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