mirror of https://github.com/jellyfin/jellyfin.git
update stream start events
This commit is contained in:
parent
db9c02fffd
commit
eb36b009ca
|
@ -22,6 +22,8 @@ using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback
|
namespace MediaBrowser.Api.Playback
|
||||||
{
|
{
|
||||||
|
@ -69,6 +71,9 @@ namespace MediaBrowser.Api.Playback
|
||||||
protected IZipClient ZipClient { get; private set; }
|
protected IZipClient ZipClient { get; private set; }
|
||||||
protected IJsonSerializer JsonSerializer { get; private set; }
|
protected IJsonSerializer JsonSerializer { get; private set; }
|
||||||
|
|
||||||
|
public static IServerApplicationHost AppHost;
|
||||||
|
public static IHttpClient HttpClient;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
|
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1112,6 +1117,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
}
|
}
|
||||||
|
|
||||||
StartThrottler(state, transcodingJob);
|
StartThrottler(state, transcodingJob);
|
||||||
|
ReportUsage(state);
|
||||||
|
|
||||||
return transcodingJob;
|
return transcodingJob;
|
||||||
}
|
}
|
||||||
|
@ -1131,7 +1137,7 @@ namespace MediaBrowser.Api.Playback
|
||||||
return state.InputProtocol == MediaProtocol.File &&
|
return state.InputProtocol == MediaProtocol.File &&
|
||||||
state.RunTimeTicks.HasValue &&
|
state.RunTimeTicks.HasValue &&
|
||||||
state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks &&
|
state.RunTimeTicks.Value >= TimeSpan.FromMinutes(5).Ticks &&
|
||||||
state.IsInputVideo &&
|
state.IsInputVideo &&
|
||||||
state.VideoType == VideoType.VideoFile &&
|
state.VideoType == VideoType.VideoFile &&
|
||||||
!string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) &&
|
!string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) &&
|
||||||
string.Equals(GetVideoEncoder(state), "libx264", StringComparison.OrdinalIgnoreCase);
|
string.Equals(GetVideoEncoder(state), "libx264", StringComparison.OrdinalIgnoreCase);
|
||||||
|
@ -2197,6 +2203,121 @@ namespace MediaBrowser.Api.Playback
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void ReportUsage(StreamState state)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await ReportUsageInternal(state).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task ReportUsageInternal(StreamState state)
|
||||||
|
{
|
||||||
|
if (!ServerConfigurationManager.Configuration.EnableAnonymousUsageReporting)
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.Equals(MediaEncoder.EncoderLocationType, "Default", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
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 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
options.RequestContent = JsonSerializer.SerializeToString(dict);
|
||||||
|
options.RequestContentType = "application/json";
|
||||||
|
|
||||||
|
return HttpClient.Post(options);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the dlna headers.
|
/// Adds the dlna headers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -123,10 +123,22 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
||||||
return "System";
|
return "System";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsDefaultPath(FFMpegPath))
|
||||||
|
{
|
||||||
|
return "Default";
|
||||||
|
}
|
||||||
|
|
||||||
return "Custom";
|
return "Custom";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsDefaultPath(string path)
|
||||||
|
{
|
||||||
|
var parentPath = Path.Combine(ConfigurationManager.ApplicationPaths.ProgramDataPath, "ffmpeg", "20160410");
|
||||||
|
|
||||||
|
return FileSystem.ContainsSubPath(parentPath, path);
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsSystemInstalledPath(string path)
|
private bool IsSystemInstalledPath(string path)
|
||||||
{
|
{
|
||||||
if (path.IndexOf("/", StringComparison.Ordinal) == -1 && path.IndexOf("\\", StringComparison.Ordinal) == -1)
|
if (path.IndexOf("/", StringComparison.Ordinal) == -1 && path.IndexOf("\\", StringComparison.Ordinal) == -1)
|
||||||
|
|
|
@ -202,6 +202,7 @@ namespace MediaBrowser.Model.Configuration
|
||||||
public bool DisplaySpecialsWithinSeasons { get; set; }
|
public bool DisplaySpecialsWithinSeasons { get; set; }
|
||||||
public bool DisplayCollectionsView { get; set; }
|
public bool DisplayCollectionsView { get; set; }
|
||||||
public string[] LocalNetworkAddresses { get; set; }
|
public string[] LocalNetworkAddresses { get; set; }
|
||||||
|
public string[] CodecsUsed { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
|
@ -210,6 +211,7 @@ namespace MediaBrowser.Model.Configuration
|
||||||
{
|
{
|
||||||
LocalNetworkAddresses = new string[] { };
|
LocalNetworkAddresses = new string[] { };
|
||||||
Migrations = new string[] { };
|
Migrations = new string[] { };
|
||||||
|
CodecsUsed = new string[] { };
|
||||||
SqliteCacheSize = 0;
|
SqliteCacheSize = 0;
|
||||||
|
|
||||||
EnableLocalizedGuids = true;
|
EnableLocalizedGuids = true;
|
||||||
|
|
|
@ -101,6 +101,7 @@ using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CommonIO;
|
using CommonIO;
|
||||||
|
using MediaBrowser.Api.Playback;
|
||||||
using MediaBrowser.Common.Implementations.Updates;
|
using MediaBrowser.Common.Implementations.Updates;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Startup.Common
|
namespace MediaBrowser.Server.Startup.Common
|
||||||
|
@ -766,6 +767,8 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
BaseItem.CollectionManager = CollectionManager;
|
BaseItem.CollectionManager = CollectionManager;
|
||||||
BaseItem.MediaSourceManager = MediaSourceManager;
|
BaseItem.MediaSourceManager = MediaSourceManager;
|
||||||
CollectionFolder.XmlSerializer = XmlSerializer;
|
CollectionFolder.XmlSerializer = XmlSerializer;
|
||||||
|
BaseStreamingService.AppHost = this;
|
||||||
|
BaseStreamingService.HttpClient = HttpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue