mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
update live tv return object
This commit is contained in:
@@ -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<string, string>(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<MediaStream> GetMediaStreams(ChannelMediaInfo info)
|
||||
{
|
||||
var list = new List<MediaStream>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{Stream}.</returns>
|
||||
Task<LiveStreamInfo> GetRecordingStream(string id, CancellationToken cancellationToken);
|
||||
Task<ChannelMediaInfo> GetRecordingStream(string id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel stream.
|
||||
@@ -162,7 +163,7 @@ namespace MediaBrowser.Controller.LiveTv
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{StreamResponseInfo}.</returns>
|
||||
Task<LiveStreamInfo> GetChannelStream(string id, CancellationToken cancellationToken);
|
||||
Task<ChannelMediaInfo> GetChannelStream(string id, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the program.
|
||||
|
||||
@@ -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
|
||||
/// <param name="recordingId">The recording identifier.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{Stream}.</returns>
|
||||
Task<LiveStreamInfo> GetRecordingStream(string recordingId, CancellationToken cancellationToken);
|
||||
Task<ChannelMediaInfo> GetRecordingStream(string recordingId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the channel stream.
|
||||
@@ -180,7 +181,7 @@ namespace MediaBrowser.Controller.LiveTv
|
||||
/// <param name="channelId">The channel identifier.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{Stream}.</returns>
|
||||
Task<LiveStreamInfo> GetChannelStream(string channelId, CancellationToken cancellationToken);
|
||||
Task<ChannelMediaInfo> GetChannelStream(string channelId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Closes the live stream.
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.LiveTv
|
||||
{
|
||||
public class LiveStreamInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the path.
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the URL.
|
||||
/// </summary>
|
||||
/// <value>The URL.</value>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the identifier.
|
||||
/// </summary>
|
||||
/// <value>The identifier.</value>
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the media container.
|
||||
/// </summary>
|
||||
/// <value>The media container.</value>
|
||||
public string MediaContainer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the media streams.
|
||||
/// </summary>
|
||||
/// <value>The media streams.</value>
|
||||
public List<MediaStream> MediaStreams { get; set; }
|
||||
|
||||
public LiveStreamInfo()
|
||||
{
|
||||
MediaStreams = new List<MediaStream>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,6 @@
|
||||
<Compile Include="LiveTv\RecordingGroup.cs" />
|
||||
<Compile Include="LiveTv\RecordingStatusChangedEventArgs.cs" />
|
||||
<Compile Include="LiveTv\ILiveTvRecording.cs" />
|
||||
<Compile Include="LiveTv\LiveStreamInfo.cs" />
|
||||
<Compile Include="LiveTv\LiveTvAudioRecording.cs" />
|
||||
<Compile Include="LiveTv\LiveTvChannel.cs" />
|
||||
<Compile Include="LiveTv\ChannelInfo.cs" />
|
||||
|
||||
Reference in New Issue
Block a user