parent
64805410c2
commit
1d7d52ff9e
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,137 @@
|
|||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Devices;
|
||||||
|
using MediaBrowser.Controller.Dlna;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using System;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Dlna;
|
||||||
|
using MediaBrowser.Model.Services;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Api.Playback.Hls
|
||||||
|
{
|
||||||
|
[Route("/Videos/{Id}/live.m3u8", "GET")]
|
||||||
|
public class GetLiveHlsStream : VideoStreamRequest
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class VideoHlsService
|
||||||
|
/// </summary>
|
||||||
|
[Authenticated]
|
||||||
|
public class VideoHlsService : BaseHlsService
|
||||||
|
{
|
||||||
|
public object Get(GetLiveHlsStream request)
|
||||||
|
{
|
||||||
|
return ProcessRequest(request, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the audio arguments.
|
||||||
|
/// </summary>
|
||||||
|
protected override string GetAudioArguments(StreamState state, EncodingOptions encodingOptions)
|
||||||
|
{
|
||||||
|
var codec = EncodingHelper.GetAudioEncoder(state);
|
||||||
|
|
||||||
|
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return "-codec:a:0 copy";
|
||||||
|
}
|
||||||
|
|
||||||
|
var args = "-codec:a:0 " + codec;
|
||||||
|
|
||||||
|
var channels = state.OutputAudioChannels;
|
||||||
|
|
||||||
|
if (channels.HasValue)
|
||||||
|
{
|
||||||
|
args += " -ac " + channels.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bitrate = state.OutputAudioBitrate;
|
||||||
|
|
||||||
|
if (bitrate.HasValue)
|
||||||
|
{
|
||||||
|
args += " -ab " + bitrate.Value.ToString(UsCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.OutputAudioSampleRate.HasValue)
|
||||||
|
{
|
||||||
|
args += " -ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
args += " " + EncodingHelper.GetAudioFilterParam(state, encodingOptions, true);
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the video arguments.
|
||||||
|
/// </summary>
|
||||||
|
protected override string GetVideoArguments(StreamState state, EncodingOptions encodingOptions)
|
||||||
|
{
|
||||||
|
if (!state.IsOutputVideo)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var codec = EncodingHelper.GetVideoEncoder(state, encodingOptions);
|
||||||
|
|
||||||
|
var args = "-codec:v:0 " + codec;
|
||||||
|
|
||||||
|
// if (state.EnableMpegtsM2TsMode)
|
||||||
|
// {
|
||||||
|
// args += " -mpegts_m2ts_mode 1";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// See if we can save come cpu cycles by avoiding encoding
|
||||||
|
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// if h264_mp4toannexb is ever added, do not use it for live tv
|
||||||
|
if (state.VideoStream != null && EncodingHelper.IsH264(state.VideoStream) &&
|
||||||
|
!string.Equals(state.VideoStream.NalLengthSize, "0", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
args += " -bsf:v h264_mp4toannexb";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||||
|
|
||||||
|
args += " " + EncodingHelper.GetVideoQualityParam(state, codec, encodingOptions, GetDefaultH264Preset()) + keyFrameArg;
|
||||||
|
|
||||||
|
// Add resolution params, if specified
|
||||||
|
if (!hasGraphicalSubs)
|
||||||
|
{
|
||||||
|
args += EncodingHelper.GetOutputSizeParam(state, encodingOptions, codec);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is for internal graphical subs
|
||||||
|
if (hasGraphicalSubs)
|
||||||
|
{
|
||||||
|
args += EncodingHelper.GetGraphicalSubtitleParam(state, encodingOptions, codec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args += " -flags -global_header";
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(state.OutputVideoSync))
|
||||||
|
{
|
||||||
|
args += " -vsync " + state.OutputVideoSync;
|
||||||
|
}
|
||||||
|
|
||||||
|
args += EncodingHelper.GetOutputFFlags(state);
|
||||||
|
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Devices;
|
||||||
|
using MediaBrowser.Controller.Dlna;
|
||||||
|
using MediaBrowser.Controller.Drawing;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.MediaEncoding;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Services;
|
||||||
|
using MediaBrowser.Model.System;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Api.Playback.Progressive
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class GetVideoStream
|
||||||
|
/// </summary>
|
||||||
|
[Route("/Videos/{Id}/stream.mpegts", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.ts", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.webm", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.asf", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.wmv", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.ogv", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.mp4", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.m4v", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.mkv", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.mpeg", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.mpg", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.avi", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.m2ts", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.3gp", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.wmv", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.wtv", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.mov", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.iso", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.flv", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream", "GET")]
|
||||||
|
[Route("/Videos/{Id}/stream.ts", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.webm", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.asf", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.wmv", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.ogv", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.mp4", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.m4v", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.mkv", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.mpeg", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.mpg", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.avi", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.3gp", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.wmv", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.wtv", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.m2ts", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.mov", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.iso", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream.flv", "HEAD")]
|
||||||
|
[Route("/Videos/{Id}/stream", "HEAD")]
|
||||||
|
public class GetVideoStream : VideoStreamRequest
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class VideoService
|
||||||
|
/// </summary>
|
||||||
|
// TODO: In order to autheneticate this in the future, Dlna playback will require updating
|
||||||
|
//[Authenticated]
|
||||||
|
public class VideoService : BaseProgressiveStreamingService
|
||||||
|
{
|
||||||
|
public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor, environmentInfo)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request.</param>
|
||||||
|
/// <returns>System.Object.</returns>
|
||||||
|
public Task<object> Get(GetVideoStream request)
|
||||||
|
{
|
||||||
|
return ProcessRequest(request, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Heads the specified request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request.</param>
|
||||||
|
/// <returns>System.Object.</returns>
|
||||||
|
public Task<object> Head(GetVideoStream request)
|
||||||
|
{
|
||||||
|
return ProcessRequest(request, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetCommandLineArguments(string outputPath, EncodingOptions encodingOptions, StreamState state, bool isEncoding)
|
||||||
|
{
|
||||||
|
return EncodingHelper.GetProgressiveVideoFullCommandLine(state, encodingOptions, outputPath, GetDefaultH264Preset());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Target Name="EmitMSBuildWarning" BeforeTargets="Build">
|
||||||
|
<Warning Text="Packages containing MSBuild targets and props files cannot be fully installed in projects targeting multiple frameworks. The MSBuild targets and props files have been ignored." />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
</packages>
|
Loading…
Reference in new issue