mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-24 09:44:47 +03:00
make api project portable
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Controller.Dlna;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
@@ -14,18 +13,15 @@ using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Model.Diagnostics;
|
||||
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
@@ -1158,32 +1154,24 @@ namespace MediaBrowser.Api.Playback
|
||||
var transcodingId = Guid.NewGuid().ToString("N");
|
||||
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,
|
||||
state.Request.PlaySessionId,
|
||||
@@ -1268,7 +1256,7 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1520,7 +1508,7 @@ namespace MediaBrowser.Api.Playback
|
||||
/// <param name="process">The process.</param>
|
||||
/// <param name="job">The job.</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)
|
||||
{
|
||||
@@ -2408,97 +2396,98 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
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 outputAudio = GetAudioEncoder(state);
|
||||
//if (!string.IsNullOrWhiteSpace(outputAudio))
|
||||
//{
|
||||
// dict["outputAudio"] = outputAudio;
|
||||
//}
|
||||
|
||||
var outputVideo = GetVideoEncoder(state);
|
||||
if (!string.IsNullOrWhiteSpace(outputVideo))
|
||||
{
|
||||
dict["outputVideo"] = outputVideo;
|
||||
}
|
||||
//var outputVideo = GetVideoEncoder(state);
|
||||
//if (!string.IsNullOrWhiteSpace(outputVideo))
|
||||
//{
|
||||
// dict["outputVideo"] = outputVideo;
|
||||
//}
|
||||
|
||||
if (ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase) &&
|
||||
ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
//if (ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputAudio ?? string.Empty, StringComparer.OrdinalIgnoreCase) &&
|
||||
// ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||
//{
|
||||
// return Task.FromResult(true);
|
||||
//}
|
||||
|
||||
dict["id"] = AppHost.SystemId;
|
||||
dict["type"] = state.VideoRequest == null ? "Audio" : "Video";
|
||||
//dict["id"] = AppHost.SystemId;
|
||||
//dict["type"] = state.VideoRequest == null ? "Audio" : "Video";
|
||||
|
||||
var audioStream = state.AudioStream;
|
||||
if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec))
|
||||
{
|
||||
dict["inputAudio"] = audioStream.Codec;
|
||||
}
|
||||
//var audioStream = state.AudioStream;
|
||||
//if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec))
|
||||
//{
|
||||
// dict["inputAudio"] = audioStream.Codec;
|
||||
//}
|
||||
|
||||
var videoStream = state.VideoStream;
|
||||
if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec))
|
||||
{
|
||||
dict["inputVideo"] = videoStream.Codec;
|
||||
}
|
||||
//var videoStream = state.VideoStream;
|
||||
//if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec))
|
||||
//{
|
||||
// dict["inputVideo"] = videoStream.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 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);
|
||||
//}
|
||||
|
||||
if (state.SupportedAudioCodecs.Count > 0)
|
||||
{
|
||||
dict["supportedAudioCodecs"] = string.Join(",", state.SupportedAudioCodecs.ToArray());
|
||||
}
|
||||
//if (state.SupportedAudioCodecs.Count > 0)
|
||||
//{
|
||||
// dict["supportedAudioCodecs"] = string.Join(",", state.SupportedAudioCodecs.ToArray());
|
||||
//}
|
||||
|
||||
var auth = AuthorizationContext.GetAuthorizationInfo(Request);
|
||||
//var auth = AuthorizationContext.GetAuthorizationInfo(Request);
|
||||
|
||||
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";
|
||||
//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";
|
||||
|
||||
//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();
|
||||
}
|
||||
////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();
|
||||
//}
|
||||
|
||||
if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
|
||||
list.Add(outputVideo);
|
||||
ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
|
||||
}
|
||||
//if (!ServerConfigurationManager.Configuration.CodecsUsed.Contains(outputVideo ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||
//{
|
||||
// var list = ServerConfigurationManager.Configuration.CodecsUsed.ToList();
|
||||
// list.Add(outputVideo);
|
||||
// ServerConfigurationManager.Configuration.CodecsUsed = list.ToArray();
|
||||
//}
|
||||
|
||||
ServerConfigurationManager.SaveConfiguration();
|
||||
//ServerConfigurationManager.SaveConfiguration();
|
||||
|
||||
//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";
|
||||
////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);
|
||||
//return HttpClient.Post(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user