From b7ed4df4fa11e691dc91892c274aaeb0960fe0bc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 15 Oct 2014 00:11:40 -0400 Subject: update live tv return object --- .../Channels/ChannelMediaInfo.cs | 70 +++++++++++++++++++++- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 7 ++- MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 5 +- MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs | 43 ------------- .../MediaBrowser.Controller.csproj | 1 - 5 files changed, 76 insertions(+), 50 deletions(-) delete mode 100644 MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs index f16fd1120..64a4f355c 100644 --- a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs +++ b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs @@ -1,6 +1,10 @@ -using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Channels { @@ -31,6 +35,8 @@ namespace MediaBrowser.Controller.Channels public long? RunTimeTicks { get; set; } + public string Id { get; set; } + public ChannelMediaInfo() { RequiredHttpHeaders = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -38,5 +44,67 @@ namespace MediaBrowser.Controller.Channels // This is most common Protocol = MediaProtocol.Http; } + + public MediaSourceInfo ToMediaSource() + { + var id = Path.GetMD5().ToString("N"); + + var source = new MediaSourceInfo + { + MediaStreams = GetMediaStreams(this).ToList(), + + Container = Container, + Protocol = Protocol, + Path = Path, + RequiredHttpHeaders = RequiredHttpHeaders, + RunTimeTicks = RunTimeTicks, + Name = id, + Id = id + }; + + var bitrate = (AudioBitrate ?? 0) + (VideoBitrate ?? 0); + + if (bitrate > 0) + { + source.Bitrate = bitrate; + } + + return source; + } + + private IEnumerable GetMediaStreams(ChannelMediaInfo info) + { + var list = new List(); + + if (!string.IsNullOrWhiteSpace(info.VideoCodec) && + !string.IsNullOrWhiteSpace(info.AudioCodec)) + { + list.Add(new MediaStream + { + Type = MediaStreamType.Video, + Width = info.Width, + RealFrameRate = info.Framerate, + Profile = info.VideoProfile, + Level = info.VideoLevel, + Index = -1, + Height = info.Height, + Codec = info.VideoCodec, + BitRate = info.VideoBitrate, + AverageFrameRate = info.Framerate + }); + + list.Add(new MediaStream + { + Type = MediaStreamType.Audio, + Index = -1, + Codec = info.AudioCodec, + BitRate = info.AudioBitrate, + Channels = info.AudioChannels, + SampleRate = info.AudioSampleRate + }); + } + + return list; + } } } \ No newline at end of file diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 370ac2e75..fcd973ec2 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Channels; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Dto; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; @@ -154,7 +155,7 @@ namespace MediaBrowser.Controller.LiveTv /// The identifier. /// The cancellation token. /// Task{Stream}. - Task GetRecordingStream(string id, CancellationToken cancellationToken); + Task GetRecordingStream(string id, CancellationToken cancellationToken); /// /// Gets the channel stream. @@ -162,7 +163,7 @@ namespace MediaBrowser.Controller.LiveTv /// The identifier. /// The cancellation token. /// Task{StreamResponseInfo}. - Task GetChannelStream(string id, CancellationToken cancellationToken); + Task GetChannelStream(string id, CancellationToken cancellationToken); /// /// Gets the program. diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 3abbe500f..eda69b164 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Controller.Channels; namespace MediaBrowser.Controller.LiveTv { @@ -172,7 +173,7 @@ namespace MediaBrowser.Controller.LiveTv /// The recording identifier. /// The cancellation token. /// Task{Stream}. - Task GetRecordingStream(string recordingId, CancellationToken cancellationToken); + Task GetRecordingStream(string recordingId, CancellationToken cancellationToken); /// /// Gets the channel stream. @@ -180,7 +181,7 @@ namespace MediaBrowser.Controller.LiveTv /// The channel identifier. /// The cancellation token. /// Task{Stream}. - Task GetChannelStream(string channelId, CancellationToken cancellationToken); + Task GetChannelStream(string channelId, CancellationToken cancellationToken); /// /// Closes the live stream. diff --git a/MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs b/MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs deleted file mode 100644 index 019c9d31a..000000000 --- a/MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -using MediaBrowser.Model.Entities; -using System.Collections.Generic; - -namespace MediaBrowser.Controller.LiveTv -{ - public class LiveStreamInfo - { - /// - /// Gets or sets the path. - /// - /// The path. - public string Path { get; set; } - - /// - /// Gets or sets the URL. - /// - /// The URL. - public string Url { get; set; } - - /// - /// Gets or sets the identifier. - /// - /// The identifier. - public string Id { get; set; } - - /// - /// Gets or sets the media container. - /// - /// The media container. - public string MediaContainer { get; set; } - - /// - /// Gets or sets the media streams. - /// - /// The media streams. - public List MediaStreams { get; set; } - - public LiveStreamInfo() - { - MediaStreams = new List(); - } - } -} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 8ae605b62..7039a00eb 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -181,7 +181,6 @@ - -- cgit v1.2.3