mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-16 03:03:40 +01:00
Merge branch 'master' into images
This commit is contained in:
@@ -12,7 +12,6 @@ using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Session;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -6,7 +6,6 @@ using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Net;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
@@ -640,7 +640,7 @@ namespace MediaBrowser.Api.Images
|
||||
IsHeadRequest = isHeadRequest,
|
||||
Path = imageResult.Item1,
|
||||
|
||||
FileShare = FileShareMode.Read
|
||||
FileShare = FileShare.Read
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -274,11 +274,9 @@ namespace MediaBrowser.Api.Images
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
|
||||
using (var stream = result.Content)
|
||||
using (var filestream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||
{
|
||||
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
|
||||
{
|
||||
await stream.CopyToAsync(filestream).ConfigureAwait(false);
|
||||
}
|
||||
await stream.CopyToAsync(filestream).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(pointerCachePath));
|
||||
|
||||
@@ -305,7 +305,7 @@ namespace MediaBrowser.Api
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fullCachePath));
|
||||
using (var stream = result.Content)
|
||||
using (var filestream = _fileSystem.GetFileStream(fullCachePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
|
||||
using (var filestream = new FileStream(fullCachePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true))
|
||||
{
|
||||
await stream.CopyToAsync(filestream).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
|
||||
@@ -16,17 +16,13 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||
using MediaBrowser.Controller.Entities.Movies;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.TV;
|
||||
using MediaBrowser.Model.Activity;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Globalization;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -261,7 +261,7 @@ namespace MediaBrowser.Api.Playback
|
||||
var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt");
|
||||
|
||||
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
|
||||
Stream logStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true);
|
||||
Stream logStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, IODefaults.FileStreamBufferSize, true);
|
||||
|
||||
var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(Request.AbsoluteUri + Environment.NewLine + Environment.NewLine + JsonSerializer.SerializeToString(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine);
|
||||
await logStream.WriteAsync(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
private string GetLivePlaylistText(string path, int segmentLength)
|
||||
{
|
||||
using (var stream = FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite))
|
||||
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
@@ -211,7 +211,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
try
|
||||
{
|
||||
// Need to use FileShareMode.ReadWrite because we're reading the file at the same time it's being written
|
||||
// Need to use FileShare.ReadWrite because we're reading the file at the same time it's being written
|
||||
using (var fileStream = GetPlaylistFileStream(playlist))
|
||||
{
|
||||
using (var reader = new StreamReader(fileStream))
|
||||
@@ -252,11 +252,11 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
try
|
||||
{
|
||||
return FileSystem.GetFileStream(tmpPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, FileOpenOptions.SequentialScan);
|
||||
return new FileStream(tmpPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, FileOptions.SequentialScan);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
return FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, FileOpenOptions.SequentialScan);
|
||||
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, FileOptions.SequentialScan);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Services;
|
||||
@@ -537,7 +536,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||
{
|
||||
Path = segmentPath,
|
||||
FileShare = FileShareMode.ReadWrite,
|
||||
FileShare = FileShare.ReadWrite,
|
||||
OnComplete = () =>
|
||||
{
|
||||
Logger.LogDebug("finished serving {0}", segmentPath);
|
||||
@@ -954,12 +953,12 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
// Unable to force key frames to h264_qsv transcode
|
||||
if (string.Equals(codec, "h264_qsv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Logger.LogInformation("Bug Workaround: Disabling force_key_frames for h264_qsv");
|
||||
}
|
||||
Logger.LogInformation("Bug Workaround: Disabling force_key_frames for h264_qsv");
|
||||
}
|
||||
else
|
||||
{
|
||||
args += " " + keyFrameArg;
|
||||
}
|
||||
}
|
||||
|
||||
//args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0";
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||
file = Path.Combine(ServerConfigurationManager.GetTranscodePath(), file);
|
||||
|
||||
return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite);
|
||||
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
||||
}
|
||||
|
||||
private Task<object> GetFileResult(string path, string playlistPath)
|
||||
@@ -150,7 +150,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||
{
|
||||
Path = path,
|
||||
FileShare = FileShareMode.ReadWrite,
|
||||
FileShare = FileShare.ReadWrite,
|
||||
OnComplete = () =>
|
||||
{
|
||||
if (transcodingJob != null)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using System.Linq;
|
||||
@@ -23,7 +22,6 @@ using MediaBrowser.Model.Dlna;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.MediaInfo;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Services;
|
||||
using MediaBrowser.Model.Session;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
// ContentType = contentType,
|
||||
// IsHeadRequest = isHeadRequest,
|
||||
// Path = outputPath,
|
||||
// FileShare = FileShareMode.ReadWrite,
|
||||
// FileShare = FileShare.ReadWrite,
|
||||
// OnComplete = () =>
|
||||
// {
|
||||
// if (transcodingJob != null)
|
||||
|
||||
@@ -21,8 +21,6 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
private readonly CancellationToken _cancellationToken;
|
||||
private readonly Dictionary<string, string> _outputHeaders;
|
||||
|
||||
const int StreamCopyToBufferSize = 81920;
|
||||
|
||||
private long _bytesWritten = 0;
|
||||
public long StartPosition { get; set; }
|
||||
public bool AllowEndOfFile = true;
|
||||
@@ -52,14 +50,14 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
private Stream GetInputStream(bool allowAsyncFileRead)
|
||||
{
|
||||
var fileOpenOptions = FileOpenOptions.SequentialScan;
|
||||
var fileOptions = FileOptions.SequentialScan;
|
||||
|
||||
if (allowAsyncFileRead)
|
||||
{
|
||||
fileOpenOptions |= FileOpenOptions.Asynchronous;
|
||||
fileOptions |= FileOptions.Asynchronous;
|
||||
}
|
||||
|
||||
return _fileSystem.GetFileStream(_path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, fileOpenOptions);
|
||||
return new FileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, IODefaults.FileStreamBufferSize, fileOptions);
|
||||
}
|
||||
|
||||
public async Task WriteToAsync(Stream outputStream, CancellationToken cancellationToken)
|
||||
@@ -127,7 +125,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
private async Task<int> CopyToInternalAsyncWithSyncRead(Stream source, Stream destination, CancellationToken cancellationToken)
|
||||
{
|
||||
var array = new byte[StreamCopyToBufferSize];
|
||||
var array = new byte[IODefaults.CopyToBufferSize];
|
||||
int bytesRead;
|
||||
int totalBytesRead = 0;
|
||||
|
||||
@@ -154,7 +152,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
private async Task<int> CopyToInternalAsync(Stream source, Stream destination, CancellationToken cancellationToken)
|
||||
{
|
||||
var array = new byte[StreamCopyToBufferSize];
|
||||
var array = new byte[IODefaults.CopyToBufferSize];
|
||||
int bytesRead;
|
||||
int totalBytesRead = 0;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using MediaBrowser.Model.Services;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace MediaBrowser.Api.Playback
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
}
|
||||
|
||||
public override void ReportTranscodingProgress(TimeSpan? transcodingPosition, float framerate, double? percentComplete, long bytesTranscoded, int? bitRate)
|
||||
public override void ReportTranscodingProgress(TimeSpan? transcodingPosition, float? framerate, double? percentComplete, long? bytesTranscoded, int? bitRate)
|
||||
{
|
||||
ApiEntryPoint.Instance.ReportTranscodingProgress(TranscodingJob, this, transcodingPosition, framerate, percentComplete, bytesTranscoded, bitRate);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.Session
|
||||
{
|
||||
/// <summary>
|
||||
/// Class GetSessions
|
||||
/// Class GetSessions.
|
||||
/// </summary>
|
||||
[Route("/Sessions", "GET", Summary = "Gets a list of sessions")]
|
||||
[Authenticated]
|
||||
@@ -34,7 +34,7 @@ namespace MediaBrowser.Api.Session
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class DisplayContent
|
||||
/// Class DisplayContent.
|
||||
/// </summary>
|
||||
[Route("/Sessions/{Id}/Viewing", "POST", Summary = "Instructs a session to browse to an item or view")]
|
||||
[Authenticated]
|
||||
@@ -230,6 +230,17 @@ namespace MediaBrowser.Api.Session
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Sessions/Viewing", "POST", Summary = "Reports that a session is viewing an item")]
|
||||
[Authenticated]
|
||||
public class ReportViewing : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "SessionId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string SessionId { get; set; }
|
||||
|
||||
[ApiMember(Name = "ItemId", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string ItemId { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Sessions/Logout", "POST", Summary = "Reports that a session has ended")]
|
||||
[Authenticated]
|
||||
public class ReportSessionEnded : IReturnVoid
|
||||
@@ -276,7 +287,7 @@ namespace MediaBrowser.Api.Session
|
||||
public class SessionsService : BaseApiService
|
||||
{
|
||||
/// <summary>
|
||||
/// The _session manager.
|
||||
/// The session manager.
|
||||
/// </summary>
|
||||
private readonly ISessionManager _sessionManager;
|
||||
|
||||
@@ -438,14 +449,12 @@ namespace MediaBrowser.Api.Session
|
||||
public Task Post(SendSystemCommand request)
|
||||
{
|
||||
var name = request.Command;
|
||||
|
||||
if (Enum.TryParse(name, true, out GeneralCommandType commandType))
|
||||
{
|
||||
name = commandType.ToString();
|
||||
}
|
||||
|
||||
var currentSession = GetSession(_sessionContext);
|
||||
|
||||
var command = new GeneralCommand
|
||||
{
|
||||
Name = name,
|
||||
@@ -518,16 +527,13 @@ namespace MediaBrowser.Api.Session
|
||||
{
|
||||
request.Id = GetSession(_sessionContext).Id;
|
||||
}
|
||||
|
||||
_sessionManager.ReportCapabilities(request.Id, new ClientCapabilities
|
||||
{
|
||||
PlayableMediaTypes = SplitValue(request.PlayableMediaTypes, ','),
|
||||
|
||||
SupportedCommands = SplitValue(request.SupportedCommands, ','),
|
||||
|
||||
SupportsMediaControl = request.SupportsMediaControl,
|
||||
|
||||
SupportsSync = request.SupportsSync,
|
||||
|
||||
SupportsPersistentIdentifier = request.SupportsPersistentIdentifier
|
||||
});
|
||||
}
|
||||
@@ -538,7 +544,15 @@ namespace MediaBrowser.Api.Session
|
||||
{
|
||||
request.Id = GetSession(_sessionContext).Id;
|
||||
}
|
||||
|
||||
_sessionManager.ReportCapabilities(request.Id, request);
|
||||
}
|
||||
|
||||
public void Post(ReportViewing request)
|
||||
{
|
||||
request.SessionId = GetSession(_sessionContext).Id;
|
||||
|
||||
_sessionManager.ReportNowViewingItem(request.SessionId, request.ItemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Activity;
|
||||
|
||||
@@ -170,10 +170,10 @@ namespace MediaBrowser.Api.System
|
||||
// For older files, assume fully static
|
||||
if (file.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-1))
|
||||
{
|
||||
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShareMode.Read);
|
||||
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShare.Read);
|
||||
}
|
||||
|
||||
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShareMode.ReadWrite);
|
||||
return ResultFactory.GetStaticFileResult(Request, file.FullName, FileShare.ReadWrite);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,7 +5,6 @@ using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
|
||||
@@ -6,7 +6,6 @@ using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Services;
|
||||
|
||||
@@ -103,10 +103,6 @@ namespace MediaBrowser.Api.UserLibrary
|
||||
[ApiMember(Name = "MediaSourceId", Description = "The id of the MediaSource", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "POST")]
|
||||
public string MediaSourceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="UpdateUserItemRating" /> is likes.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if likes; otherwise, <c>false</c>.</value>
|
||||
[ApiMember(Name = "CanSeek", Description = "Indicates if the client can seek", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "POST")]
|
||||
public bool CanSeek { get; set; }
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace MediaBrowser.Api
|
||||
public class UserService : BaseApiService
|
||||
{
|
||||
/// <summary>
|
||||
/// The _user manager
|
||||
/// The user manager.
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ISessionManager _sessionMananger;
|
||||
@@ -281,7 +281,6 @@ namespace MediaBrowser.Api
|
||||
{
|
||||
IsHidden = false,
|
||||
IsDisabled = false
|
||||
|
||||
}, true, true);
|
||||
}
|
||||
|
||||
@@ -395,10 +394,11 @@ namespace MediaBrowser.Api
|
||||
throw new MethodNotAllowedException("Hashed-only passwords are not valid for this API.");
|
||||
}
|
||||
|
||||
// Password should always be null
|
||||
return Post(new AuthenticateUserByName
|
||||
{
|
||||
Username = user.Name,
|
||||
Password = null, // This should always be null
|
||||
Password = null,
|
||||
Pw = request.Pw
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user