fix audio-only hls

This commit is contained in:
Luke Pulverenti 2015-05-24 14:33:28 -04:00
parent a2b1977f60
commit f26a639a36
12 changed files with 225 additions and 153 deletions

View File

@ -148,7 +148,6 @@ namespace MediaBrowser.Api.Playback
} }
protected readonly CultureInfo UsCulture = new CultureInfo("en-US"); protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
private readonly long _slowSeekTicks = TimeSpan.FromSeconds(0).Ticks;
/// <summary> /// <summary>
/// Gets the fast seek command line parameter. /// Gets the fast seek command line parameter.
@ -162,37 +161,12 @@ namespace MediaBrowser.Api.Playback
if (time > 0) if (time > 0)
{ {
if (time > _slowSeekTicks && EnableSlowSeek)
{
time -= _slowSeekTicks;
}
return string.Format("-ss {0}", MediaEncoder.GetTimeParameter(time)); return string.Format("-ss {0}", MediaEncoder.GetTimeParameter(time));
} }
return string.Empty; return string.Empty;
} }
protected string GetSlowSeekCommandLineParameter(StreamRequest request)
{
var time = request.StartTimeTicks ?? 0;
if (time > _slowSeekTicks && _slowSeekTicks > 0)
{
return string.Format("-ss {0}", MediaEncoder.GetTimeParameter(time));
}
return string.Empty;
}
protected virtual bool EnableSlowSeek
{
get
{
return false;
}
}
/// <summary> /// <summary>
/// Gets the map args. /// Gets the map args.
/// </summary> /// </summary>

View File

@ -134,7 +134,7 @@ namespace MediaBrowser.Api.Playback.Hls
var appendBaselineStream = false; var appendBaselineStream = false;
var baselineStreamBitrate = 64000; var baselineStreamBitrate = 64000;
var hlsVideoRequest = state.VideoRequest as GetHlsVideoStream; var hlsVideoRequest = state.VideoRequest as GetHlsVideoStreamLegacy;
if (hlsVideoRequest != null) if (hlsVideoRequest != null)
{ {
appendBaselineStream = hlsVideoRequest.AppendBaselineStream; appendBaselineStream = hlsVideoRequest.AppendBaselineStream;
@ -245,7 +245,7 @@ namespace MediaBrowser.Api.Playback.Hls
protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding) protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding)
{ {
var hlsVideoRequest = state.VideoRequest as GetHlsVideoStream; var hlsVideoRequest = state.VideoRequest as GetHlsVideoStreamLegacy;
var itsOffsetMs = hlsVideoRequest == null var itsOffsetMs = hlsVideoRequest == null
? 0 ? 0

View File

@ -30,27 +30,60 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary> /// </summary>
[Route("/Videos/{Id}/master.m3u8", "GET", Summary = "Gets a video stream using HTTP live streaming.")] [Route("/Videos/{Id}/master.m3u8", "GET", Summary = "Gets a video stream using HTTP live streaming.")]
[Route("/Videos/{Id}/master.m3u8", "HEAD", Summary = "Gets a video stream using HTTP live streaming.")] [Route("/Videos/{Id}/master.m3u8", "HEAD", Summary = "Gets a video stream using HTTP live streaming.")]
public class GetMasterHlsVideoStream : VideoStreamRequest public class GetMasterHlsVideoPlaylist : VideoStreamRequest, IMasterHlsRequest
{ {
public bool EnableAdaptiveBitrateStreaming { get; set; } public bool EnableAdaptiveBitrateStreaming { get; set; }
public GetMasterHlsVideoStream() public GetMasterHlsVideoPlaylist()
{ {
EnableAdaptiveBitrateStreaming = true; EnableAdaptiveBitrateStreaming = true;
} }
} }
[Route("/Audio/{Id}/master.m3u8", "GET", Summary = "Gets an audio stream using HTTP live streaming.")]
[Route("/Audio/{Id}/master.m3u8", "HEAD", Summary = "Gets an audio stream using HTTP live streaming.")]
public class GetMasterHlsAudioPlaylist : StreamRequest, IMasterHlsRequest
{
public bool EnableAdaptiveBitrateStreaming { get; set; }
public GetMasterHlsAudioPlaylist()
{
EnableAdaptiveBitrateStreaming = true;
}
}
public interface IMasterHlsRequest
{
bool EnableAdaptiveBitrateStreaming { get; set; }
}
[Route("/Videos/{Id}/main.m3u8", "GET", Summary = "Gets a video stream using HTTP live streaming.")] [Route("/Videos/{Id}/main.m3u8", "GET", Summary = "Gets a video stream using HTTP live streaming.")]
public class GetMainHlsVideoStream : VideoStreamRequest public class GetVariantHlsVideoPlaylist : VideoStreamRequest
{
}
[Route("/Audio/{Id}/main.m3u8", "GET", Summary = "Gets an audio stream using HTTP live streaming.")]
public class GetVariantHlsAudioPlaylist : StreamRequest
{ {
} }
/// <summary>
/// Class GetHlsVideoSegment
/// </summary>
[Route("/Videos/{Id}/hlsdynamic/{PlaylistId}/{SegmentId}.ts", "GET")] [Route("/Videos/{Id}/hlsdynamic/{PlaylistId}/{SegmentId}.ts", "GET")]
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")] [Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
public class GetDynamicHlsVideoSegment : VideoStreamRequest public class GetHlsVideoSegment : VideoStreamRequest
{
public string PlaylistId { get; set; }
/// <summary>
/// Gets or sets the segment id.
/// </summary>
/// <value>The segment id.</value>
public string SegmentId { get; set; }
}
[Route("/Audio/{Id}/hlsdynamic/{PlaylistId}/{SegmentId}.aac", "GET")]
[Route("/Audio/{Id}/hlsdynamic/{PlaylistId}/{SegmentId}.ts", "GET")]
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
public class GetHlsAudioSegment : StreamRequest
{ {
public string PlaylistId { get; set; } public string PlaylistId { get; set; }
@ -71,27 +104,47 @@ namespace MediaBrowser.Api.Playback.Hls
protected INetworkManager NetworkManager { get; private set; } protected INetworkManager NetworkManager { get; private set; }
public Task<object> Get(GetMasterHlsVideoStream request) public Task<object> Get(GetMasterHlsVideoPlaylist request)
{ {
return GetAsync(request, "GET"); return GetMasterPlaylistInternal(request, "GET");
} }
public Task<object> Head(GetMasterHlsVideoStream request) public Task<object> Head(GetMasterHlsVideoPlaylist request)
{ {
return GetAsync(request, "HEAD"); return GetMasterPlaylistInternal(request, "HEAD");
} }
public Task<object> Get(GetMainHlsVideoStream request) public Task<object> Get(GetMasterHlsAudioPlaylist request)
{ {
return GetPlaylistAsync(request, "main"); return GetMasterPlaylistInternal(request, "GET");
} }
public Task<object> Get(GetDynamicHlsVideoSegment request) public Task<object> Head(GetMasterHlsAudioPlaylist request)
{
return GetMasterPlaylistInternal(request, "HEAD");
}
public Task<object> Get(GetVariantHlsVideoPlaylist request)
{
return GetVariantPlaylistInternal(request, true, "main");
}
public Task<object> Get(GetVariantHlsAudioPlaylist request)
{
return GetVariantPlaylistInternal(request, false, "main");
}
public Task<object> Get(GetHlsVideoSegment request)
{ {
return GetDynamicSegment(request, request.SegmentId); return GetDynamicSegment(request, request.SegmentId);
} }
private async Task<object> GetDynamicSegment(VideoStreamRequest request, string segmentId) public Task<object> Get(GetHlsAudioSegment request)
{
return GetDynamicSegment(request, request.SegmentId);
}
private async Task<object> GetDynamicSegment(StreamRequest request, string segmentId)
{ {
if ((request.StartTimeTicks ?? 0) > 0) if ((request.StartTimeTicks ?? 0) > 0)
{ {
@ -107,7 +160,7 @@ namespace MediaBrowser.Api.Playback.Hls
var playlistPath = Path.ChangeExtension(state.OutputFilePath, ".m3u8"); var playlistPath = Path.ChangeExtension(state.OutputFilePath, ".m3u8");
var segmentPath = GetSegmentPath(playlistPath, requestedIndex); var segmentPath = GetSegmentPath(state, playlistPath, requestedIndex);
var segmentLength = state.SegmentLength; var segmentLength = state.SegmentLength;
var segmentExtension = GetSegmentFileExtension(state); var segmentExtension = GetSegmentFileExtension(state);
@ -191,11 +244,11 @@ namespace MediaBrowser.Api.Playback.Hls
ApiEntryPoint.Instance.TranscodingStartLock.Release(); ApiEntryPoint.Instance.TranscodingStartLock.Release();
} }
Logger.Info("waiting for {0}", segmentPath); //Logger.Info("waiting for {0}", segmentPath);
while (!File.Exists(segmentPath)) //while (!File.Exists(segmentPath))
{ //{
await Task.Delay(50, cancellationToken).ConfigureAwait(false); // await Task.Delay(50, cancellationToken).ConfigureAwait(false);
} //}
Logger.Info("returning {0}", segmentPath); Logger.Info("returning {0}", segmentPath);
job = job ?? ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType); job = job ?? ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
@ -254,7 +307,7 @@ namespace MediaBrowser.Api.Playback.Hls
for (var i = 0; i < requestedIndex; i++) for (var i = 0; i < requestedIndex; i++)
{ {
var segmentPath = GetSegmentPath(playlist, i); var segmentPath = GetSegmentPath(state, playlist, i);
double length; double length;
if (SegmentLengths.TryGetValue(Path.GetFileName(segmentPath), out length)) if (SegmentLengths.TryGetValue(Path.GetFileName(segmentPath), out length))
@ -360,7 +413,7 @@ namespace MediaBrowser.Api.Playback.Hls
{ {
var segmentId = "0"; var segmentId = "0";
var segmentRequest = request as GetDynamicHlsVideoSegment; var segmentRequest = request as GetHlsVideoSegment;
if (segmentRequest != null) if (segmentRequest != null)
{ {
segmentId = segmentRequest.SegmentId; segmentId = segmentRequest.SegmentId;
@ -369,13 +422,13 @@ namespace MediaBrowser.Api.Playback.Hls
return int.Parse(segmentId, NumberStyles.Integer, UsCulture); return int.Parse(segmentId, NumberStyles.Integer, UsCulture);
} }
private string GetSegmentPath(string playlist, int index) private string GetSegmentPath(StreamState state, string playlist, int index)
{ {
var folder = Path.GetDirectoryName(playlist); var folder = Path.GetDirectoryName(playlist);
var filename = Path.GetFileNameWithoutExtension(playlist); var filename = Path.GetFileNameWithoutExtension(playlist);
return Path.Combine(folder, filename + index.ToString(UsCulture) + ".ts"); return Path.Combine(folder, filename + index.ToString(UsCulture) + GetSegmentFileExtension(state));
} }
private async Task<object> GetSegmentResult(string playlistPath, private async Task<object> GetSegmentResult(string playlistPath,
@ -474,7 +527,7 @@ namespace MediaBrowser.Api.Playback.Hls
}); });
} }
private async Task<object> GetAsync(GetMasterHlsVideoStream request, string method) private async Task<object> GetMasterPlaylistInternal(StreamRequest request, string method)
{ {
var state = await GetState(request, CancellationToken.None).ConfigureAwait(false); var state = await GetState(request, CancellationToken.None).ConfigureAwait(false);
@ -511,14 +564,16 @@ namespace MediaBrowser.Api.Playback.Hls
var playlistUrl = isLiveStream ? "live.m3u8" : "main.m3u8"; var playlistUrl = isLiveStream ? "live.m3u8" : "main.m3u8";
playlistUrl += queryString; playlistUrl += queryString;
var request = (GetMasterHlsVideoStream)state.Request; var request = state.Request;
var subtitleStreams = state.MediaSource var subtitleStreams = state.MediaSource
.MediaStreams .MediaStreams
.Where(i => i.IsTextSubtitleStream) .Where(i => i.IsTextSubtitleStream)
.ToList(); .ToList();
var subtitleGroup = subtitleStreams.Count > 0 && request.SubtitleMethod == SubtitleDeliveryMethod.Hls ? var subtitleGroup = subtitleStreams.Count > 0 &&
(request is GetMasterHlsVideoPlaylist) &&
((GetMasterHlsVideoPlaylist)request).SubtitleMethod == SubtitleDeliveryMethod.Hls ?
"subs" : "subs" :
null; null;
@ -526,7 +581,7 @@ namespace MediaBrowser.Api.Playback.Hls
if (EnableAdaptiveBitrateStreaming(state, isLiveStream)) if (EnableAdaptiveBitrateStreaming(state, isLiveStream))
{ {
var requestedVideoBitrate = state.VideoRequest.VideoBitRate.Value; var requestedVideoBitrate = state.VideoRequest == null ? 0 : state.VideoRequest.VideoBitRate ?? 0;
// By default, vary by just 200k // By default, vary by just 200k
var variation = GetBitrateVariation(totalBitrate); var variation = GetBitrateVariation(totalBitrate);
@ -596,7 +651,7 @@ namespace MediaBrowser.Api.Playback.Hls
return false; return false;
} }
var request = state.Request as GetMasterHlsVideoStream; var request = state.Request as IMasterHlsRequest;
if (request != null && !request.EnableAdaptiveBitrateStreaming) if (request != null && !request.EnableAdaptiveBitrateStreaming)
{ {
return false; return false;
@ -618,6 +673,11 @@ namespace MediaBrowser.Api.Playback.Hls
return false; return false;
} }
if (!state.IsOutputVideo)
{
return false;
}
// Having problems in android // Having problems in android
return false; return false;
//return state.VideoRequest.VideoBitRate.HasValue; //return state.VideoRequest.VideoBitRate.HasValue;
@ -673,7 +733,7 @@ namespace MediaBrowser.Api.Playback.Hls
return variation; return variation;
} }
private async Task<object> GetPlaylistAsync(VideoStreamRequest request, string name) private async Task<object> GetVariantPlaylistInternal(StreamRequest request, bool isOutputVideo, string name)
{ {
var state = await GetState(request, CancellationToken.None).ConfigureAwait(false); var state = await GetState(request, CancellationToken.None).ConfigureAwait(false);
@ -697,10 +757,11 @@ namespace MediaBrowser.Api.Playback.Hls
builder.AppendLine("#EXTINF:" + length.ToString(UsCulture) + ","); builder.AppendLine("#EXTINF:" + length.ToString(UsCulture) + ",");
builder.AppendLine(string.Format("hlsdynamic/{0}/{1}.ts{2}", builder.AppendLine(string.Format("hlsdynamic/{0}/{1}{2}{3}",
name, name,
index.ToString(UsCulture), index.ToString(UsCulture),
GetSegmentFileExtension(isOutputVideo),
queryString)); queryString));
seconds -= state.SegmentLength; seconds -= state.SegmentLength;
@ -716,6 +777,28 @@ namespace MediaBrowser.Api.Playback.Hls
protected override string GetAudioArguments(StreamState state) protected override string GetAudioArguments(StreamState state)
{ {
if (!state.IsOutputVideo)
{
var audioTranscodeParams = new List<string>();
if (state.OutputAudioBitrate.HasValue)
{
audioTranscodeParams.Add("-ab " + state.OutputAudioBitrate.Value.ToString(UsCulture));
}
if (state.OutputAudioChannels.HasValue)
{
audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture));
}
if (state.OutputAudioSampleRate.HasValue)
{
audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture));
}
audioTranscodeParams.Add("-vn");
return string.Join(" ", audioTranscodeParams.ToArray());
}
var codec = state.OutputAudioCodec; var codec = state.OutputAudioCodec;
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
@ -746,6 +829,11 @@ namespace MediaBrowser.Api.Playback.Hls
protected override string GetVideoArguments(StreamState state) protected override string GetVideoArguments(StreamState state)
{ {
if (!state.IsOutputVideo)
{
return string.Empty;
}
var codec = state.OutputVideoCodec; var codec = state.OutputVideoCodec;
var args = "-codec:v:0 " + codec; var args = "-codec:v:0 " + codec;
@ -758,31 +846,35 @@ namespace MediaBrowser.Api.Playback.Hls
// See if we can save come cpu cycles by avoiding encoding // See if we can save come cpu cycles by avoiding encoding
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase)) if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{ {
return state.VideoStream != null && IsH264(state.VideoStream) ? args += state.VideoStream != null && IsH264(state.VideoStream)
args + " -bsf:v h264_mp4toannexb" : ? args + " -bsf:v h264_mp4toannexb"
args; : args;
} }
else
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
state.SegmentLength.ToString(UsCulture));
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
//args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0";
// Add resolution params, if specified
if (!hasGraphicalSubs)
{ {
args += GetOutputSizeParam(state, codec, false); var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
state.SegmentLength.ToString(UsCulture));
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
//args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0";
// Add resolution params, if specified
if (!hasGraphicalSubs)
{
args += GetOutputSizeParam(state, codec, false);
}
// This is for internal graphical subs
if (hasGraphicalSubs)
{
args += GetGraphicalSubtitleParam(state, codec);
}
} }
// This is for internal graphical subs args += " -flags +loop-global_header -sc_threshold 0";
if (hasGraphicalSubs)
{
args += GetGraphicalSubtitleParam(state, codec);
}
return args; return args;
} }
@ -797,7 +889,7 @@ namespace MediaBrowser.Api.Playback.Hls
var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0"; var startNumberParam = isEncoding ? GetStartNumber(state).ToString(UsCulture) : "0";
var toTimeParam = string.Empty; var toTimeParam = string.Empty;
if (state.RunTimeTicks.HasValue) if (state.RunTimeTicks.HasValue && state.IsOutputVideo)
{ {
var startTime = state.Request.StartTimeTicks ?? 0; var startTime = state.Request.StartTimeTicks ?? 0;
var durationSeconds = ApiEntryPoint.Instance.GetEncodingOptions().ThrottleThresholdInSeconds; var durationSeconds = ApiEntryPoint.Instance.GetEncodingOptions().ThrottleThresholdInSeconds;
@ -812,46 +904,43 @@ namespace MediaBrowser.Api.Playback.Hls
} }
} }
var slowSeekParam = GetSlowSeekCommandLineParameter(state.Request); var timestampOffsetParam = string.Empty;
if (!string.IsNullOrWhiteSpace(slowSeekParam)) if (state.IsOutputVideo)
{ {
slowSeekParam = " " + slowSeekParam; timestampOffsetParam = " -output_ts_offset " + MediaEncoder.GetTimeParameter(state.Request.StartTimeTicks ?? 0).ToString(CultureInfo.InvariantCulture);
} }
var mapArgs = state.IsOutputVideo ? GetMapArgs(state) : string.Empty;
//state.EnableGenericHlsSegmenter = true; //var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d" + GetSegmentFileExtension(state);
if (state.EnableGenericHlsSegmenter) //return string.Format("{0} {11} {1}{10} -map_metadata -1 -threads {2} {3} {4} {5} -f segment -segment_time {6} -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"",
{ // inputModifier,
var outputTsArg = Path.Combine(Path.GetDirectoryName(outputPath), Path.GetFileNameWithoutExtension(outputPath)) + "%d.ts"; // GetInputArgument(state),
// threads,
// mapArgs,
// GetVideoArguments(state),
// GetAudioArguments(state),
// state.SegmentLength.ToString(UsCulture),
// startNumberParam,
// outputPath,
// outputTsArg,
// slowSeekParam,
// toTimeParam
// ).Trim();
return string.Format("{0} {11} {1}{10} -map_metadata -1 -threads {2} {3} {4} -flags -global_header -sc_threshold 0 {5} -f segment -segment_time {6} -segment_format mpegts -segment_list_type m3u8 -segment_start_number {7} -segment_list \"{8}\" -y \"{9}\"", return string.Format("{0}{11} {1} -map_metadata -1 -threads {2} {3} {4}{5} {6} -hls_time {7} -start_number {8} -hls_list_size {9} -y \"{10}\"",
inputModifier,
GetInputArgument(state),
threads,
GetMapArgs(state),
GetVideoArguments(state),
GetAudioArguments(state),
state.SegmentLength.ToString(UsCulture),
startNumberParam,
outputPath,
outputTsArg,
slowSeekParam,
toTimeParam
).Trim();
}
return string.Format("{0}{11} {1}{10} -map_metadata -1 -threads {2} {3} {4} -output_ts_offset " + MediaEncoder.GetTimeParameter(state.Request.StartTimeTicks ?? 0) + " -flags -global_header -sc_threshold 0 {5} -hls_time {6} -start_number {7} -hls_list_size {8} -y \"{9}\"",
inputModifier, inputModifier,
GetInputArgument(state), GetInputArgument(state),
threads, threads,
GetMapArgs(state), mapArgs,
GetVideoArguments(state), GetVideoArguments(state),
timestampOffsetParam,
GetAudioArguments(state), GetAudioArguments(state),
state.SegmentLength.ToString(UsCulture), state.SegmentLength.ToString(UsCulture),
startNumberParam, startNumberParam,
state.HlsListSize.ToString(UsCulture), state.HlsListSize.ToString(UsCulture),
outputPath, outputPath,
slowSeekParam,
toTimeParam toTimeParam
).Trim(); ).Trim();
} }
@ -872,14 +961,6 @@ namespace MediaBrowser.Api.Playback.Hls
} }
} }
protected override bool EnableSlowSeek
{
get
{
return true;
}
}
/// <summary> /// <summary>
/// Gets the segment file extension. /// Gets the segment file extension.
/// </summary> /// </summary>
@ -887,7 +968,12 @@ namespace MediaBrowser.Api.Playback.Hls
/// <returns>System.String.</returns> /// <returns>System.String.</returns>
protected override string GetSegmentFileExtension(StreamState state) protected override string GetSegmentFileExtension(StreamState state)
{ {
return ".ts"; return GetSegmentFileExtension(state.IsOutputVideo);
}
protected string GetSegmentFileExtension(bool isOutputVideo)
{
return isOutputVideo ? ".ts" : ".ts";
} }
} }
} }

View File

@ -14,8 +14,10 @@ namespace MediaBrowser.Api.Playback.Hls
[Route("/Audio/{Id}/hls/{SegmentId}/stream.mp3", "GET")] [Route("/Audio/{Id}/hls/{SegmentId}/stream.mp3", "GET")]
[Route("/Audio/{Id}/hls/{SegmentId}/stream.aac", "GET")] [Route("/Audio/{Id}/hls/{SegmentId}/stream.aac", "GET")]
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")] [Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
public class GetHlsAudioSegment public class GetHlsAudioSegmentLegacy
{ {
// TODO: Deprecate with new iOS app
/// <summary> /// <summary>
/// Gets or sets the id. /// Gets or sets the id.
/// </summary> /// </summary>
@ -29,12 +31,31 @@ namespace MediaBrowser.Api.Playback.Hls
public string SegmentId { get; set; } public string SegmentId { get; set; }
} }
/// <summary>
/// Class GetHlsVideoStream
/// </summary>
[Route("/Videos/{Id}/stream.m3u8", "GET")]
[Api(Description = "Gets a video stream using HTTP live streaming.")]
public class GetHlsVideoStreamLegacy : VideoStreamRequest
{
// TODO: Deprecate with new iOS app
[ApiMember(Name = "BaselineStreamAudioBitRate", Description = "Optional. Specify the audio bitrate for the baseline stream.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? BaselineStreamAudioBitRate { get; set; }
[ApiMember(Name = "AppendBaselineStream", Description = "Optional. Whether or not to include a baseline audio-only stream in the master playlist.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool AppendBaselineStream { get; set; }
[ApiMember(Name = "TimeStampOffsetMs", Description = "Optional. Alter the timestamps in the playlist by a given amount, in ms. Default is 1000.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int TimeStampOffsetMs { get; set; }
}
/// <summary> /// <summary>
/// Class GetHlsVideoSegment /// Class GetHlsVideoSegment
/// </summary> /// </summary>
[Route("/Videos/{Id}/hls/{PlaylistId}/stream.m3u8", "GET")] [Route("/Videos/{Id}/hls/{PlaylistId}/stream.m3u8", "GET")]
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")] [Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
public class GetHlsPlaylist public class GetHlsPlaylistLegacy
{ {
// TODO: Deprecate with new iOS app // TODO: Deprecate with new iOS app
@ -63,8 +84,10 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary> /// </summary>
[Route("/Videos/{Id}/hls/{PlaylistId}/{SegmentId}.ts", "GET")] [Route("/Videos/{Id}/hls/{PlaylistId}/{SegmentId}.ts", "GET")]
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")] [Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
public class GetHlsVideoSegment : VideoStreamRequest public class GetHlsVideoSegmentLegacy : VideoStreamRequest
{ {
// TODO: Deprecate with new iOS app
public string PlaylistId { get; set; } public string PlaylistId { get; set; }
/// <summary> /// <summary>
@ -85,7 +108,7 @@ namespace MediaBrowser.Api.Playback.Hls
_config = config; _config = config;
} }
public object Get(GetHlsPlaylist request) public object Get(GetHlsPlaylistLegacy request)
{ {
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo); var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
file = Path.Combine(_appPaths.TranscodingTempPath, file); file = Path.Combine(_appPaths.TranscodingTempPath, file);
@ -103,7 +126,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
public object Get(GetHlsVideoSegment request) public object Get(GetHlsVideoSegmentLegacy request)
{ {
var file = request.SegmentId + Path.GetExtension(Request.PathInfo); var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
file = Path.Combine(_config.ApplicationPaths.TranscodingTempPath, file); file = Path.Combine(_config.ApplicationPaths.TranscodingTempPath, file);
@ -121,7 +144,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
public object Get(GetHlsAudioSegment request) public object Get(GetHlsAudioSegmentLegacy request)
{ {
// TODO: Deprecate with new iOS app // TODO: Deprecate with new iOS app
var file = request.SegmentId + Path.GetExtension(Request.PathInfo); var file = request.SegmentId + Path.GetExtension(Request.PathInfo);

View File

@ -11,25 +11,6 @@ using System;
namespace MediaBrowser.Api.Playback.Hls namespace MediaBrowser.Api.Playback.Hls
{ {
/// <summary>
/// Class GetHlsVideoStream
/// </summary>
[Route("/Videos/{Id}/stream.m3u8", "GET")]
[Api(Description = "Gets a video stream using HTTP live streaming.")]
public class GetHlsVideoStream : VideoStreamRequest
{
// TODO: Deprecate with new iOS app
[ApiMember(Name = "BaselineStreamAudioBitRate", Description = "Optional. Specify the audio bitrate for the baseline stream.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int? BaselineStreamAudioBitRate { get; set; }
[ApiMember(Name = "AppendBaselineStream", Description = "Optional. Whether or not to include a baseline audio-only stream in the master playlist.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
public bool AppendBaselineStream { get; set; }
[ApiMember(Name = "TimeStampOffsetMs", Description = "Optional. Alter the timestamps in the playlist by a given amount, in ms. Default is 1000.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
public int TimeStampOffsetMs { get; set; }
}
[Route("/Videos/{Id}/live.m3u8", "GET")] [Route("/Videos/{Id}/live.m3u8", "GET")]
[Api(Description = "Gets a video stream using HTTP live streaming.")] [Api(Description = "Gets a video stream using HTTP live streaming.")]
public class GetLiveHlsStream : VideoStreamRequest public class GetLiveHlsStream : VideoStreamRequest
@ -50,7 +31,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// </summary> /// </summary>
/// <param name="request">The request.</param> /// <param name="request">The request.</param>
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
public object Get(GetHlsVideoStream request) public object Get(GetHlsVideoStreamLegacy request)
{ {
return ProcessRequest(request, false); return ProcessRequest(request, false);
} }

View File

@ -15,7 +15,7 @@ using System.IO;
namespace MediaBrowser.Api.Playback.Progressive namespace MediaBrowser.Api.Playback.Progressive
{ {
/// <summary> /// <summary>
/// Class GetAudioStream /// Class GetVideoStream
/// </summary> /// </summary>
[Route("/Videos/{Id}/stream.ts", "GET")] [Route("/Videos/{Id}/stream.ts", "GET")]
[Route("/Videos/{Id}/stream.webm", "GET")] [Route("/Videos/{Id}/stream.webm", "GET")]

View File

@ -41,7 +41,7 @@ namespace MediaBrowser.Api.Playback
public string InputContainer { get; set; } public string InputContainer { get; set; }
public MediaSourceInfo MediaSource { get; set; } public MediaSourceInfo MediaSource { get; set; }
public MediaStream AudioStream { get; set; } public MediaStream AudioStream { get; set; }
public MediaStream VideoStream { get; set; } public MediaStream VideoStream { get; set; }
public MediaStream SubtitleStream { get; set; } public MediaStream SubtitleStream { get; set; }
@ -57,6 +57,10 @@ namespace MediaBrowser.Api.Playback
public MediaProtocol InputProtocol { get; set; } public MediaProtocol InputProtocol { get; set; }
public bool IsOutputVideo
{
get { return Request is VideoStreamRequest; }
}
public bool IsInputVideo { get; set; } public bool IsInputVideo { get; set; }
public bool IsInputArchive { get; set; } public bool IsInputArchive { get; set; }
@ -66,7 +70,6 @@ namespace MediaBrowser.Api.Playback
public List<string> PlayableStreamFileNames { get; set; } public List<string> PlayableStreamFileNames { get; set; }
public int SegmentLength = 3; public int SegmentLength = 3;
public bool EnableGenericHlsSegmenter = false;
public int HlsListSize public int HlsListSize
{ {
get get

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Dlna.Profiles
Identification = new DeviceIdentification Identification = new DeviceIdentification
{ {
ModelName = "WD TV HD Live", ModelName = "WD TV",
Headers = new [] Headers = new []
{ {

View File

@ -2,7 +2,7 @@
<Profile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Profile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>WDTV Live</Name> <Name>WDTV Live</Name>
<Identification> <Identification>
<ModelName>WD TV HD Live</ModelName> <ModelName>WD TV</ModelName>
<Headers> <Headers>
<HttpHeaderInfo name="User-Agent" value="alphanetworks" match="Substring" /> <HttpHeaderInfo name="User-Agent" value="alphanetworks" match="Substring" />
<HttpHeaderInfo name="User-Agent" value="ALPHA Networks" match="Substring" /> <HttpHeaderInfo name="User-Agent" value="ALPHA Networks" match="Substring" />

View File

@ -158,6 +158,11 @@ namespace MediaBrowser.Model.Dlna
if (MediaType == DlnaProfileType.Audio) if (MediaType == DlnaProfileType.Audio)
{ {
if (StringHelper.EqualsIgnoreCase(SubProtocol, "hls"))
{
return string.Format("{0}/audio/{1}/master.m3u8?{2}", baseUrl, ItemId, queryString);
}
return string.Format("{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString); return string.Format("{0}/audio/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
} }

View File

@ -82,9 +82,9 @@ namespace MediaBrowser.Server.Implementations.IO
} }
// This is an arbitraty amount of time, but delay it because file system writes often trigger events after RemoveTempIgnore has been called. // This is an arbitraty amount of time, but delay it because file system writes often trigger events after RemoveTempIgnore has been called.
// Seeing long delays in some situations, especially over the network. // Seeing long delays in some situations, especially over the network, sometimes up to 45 seconds
// Seeing delays up to 40 seconds, but not going to ignore changes for that long. // But if we make this delay too high, we risk missing legitimate changes
await Task.Delay(5000).ConfigureAwait(false); await Task.Delay(10000).ConfigureAwait(false);
string val; string val;
_tempIgnoredPaths.TryRemove(path, out val); _tempIgnoredPaths.TryRemove(path, out val);

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
//[assembly: AssemblyVersion("3.0.*")] [assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5621.1")] //[assembly: AssemblyVersion("3.0.5621.1")]