mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-12 18:50:23 +01:00
added new cabac value
This commit is contained in:
@@ -122,53 +122,12 @@ namespace MediaBrowser.Api
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
const string XbmcMetadata = "Xbmc Nfo";
|
||||
const string MediaBrowserMetadata = "Media Browser Xml";
|
||||
|
||||
public void Post(AutoSetMetadataOptions request)
|
||||
{
|
||||
var service = AutoDetectMetadataService();
|
||||
|
||||
Logger.Info("Setting preferred metadata format to " + service);
|
||||
|
||||
var serviceToDisable = string.Equals(service, XbmcMetadata) ?
|
||||
MediaBrowserMetadata :
|
||||
XbmcMetadata;
|
||||
|
||||
_configurationManager.DisableMetadataService(serviceToDisable);
|
||||
_configurationManager.DisableMetadataService("Media Browser Xml");
|
||||
_configurationManager.SaveConfiguration();
|
||||
}
|
||||
|
||||
private string AutoDetectMetadataService()
|
||||
{
|
||||
try
|
||||
{
|
||||
var paths = _libraryManager.GetDefaultVirtualFolders()
|
||||
.SelectMany(i => i.Locations)
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Select(i => new DirectoryInfo(i))
|
||||
.ToList();
|
||||
|
||||
if (paths.SelectMany(i => i.EnumerateFiles("*.xml", SearchOption.AllDirectories))
|
||||
.Any())
|
||||
{
|
||||
return XbmcMetadata;
|
||||
}
|
||||
|
||||
if (paths.SelectMany(i => i.EnumerateFiles("*.xml", SearchOption.AllDirectories))
|
||||
.Any(i => string.Equals(i.Name, "series.xml", StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, "movie.xml", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return MediaBrowserMetadata;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return XbmcMetadata;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the specified configuraiton.
|
||||
/// </summary>
|
||||
|
||||
@@ -1978,6 +1978,7 @@ namespace MediaBrowser.Api.Playback
|
||||
state.TargetPacketLength,
|
||||
state.TargetTimestamp,
|
||||
state.IsTargetAnamorphic,
|
||||
state.IsTargetCabac,
|
||||
state.TargetRefFrames);
|
||||
|
||||
if (mediaProfile != null)
|
||||
@@ -2067,6 +2068,7 @@ namespace MediaBrowser.Api.Playback
|
||||
state.TargetPacketLength,
|
||||
state.TranscodeSeekInfo,
|
||||
state.IsTargetAnamorphic,
|
||||
state.IsTargetCabac,
|
||||
state.TargetRefFrames
|
||||
|
||||
).FirstOrDefault() ?? string.Empty;
|
||||
|
||||
@@ -501,7 +501,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
private void AppendPlaylist(StringBuilder builder, string url, int bitrate, string subtitleGroup)
|
||||
{
|
||||
var header = "#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=" + bitrate.ToString(UsCulture);
|
||||
var header = "#EXT-X-STREAM-INF:BANDWIDTH=" + bitrate.ToString(UsCulture);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(subtitleGroup))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Threading;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using ServiceStack.Web;
|
||||
using System;
|
||||
@@ -49,9 +48,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
/// <param name="responseStream">The response stream.</param>
|
||||
public void WriteTo(Stream responseStream)
|
||||
{
|
||||
var task = WriteToAsync(responseStream);
|
||||
|
||||
Task.WaitAll(task);
|
||||
WriteToInternal(responseStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,12 +56,12 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
/// </summary>
|
||||
/// <param name="responseStream">The response stream.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task WriteToAsync(Stream responseStream)
|
||||
private void WriteToInternal(Stream responseStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
await new ProgressiveFileCopier(_fileSystem, _job)
|
||||
.StreamFile(Path, responseStream).ConfigureAwait(false);
|
||||
new ProgressiveFileCopier(_fileSystem, _job)
|
||||
.StreamFile(Path, responseStream);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -95,16 +92,16 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
_job = job;
|
||||
}
|
||||
|
||||
public async Task StreamFile(string path, Stream outputStream)
|
||||
public void StreamFile(string path, Stream outputStream)
|
||||
{
|
||||
var eofCount = 0;
|
||||
long position = 0;
|
||||
|
||||
using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
|
||||
using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, false))
|
||||
{
|
||||
while (eofCount < 15)
|
||||
{
|
||||
await CopyToAsyncInternal(fs, outputStream, 81920, CancellationToken.None).ConfigureAwait(false);
|
||||
CopyToInternal(fs, outputStream, 81920);
|
||||
|
||||
var fsPosition = fs.Position;
|
||||
|
||||
@@ -118,7 +115,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
eofCount++;
|
||||
}
|
||||
await Task.Delay(100).ConfigureAwait(false);
|
||||
var task = Task.Delay(100);
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -130,13 +128,13 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CopyToAsyncInternal(Stream source, Stream destination, int bufferSize, CancellationToken cancellationToken)
|
||||
private void CopyToInternal(Stream source, Stream destination, int bufferSize)
|
||||
{
|
||||
byte[] array = new byte[bufferSize];
|
||||
int count;
|
||||
while ((count = await source.ReadAsync(array, 0, array.Length, cancellationToken).ConfigureAwait(false)) != 0)
|
||||
while ((count = source.Read(array, 0, array.Length)) != 0)
|
||||
{
|
||||
await destination.WriteAsync(array, 0, count, cancellationToken).ConfigureAwait(false);
|
||||
destination.Write(array, 0, count);
|
||||
|
||||
_bytesWritten += count;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using ServiceStack.Web;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
@@ -41,22 +40,7 @@ namespace MediaBrowser.Api.Playback
|
||||
/// <param name="responseStream">The response stream.</param>
|
||||
public void WriteTo(Stream responseStream)
|
||||
{
|
||||
var task = WriteToAsync(responseStream);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes to async.
|
||||
/// </summary>
|
||||
/// <param name="responseStream">The response stream.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task WriteToAsync(Stream responseStream)
|
||||
{
|
||||
using (_response)
|
||||
{
|
||||
await _response.Content.CopyToAsync(responseStream, 819200).ConfigureAwait(false);
|
||||
}
|
||||
_response.Content.CopyTo(responseStream, 819200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,5 +418,18 @@ namespace MediaBrowser.Api.Playback
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool? IsTargetCabac
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Request.Static)
|
||||
{
|
||||
return VideoStream == null ? null : VideoStream.IsCabac;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user