aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-10-15 00:11:40 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-10-15 00:11:40 -0400
commitb7ed4df4fa11e691dc91892c274aaeb0960fe0bc (patch)
treec031639e4940fe6a738601d7835fe75e2e318a00 /MediaBrowser.Api
parentbd1bd5e87e1744b363279577a6550afc5f2229c1 (diff)
update live tv return object
Diffstat (limited to 'MediaBrowser.Api')
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs47
-rw-r--r--MediaBrowser.Api/Playback/Hls/MpegDashService.cs11
2 files changed, 32 insertions, 26 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index c188376fe6..919e51eccf 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -859,19 +859,12 @@ namespace MediaBrowser.Api.Playback
state.LiveTvStreamId = streamInfo.Id;
- if (!string.IsNullOrEmpty(streamInfo.Path))
- {
- state.MediaPath = streamInfo.Path;
- }
- else if (!string.IsNullOrEmpty(streamInfo.Url))
- {
- state.MediaPath = streamInfo.Url;
- }
+ state.MediaPath = streamInfo.Path;
+ state.InputProtocol = streamInfo.Protocol;
await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
-
- state.InputProtocol = GetProtocol(state.MediaPath);
- AttachMediaStreamInfo(state, streamInfo.MediaStreams, state.VideoRequest, state.RequestedUrl);
+
+ AttachMediaStreamInfo(state, streamInfo, state.VideoRequest, state.RequestedUrl);
checkCodecs = true;
}
@@ -882,19 +875,12 @@ namespace MediaBrowser.Api.Playback
state.LiveTvStreamId = streamInfo.Id;
- if (!string.IsNullOrEmpty(streamInfo.Path))
- {
- state.MediaPath = streamInfo.Path;
- }
- else if (!string.IsNullOrEmpty(streamInfo.Url))
- {
- state.MediaPath = streamInfo.Url;
- }
+ state.MediaPath = streamInfo.Path;
+ state.InputProtocol = streamInfo.Protocol;
await Task.Delay(1500, cancellationTokenSource.Token).ConfigureAwait(false);
- state.InputProtocol = GetProtocol(state.MediaPath);
- AttachMediaStreamInfo(state, streamInfo.MediaStreams, state.VideoRequest, state.RequestedUrl);
+ AttachMediaStreamInfo(state, streamInfo, state.VideoRequest, state.RequestedUrl);
checkCodecs = true;
}
@@ -1006,7 +992,7 @@ namespace MediaBrowser.Api.Playback
await Task.Delay(100, cancellationTokenSource.Token).ConfigureAwait(false);
}
- if (state.IsInputVideo && transcodingJob.Type == Api.TranscodingJobType.Progressive)
+ if (state.IsInputVideo && transcodingJob.Type == TranscodingJobType.Progressive)
{
await Task.Delay(1000, cancellationTokenSource.Token).ConfigureAwait(false);
@@ -1713,6 +1699,23 @@ namespace MediaBrowser.Api.Playback
}
private void AttachMediaStreamInfo(StreamState state,
+ ChannelMediaInfo mediaInfo,
+ VideoStreamRequest videoRequest,
+ string requestedUrl)
+ {
+ var mediaSource = mediaInfo.ToMediaSource();
+
+ state.InputProtocol = mediaSource.Protocol;
+ state.MediaPath = mediaSource.Path;
+ state.RunTimeTicks = mediaSource.RunTimeTicks;
+ state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders;
+ state.InputBitrate = mediaSource.Bitrate;
+ state.InputFileSize = mediaSource.Size;
+
+ AttachMediaStreamInfo(state, mediaSource.MediaStreams, videoRequest, requestedUrl);
+ }
+
+ private void AttachMediaStreamInfo(StreamState state,
List<MediaStream> mediaStreams,
VideoStreamRequest videoRequest,
string requestedUrl)
diff --git a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs
index 1150220158..baa6233809 100644
--- a/MediaBrowser.Api/Playback/Hls/MpegDashService.cs
+++ b/MediaBrowser.Api/Playback/Hls/MpegDashService.cs
@@ -103,7 +103,9 @@ namespace MediaBrowser.Api.Playback.Hls
var builder = new StringBuilder();
- var duration = "PT0H02M11.00S";
+ var time = TimeSpan.FromTicks(state.RunTimeTicks.Value);
+
+ var duration = "PT" + time.Hours.ToString("00", UsCulture) + "H" + time.Minutes.ToString("00", UsCulture) + "M" + time.Seconds.ToString("00", UsCulture) + ".00S";
builder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
builder.AppendFormat(
@@ -239,16 +241,17 @@ namespace MediaBrowser.Api.Playback.Hls
{
var seconds = TimeSpan.FromTicks(state.RunTimeTicks ?? 0).TotalSeconds;
- builder.Append("<SegmentList timescale=\"1000\" duration=\"10000\">");
-
var queryStringIndex = Request.RawUrl.IndexOf('?');
var queryString = queryStringIndex == -1 ? string.Empty : Request.RawUrl.Substring(queryStringIndex);
var index = 0;
+ builder.Append("<SegmentList timescale=\"1000\" duration=\"10000\">");
while (seconds > 0)
{
- builder.AppendFormat("<SegmentURL media=\"{0}.ts{1}\"/>", index.ToString(UsCulture), SecurityElement.Escape(queryString));
+ var segmentUrl = string.Format("{0}.ts{1}", index.ToString(UsCulture), SecurityElement.Escape(queryString));
+
+ builder.AppendFormat("<SegmentURL media=\"{0}\"/>", segmentUrl);
seconds -= state.SegmentLength;
index++;