mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-04-24 14:08:44 -04:00
commit
b1e76db21e
7 changed files with 154 additions and 31 deletions
|
@ -264,41 +264,26 @@ namespace MediaBrowser.Api.Playback
|
|||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
||||
private T Clone<T>(T obj)
|
||||
{
|
||||
// Since we're going to be setting properties on MediaSourceInfos that come out of _mediaSourceManager, we should clone it
|
||||
// Should we move this directly into MediaSourceManager?
|
||||
var json = JsonSerializer.SerializeToUtf8Bytes(obj);
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
|
||||
private async Task<PlaybackInfoResponse> GetPlaybackInfo(Guid id, Guid userId, string[] supportedLiveMediaTypes, string mediaSourceId = null, string liveStreamId = null)
|
||||
{
|
||||
var user = _userManager.GetUserById(userId);
|
||||
var item = _libraryManager.GetItemById(id);
|
||||
var result = new PlaybackInfoResponse();
|
||||
|
||||
MediaSourceInfo[] mediaSources;
|
||||
if (string.IsNullOrWhiteSpace(liveStreamId))
|
||||
{
|
||||
IEnumerable<MediaSourceInfo> mediaSources;
|
||||
try
|
||||
{
|
||||
// TODO handle supportedLiveMediaTypes ?
|
||||
mediaSources = await _mediaSourceManager.GetPlaybackMediaSources(item, user, true, false, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mediaSources = new List<MediaSourceInfo>();
|
||||
Logger.LogError(ex, "Could not find media sources for item id {id}", id);
|
||||
// TODO PlaybackException ??
|
||||
//result.ErrorCode = ex.ErrorCode;
|
||||
}
|
||||
|
||||
result.MediaSources = mediaSources.ToArray();
|
||||
// TODO handle supportedLiveMediaTypes?
|
||||
var mediaSourcesList = await _mediaSourceManager.GetPlaybackMediaSources(item, user, true, false, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(mediaSourceId))
|
||||
if (string.IsNullOrWhiteSpace(mediaSourceId))
|
||||
{
|
||||
result.MediaSources = result.MediaSources
|
||||
mediaSources = mediaSourcesList.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
mediaSources = mediaSourcesList
|
||||
.Where(i => string.Equals(i.Id, mediaSourceId, StringComparison.OrdinalIgnoreCase))
|
||||
.ToArray();
|
||||
}
|
||||
|
@ -307,11 +292,13 @@ namespace MediaBrowser.Api.Playback
|
|||
{
|
||||
var mediaSource = await _mediaSourceManager.GetLiveStream(liveStreamId, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
result.MediaSources = new MediaSourceInfo[] { mediaSource };
|
||||
mediaSources = new MediaSourceInfo[] { mediaSource };
|
||||
}
|
||||
|
||||
if (result.MediaSources.Count == 0)
|
||||
if (mediaSources.Length == 0)
|
||||
{
|
||||
result.MediaSources = Array.Empty<MediaSourceInfo>();
|
||||
|
||||
if (!result.ErrorCode.HasValue)
|
||||
{
|
||||
result.ErrorCode = PlaybackErrorCode.NoCompatibleStream;
|
||||
|
@ -319,7 +306,9 @@ namespace MediaBrowser.Api.Playback
|
|||
}
|
||||
else
|
||||
{
|
||||
result.MediaSources = Clone(result.MediaSources);
|
||||
// Since we're going to be setting properties on MediaSourceInfos that come out of _mediaSourceManager, we should clone it
|
||||
// Should we move this directly into MediaSourceManager?
|
||||
result.MediaSources = JsonSerializer.Deserialize<MediaSourceInfo[]>(JsonSerializer.SerializeToUtf8Bytes(mediaSources));
|
||||
|
||||
result.PlaySessionId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ namespace MediaBrowser.MediaEncoding.Probing
|
|||
/// </summary>
|
||||
/// <value>The start_pts.</value>
|
||||
[JsonPropertyName("start_pts")]
|
||||
public int StartPts { get; set; }
|
||||
public long StartPts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the is_avc.
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace MediaBrowser.Model.Dto
|
|||
{
|
||||
Formats = Array.Empty<string>();
|
||||
MediaStreams = new List<MediaStream>();
|
||||
MediaAttachments = Array.Empty<MediaAttachment>();
|
||||
RequiredHttpHeaders = new Dictionary<string, string>();
|
||||
SupportsTranscoding = true;
|
||||
SupportsDirectStream = true;
|
||||
|
|
|
@ -26,7 +26,7 @@ libswscale 5. 5.100 / 5. 5.100
|
|||
libswresample 3. 5.100 / 3. 5.100
|
||||
libpostproc 55. 5.100 / 55. 5.100";
|
||||
|
||||
public const string FFmpegV414Output = @"ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
|
||||
public const string FFmpegV414Output = @"ffmpeg version 4.1.4-1~deb10u1 Copyright (c) 2000-2019 the FFmpeg developers
|
||||
built with gcc 8 (Raspbian 8.3.0-6+rpi1)
|
||||
configuration: --prefix=/usr --extra-version='1~deb10u1' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --arch=arm --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
|
||||
libavutil 56. 22.100 / 56. 22.100
|
||||
|
@ -39,7 +39,7 @@ libswscale 5. 3.100 / 5. 3.100
|
|||
libswresample 3. 3.100 / 3. 3.100
|
||||
libpostproc 55. 3.100 / 55. 3.100";
|
||||
|
||||
public const string FFmpegV404Output = @"ffmpeg version 4.0.4 Copyright (c) 2000-2019 the FFmpeg developers
|
||||
public const string FFmpegV404Output = @"ffmpeg version 4.0.4 Copyright (c) 2000-2019 the FFmpeg developers
|
||||
built with gcc 8 (Debian 8.3.0-6)
|
||||
configuration: --toolchain=hardened --prefix=/usr --target-os=linux --enable-cross-compile --extra-cflags=--static --enable-gpl --enable-static --disable-doc --disable-ffplay --disable-shared --disable-libxcb --disable-sdl2 --disable-xlib --enable-libfontconfig --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libwebp --enable-libx264 --enable-libx265 --enable-libzvbi --enable-omx --enable-omx-rpi --enable-version3 --enable-vaapi --enable-vdpau --arch=amd64 --enable-nvenc --enable-nvdec
|
||||
libavutil 56. 14.100 / 56. 14.100
|
||||
|
@ -51,7 +51,7 @@ libswscale 5. 1.100 / 5. 1.100
|
|||
libswresample 3. 1.100 / 3. 1.100
|
||||
libpostproc 55. 1.100 / 55. 1.100";
|
||||
|
||||
public const string FFmpegGitUnknownOutput = @"ffmpeg version N-94303-g7cb4f8c962 Copyright (c) 2000-2019 the FFmpeg developers
|
||||
public const string FFmpegGitUnknownOutput = @"ffmpeg version N-94303-g7cb4f8c962 Copyright (c) 2000-2019 the FFmpeg developers
|
||||
built with gcc 9.1.1 (GCC) 20190716
|
||||
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
|
||||
libavutil 56. 30.100 / 56. 30.100
|
||||
|
|
22
tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs
Normal file
22
tests/Jellyfin.MediaEncoding.Tests/FFprobeParserTests.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.MediaEncoding.Probing;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.MediaEncoding.Tests
|
||||
{
|
||||
public class FFprobeParserTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("ffprobe1.json")]
|
||||
public async Task Test(string fileName)
|
||||
{
|
||||
var path = Path.Join("Test Data", fileName);
|
||||
using (var stream = File.OpenRead(path))
|
||||
{
|
||||
await JsonSerializer.DeserializeAsync<InternalMediaInfoResult>(stream).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,12 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Test Data\**\*.*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
|
|
105
tests/Jellyfin.MediaEncoding.Tests/Test Data/ffprobe1.json
Normal file
105
tests/Jellyfin.MediaEncoding.Tests/Test Data/ffprobe1.json
Normal file
|
@ -0,0 +1,105 @@
|
|||
{
|
||||
"streams": [
|
||||
{
|
||||
"index": 0,
|
||||
"codec_name": "h264",
|
||||
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
|
||||
"profile": "Main",
|
||||
"codec_type": "video",
|
||||
"codec_time_base": "1/50",
|
||||
"codec_tag_string": "[27][0][0][0]",
|
||||
"codec_tag": "0x001b",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"coded_width": 1920,
|
||||
"coded_height": 1080,
|
||||
"has_b_frames": 0,
|
||||
"sample_aspect_ratio": "0:1",
|
||||
"display_aspect_ratio": "0:1",
|
||||
"pix_fmt": "yuvj420p",
|
||||
"level": 42,
|
||||
"color_range": "pc",
|
||||
"color_space": "bt709",
|
||||
"color_transfer": "bt709",
|
||||
"color_primaries": "bt709",
|
||||
"chroma_location": "left",
|
||||
"field_order": "progressive",
|
||||
"refs": 1,
|
||||
"is_avc": "false",
|
||||
"nal_length_size": "0",
|
||||
"id": "0x1",
|
||||
"r_frame_rate": "25/1",
|
||||
"avg_frame_rate": "25/1",
|
||||
"time_base": "1/90000",
|
||||
"start_pts": 8570867078,
|
||||
"start_time": "95231.856422",
|
||||
"duration_ts": 31694552,
|
||||
"duration": "352.161689",
|
||||
"bits_per_raw_sample": "8",
|
||||
"disposition": {
|
||||
"default": 0,
|
||||
"dub": 0,
|
||||
"original": 0,
|
||||
"comment": 0,
|
||||
"lyrics": 0,
|
||||
"karaoke": 0,
|
||||
"forced": 0,
|
||||
"hearing_impaired": 0,
|
||||
"visual_impaired": 0,
|
||||
"clean_effects": 0,
|
||||
"attached_pic": 0,
|
||||
"timed_thumbnails": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"index": 1,
|
||||
"codec_name": "aac",
|
||||
"codec_long_name": "AAC (Advanced Audio Coding)",
|
||||
"profile": "LC",
|
||||
"codec_type": "audio",
|
||||
"codec_time_base": "1/44100",
|
||||
"codec_tag_string": "[15][0][0][0]",
|
||||
"codec_tag": "0x000f",
|
||||
"sample_fmt": "fltp",
|
||||
"sample_rate": "44100",
|
||||
"channels": 2,
|
||||
"channel_layout": "stereo",
|
||||
"bits_per_sample": 0,
|
||||
"id": "0x2",
|
||||
"r_frame_rate": "0/0",
|
||||
"avg_frame_rate": "0/0",
|
||||
"time_base": "1/90000",
|
||||
"start_pts": 8570867697,
|
||||
"start_time": "95231.863300",
|
||||
"duration_ts": 31695687,
|
||||
"duration": "352.174300",
|
||||
"bit_rate": "98191",
|
||||
"disposition": {
|
||||
"default": 0,
|
||||
"dub": 0,
|
||||
"original": 0,
|
||||
"comment": 0,
|
||||
"lyrics": 0,
|
||||
"karaoke": 0,
|
||||
"forced": 0,
|
||||
"hearing_impaired": 0,
|
||||
"visual_impaired": 0,
|
||||
"clean_effects": 0,
|
||||
"attached_pic": 0,
|
||||
"timed_thumbnails": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"format": {
|
||||
"filename": "TS Test record.ts",
|
||||
"nb_streams": 2,
|
||||
"nb_programs": 1,
|
||||
"format_name": "mpegts",
|
||||
"format_long_name": "MPEG-TS (MPEG-2 Transport Stream)",
|
||||
"start_time": "95231.856422",
|
||||
"duration": "352.181178",
|
||||
"size": "179003772",
|
||||
"bit_rate": "4066174",
|
||||
"probe_score": 50
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue