|
@@ -2,7 +2,6 @@
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Configuration;
|
|
using MediaBrowser.Controller.Devices;
|
|
using MediaBrowser.Controller.Devices;
|
|
using MediaBrowser.Controller.Dlna;
|
|
using MediaBrowser.Controller.Dlna;
|
|
-using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Controller.Library;
|
|
using MediaBrowser.Controller.MediaEncoding;
|
|
using MediaBrowser.Controller.MediaEncoding;
|
|
using MediaBrowser.Model.Dlna;
|
|
using MediaBrowser.Model.Dlna;
|
|
@@ -14,18 +13,15 @@ using MediaBrowser.Model.MediaInfo;
|
|
using MediaBrowser.Model.Serialization;
|
|
using MediaBrowser.Model.Serialization;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
-using System.Diagnostics;
|
|
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
-using MediaBrowser.Common.IO;
|
|
|
|
-using MediaBrowser.Model.IO;
|
|
|
|
using MediaBrowser.Common.Net;
|
|
using MediaBrowser.Common.Net;
|
|
using MediaBrowser.Controller;
|
|
using MediaBrowser.Controller;
|
|
-using MediaBrowser.Controller.IO;
|
|
|
|
|
|
+using MediaBrowser.Model.Diagnostics;
|
|
|
|
|
|
namespace MediaBrowser.Api.Playback
|
|
namespace MediaBrowser.Api.Playback
|
|
{
|
|
{
|
|
@@ -1158,32 +1154,24 @@ namespace MediaBrowser.Api.Playback
|
|
var transcodingId = Guid.NewGuid().ToString("N");
|
|
var transcodingId = Guid.NewGuid().ToString("N");
|
|
var commandLineArgs = GetCommandLineArguments(outputPath, state, true);
|
|
var commandLineArgs = GetCommandLineArguments(outputPath, state, true);
|
|
|
|
|
|
- var process = new Process
|
|
|
|
|
|
+ var process = ApiEntryPoint.Instance.ProcessFactory.Create(new ProcessOptions
|
|
{
|
|
{
|
|
- StartInfo = new ProcessStartInfo
|
|
|
|
- {
|
|
|
|
- CreateNoWindow = true,
|
|
|
|
- UseShellExecute = false,
|
|
|
|
|
|
+ CreateNoWindow = true,
|
|
|
|
+ UseShellExecute = false,
|
|
|
|
|
|
- // Must consume both stdout and stderr or deadlocks may occur
|
|
|
|
- //RedirectStandardOutput = true,
|
|
|
|
- RedirectStandardError = true,
|
|
|
|
- RedirectStandardInput = true,
|
|
|
|
|
|
+ // Must consume both stdout and stderr or deadlocks may occur
|
|
|
|
+ //RedirectStandardOutput = true,
|
|
|
|
+ RedirectStandardError = true,
|
|
|
|
+ RedirectStandardInput = true,
|
|
|
|
|
|
- FileName = MediaEncoder.EncoderPath,
|
|
|
|
- Arguments = commandLineArgs,
|
|
|
|
|
|
+ FileName = MediaEncoder.EncoderPath,
|
|
|
|
+ Arguments = commandLineArgs,
|
|
|
|
|
|
- WindowStyle = ProcessWindowStyle.Hidden,
|
|
|
|
- ErrorDialog = false
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- EnableRaisingEvents = true
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- if (!string.IsNullOrWhiteSpace(workingDirectory))
|
|
|
|
- {
|
|
|
|
- process.StartInfo.WorkingDirectory = workingDirectory;
|
|
|
|
- }
|
|
|
|
|
|
+ IsHidden = true,
|
|
|
|
+ ErrorDialog = false,
|
|
|
|
+ EnableRaisingEvents = true,
|
|
|
|
+ WorkingDirectory = !string.IsNullOrWhiteSpace(workingDirectory) ? workingDirectory : null
|
|
|
|
+ });
|
|
|
|
|
|
var transcodingJob = ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath,
|
|
var transcodingJob = ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath,
|
|
state.Request.PlaySessionId,
|
|
state.Request.PlaySessionId,
|
|
@@ -1268,7 +1256,7 @@ namespace MediaBrowser.Api.Playback
|
|
{
|
|
{
|
|
if (EnableThrottling(state))
|
|
if (EnableThrottling(state))
|
|
{
|
|
{
|
|
- transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager);
|
|
|
|
|
|
+ transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager, ApiEntryPoint.Instance.TimerFactory, FileSystem);
|
|
state.TranscodingThrottler.Start();
|
|
state.TranscodingThrottler.Start();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1520,7 +1508,7 @@ namespace MediaBrowser.Api.Playback
|
|
/// <param name="process">The process.</param>
|
|
/// <param name="process">The process.</param>
|
|
/// <param name="job">The job.</param>
|
|
/// <param name="job">The job.</param>
|
|
/// <param name="state">The state.</param>
|
|
/// <param name="state">The state.</param>
|
|
- private void OnFfMpegProcessExited(Process process, TranscodingJob job, StreamState state)
|
|
|
|
|
|
+ private void OnFfMpegProcessExited(IProcess process, TranscodingJob job, StreamState state)
|
|
{
|
|
{
|
|
if (job != null)
|
|
if (job != null)
|
|
{
|
|
{
|
|
@@ -2408,97 +2396,98 @@ namespace MediaBrowser.Api.Playback
|
|
{
|
|
{
|
|
return Task.FromResult(true);
|
|
return Task.FromResult(true);
|
|
}
|
|
}
|
|
|
|
+ return Task.FromResult(true);
|
|
|
|
|
|
- var dict = new Dictionary<string, string>();
|
|
|
|
|
|
+ //var dict = new Dictionary<string, string>();
|
|
|
|
|
|
- var outputAudio = GetAudioEncoder(state);
|
|
|
|
- if (!string.IsNullOrWhiteSpace(outputAudio))
|
|
|
|
- {
|
|
|
|
- dict["outputAudio"] = outputAudio;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var outputVideo = GetVideoEncoder(state);
|
|
|
|
- if (!string.IsNullOrWhiteSpace(outputVideo))
|
|
|
|
- {
|
|
|
|
- dict["outputVideo"] = outputVideo;
|
|
|
|
- }
|
|
|
|
|
|
+ //var outputAudio = GetAudioEncoder(state);
|
|
|
|
+ //if (!string.IsNullOrWhiteSpace(outputAudio))
|
|
|
|
+ //{
|
|
|
|
+ // dict["outputAudio"] = outputAudio;
|
|
|
|
+ //}
|
|
|
|
|
|
- if (ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase) &&
|
|
|
|
- ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
|
|
- {
|
|
|
|
- return Task.FromResult(true);
|
|
|
|
- }
|
|
|
|
|
|
+ //var outputVideo = GetVideoEncoder(state);
|
|
|
|
+ //if (!string.IsNullOrWhiteSpace(outputVideo))
|
|
|
|
+ //{
|
|
|
|
+ // dict["outputVideo"] = outputVideo;
|
|
|
|
+ //}
|
|
|
|
|
|
- dict["id"] = AppHost.SystemId;
|
|
|
|
- dict["type"] = state.VideoRequest == null ? "Audio" : "Video";
|
|
|
|
|
|
+ //if (ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase) &&
|
|
|
|
+ // ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
|
|
+ //{
|
|
|
|
+ // return Task.FromResult(true);
|
|
|
|
+ //}
|
|
|
|
|
|
- var audioStream = state.AudioStream;
|
|
|
|
- if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec))
|
|
|
|
- {
|
|
|
|
- dict["inputAudio"] = audioStream.Codec;
|
|
|
|
- }
|
|
|
|
|
|
+ //dict["id"] = AppHost.SystemId;
|
|
|
|
+ //dict["type"] = state.VideoRequest == null ? "Audio" : "Video";
|
|
|
|
|
|
- var videoStream = state.VideoStream;
|
|
|
|
- if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec))
|
|
|
|
- {
|
|
|
|
- dict["inputVideo"] = videoStream.Codec;
|
|
|
|
- }
|
|
|
|
|
|
+ //var audioStream = state.AudioStream;
|
|
|
|
+ //if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec))
|
|
|
|
+ //{
|
|
|
|
+ // dict["inputAudio"] = audioStream.Codec;
|
|
|
|
+ //}
|
|
|
|
|
|
- var cert = GetType().Assembly.GetModules().First().GetSignerCertificate();
|
|
|
|
- if (cert != null)
|
|
|
|
- {
|
|
|
|
- dict["assemblySig"] = cert.GetCertHashString();
|
|
|
|
- dict["certSubject"] = cert.Subject ?? string.Empty;
|
|
|
|
- dict["certIssuer"] = cert.Issuer ?? string.Empty;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- return Task.FromResult(true);
|
|
|
|
- }
|
|
|
|
|
|
+ //var videoStream = state.VideoStream;
|
|
|
|
+ //if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec))
|
|
|
|
+ //{
|
|
|
|
+ // dict["inputVideo"] = videoStream.Codec;
|
|
|
|
+ //}
|
|
|
|
|
|
- if (state.SupportedAudioCodecs.Count > 0)
|
|
|
|
- {
|
|
|
|
- dict["supportedAudioCodecs"] = string.Join(",", state.SupportedAudioCodecs.ToArray());
|
|
|
|
- }
|
|
|
|
|
|
+ //var cert = GetType().Assembly.GetModules().First().GetSignerCertificate();
|
|
|
|
+ //if (cert != null)
|
|
|
|
+ //{
|
|
|
|
+ // dict["assemblySig"] = cert.GetCertHashString();
|
|
|
|
+ // dict["certSubject"] = cert.Subject ?? string.Empty;
|
|
|
|
+ // dict["certIssuer"] = cert.Issuer ?? string.Empty;
|
|
|
|
+ //}
|
|
|
|
+ //else
|
|
|
|
+ //{
|
|
|
|
+ // return Task.FromResult(true);
|
|
|
|
+ //}
|
|
|
|
|
|
- var auth = AuthorizationContext.GetAuthorizationInfo(Request);
|
|
|
|
|
|
+ //if (state.SupportedAudioCodecs.Count > 0)
|
|
|
|
+ //{
|
|
|
|
+ // dict["supportedAudioCodecs"] = string.Join(",", state.SupportedAudioCodecs.ToArray());
|
|
|
|
+ //}
|
|
|
|
|
|
- dict["appName"] = auth.Client ?? string.Empty;
|
|
|
|
- dict["appVersion"] = auth.Version ?? string.Empty;
|
|
|
|
- dict["device"] = auth.Device ?? string.Empty;
|
|
|
|
- dict["deviceId"] = auth.DeviceId ?? string.Empty;
|
|
|
|
- dict["context"] = "streaming";
|
|
|
|
|
|
+ //var auth = AuthorizationContext.GetAuthorizationInfo(Request);
|
|
|
|
|
|
- //Logger.Info(JsonSerializer.SerializeToString(dict));
|
|
|
|
- if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
|
|
- {
|
|
|
|
- var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
|
|
|
|
- list.Add(outputAudio);
|
|
|
|
- ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
|
|
|
|
- }
|
|
|
|
|
|
+ //dict["appName"] = auth.Client ?? string.Empty;
|
|
|
|
+ //dict["appVersion"] = auth.Version ?? string.Empty;
|
|
|
|
+ //dict["device"] = auth.Device ?? string.Empty;
|
|
|
|
+ //dict["deviceId"] = auth.DeviceId ?? string.Empty;
|
|
|
|
+ //dict["context"] = "streaming";
|
|
|
|
|
|
- if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
|
|
- {
|
|
|
|
- var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
|
|
|
|
- list.Add(outputVideo);
|
|
|
|
- ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
|
|
|
|
- }
|
|
|
|
|
|
+ ////Logger.Info(JsonSerializer.SerializeToString(dict));
|
|
|
|
+ //if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
|
|
+ //{
|
|
|
|
+ // var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
|
|
|
|
+ // list.Add(outputAudio);
|
|
|
|
+ // ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
|
|
|
|
+ //}
|
|
|
|
|
|
- ServerConfigurationManager.SaveConfiguration();
|
|
|
|
|
|
+ //if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
|
|
|
+ //{
|
|
|
|
+ // var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
|
|
|
|
+ // list.Add(outputVideo);
|
|
|
|
+ // ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
|
|
|
|
+ //}
|
|
|
|
|
|
- //Logger.Info(JsonSerializer.SerializeToString(dict));
|
|
|
|
- var options = new HttpRequestOptions()
|
|
|
|
- {
|
|
|
|
- Url = "https://mb3admin.com/admin/service/transcoding/report",
|
|
|
|
- CancellationToken = CancellationToken.None,
|
|
|
|
- LogRequest = false,
|
|
|
|
- LogErrors = false,
|
|
|
|
- BufferContent = false
|
|
|
|
- };
|
|
|
|
- options.RequestContent = JsonSerializer.SerializeToString(dict);
|
|
|
|
- options.RequestContentType = "application/json";
|
|
|
|
|
|
+ //ServerConfigurationManager.SaveConfiguration();
|
|
|
|
|
|
- return HttpClient.Post(options);
|
|
|
|
|
|
+ ////Logger.Info(JsonSerializer.SerializeToString(dict));
|
|
|
|
+ //var options = new HttpRequestOptions()
|
|
|
|
+ //{
|
|
|
|
+ // Url = "https://mb3admin.com/admin/service/transcoding/report",
|
|
|
|
+ // CancellationToken = CancellationToken.None,
|
|
|
|
+ // LogRequest = false,
|
|
|
|
+ // LogErrors = false,
|
|
|
|
+ // BufferContent = false
|
|
|
|
+ //};
|
|
|
|
+ //options.RequestContent = JsonSerializer.SerializeToString(dict);
|
|
|
|
+ //options.RequestContentType = "application/json";
|
|
|
|
+
|
|
|
|
+ //return HttpClient.Post(options);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|