mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-07 16:28:56 +01:00
sync updates
This commit is contained in:
@@ -18,6 +18,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||
|
||||
namespace MediaBrowser.Api.Images
|
||||
{
|
||||
@@ -668,26 +669,26 @@ namespace MediaBrowser.Api.Images
|
||||
{
|
||||
if (format == ImageFormat.Bmp)
|
||||
{
|
||||
return Common.Net.MimeTypes.GetMimeType("i.bmp");
|
||||
return MimeTypes.GetMimeType("i.bmp");
|
||||
}
|
||||
if (format == ImageFormat.Gif)
|
||||
{
|
||||
return Common.Net.MimeTypes.GetMimeType("i.gif");
|
||||
return MimeTypes.GetMimeType("i.gif");
|
||||
}
|
||||
if (format == ImageFormat.Jpg)
|
||||
{
|
||||
return Common.Net.MimeTypes.GetMimeType("i.jpg");
|
||||
return MimeTypes.GetMimeType("i.jpg");
|
||||
}
|
||||
if (format == ImageFormat.Png)
|
||||
{
|
||||
return Common.Net.MimeTypes.GetMimeType("i.png");
|
||||
return MimeTypes.GetMimeType("i.png");
|
||||
}
|
||||
if (format == ImageFormat.Webp)
|
||||
{
|
||||
return Common.Net.MimeTypes.GetMimeType("i.webp");
|
||||
return MimeTypes.GetMimeType("i.webp");
|
||||
}
|
||||
|
||||
return Common.Net.MimeTypes.GetMimeType(path);
|
||||
return MimeTypes.GetMimeType(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Net;
|
||||
|
||||
namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||
|
||||
namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
@@ -387,7 +388,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
playlistText = GetMasterPlaylistFileText(state, videoBitrate + audioBitrate);
|
||||
}
|
||||
|
||||
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
private string GetMasterPlaylistFileText(StreamState state, int totalBitrate)
|
||||
@@ -603,7 +604,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
var playlistText = builder.ToString();
|
||||
|
||||
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
protected override string GetAudioArguments(StreamState state)
|
||||
@@ -640,10 +641,19 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
var codec = state.OutputVideoCodec;
|
||||
|
||||
// See if we can save come cpu cycles by avoiding encoding
|
||||
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
|
||||
var args = "-codec:v:0 " + codec;
|
||||
|
||||
if (state.EnableMpegtsM2TsMode)
|
||||
{
|
||||
return state.VideoStream != null && IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
|
||||
args += " -mpegts_m2ts_mode 1";
|
||||
}
|
||||
|
||||
// See if we can save come cpu cycles by avoiding encoding
|
||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return state.VideoStream != null && IsH264(state.VideoStream) ?
|
||||
args + " -bsf:v h264_mp4toannexb" :
|
||||
args;
|
||||
}
|
||||
|
||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||
@@ -651,7 +661,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
|
||||
// Add resolution params, if specified
|
||||
if (!hasGraphicalSubs)
|
||||
|
||||
@@ -18,6 +18,7 @@ using System.Security;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||
|
||||
namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
@@ -97,7 +98,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
playlistText = GetManifestText(state);
|
||||
}
|
||||
|
||||
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.mpd"), new Dictionary<string, string>());
|
||||
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.mpd"), new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
private string GetManifestText(StreamState state)
|
||||
@@ -583,10 +584,19 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
var codec = state.OutputVideoCodec;
|
||||
|
||||
var args = "-codec:v:0 " + codec;
|
||||
|
||||
if (state.EnableMpegtsM2TsMode)
|
||||
{
|
||||
args += " -mpegts_m2ts_mode 1";
|
||||
}
|
||||
|
||||
// See if we can save come cpu cycles by avoiding encoding
|
||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
|
||||
return state.VideoStream != null && IsH264(state.VideoStream) ?
|
||||
args + " -bsf:v h264_mp4toannexb" :
|
||||
args;
|
||||
}
|
||||
|
||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||
@@ -594,7 +604,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
args+= " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
|
||||
args += " -r 24 -g 24";
|
||||
|
||||
|
||||
@@ -134,18 +134,27 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
var codec = state.OutputVideoCodec;
|
||||
|
||||
var args = "-codec:v:0 " + codec;
|
||||
|
||||
if (state.EnableMpegtsM2TsMode)
|
||||
{
|
||||
args += " -mpegts_m2ts_mode 1";
|
||||
}
|
||||
|
||||
// See if we can save come cpu cycles by avoiding encoding
|
||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return state.VideoStream != null && IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
|
||||
return state.VideoStream != null && IsH264(state.VideoStream) ?
|
||||
args + " -bsf:v h264_mp4toannexb" :
|
||||
args;
|
||||
}
|
||||
|
||||
|
||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||
state.SegmentLength.ToString(UsCulture));
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
|
||||
|
||||
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
|
||||
|
||||
// Add resolution params, if specified
|
||||
if (!hasGraphicalSubs)
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
/// <returns>System.String.</returns>
|
||||
private string GetVideoArguments(StreamState state, string codec)
|
||||
{
|
||||
var args = "-vcodec " + codec;
|
||||
var args = "-codec:v:0 " + codec;
|
||||
|
||||
if (state.EnableMpegtsM2TsMode)
|
||||
{
|
||||
@@ -134,7 +134,9 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
// See if we can save come cpu cycles by avoiding encoding
|
||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return state.VideoStream != null && IsH264(state.VideoStream) ? args + " -bsf:v h264_mp4toannexb" : args;
|
||||
return state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) ?
|
||||
args + " -bsf:v h264_mp4toannexb" :
|
||||
args;
|
||||
}
|
||||
|
||||
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
|
||||
@@ -182,13 +184,13 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
// Get the output codec name
|
||||
var codec = state.OutputAudioCodec;
|
||||
|
||||
var args = "-codec:a:0 " + codec;
|
||||
|
||||
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "-acodec copy";
|
||||
return args;
|
||||
}
|
||||
|
||||
var args = "-acodec " + codec;
|
||||
|
||||
// Add the number of audio channels
|
||||
var channels = state.OutputAudioChannels;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using MediaBrowser.Model.Net;
|
||||
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
|
||||
|
||||
namespace MediaBrowser.Api.Subtitles
|
||||
{
|
||||
@@ -175,7 +176,7 @@ namespace MediaBrowser.Api.Subtitles
|
||||
|
||||
builder.AppendLine("#EXT-X-ENDLIST");
|
||||
|
||||
return ResultFactory.GetResult(builder.ToString(), Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
return ResultFactory.GetResult(builder.ToString(), MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
public object Get(GetSubtitle request)
|
||||
@@ -199,7 +200,7 @@ namespace MediaBrowser.Api.Subtitles
|
||||
|
||||
var stream = GetSubtitles(request).Result;
|
||||
|
||||
return ResultFactory.GetResult(stream, Common.Net.MimeTypes.GetMimeType("file." + request.Format));
|
||||
return ResultFactory.GetResult(stream, MimeTypes.GetMimeType("file." + request.Format));
|
||||
}
|
||||
|
||||
private async Task<Stream> GetSubtitles(GetSubtitle request)
|
||||
@@ -240,7 +241,7 @@ namespace MediaBrowser.Api.Subtitles
|
||||
{
|
||||
var result = _subtitleManager.GetRemoteSubtitles(request.Id, CancellationToken.None).Result;
|
||||
|
||||
return ResultFactory.GetResult(result.Stream, Common.Net.MimeTypes.GetMimeType("file." + result.Format));
|
||||
return ResultFactory.GetResult(result.Stream, MimeTypes.GetMimeType("file." + result.Format));
|
||||
}
|
||||
|
||||
public void Post(DownloadRemoteSubtitles request)
|
||||
|
||||
@@ -5,6 +5,7 @@ using MediaBrowser.Controller.Sync;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Sync;
|
||||
using MediaBrowser.Model.Users;
|
||||
using ServiceStack;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -60,7 +61,7 @@ namespace MediaBrowser.Api.Sync
|
||||
|
||||
[ApiMember(Name = "ParentId", Description = "ParentId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string ParentId { get; set; }
|
||||
|
||||
|
||||
[ApiMember(Name = "Category", Description = "Category", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public SyncCategory? Category { get; set; }
|
||||
}
|
||||
@@ -79,6 +80,11 @@ namespace MediaBrowser.Api.Sync
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Sync/OfflineActions", "POST", Summary = "Reports an action that occurred while offline.")]
|
||||
public class ReportOfflineActions : List<UserAction>, IReturnVoid
|
||||
{
|
||||
}
|
||||
|
||||
[Authenticated]
|
||||
public class SyncService : BaseApiService
|
||||
{
|
||||
@@ -173,9 +179,9 @@ namespace MediaBrowser.Api.Sync
|
||||
.Select(i => _dtoService.GetBaseItemDto(i, new DtoOptions
|
||||
{
|
||||
Fields = new List<ItemFields>
|
||||
{
|
||||
ItemFields.SyncInfo
|
||||
}
|
||||
{
|
||||
ItemFields.SyncInfo
|
||||
}
|
||||
}))
|
||||
.ToList();
|
||||
|
||||
@@ -184,5 +190,20 @@ namespace MediaBrowser.Api.Sync
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
public void Post(ReportOfflineActions request)
|
||||
{
|
||||
var task = PostAsync(request);
|
||||
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
|
||||
public async Task PostAsync(ReportOfflineActions request)
|
||||
{
|
||||
foreach (var action in request)
|
||||
{
|
||||
await _syncManager.ReportOfflineAction(action).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user