< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.MediaSourceWidthComparator
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/MediaSourceWidthComparator.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 17
Coverable lines: 17
Total lines: 56
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 18
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Compare(...)0%342180%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/MediaSourceWidthComparator.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Runtime.Intrinsics.X86;
 4using MediaBrowser.Model.Dto;
 5
 6namespace MediaBrowser.Controller.Entities;
 7
 8/// <summary>
 9/// Compare MediaSource of the same file by Video width <see cref="IComparer{T}" />.
 10/// </summary>
 11public class MediaSourceWidthComparator : IComparer<MediaSourceInfo>
 12{
 13    /// <inheritdoc />
 14    public int Compare(MediaSourceInfo? x, MediaSourceInfo? y)
 15    {
 016        if (x is null && y is null)
 17        {
 018            return 0;
 19        }
 20
 021        if (x is null)
 22        {
 023            return -1;
 24        }
 25
 026        if (y is null)
 27        {
 028            return 1;
 29        }
 30
 031        if (string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase))
 32        {
 033            if (x.VideoStream is null && y.VideoStream is null)
 34            {
 035                return 0;
 36            }
 37
 038            if (x.VideoStream is null)
 39            {
 040                return -1;
 41            }
 42
 043            if (y.VideoStream is null)
 44            {
 045                return 1;
 46            }
 47
 048            var xWidth = x.VideoStream.Width ?? 0;
 049            var yWidth = y.VideoStream.Width ?? 0;
 50
 051            return xWidth - yWidth;
 52        }
 53
 054        return 0;
 55    }
 56}