produce valid mpeg dash manifest

This commit is contained in:
Luke Pulverenti
2014-10-14 20:04:44 -04:00
parent daacf3f3db
commit 52776df012
2 changed files with 136 additions and 23 deletions

View File

@@ -825,6 +825,23 @@ namespace MediaBrowser.Api.Playback
return MediaEncoder.GetInputArgument(inputPath, protocol);
}
private MediaProtocol GetProtocol(string path)
{
if (path.StartsWith("Http", StringComparison.OrdinalIgnoreCase))
{
return MediaProtocol.Http;
}
if (path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase))
{
return MediaProtocol.Rtsp;
}
if (path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase))
{
return MediaProtocol.Rtmp;
}
return MediaProtocol.File;
}
private async Task AcquireResources(StreamState state, CancellationTokenSource cancellationTokenSource)
{
if (state.VideoType == VideoType.Iso && state.IsoType.HasValue && IsoManager.CanMount(state.MediaPath))
@@ -845,16 +862,15 @@ namespace MediaBrowser.Api.Playback
if (!string.IsNullOrEmpty(streamInfo.Path))
{
state.MediaPath = streamInfo.Path;
state.InputProtocol = MediaProtocol.File;
await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
}
else if (!string.IsNullOrEmpty(streamInfo.Url))
{
state.MediaPath = streamInfo.Url;
state.InputProtocol = MediaProtocol.Http;
}
await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
state.InputProtocol = GetProtocol(state.MediaPath);
AttachMediaStreamInfo(state, streamInfo.MediaStreams, state.VideoRequest, state.RequestedUrl);
checkCodecs = true;
}
@@ -869,16 +885,15 @@ namespace MediaBrowser.Api.Playback
if (!string.IsNullOrEmpty(streamInfo.Path))
{
state.MediaPath = streamInfo.Path;
state.InputProtocol = MediaProtocol.File;
await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
}
else if (!string.IsNullOrEmpty(streamInfo.Url))
{
state.MediaPath = streamInfo.Url;
state.InputProtocol = MediaProtocol.Http;
}
await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
state.InputProtocol = GetProtocol(state.MediaPath);
AttachMediaStreamInfo(state, streamInfo.MediaStreams, state.VideoRequest, state.RequestedUrl);
checkCodecs = true;
}
@@ -991,6 +1006,16 @@ namespace MediaBrowser.Api.Playback
await Task.Delay(100, cancellationTokenSource.Token).ConfigureAwait(false);
}
if (state.IsInputVideo && transcodingJob.Type == Api.TranscodingJobType.Progressive)
{
await Task.Delay(1000, cancellationTokenSource.Token).ConfigureAwait(false);
if (state.ReadInputAtNativeFramerate)
{
await Task.Delay(1000, cancellationTokenSource.Token).ConfigureAwait(false);
}
}
return transcodingJob;
}
@@ -1610,11 +1635,6 @@ namespace MediaBrowser.Api.Playback
{
state.InputTimestamp = mediaSource.Timestamp.Value;
}
if (video.IsShortcut)
{
state.MediaPath = File.ReadAllText(video.Path);
}
}
state.RunTimeTicks = mediaSource.RunTimeTicks;