Merge pull request #7233 from Bond-009/warn60

This commit is contained in:
Cody Robibero 2022-02-14 16:57:00 -07:00 committed by GitHub
commit 4ef0099598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 133 additions and 153 deletions

View File

@ -569,7 +569,7 @@ namespace Emby.Dlna.PlayTo
streamInfo.TargetVideoCodecTag, streamInfo.TargetVideoCodecTag,
streamInfo.IsTargetAVC); streamInfo.IsTargetAVC);
return list.Count == 0 ? null : list[0]; return list.FirstOrDefault();
} }
return null; return null;
@ -883,7 +883,7 @@ namespace Emby.Dlna.PlayTo
private class StreamParams private class StreamParams
{ {
private MediaSourceInfo mediaSource; private MediaSourceInfo _mediaSource;
private IMediaSourceManager _mediaSourceManager; private IMediaSourceManager _mediaSourceManager;
public Guid ItemId { get; set; } public Guid ItemId { get; set; }
@ -908,24 +908,22 @@ namespace Emby.Dlna.PlayTo
public async Task<MediaSourceInfo> GetMediaSource(CancellationToken cancellationToken) public async Task<MediaSourceInfo> GetMediaSource(CancellationToken cancellationToken)
{ {
if (mediaSource != null) if (_mediaSource != null)
{ {
return mediaSource; return _mediaSource;
} }
var hasMediaSources = Item as IHasMediaSources; if (Item is not IHasMediaSources)
if (hasMediaSources == null)
{ {
return null; return null;
} }
if (_mediaSourceManager != null) if (_mediaSourceManager != null)
{ {
mediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false); _mediaSource = await _mediaSourceManager.GetMediaSource(Item, MediaSourceId, LiveStreamId, false, cancellationToken).ConfigureAwait(false);
} }
return mediaSource; return _mediaSource;
} }
private static Guid GetItemId(string url) private static Guid GetItemId(string url)

View File

@ -5914,7 +5914,7 @@ AND Type = @InternalPersonType)");
} }
} }
public void SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken) public void SaveMediaStreams(Guid id, IReadOnlyList<MediaStream> streams, CancellationToken cancellationToken)
{ {
CheckDisposed(); CheckDisposed();
@ -5946,7 +5946,7 @@ AND Type = @InternalPersonType)");
} }
} }
private void InsertMediaStreams(byte[] idBlob, List<MediaStream> streams, IDatabaseConnection db) private void InsertMediaStreams(byte[] idBlob, IReadOnlyList<MediaStream> streams, IDatabaseConnection db)
{ {
const int Limit = 10; const int Limit = 10;
var startIndex = 0; var startIndex = 0;

View File

@ -581,7 +581,7 @@ namespace Emby.Server.Implementations.IO
} }
/// <inheritdoc /> /// <inheritdoc />
public virtual List<FileSystemMetadata> GetDrives() public virtual IEnumerable<FileSystemMetadata> GetDrives()
{ {
// check for ready state to avoid waiting for drives to timeout // check for ready state to avoid waiting for drives to timeout
// some drives on linux have no actual size or are used for other purposes // some drives on linux have no actual size or are used for other purposes
@ -595,7 +595,7 @@ namespace Emby.Server.Implementations.IO
Name = d.Name, Name = d.Name,
FullName = d.RootDirectory.FullName, FullName = d.RootDirectory.FullName,
IsDirectory = true IsDirectory = true
}).ToList(); });
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -344,7 +344,7 @@ namespace Emby.Server.Implementations.Library
return sources; return sources;
} }
private string[] NormalizeLanguage(string language) private IReadOnlyList<string> NormalizeLanguage(string language)
{ {
if (string.IsNullOrEmpty(language)) if (string.IsNullOrEmpty(language))
{ {

View File

@ -1,5 +1,3 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
@ -13,10 +11,9 @@ namespace Emby.Server.Implementations.Library
{ {
public static class MediaStreamSelector public static class MediaStreamSelector
{ {
public static int? GetDefaultAudioStreamIndex(List<MediaStream> streams, string[] preferredLanguages, bool preferDefaultTrack) public static int? GetDefaultAudioStreamIndex(IReadOnlyList<MediaStream> streams, IReadOnlyList<string> preferredLanguages, bool preferDefaultTrack)
{ {
streams = GetSortedStreams(streams, MediaStreamType.Audio, preferredLanguages) var sortedStreams = GetSortedStreams(streams, MediaStreamType.Audio, preferredLanguages);
.ToList();
if (preferDefaultTrack) if (preferDefaultTrack)
{ {
@ -28,24 +25,15 @@ namespace Emby.Server.Implementations.Library
} }
} }
var stream = streams.FirstOrDefault(); return sortedStreams.FirstOrDefault()?.Index;
if (stream != null)
{
return stream.Index;
}
return null;
} }
public static int? GetDefaultSubtitleStreamIndex( public static int? GetDefaultSubtitleStreamIndex(
IEnumerable<MediaStream> streams, IEnumerable<MediaStream> streams,
string[] preferredLanguages, IReadOnlyList<string> preferredLanguages,
SubtitlePlaybackMode mode, SubtitlePlaybackMode mode,
string audioTrackLanguage) string audioTrackLanguage)
{ {
MediaStream stream = null;
if (mode == SubtitlePlaybackMode.None) if (mode == SubtitlePlaybackMode.None)
{ {
return null; return null;
@ -59,6 +47,7 @@ namespace Emby.Server.Implementations.Library
.ThenByDescending(x => x.IsDefault) .ThenByDescending(x => x.IsDefault)
.ToList(); .ToList();
MediaStream? stream = null;
if (mode == SubtitlePlaybackMode.Default) if (mode == SubtitlePlaybackMode.Default)
{ {
// Prefer embedded metadata over smart logic // Prefer embedded metadata over smart logic
@ -95,26 +84,27 @@ namespace Emby.Server.Implementations.Library
return stream?.Index; return stream?.Index;
} }
private static IEnumerable<MediaStream> GetSortedStreams(IEnumerable<MediaStream> streams, MediaStreamType type, string[] languagePreferences) private static IEnumerable<MediaStream> GetSortedStreams(IEnumerable<MediaStream> streams, MediaStreamType type, IReadOnlyList<string> languagePreferences)
{ {
// Give some preference to external text subs for better performance // Give some preference to external text subs for better performance
return streams.Where(i => i.Type == type) return streams
.Where(i => i.Type == type)
.OrderBy(i => .OrderBy(i =>
{ {
var index = FindIndex(languagePreferences, i.Language); var index = languagePreferences.FindIndex(x => string.Equals(x, i.Language, StringComparison.OrdinalIgnoreCase));
return index == -1 ? 100 : index; return index == -1 ? 100 : index;
}) })
.ThenBy(i => GetBooleanOrderBy(i.IsDefault)) .ThenBy(i => GetBooleanOrderBy(i.IsDefault))
.ThenBy(i => GetBooleanOrderBy(i.SupportsExternalStream)) .ThenBy(i => GetBooleanOrderBy(i.SupportsExternalStream))
.ThenBy(i => GetBooleanOrderBy(i.IsTextSubtitleStream)) .ThenBy(i => GetBooleanOrderBy(i.IsTextSubtitleStream))
.ThenBy(i => GetBooleanOrderBy(i.IsExternal)) .ThenBy(i => GetBooleanOrderBy(i.IsExternal))
.ThenBy(i => i.Index); .ThenBy(i => i.Index);
} }
public static void SetSubtitleStreamScores( public static void SetSubtitleStreamScores(
List<MediaStream> streams, IReadOnlyList<MediaStream> streams,
string[] preferredLanguages, IReadOnlyList<string> preferredLanguages,
SubtitlePlaybackMode mode, SubtitlePlaybackMode mode,
string audioTrackLanguage) string audioTrackLanguage)
{ {
@ -123,15 +113,14 @@ namespace Emby.Server.Implementations.Library
return; return;
} }
streams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages) var sortedStreams = GetSortedStreams(streams, MediaStreamType.Subtitle, preferredLanguages);
.ToList();
var filteredStreams = new List<MediaStream>(); var filteredStreams = new List<MediaStream>();
if (mode == SubtitlePlaybackMode.Default) if (mode == SubtitlePlaybackMode.Default)
{ {
// Prefer embedded metadata over smart logic // Prefer embedded metadata over smart logic
filteredStreams = streams.Where(s => s.IsForced || s.IsDefault) filteredStreams = sortedStreams.Where(s => s.IsForced || s.IsDefault)
.ToList(); .ToList();
} }
else if (mode == SubtitlePlaybackMode.Smart) else if (mode == SubtitlePlaybackMode.Smart)
@ -139,54 +128,37 @@ namespace Emby.Server.Implementations.Library
// Prefer smart logic over embedded metadata // Prefer smart logic over embedded metadata
if (!preferredLanguages.Contains(audioTrackLanguage, StringComparison.OrdinalIgnoreCase)) if (!preferredLanguages.Contains(audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
{ {
filteredStreams = streams.Where(s => !s.IsForced && preferredLanguages.Contains(s.Language, StringComparison.OrdinalIgnoreCase)) filteredStreams = sortedStreams.Where(s => !s.IsForced && preferredLanguages.Contains(s.Language, StringComparison.OrdinalIgnoreCase))
.ToList(); .ToList();
} }
} }
else if (mode == SubtitlePlaybackMode.Always) else if (mode == SubtitlePlaybackMode.Always)
{ {
// always load the most suitable full subtitles // always load the most suitable full subtitles
filteredStreams = streams.Where(s => !s.IsForced) filteredStreams = sortedStreams.Where(s => !s.IsForced).ToList();
.ToList();
} }
else if (mode == SubtitlePlaybackMode.OnlyForced) else if (mode == SubtitlePlaybackMode.OnlyForced)
{ {
// always load the most suitable full subtitles // always load the most suitable full subtitles
filteredStreams = streams.Where(s => s.IsForced).ToList(); filteredStreams = sortedStreams.Where(s => s.IsForced).ToList();
} }
// load forced subs if we have found no suitable full subtitles // load forced subs if we have found no suitable full subtitles
if (filteredStreams.Count == 0) var iterStreams = filteredStreams.Count == 0
{ ? sortedStreams.Where(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
filteredStreams = streams : filteredStreams;
.Where(s => s.IsForced && string.Equals(s.Language, audioTrackLanguage, StringComparison.OrdinalIgnoreCase))
.ToList();
}
foreach (var stream in filteredStreams) foreach (var stream in iterStreams)
{ {
stream.Score = GetSubtitleScore(stream, preferredLanguages); stream.Score = GetSubtitleScore(stream, preferredLanguages);
} }
} }
private static int FindIndex(string[] list, string value) private static int GetSubtitleScore(MediaStream stream, IReadOnlyList<string> languagePreferences)
{
for (var i = 0; i < list.Length; i++)
{
if (string.Equals(list[i], value, StringComparison.OrdinalIgnoreCase))
{
return i;
}
}
return -1;
}
private static int GetSubtitleScore(MediaStream stream, string[] languagePreferences)
{ {
var values = new List<int>(); var values = new List<int>();
var index = FindIndex(languagePreferences, stream.Language); var index = languagePreferences.FindIndex(x => string.Equals(x, stream.Language, StringComparison.OrdinalIgnoreCase));
values.Add(index == -1 ? 0 : 100 - index); values.Add(index == -1 ? 0 : 100 - index);

View File

@ -312,7 +312,7 @@ namespace Emby.Server.Implementations.LiveTv
{ {
if (isVideo) if (isVideo)
{ {
mediaSource.MediaStreams.AddRange(new List<MediaStream> mediaSource.MediaStreams = new MediaStream[]
{ {
new MediaStream new MediaStream
{ {
@ -329,11 +329,11 @@ namespace Emby.Server.Implementations.LiveTv
// Set the index to -1 because we don't know the exact index of the audio stream within the container // Set the index to -1 because we don't know the exact index of the audio stream within the container
Index = -1 Index = -1
} }
}); };
} }
else else
{ {
mediaSource.MediaStreams.AddRange(new List<MediaStream> mediaSource.MediaStreams = new MediaStream[]
{ {
new MediaStream new MediaStream
{ {
@ -341,7 +341,7 @@ namespace Emby.Server.Implementations.LiveTv
// Set the index to -1 because we don't know the exact index of the audio stream within the container // Set the index to -1 because we don't know the exact index of the audio stream within the container
Index = -1 Index = -1
} }
}); };
} }
} }

View File

@ -446,7 +446,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
{ {
Path = url, Path = url,
Protocol = MediaProtocol.Udp, Protocol = MediaProtocol.Udp,
MediaStreams = new List<MediaStream> MediaStreams = new MediaStream[]
{ {
new MediaStream new MediaStream
{ {

View File

@ -170,7 +170,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
{ {
Path = path, Path = path,
Protocol = protocol, Protocol = protocol,
MediaStreams = new List<MediaStream> MediaStreams = new MediaStream[]
{ {
new MediaStream new MediaStream
{ {

View File

@ -147,13 +147,7 @@ namespace Emby.Server.Implementations.Localization
threeletterNames = new[] { parts[0], parts[1] }; threeletterNames = new[] { parts[0], parts[1] };
} }
list.Add(new CultureDto list.Add(new CultureDto(name, name, twoCharName, threeletterNames));
{
DisplayName = name,
Name = name,
ThreeLetterISOLanguageNames = threeletterNames,
TwoLetterISOLanguageName = twoCharName
});
} }
} }

View File

@ -121,11 +121,7 @@ namespace Jellyfin.Api.Controllers
IsSports = isSports IsSports = isSports
}); });
return new SearchHintResult return new SearchHintResult(result.Items.Select(GetSearchHintResult).ToArray(), result.TotalRecordCount);
{
TotalRecordCount = result.TotalRecordCount,
SearchHints = result.Items.Select(GetSearchHintResult).ToArray()
};
} }
/// <summary> /// <summary>

View File

@ -134,7 +134,7 @@ namespace MediaBrowser.Controller.LiveTv
{ {
Id = Id.ToString("N", CultureInfo.InvariantCulture), Id = Id.ToString("N", CultureInfo.InvariantCulture),
Protocol = PathProtocol ?? MediaProtocol.File, Protocol = PathProtocol ?? MediaProtocol.File,
MediaStreams = new List<MediaStream>(), MediaStreams = Array.Empty<MediaStream>(),
Name = Name, Name = Name,
Path = Path, Path = Path,
RunTimeTicks = RunTimeTicks, RunTimeTicks = RunTimeTicks,

View File

@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Persistence
/// <param name="id">The identifier.</param> /// <param name="id">The identifier.</param>
/// <param name="streams">The streams.</param> /// <param name="streams">The streams.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
void SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken); void SaveMediaStreams(Guid id, IReadOnlyList<MediaStream> streams, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Gets the media attachments. /// Gets the media attachments.

View File

@ -115,7 +115,7 @@ namespace MediaBrowser.Model.Dlna
return "DLNA.ORG_PN=" + orgPn + orgOp + orgCi + dlnaflags; return "DLNA.ORG_PN=" + orgPn + orgOp + orgCi + dlnaflags;
} }
public static List<string> BuildVideoHeader( public static IEnumerable<string> BuildVideoHeader(
DeviceProfile profile, DeviceProfile profile,
string container, string container,
string videoCodec, string videoCodec,

View File

@ -675,7 +675,7 @@ namespace MediaBrowser.Model.Dlna
return string.Format(CultureInfo.InvariantCulture, "{0}/videos/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString); return string.Format(CultureInfo.InvariantCulture, "{0}/videos/{1}/stream{2}?{3}", baseUrl, ItemId, extension, queryString);
} }
private static List<NameValuePair> BuildParams(StreamInfo item, string accessToken) private static IEnumerable<NameValuePair> BuildParams(StreamInfo item, string accessToken)
{ {
var list = new List<NameValuePair>(); var list = new List<NameValuePair>();
@ -805,34 +805,12 @@ namespace MediaBrowser.Model.Dlna
return list; return list;
} }
public List<SubtitleStreamInfo> GetExternalSubtitles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, string baseUrl, string accessToken) public IEnumerable<SubtitleStreamInfo> GetSubtitleProfiles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, string baseUrl, string accessToken)
{
return GetExternalSubtitles(transcoderSupport, includeSelectedTrackOnly, false, baseUrl, accessToken);
}
public List<SubtitleStreamInfo> GetExternalSubtitles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken)
{
var list = GetSubtitleProfiles(transcoderSupport, includeSelectedTrackOnly, enableAllProfiles, baseUrl, accessToken);
var newList = new List<SubtitleStreamInfo>();
// First add the selected track
foreach (SubtitleStreamInfo stream in list)
{
if (stream.DeliveryMethod == SubtitleDeliveryMethod.External)
{
newList.Add(stream);
}
}
return newList;
}
public List<SubtitleStreamInfo> GetSubtitleProfiles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, string baseUrl, string accessToken)
{ {
return GetSubtitleProfiles(transcoderSupport, includeSelectedTrackOnly, false, baseUrl, accessToken); return GetSubtitleProfiles(transcoderSupport, includeSelectedTrackOnly, false, baseUrl, accessToken);
} }
public List<SubtitleStreamInfo> GetSubtitleProfiles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken) public IEnumerable<SubtitleStreamInfo> GetSubtitleProfiles(ITranscoderSupport transcoderSupport, bool includeSelectedTrackOnly, bool enableAllProfiles, string baseUrl, string accessToken)
{ {
var list = new List<SubtitleStreamInfo>(); var list = new List<SubtitleStreamInfo>();

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Model.Dto
public MediaSourceInfo() public MediaSourceInfo()
{ {
Formats = Array.Empty<string>(); Formats = Array.Empty<string>();
MediaStreams = new List<MediaStream>(); MediaStreams = Array.Empty<MediaStream>();
MediaAttachments = Array.Empty<MediaAttachment>(); MediaAttachments = Array.Empty<MediaAttachment>();
RequiredHttpHeaders = new Dictionary<string, string>(); RequiredHttpHeaders = new Dictionary<string, string>();
SupportsTranscoding = true; SupportsTranscoding = true;
@ -88,7 +88,7 @@ namespace MediaBrowser.Model.Dto
public Video3DFormat? Video3DFormat { get; set; } public Video3DFormat? Video3DFormat { get; set; }
public List<MediaStream> MediaStreams { get; set; } public IReadOnlyList<MediaStream> MediaStreams { get; set; }
public IReadOnlyList<MediaAttachment> MediaAttachments { get; set; } public IReadOnlyList<MediaAttachment> MediaAttachments { get; set; }

View File

@ -1,7 +1,7 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System;
using System.Collections.Generic;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Globalization; using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Providers; using MediaBrowser.Model.Providers;
@ -19,16 +19,16 @@ namespace MediaBrowser.Model.Dto
ContentTypeOptions = Array.Empty<NameValuePair>(); ContentTypeOptions = Array.Empty<NameValuePair>();
} }
public ParentalRating[] ParentalRatingOptions { get; set; } public IReadOnlyList<ParentalRating> ParentalRatingOptions { get; set; }
public CountryInfo[] Countries { get; set; } public IReadOnlyList<CountryInfo> Countries { get; set; }
public CultureDto[] Cultures { get; set; } public IReadOnlyList<CultureDto> Cultures { get; set; }
public ExternalIdInfo[] ExternalIdInfos { get; set; } public IReadOnlyList<ExternalIdInfo> ExternalIdInfos { get; set; }
public string ContentType { get; set; } public string? ContentType { get; set; }
public NameValuePair[] ContentTypeOptions { get; set; } public IReadOnlyList<NameValuePair> ContentTypeOptions { get; set; }
} }
} }

View File

@ -1,7 +1,6 @@
#nullable disable
#pragma warning disable CS1591 #pragma warning disable CS1591
using System; using System.Collections.Generic;
namespace MediaBrowser.Model.Globalization namespace MediaBrowser.Model.Globalization
{ {
@ -10,39 +9,42 @@ namespace MediaBrowser.Model.Globalization
/// </summary> /// </summary>
public class CultureDto public class CultureDto
{ {
public CultureDto() public CultureDto(string name, string displayName, string twoLetterISOLanguageName, IReadOnlyList<string> threeLetterISOLanguageNames)
{ {
ThreeLetterISOLanguageNames = Array.Empty<string>(); Name = name;
DisplayName = displayName;
TwoLetterISOLanguageName = twoLetterISOLanguageName;
ThreeLetterISOLanguageNames = threeLetterISOLanguageNames;
} }
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets the name.
/// </summary> /// </summary>
/// <value>The name.</value> /// <value>The name.</value>
public string Name { get; set; } public string Name { get; }
/// <summary> /// <summary>
/// Gets or sets the display name. /// Gets the display name.
/// </summary> /// </summary>
/// <value>The display name.</value> /// <value>The display name.</value>
public string DisplayName { get; set; } public string DisplayName { get; }
/// <summary> /// <summary>
/// Gets or sets the name of the two letter ISO language. /// Gets the name of the two letter ISO language.
/// </summary> /// </summary>
/// <value>The name of the two letter ISO language.</value> /// <value>The name of the two letter ISO language.</value>
public string TwoLetterISOLanguageName { get; set; } public string TwoLetterISOLanguageName { get; }
/// <summary> /// <summary>
/// Gets the name of the three letter ISO language. /// Gets the name of the three letter ISO language.
/// </summary> /// </summary>
/// <value>The name of the three letter ISO language.</value> /// <value>The name of the three letter ISO language.</value>
public string ThreeLetterISOLanguageName public string? ThreeLetterISOLanguageName
{ {
get get
{ {
var vals = ThreeLetterISOLanguageNames; var vals = ThreeLetterISOLanguageNames;
if (vals.Length > 0) if (vals.Count > 0)
{ {
return vals[0]; return vals[0];
} }
@ -51,6 +53,6 @@ namespace MediaBrowser.Model.Globalization
} }
} }
public string[] ThreeLetterISOLanguageNames { get; set; } public IReadOnlyList<string> ThreeLetterISOLanguageNames { get; }
} }
} }

View File

@ -199,6 +199,6 @@ namespace MediaBrowser.Model.IO
void SetAttributes(string path, bool isHidden, bool readOnly); void SetAttributes(string path, bool isHidden, bool readOnly);
List<FileSystemMetadata> GetDrives(); IEnumerable<FileSystemMetadata> GetDrives();
} }
} }

View File

@ -1,4 +1,5 @@
#nullable disable using System.Collections.Generic;
namespace MediaBrowser.Model.Search namespace MediaBrowser.Model.Search
{ {
/// <summary> /// <summary>
@ -7,15 +8,26 @@ namespace MediaBrowser.Model.Search
public class SearchHintResult public class SearchHintResult
{ {
/// <summary> /// <summary>
/// Gets or sets the search hints. /// Initializes a new instance of the <see cref="SearchHintResult" /> class.
/// </summary> /// </summary>
/// <value>The search hints.</value> /// <param name="searchHints">The search hints.</param>
public SearchHint[] SearchHints { get; set; } /// <param name="totalRecordCount">The total record count.</param>
public SearchHintResult(IReadOnlyList<SearchHint> searchHints, int totalRecordCount)
{
SearchHints = searchHints;
TotalRecordCount = totalRecordCount;
}
/// <summary> /// <summary>
/// Gets or sets the total record count. /// Gets the search hints.
/// </summary>
/// <value>The search hints.</value>
public IReadOnlyList<SearchHint> SearchHints { get; }
/// <summary>
/// Gets the total record count.
/// </summary> /// </summary>
/// <value>The total record count.</value> /// <value>The total record count.</value>
public int TotalRecordCount { get; set; } public int TotalRecordCount { get; }
} }
} }

View File

@ -84,8 +84,6 @@ namespace MediaBrowser.Providers.MediaInfo
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
protected void Fetch(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, CancellationToken cancellationToken) protected void Fetch(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, CancellationToken cancellationToken)
{ {
var mediaStreams = mediaInfo.MediaStreams;
audio.Container = mediaInfo.Container; audio.Container = mediaInfo.Container;
audio.TotalBitrate = mediaInfo.Bitrate; audio.TotalBitrate = mediaInfo.Bitrate;
@ -97,7 +95,7 @@ namespace MediaBrowser.Providers.MediaInfo
FetchDataFromTags(audio, mediaInfo); FetchDataFromTags(audio, mediaInfo);
_itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken); _itemRepo.SaveMediaStreams(audio.Id, mediaInfo.MediaStreams, cancellationToken);
} }
/// <summary> /// <summary>

View File

@ -172,7 +172,7 @@ namespace MediaBrowser.Providers.MediaInfo
if (mediaInfo != null) if (mediaInfo != null)
{ {
mediaStreams = mediaInfo.MediaStreams; mediaStreams = mediaInfo.MediaStreams.ToList();
mediaAttachments = mediaInfo.MediaAttachments; mediaAttachments = mediaInfo.MediaAttachments;
video.TotalBitrate = mediaInfo.Bitrate; video.TotalBitrate = mediaInfo.Bitrate;
@ -202,7 +202,7 @@ namespace MediaBrowser.Providers.MediaInfo
video.Container = mediaInfo.Container; video.Container = mediaInfo.Container;
chapters = mediaInfo.Chapters == null ? Array.Empty<ChapterInfo>() : mediaInfo.Chapters; chapters = mediaInfo.Chapters ?? Array.Empty<ChapterInfo>();
if (blurayInfo != null) if (blurayInfo != null)
{ {
FetchBdInfo(video, ref chapters, mediaStreams, blurayInfo); FetchBdInfo(video, ref chapters, mediaStreams, blurayInfo);
@ -246,7 +246,7 @@ namespace MediaBrowser.Providers.MediaInfo
video.Height = videoStream?.Height ?? 0; video.Height = videoStream?.Height ?? 0;
video.Width = videoStream?.Width ?? 0; video.Width = videoStream?.Width ?? 0;
video.DefaultVideoStreamIndex = videoStream == null ? (int?)null : videoStream.Index; video.DefaultVideoStreamIndex = videoStream?.Index;
video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle); video.HasSubtitles = mediaStreams.Any(i => i.Type == MediaStreamType.Subtitle);

View File

@ -0,0 +1,30 @@
using System;
using Emby.Server.Implementations.Library;
using MediaBrowser.Model.Entities;
using Xunit;
namespace Jellyfin.Server.Implementations.Tests.Library;
public class MediaStreamSelectorTests
{
[Theory]
[InlineData(true)]
[InlineData(false)]
public void GetDefaultAudioStreamIndex_EmptyStreams_Null(bool preferDefaultTrack)
{
Assert.Null(MediaStreamSelector.GetDefaultAudioStreamIndex(Array.Empty<MediaStream>(), Array.Empty<string>(), preferDefaultTrack));
}
[Theory]
[InlineData(true)]
[InlineData(false)]
public void GetDefaultAudioStreamIndex_WithoutDefault_NotNull(bool preferDefaultTrack)
{
var streams = new[]
{
new MediaStream()
};
Assert.NotNull(MediaStreamSelector.GetDefaultAudioStreamIndex(streams, Array.Empty<string>(), preferDefaultTrack));
}
}