Files
pgsql-jellyfin/MediaBrowser.Controller/Entities/MediaSourceWidthComparator.cs
T
wjones af1152b001 Refactor: standardize namespace and using directive style
Refactored all C# test files to use explicit namespace declarations and moved all using directives inside the namespace block for consistency. Updated assembly info and cache files to reflect the new build. Adjusted MvcTestingAppManifest.json to use fully qualified assembly names. No functional changes; all updates are related to code style, organization, and project metadata.
2026-02-20 16:26:53 -05:00

61 lines
1.3 KiB
C#

// <copyright file="MediaSourceWidthComparator.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>
namespace MediaBrowser.Controller.Entities;
using System;
using System.Collections.Generic;
using System.Runtime.Intrinsics.X86;
using MediaBrowser.Model.Dto;
/// <summary>
/// Compare MediaSource of the same file by Video width <see cref="IComparer{T}" />.
/// </summary>
public class MediaSourceWidthComparator : IComparer<MediaSourceInfo>
{
/// <inheritdoc />
public int Compare(MediaSourceInfo? x, MediaSourceInfo? y)
{
if (x is null && y is null)
{
return 0;
}
if (x is null)
{
return -1;
}
if (y is null)
{
return 1;
}
if (string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase))
{
if (x.VideoStream is null && y.VideoStream is null)
{
return 0;
}
if (x.VideoStream is null)
{
return -1;
}
if (y.VideoStream is null)
{
return 1;
}
var xWidth = x.VideoStream.Width ?? 0;
var yWidth = y.VideoStream.Width ?? 0;
return xWidth - yWidth;
}
return 0;
}
}