< Summary - Jellyfin

Information
Class: Jellyfin.Api.Helpers.DynamicHlsHelper
Assembly: Jellyfin.Api
File(s): /srv/git/jellyfin/Jellyfin.Api/Helpers/DynamicHlsHelper.cs
Line coverage
3%
Covered lines: 16
Uncovered lines: 394
Coverable lines: 410
Total lines: 1014
Line coverage: 3.9%
Branch coverage
0%
Covered branches: 2
Total branches: 300
Branch coverage: 0.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 5/31/2026 - 12:15:44 AM Line coverage: 0% (0/406) Branch coverage: 0% (0/298) Total lines: 99810/29/2026 - 12:17:11 AM Line coverage: 0.9% (4/413) Branch coverage: 0.6% (2/304) Total lines: 101511/7/2026 - 12:19:31 AM Line coverage: 0.9% (4/410) Branch coverage: 0.6% (2/300) Total lines: 101411/13/2026 - 12:19:51 AM Line coverage: 3.9% (16/410) Branch coverage: 0.6% (2/300) Total lines: 1014 5/31/2026 - 12:15:44 AM Line coverage: 0% (0/406) Branch coverage: 0% (0/298) Total lines: 99810/29/2026 - 12:17:11 AM Line coverage: 0.9% (4/413) Branch coverage: 0.6% (2/304) Total lines: 101511/7/2026 - 12:19:31 AM Line coverage: 0.9% (4/410) Branch coverage: 0.6% (2/300) Total lines: 101411/13/2026 - 12:19:51 AM Line coverage: 3.9% (16/410) Branch coverage: 0.6% (2/300) Total lines: 1014

Coverage delta

Coverage delta 3 -3

Metrics

File(s)

/srv/git/jellyfin/Jellyfin.Api/Helpers/DynamicHlsHelper.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Globalization;
 4using System.Linq;
 5using System.Net;
 6using System.Security.Claims;
 7using System.Text;
 8using System.Threading;
 9using System.Threading.Tasks;
 10using Jellyfin.Api.Controllers;
 11using Jellyfin.Api.Extensions;
 12using Jellyfin.Data.Enums;
 13using Jellyfin.Database.Implementations.Entities;
 14using Jellyfin.Extensions;
 15using MediaBrowser.Common.Configuration;
 16using MediaBrowser.Common.Extensions;
 17using MediaBrowser.Common.Net;
 18using MediaBrowser.Controller.Configuration;
 19using MediaBrowser.Controller.Library;
 20using MediaBrowser.Controller.MediaEncoding;
 21using MediaBrowser.Controller.Streaming;
 22using MediaBrowser.Controller.Trickplay;
 23using MediaBrowser.Model.Dlna;
 24using MediaBrowser.Model.Entities;
 25using MediaBrowser.Model.Net;
 26using Microsoft.AspNetCore.Http;
 27using Microsoft.AspNetCore.Mvc;
 28using Microsoft.Extensions.Logging;
 29using Microsoft.Net.Http.Headers;
 30
 31namespace Jellyfin.Api.Helpers;
 32
 33/// <summary>
 34/// Dynamic hls helper.
 35/// </summary>
 36public class DynamicHlsHelper
 37{
 38    private readonly ILibraryManager _libraryManager;
 39    private readonly IUserManager _userManager;
 40    private readonly IMediaSourceManager _mediaSourceManager;
 41    private readonly IServerConfigurationManager _serverConfigurationManager;
 42    private readonly IMediaEncoder _mediaEncoder;
 43    private readonly ITranscodeManager _transcodeManager;
 44    private readonly INetworkManager _networkManager;
 45    private readonly ILogger<DynamicHlsHelper> _logger;
 46    private readonly IHttpContextAccessor _httpContextAccessor;
 47    private readonly EncodingHelper _encodingHelper;
 48    private readonly ITrickplayManager _trickplayManager;
 49
 50    /// <summary>
 51    /// Initializes a new instance of the <see cref="DynamicHlsHelper"/> class.
 52    /// </summary>
 53    /// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
 54    /// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
 55    /// <param name="mediaSourceManager">Instance of the <see cref="IMediaSourceManager"/> interface.</param>
 56    /// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</p
 57    /// <param name="mediaEncoder">Instance of the <see cref="IMediaEncoder"/> interface.</param>
 58    /// <param name="transcodeManager">Instance of <see cref="ITranscodeManager"/>.</param>
 59    /// <param name="networkManager">Instance of the <see cref="INetworkManager"/> interface.</param>
 60    /// <param name="logger">Instance of the <see cref="ILogger{DynamicHlsHelper}"/> interface.</param>
 61    /// <param name="httpContextAccessor">Instance of the <see cref="IHttpContextAccessor"/> interface.</param>
 62    /// <param name="encodingHelper">Instance of <see cref="EncodingHelper"/>.</param>
 63    /// <param name="trickplayManager">Instance of <see cref="ITrickplayManager"/>.</param>
 64    public DynamicHlsHelper(
 65        ILibraryManager libraryManager,
 66        IUserManager userManager,
 67        IMediaSourceManager mediaSourceManager,
 68        IServerConfigurationManager serverConfigurationManager,
 69        IMediaEncoder mediaEncoder,
 70        ITranscodeManager transcodeManager,
 71        INetworkManager networkManager,
 72        ILogger<DynamicHlsHelper> logger,
 73        IHttpContextAccessor httpContextAccessor,
 74        EncodingHelper encodingHelper,
 75        ITrickplayManager trickplayManager)
 76    {
 1577        _libraryManager = libraryManager;
 1578        _userManager = userManager;
 1579        _mediaSourceManager = mediaSourceManager;
 1580        _serverConfigurationManager = serverConfigurationManager;
 1581        _mediaEncoder = mediaEncoder;
 1582        _transcodeManager = transcodeManager;
 1583        _networkManager = networkManager;
 1584        _logger = logger;
 1585        _httpContextAccessor = httpContextAccessor;
 1586        _encodingHelper = encodingHelper;
 1587        _trickplayManager = trickplayManager;
 1588    }
 89
 90    /// <summary>
 91    /// Get master hls playlist.
 92    /// </summary>
 93    /// <param name="transcodingJobType">Transcoding job type.</param>
 94    /// <param name="streamingRequest">Streaming request dto.</param>
 95    /// <param name="enableAdaptiveBitrateStreaming">Enable adaptive bitrate streaming.</param>
 96    /// <returns>A <see cref="Task"/> containing the resulting <see cref="ActionResult"/>.</returns>
 97    public async Task<ActionResult> GetMasterHlsPlaylist(
 98        TranscodingJobType transcodingJobType,
 99        StreamingRequestDto streamingRequest,
 100        bool enableAdaptiveBitrateStreaming)
 101    {
 0102        var isHeadRequest = _httpContextAccessor.HttpContext?.Request.Method == WebRequestMethods.Http.Head;
 103        // CTS lifecycle is managed internally.
 0104        var cancellationTokenSource = new CancellationTokenSource();
 0105        return await GetMasterPlaylistInternal(
 0106            streamingRequest,
 0107            isHeadRequest,
 0108            enableAdaptiveBitrateStreaming,
 0109            transcodingJobType,
 0110            cancellationTokenSource).ConfigureAwait(false);
 0111    }
 112
 113    private async Task<ActionResult> GetMasterPlaylistInternal(
 114        StreamingRequestDto streamingRequest,
 115        bool isHeadRequest,
 116        bool enableAdaptiveBitrateStreaming,
 117        TranscodingJobType transcodingJobType,
 118        CancellationTokenSource cancellationTokenSource)
 119    {
 0120        if (_httpContextAccessor.HttpContext is null)
 121        {
 0122            throw new ResourceNotFoundException(nameof(_httpContextAccessor.HttpContext));
 123        }
 124
 0125        using var state = await StreamingHelpers.GetStreamingState(
 0126                streamingRequest,
 0127                _httpContextAccessor.HttpContext,
 0128                _mediaSourceManager,
 0129                _userManager,
 0130                _libraryManager,
 0131                _serverConfigurationManager,
 0132                _mediaEncoder,
 0133                _encodingHelper,
 0134                _transcodeManager,
 0135                transcodingJobType,
 0136                cancellationTokenSource.Token)
 0137            .ConfigureAwait(false);
 138
 0139        _httpContextAccessor.HttpContext.Response.Headers.Append(HeaderNames.Expires, "0");
 0140        if (isHeadRequest)
 141        {
 0142            return new FileContentResult(Array.Empty<byte>(), MimeTypes.GetMimeType("playlist.m3u8"));
 143        }
 144
 0145        var totalBitrate = (state.OutputAudioBitrate ?? 0) + (state.OutputVideoBitrate ?? 0);
 146
 0147        var builder = new StringBuilder();
 148
 0149        builder.AppendLine("#EXTM3U");
 150
 0151        var isLiveStream = state.IsSegmentedLiveStream;
 152
 0153        var queryString = _httpContextAccessor.HttpContext.Request.QueryString.ToString();
 0154        var playlistQuery = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(queryString);
 155
 156        // From universal audio service: timeline is determined by segment index and runtime ticks, not StartTimeTicks
 0157        playlistQuery.Remove("StartTimeTicks");
 158
 159        // From universal audio service: override AudioCodec when the actual request differs from original query
 0160        if (!string.Equals(state.OutputAudioCodec, _httpContextAccessor.HttpContext.Request.Query["AudioCodec"].ToString
 161        {
 0162            playlistQuery["AudioCodec"] = state.OutputAudioCodec;
 163        }
 164
 165        // From universal audio service
 0166        if (!string.IsNullOrWhiteSpace(state.Request.SegmentContainer))
 167        {
 0168            playlistQuery.TryAdd("SegmentContainer", state.Request.SegmentContainer);
 169        }
 170
 171        // From universal audio service
 0172        if (!string.IsNullOrWhiteSpace(state.Request.TranscodeReasons))
 173        {
 0174            playlistQuery.TryAdd("TranscodeReasons", state.Request.TranscodeReasons);
 175        }
 176
 177        // Video rotation metadata is only supported in fMP4 remuxing
 0178        if (state.VideoStream is not null
 0179            && state.VideoRequest is not null
 0180            && (state.VideoStream?.Rotation ?? 0) != 0
 0181            && EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0182            && !string.IsNullOrWhiteSpace(state.Request.SegmentContainer)
 0183            && !string.Equals(state.Request.SegmentContainer, "mp4", StringComparison.OrdinalIgnoreCase))
 184        {
 0185            playlistQuery["AllowVideoStreamCopy"] = "false";
 186        }
 187
 188        // Main stream
 0189        var baseUrl = isLiveStream ? "live.m3u8" : "main.m3u8";
 0190        var playlistUrl = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(baseUrl, playlistQuery);
 191
 0192        var subtitleStreams = state.MediaSource
 0193            .MediaStreams
 0194            .Where(i => i.IsTextSubtitleStream)
 0195            .ToList();
 196
 0197        var subtitleGroup = subtitleStreams.Count > 0 && (state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Hls || 
 0198            ? "subs"
 0199            : null;
 200
 201        // If we're burning in subtitles then don't add additional subs to the manifest
 0202        if (state.SubtitleStream is not null && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode)
 203        {
 0204            subtitleGroup = null;
 205        }
 206
 0207        if (!string.IsNullOrWhiteSpace(subtitleGroup))
 208        {
 0209            AddSubtitles(state, subtitleStreams, builder, _httpContextAccessor.HttpContext.User);
 210        }
 211
 212        // For DoVi profiles without a compatible base layer (P5 HEVC, P10/bl0 AV1),
 213        // add a spec-compliant dvh1/dav1 variant before the hvc1 hack variant.
 214        // SUPPLEMENTAL-CODECS cannot be used for these profiles (no compatible BL to supplement).
 215        // The DoVi variant is listed first so spec-compliant clients (Apple TV, webOS 24+)
 216        // select it over the fallback when both have identical BANDWIDTH.
 217        // Only emit for clients that explicitly declared DOVI support to avoid breaking
 218        // non-compliant players that don't recognize dvh1/dav1 CODECS strings.
 0219        if (state.VideoStream is not null
 0220            && state.VideoRequest is not null
 0221            && EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0222            && state.VideoStream.VideoRangeType == VideoRangeType.DOVI
 0223            && state.VideoStream.DvProfile.HasValue
 0224            && state.VideoStream.DvLevel.HasValue
 0225            && state.GetRequestedRangeTypes(state.VideoStream.Codec)
 0226                .Contains(VideoRangeType.DOVI.ToString(), StringComparison.OrdinalIgnoreCase))
 227        {
 0228            AppendDoviPlaylist(builder, state, playlistUrl, totalBitrate, subtitleGroup);
 229        }
 230
 0231        var basicPlaylist = AppendPlaylist(builder, state, playlistUrl, totalBitrate, subtitleGroup);
 232
 0233        if (state.VideoStream is not null && state.VideoRequest is not null)
 234        {
 0235            var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
 236
 237            // Provide AV1 and HEVC SDR entrances for backward compatibility.
 0238            foreach (var sdrVideoCodec in new[] { "av1", "hevc" })
 239            {
 0240                var isAv1EncodingAllowed = encodingOptions.AllowAv1Encoding
 0241                    && string.Equals(sdrVideoCodec, "av1", StringComparison.OrdinalIgnoreCase)
 0242                    && string.Equals(state.ActualOutputVideoCodec, "av1", StringComparison.OrdinalIgnoreCase);
 0243                var isHevcEncodingAllowed = encodingOptions.AllowHevcEncoding
 0244                    && string.Equals(sdrVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase)
 0245                    && string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase);
 0246                var isEncodingAllowed = isAv1EncodingAllowed || isHevcEncodingAllowed;
 247
 0248                if (isEncodingAllowed
 0249                    && EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0250                    && state.VideoStream.VideoRange == VideoRange.HDR)
 251                {
 252                    // Force AV1 and HEVC Main Profile and disable video stream copy.
 0253                    state.OutputVideoCodec = sdrVideoCodec;
 254
 0255                    var sdrPlaylistQuery = playlistQuery;
 0256                    sdrPlaylistQuery["VideoCodec"] = sdrVideoCodec;
 0257                    sdrPlaylistQuery[sdrVideoCodec + "-profile"] = "main";
 0258                    sdrPlaylistQuery["AllowVideoStreamCopy"] = "false";
 259
 0260                    var sdrVideoUrl = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(baseUrl, sdrPlaylist
 261
 262                    // HACK: Use the same bitrate so that the client can choose by other attributes, such as color range
 0263                    AppendPlaylist(builder, state, sdrVideoUrl, totalBitrate, subtitleGroup);
 264
 265                    // Restore the video codec
 0266                    state.OutputVideoCodec = "copy";
 267                }
 268            }
 269
 270            // Provide H.264 SDR entrance for backward compatibility.
 0271            if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0272                && state.VideoStream.VideoRange == VideoRange.HDR)
 273            {
 274                // Force H.264 and disable video stream copy.
 0275                state.OutputVideoCodec = "h264";
 276
 0277                var sdrPlaylistQuery = playlistQuery;
 0278                sdrPlaylistQuery["VideoCodec"] = "h264";
 0279                sdrPlaylistQuery["AllowVideoStreamCopy"] = "false";
 280
 0281                var sdrVideoUrl = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(baseUrl, sdrPlaylistQuer
 282
 283                // HACK: Use the same bitrate so that the client can choose by other attributes, such as color range.
 0284                AppendPlaylist(builder, state, sdrVideoUrl, totalBitrate, subtitleGroup);
 285
 286                // Restore the video codec
 0287                state.OutputVideoCodec = "copy";
 288            }
 289
 290            // Provide Level 5.0 entrance for backward compatibility.
 291            // e.g. Apple A10 chips refuse the master playlist containing SDR HEVC Main Level 5.1 video,
 292            // but in fact it is capable of playing videos up to Level 6.1.
 0293            if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0294                && state.VideoStream.Level.HasValue
 0295                && state.VideoStream.Level > 150
 0296                && state.VideoStream.VideoRange == VideoRange.SDR
 0297                && string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase))
 298            {
 0299                var playlistCodecsField = new StringBuilder();
 0300                AppendPlaylistCodecsField(playlistCodecsField, state);
 301
 302                // Force the video level to 5.0.
 0303                var originalLevel = state.VideoStream.Level;
 0304                state.VideoStream.Level = 150;
 0305                var newPlaylistCodecsField = new StringBuilder();
 0306                AppendPlaylistCodecsField(newPlaylistCodecsField, state);
 307
 308                // Restore the video level.
 0309                state.VideoStream.Level = originalLevel;
 0310                var newPlaylist = ReplacePlaylistCodecsField(basicPlaylist, playlistCodecsField, newPlaylistCodecsField)
 0311                builder.Append(newPlaylist);
 312            }
 313        }
 314
 0315        if (EnableAdaptiveBitrateStreaming(state, isLiveStream, enableAdaptiveBitrateStreaming, _httpContextAccessor.Htt
 316        {
 0317            var requestedVideoBitrate = state.VideoRequest?.VideoBitRate ?? 0;
 318
 319            // By default, vary by just 200k
 0320            var variation = GetBitrateVariation(totalBitrate);
 321
 0322            var newBitrate = totalBitrate - variation;
 0323            var variantQuery = playlistQuery;
 0324            variantQuery["VideoBitrate"] = (requestedVideoBitrate - variation).ToString(CultureInfo.InvariantCulture);
 0325            var variantUrl = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(baseUrl, variantQuery);
 0326            AppendPlaylist(builder, state, variantUrl, newBitrate, subtitleGroup);
 327
 0328            variation *= 2;
 0329            newBitrate = totalBitrate - variation;
 0330            variantQuery["VideoBitrate"] = (requestedVideoBitrate - variation).ToString(CultureInfo.InvariantCulture);
 0331            variantUrl = Microsoft.AspNetCore.WebUtilities.QueryHelpers.AddQueryString(baseUrl, variantQuery);
 0332            AppendPlaylist(builder, state, variantUrl, newBitrate, subtitleGroup);
 333        }
 334
 0335        if (!isLiveStream && (state.VideoRequest?.EnableTrickplay ?? false))
 336        {
 0337            var sourceId = Guid.Parse(state.Request.MediaSourceId);
 0338            var trickplayResolutions = await _trickplayManager.GetTrickplayResolutions(sourceId).ConfigureAwait(false);
 0339            AddTrickplay(state, trickplayResolutions, builder, _httpContextAccessor.HttpContext.User);
 340        }
 341
 0342        return new FileContentResult(Encoding.UTF8.GetBytes(builder.ToString()), MimeTypes.GetMimeType("playlist.m3u8"))
 0343    }
 344
 345    private StringBuilder AppendPlaylist(StringBuilder builder, StreamState state, string url, int bitrate, string? subt
 346    {
 0347        var playlistBuilder = new StringBuilder();
 0348        playlistBuilder.Append("#EXT-X-STREAM-INF:BANDWIDTH=")
 0349            .Append(bitrate.ToString(CultureInfo.InvariantCulture))
 0350            .Append(",AVERAGE-BANDWIDTH=")
 0351            .Append(bitrate.ToString(CultureInfo.InvariantCulture));
 352
 0353        AppendPlaylistVideoRangeField(playlistBuilder, state);
 354
 0355        AppendPlaylistCodecsField(playlistBuilder, state);
 356
 0357        AppendPlaylistSupplementalCodecsField(playlistBuilder, state);
 358
 0359        AppendPlaylistResolutionField(playlistBuilder, state);
 360
 0361        AppendPlaylistFramerateField(playlistBuilder, state);
 362
 0363        if (!string.IsNullOrWhiteSpace(subtitleGroup))
 364        {
 0365            playlistBuilder.Append(",SUBTITLES=\"")
 0366                .Append(subtitleGroup)
 0367                .Append('"');
 368        }
 369
 0370        playlistBuilder.Append(Environment.NewLine);
 0371        playlistBuilder.AppendLine(url);
 0372        builder.Append(playlistBuilder);
 373
 0374        return playlistBuilder;
 375    }
 376
 377    /// <summary>
 378    /// Appends a Dolby Vision variant with dvh1/dav1 CODECS for profiles without a compatible
 379    /// base layer (P5 HEVC, P10/bl0 AV1). This enables spec-compliant HLS clients to detect
 380    /// DoVi from the manifest rather than relying on init segment inspection.
 381    /// </summary>
 382    /// <param name="builder">StringBuilder for the master playlist.</param>
 383    /// <param name="state">StreamState of the current stream.</param>
 384    /// <param name="url">Playlist URL for this variant.</param>
 385    /// <param name="bitrate">Bitrate for the BANDWIDTH field.</param>
 386    /// <param name="subtitleGroup">Subtitle group identifier, or null.</param>
 387    private void AppendDoviPlaylist(StringBuilder builder, StreamState state, string url, int bitrate, string? subtitleG
 388    {
 0389        var dvProfile = state.VideoStream.DvProfile;
 0390        var dvLevel = state.VideoStream.DvLevel;
 0391        if (dvProfile is null || dvLevel is null)
 392        {
 0393            return;
 394        }
 395
 0396        var playlistBuilder = new StringBuilder();
 0397        playlistBuilder.Append("#EXT-X-STREAM-INF:BANDWIDTH=")
 0398            .Append(bitrate.ToString(CultureInfo.InvariantCulture))
 0399            .Append(",AVERAGE-BANDWIDTH=")
 0400            .Append(bitrate.ToString(CultureInfo.InvariantCulture));
 401
 0402        playlistBuilder.Append(",VIDEO-RANGE=PQ");
 403
 0404        var dvCodec = HlsCodecStringHelpers.GetDoviString(dvProfile.Value, dvLevel.Value, state.ActualOutputVideoCodec);
 405
 0406        string audioCodecs = string.Empty;
 0407        if (!string.IsNullOrEmpty(state.ActualOutputAudioCodec))
 408        {
 0409            audioCodecs = GetPlaylistAudioCodecs(state);
 410        }
 411
 0412        playlistBuilder.Append(",CODECS=\"")
 0413            .Append(dvCodec);
 0414        if (!string.IsNullOrEmpty(audioCodecs))
 415        {
 0416            playlistBuilder.Append(',').Append(audioCodecs);
 417        }
 418
 0419        playlistBuilder.Append('"');
 420
 0421        AppendPlaylistResolutionField(playlistBuilder, state);
 0422        AppendPlaylistFramerateField(playlistBuilder, state);
 423
 0424        if (!string.IsNullOrWhiteSpace(subtitleGroup))
 425        {
 0426            playlistBuilder.Append(",SUBTITLES=\"")
 0427                .Append(subtitleGroup)
 0428                .Append('"');
 429        }
 430
 0431        playlistBuilder.AppendLine();
 0432        playlistBuilder.AppendLine(url);
 0433        builder.Append(playlistBuilder);
 0434    }
 435
 436    /// <summary>
 437    /// Appends a VIDEO-RANGE field containing the range of the output video stream.
 438    /// </summary>
 439    /// <seealso cref="AppendPlaylist(StringBuilder, StreamState, string, int, string)"/>
 440    /// <param name="builder">StringBuilder to append the field to.</param>
 441    /// <param name="state">StreamState of the current stream.</param>
 442    private void AppendPlaylistVideoRangeField(StringBuilder builder, StreamState state)
 443    {
 0444        if (state.VideoStream is not null && state.VideoStream.VideoRange != VideoRange.Unknown)
 445        {
 0446            var videoRange = state.VideoStream.VideoRange;
 0447            var videoRangeType = state.VideoStream.VideoRangeType;
 0448            if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
 449            {
 0450                if (videoRange == VideoRange.SDR)
 451                {
 0452                    builder.Append(",VIDEO-RANGE=SDR");
 453                }
 454
 0455                if (videoRange == VideoRange.HDR)
 456                {
 0457                    switch (videoRangeType)
 458                    {
 459                        case VideoRangeType.HLG:
 460                        case VideoRangeType.DOVIWithHLG:
 0461                        case VideoRangeType.DOVIInvalid when string.Equals(state.VideoStream.ColorTransfer, "arib-std-b6
 0462                            builder.Append(",VIDEO-RANGE=HLG");
 0463                            break;
 464                        default:
 0465                            builder.Append(",VIDEO-RANGE=PQ");
 0466                            break;
 467                    }
 468                }
 469            }
 470            else
 471            {
 472                // Currently we only encode to SDR.
 0473                builder.Append(",VIDEO-RANGE=SDR");
 474            }
 475        }
 0476    }
 477
 478    /// <summary>
 479    /// Appends a CODECS field containing formatted strings of
 480    /// the active streams output video and audio codecs.
 481    /// </summary>
 482    /// <seealso cref="AppendPlaylist(StringBuilder, StreamState, string, int, string)"/>
 483    /// <seealso cref="GetPlaylistVideoCodecs(StreamState, string, int)"/>
 484    /// <seealso cref="GetPlaylistAudioCodecs(StreamState)"/>
 485    /// <param name="builder">StringBuilder to append the field to.</param>
 486    /// <param name="state">StreamState of the current stream.</param>
 487    private void AppendPlaylistCodecsField(StringBuilder builder, StreamState state)
 488    {
 489        // Video
 0490        string videoCodecs = string.Empty;
 0491        int? videoCodecLevel = GetOutputVideoCodecLevel(state);
 0492        if (!string.IsNullOrEmpty(state.ActualOutputVideoCodec) && videoCodecLevel.HasValue)
 493        {
 0494            videoCodecs = GetPlaylistVideoCodecs(state, state.ActualOutputVideoCodec, videoCodecLevel.Value);
 495        }
 496
 497        // Audio
 0498        string audioCodecs = string.Empty;
 0499        if (!string.IsNullOrEmpty(state.ActualOutputAudioCodec))
 500        {
 0501            audioCodecs = GetPlaylistAudioCodecs(state);
 502        }
 503
 0504        StringBuilder codecs = new StringBuilder();
 505
 0506        codecs.Append(videoCodecs);
 507
 0508        if (!string.IsNullOrEmpty(videoCodecs) && !string.IsNullOrEmpty(audioCodecs))
 509        {
 0510            codecs.Append(',');
 511        }
 512
 0513        codecs.Append(audioCodecs);
 514
 0515        if (codecs.Length > 1)
 516        {
 0517            builder.Append(",CODECS=\"")
 0518                .Append(codecs)
 0519                .Append('"');
 520        }
 0521    }
 522
 523    /// <summary>
 524    /// Appends a SUPPLEMENTAL-CODECS field containing formatted strings of
 525    /// the active streams output Dolby Vision Videos.
 526    /// </summary>
 527    /// <seealso cref="AppendPlaylist(StringBuilder, StreamState, string, int, string)"/>
 528    /// <seealso cref="GetPlaylistVideoCodecs(StreamState, string, int)"/>
 529    /// <param name="builder">StringBuilder to append the field to.</param>
 530    /// <param name="state">StreamState of the current stream.</param>
 531    private void AppendPlaylistSupplementalCodecsField(StringBuilder builder, StreamState state)
 532    {
 533        // HDR dynamic metadata currently cannot exist when transcoding
 0534        if (!EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
 535        {
 0536            return;
 537        }
 538
 0539        if (EncodingHelper.IsDovi(state.VideoStream) && !_encodingHelper.IsDoviRemoved(state))
 540        {
 0541            AppendDvString();
 542        }
 0543        else if (EncodingHelper.IsHdr10Plus(state.VideoStream) && !_encodingHelper.IsHdr10PlusRemoved(state))
 544        {
 0545            AppendHdr10PlusString();
 546        }
 547
 0548        return;
 549
 550        void AppendDvString()
 551        {
 552            var dvProfile = state.VideoStream.DvProfile;
 553            var dvLevel = state.VideoStream.DvLevel;
 554            var dvRangeString = state.VideoStream.VideoRangeType switch
 555            {
 556                VideoRangeType.DOVIWithHDR10 => "db1p",
 557                VideoRangeType.DOVIWithHLG => "db4h",
 558                VideoRangeType.DOVIWithHDR10Plus => "db1p", // The HDR10+ metadata would be removed if Dovi metadata is 
 559                _ => string.Empty // Don't label Dovi with EL and SDR due to compatability issues, ignore invalid config
 560            };
 561
 562            if (dvProfile is null || dvLevel is null || string.IsNullOrEmpty(dvRangeString))
 563            {
 564                return;
 565            }
 566
 567            var dvFourCc = string.Equals(state.ActualOutputVideoCodec, "av1", StringComparison.OrdinalIgnoreCase) ? "dav
 568            builder.Append(",SUPPLEMENTAL-CODECS=\"")
 569                .Append(dvFourCc)
 570                .Append('.')
 571                .Append(dvProfile.Value.ToString("D2", CultureInfo.InvariantCulture))
 572                .Append('.')
 573                .Append(dvLevel.Value.ToString("D2", CultureInfo.InvariantCulture))
 574                .Append('/')
 575                .Append(dvRangeString)
 576                .Append('"');
 577        }
 578
 579        void AppendHdr10PlusString()
 580        {
 581            var videoCodecLevel = GetOutputVideoCodecLevel(state);
 582            if (string.IsNullOrEmpty(state.ActualOutputVideoCodec) || videoCodecLevel is null)
 583            {
 584                return;
 585            }
 586
 587            var videoCodecString = GetPlaylistVideoCodecs(state, state.ActualOutputVideoCodec, videoCodecLevel.Value);
 588            builder.Append(",SUPPLEMENTAL-CODECS=\"")
 589                .Append(videoCodecString)
 590                .Append('/')
 591                .Append("cdm4")
 592                .Append('"');
 593        }
 594    }
 595
 596    /// <summary>
 597    /// Appends a RESOLUTION field containing the resolution of the output stream.
 598    /// </summary>
 599    /// <seealso cref="AppendPlaylist(StringBuilder, StreamState, string, int, string)"/>
 600    /// <param name="builder">StringBuilder to append the field to.</param>
 601    /// <param name="state">StreamState of the current stream.</param>
 602    private void AppendPlaylistResolutionField(StringBuilder builder, StreamState state)
 603    {
 0604        if (state.OutputWidth.HasValue && state.OutputHeight.HasValue)
 605        {
 0606            builder.Append(",RESOLUTION=")
 0607                .Append(state.OutputWidth.GetValueOrDefault())
 0608                .Append('x')
 0609                .Append(state.OutputHeight.GetValueOrDefault());
 610        }
 0611    }
 612
 613    /// <summary>
 614    /// Appends a FRAME-RATE field containing the framerate of the output stream.
 615    /// </summary>
 616    /// <seealso cref="AppendPlaylist(StringBuilder, StreamState, string, int, string)"/>
 617    /// <param name="builder">StringBuilder to append the field to.</param>
 618    /// <param name="state">StreamState of the current stream.</param>
 619    private void AppendPlaylistFramerateField(StringBuilder builder, StreamState state)
 620    {
 0621        double? framerate = null;
 0622        if (state.TargetFramerate.HasValue)
 623        {
 0624            framerate = Math.Round(state.TargetFramerate.GetValueOrDefault(), 3);
 625        }
 0626        else if (state.VideoStream?.RealFrameRate is not null)
 627        {
 0628            framerate = Math.Round(state.VideoStream.RealFrameRate.GetValueOrDefault(), 3);
 629        }
 630
 0631        if (framerate.HasValue)
 632        {
 0633            builder.Append(",FRAME-RATE=")
 0634                .Append(framerate.Value.ToString(CultureInfo.InvariantCulture));
 635        }
 0636    }
 637
 638    private bool EnableAdaptiveBitrateStreaming(StreamState state, bool isLiveStream, bool enableAdaptiveBitrateStreamin
 639    {
 640        // Within the local network this will likely do more harm than good.
 0641        if (_networkManager.IsInLocalNetwork(ipAddress))
 642        {
 0643            return false;
 644        }
 645
 0646        if (!enableAdaptiveBitrateStreaming)
 647        {
 0648            return false;
 649        }
 650
 0651        if (isLiveStream || string.IsNullOrWhiteSpace(state.MediaPath))
 652        {
 653            // Opening live streams is so slow it's not even worth it
 0654            return false;
 655        }
 656
 0657        if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec))
 658        {
 0659            return false;
 660        }
 661
 0662        if (EncodingHelper.IsCopyCodec(state.OutputAudioCodec))
 663        {
 0664            return false;
 665        }
 666
 0667        if (!state.IsOutputVideo)
 668        {
 0669            return false;
 670        }
 671
 0672        return state.VideoRequest?.VideoBitRate.HasValue ?? false;
 673    }
 674
 675    private void AddSubtitles(StreamState state, IEnumerable<MediaStream> subtitles, StringBuilder builder, ClaimsPrinci
 676    {
 0677        if (state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Drop)
 678        {
 0679            return;
 680        }
 681
 0682        var selectedIndex = state.SubtitleStream is null || state.SubtitleDeliveryMethod != SubtitleDeliveryMethod.Hls ?
 683        const string Format = "#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"subs\",NAME=\"{0}\",DEFAULT={1},FORCED={2},AUTOSEL
 684
 0685        foreach (var stream in subtitles)
 686        {
 0687            var name = stream.DisplayTitle;
 688
 0689            var isDefault = selectedIndex.HasValue && selectedIndex.Value == stream.Index;
 0690            var isForced = stream.IsForced;
 691
 0692            var url = string.Format(
 0693                CultureInfo.InvariantCulture,
 0694                "{0}/Subtitles/{1}/subtitles.m3u8?SegmentLength={2}&ApiKey={3}&VttTimestampMapMpegts={4}",
 0695                state.Request.MediaSourceId,
 0696                stream.Index.ToString(CultureInfo.InvariantCulture),
 0697                30.ToString(CultureInfo.InvariantCulture),
 0698                user.GetToken(),
 0699                GetVttTimestampMapMpegts(state.Request.SegmentContainer).ToString(CultureInfo.InvariantCulture));
 700
 0701            var line = string.Format(
 0702                CultureInfo.InvariantCulture,
 0703                Format,
 0704                name,
 0705                isDefault ? "YES" : "NO",
 0706                isForced ? "YES" : "NO",
 0707                url,
 0708                stream.Language ?? "Unknown");
 709
 0710            builder.AppendLine(line);
 711        }
 0712    }
 713
 714    /// <summary>
 715    /// Gets the WebVTT X-TIMESTAMP-MAP MPEGTS offset appropriate for the given HLS segment container.
 716    /// fMP4 segments start at PTS 0, unlike legacy MPEG-TS segments which start at the historical 10 second offset.
 717    /// </summary>
 718    /// <param name="segmentContainer">The HLS segment container, e.g. "ts" or "mp4".</param>
 719    /// <returns>The MPEGTS offset to embed in the WebVTT X-TIMESTAMP-MAP header.</returns>
 720    internal static long GetVttTimestampMapMpegts(string? segmentContainer)
 721    {
 5722        var segmentExtension = EncodingHelper.GetSegmentFileExtension(segmentContainer);
 5723        return string.Equals(segmentExtension, ".mp4", StringComparison.OrdinalIgnoreCase)
 5724            ? 0
 5725            : SubtitleController.DefaultVttTimestampMapMpegts;
 726    }
 727
 728    /// <summary>
 729    /// Appends EXT-X-IMAGE-STREAM-INF playlists for each available trickplay resolution.
 730    /// </summary>
 731    /// <param name="state">StreamState of the current stream.</param>
 732    /// <param name="trickplayResolutions">Dictionary of widths to corresponding tiles info.</param>
 733    /// <param name="builder">StringBuilder to append the field to.</param>
 734    /// <param name="user">Http user context.</param>
 735    private void AddTrickplay(StreamState state, Dictionary<int, TrickplayInfo> trickplayResolutions, StringBuilder buil
 736    {
 737        const string playlistFormat = "#EXT-X-IMAGE-STREAM-INF:BANDWIDTH={0},RESOLUTION={1}x{2},CODECS=\"jpeg\",URI=\"{3
 738
 0739        foreach (var resolution in trickplayResolutions)
 740        {
 0741            var width = resolution.Key;
 0742            var trickplayInfo = resolution.Value;
 743
 0744            var url = string.Format(
 0745                CultureInfo.InvariantCulture,
 0746                "Trickplay/{0}/tiles.m3u8?MediaSourceId={1}&ApiKey={2}",
 0747                width.ToString(CultureInfo.InvariantCulture),
 0748                state.Request.MediaSourceId,
 0749                user.GetToken());
 750
 0751            builder.AppendFormat(
 0752                CultureInfo.InvariantCulture,
 0753                playlistFormat,
 0754                trickplayInfo.Bandwidth.ToString(CultureInfo.InvariantCulture),
 0755                trickplayInfo.Width.ToString(CultureInfo.InvariantCulture),
 0756                trickplayInfo.Height.ToString(CultureInfo.InvariantCulture),
 0757                url);
 758
 0759            builder.AppendLine();
 760        }
 0761    }
 762
 763    /// <summary>
 764    /// Get the H.26X level of the output video stream.
 765    /// </summary>
 766    /// <param name="state">StreamState of the current stream.</param>
 767    /// <returns>H.26X level of the output video stream.</returns>
 768    private int? GetOutputVideoCodecLevel(StreamState state)
 769    {
 0770        string levelString = string.Empty;
 0771        if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0772            && state.VideoStream is not null
 0773            && state.VideoStream.Level.HasValue)
 774        {
 0775            levelString = state.VideoStream.Level.Value.ToString(CultureInfo.InvariantCulture);
 776        }
 777        else
 778        {
 0779            if (string.Equals(state.ActualOutputVideoCodec, "h264", StringComparison.OrdinalIgnoreCase))
 780            {
 0781                levelString = state.GetRequestedLevel(state.ActualOutputVideoCodec) ?? "41";
 0782                levelString = EncodingHelper.NormalizeTranscodingLevel(state, levelString);
 783            }
 784
 0785            if (string.Equals(state.ActualOutputVideoCodec, "h265", StringComparison.OrdinalIgnoreCase)
 0786                || string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase))
 787            {
 0788                levelString = state.GetRequestedLevel("h265") ?? state.GetRequestedLevel("hevc") ?? "120";
 0789                levelString = EncodingHelper.NormalizeTranscodingLevel(state, levelString);
 790            }
 791
 0792            if (string.Equals(state.ActualOutputVideoCodec, "av1", StringComparison.OrdinalIgnoreCase))
 793            {
 0794                levelString = state.GetRequestedLevel("av1") ?? "19";
 0795                levelString = EncodingHelper.NormalizeTranscodingLevel(state, levelString);
 796            }
 797        }
 798
 0799        if (int.TryParse(levelString, NumberStyles.Integer, CultureInfo.InvariantCulture, out var parsedLevel))
 800        {
 0801            return parsedLevel;
 802        }
 803
 0804        return null;
 805    }
 806
 807    /// <summary>
 808    /// Get the profile of the output video stream.
 809    /// </summary>
 810    /// <param name="state">StreamState of the current stream.</param>
 811    /// <param name="codec">Video codec.</param>
 812    /// <returns>Profile of the output video stream.</returns>
 813    private string GetOutputVideoCodecProfile(StreamState state, string codec)
 814    {
 0815        string profileString = string.Empty;
 0816        if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0817            && !string.IsNullOrEmpty(state.VideoStream.Profile))
 818        {
 0819            profileString = state.VideoStream.Profile;
 820        }
 0821        else if (!string.IsNullOrEmpty(codec))
 822        {
 0823            profileString = state.GetRequestedProfiles(codec).FirstOrDefault() ?? string.Empty;
 0824            if (string.Equals(state.ActualOutputVideoCodec, "h264", StringComparison.OrdinalIgnoreCase))
 825            {
 0826                profileString ??= "high";
 827            }
 828
 0829            if (string.Equals(state.ActualOutputVideoCodec, "h265", StringComparison.OrdinalIgnoreCase)
 0830                || string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase)
 0831                || string.Equals(state.ActualOutputVideoCodec, "av1", StringComparison.OrdinalIgnoreCase))
 832            {
 0833                profileString ??= "main";
 834            }
 835        }
 836
 0837        return profileString;
 838    }
 839
 840    /// <summary>
 841    /// Gets a formatted string of the output audio codec, for use in the CODECS field.
 842    /// </summary>
 843    /// <seealso cref="AppendPlaylistCodecsField(StringBuilder, StreamState)"/>
 844    /// <seealso cref="GetPlaylistVideoCodecs(StreamState, string, int)"/>
 845    /// <param name="state">StreamState of the current stream.</param>
 846    /// <returns>Formatted audio codec string.</returns>
 847    private string GetPlaylistAudioCodecs(StreamState state)
 848    {
 0849        if (string.Equals(state.ActualOutputAudioCodec, "aac", StringComparison.OrdinalIgnoreCase))
 850        {
 0851            string? profile = EncodingHelper.IsCopyCodec(state.OutputAudioCodec)
 0852                ? state.AudioStream?.Profile : state.GetRequestedProfiles("aac").FirstOrDefault();
 853
 0854            return HlsCodecStringHelpers.GetAACString(profile);
 855        }
 856
 0857        if (string.Equals(state.ActualOutputAudioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
 858        {
 0859            return HlsCodecStringHelpers.GetMP3String();
 860        }
 861
 0862        if (string.Equals(state.ActualOutputAudioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
 863        {
 0864            return HlsCodecStringHelpers.GetAC3String();
 865        }
 866
 0867        if (string.Equals(state.ActualOutputAudioCodec, "eac3", StringComparison.OrdinalIgnoreCase))
 868        {
 0869            return HlsCodecStringHelpers.GetEAC3String();
 870        }
 871
 0872        if (string.Equals(state.ActualOutputAudioCodec, "flac", StringComparison.OrdinalIgnoreCase))
 873        {
 0874            return HlsCodecStringHelpers.GetFLACString();
 875        }
 876
 0877        if (string.Equals(state.ActualOutputAudioCodec, "alac", StringComparison.OrdinalIgnoreCase))
 878        {
 0879            return HlsCodecStringHelpers.GetALACString();
 880        }
 881
 0882        if (string.Equals(state.ActualOutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase))
 883        {
 0884            return HlsCodecStringHelpers.GetOPUSString();
 885        }
 886
 0887        if (string.Equals(state.ActualOutputAudioCodec, "truehd", StringComparison.OrdinalIgnoreCase))
 888        {
 0889            return HlsCodecStringHelpers.GetTRUEHDString();
 890        }
 891
 0892        if (string.Equals(state.ActualOutputAudioCodec, "dts", StringComparison.OrdinalIgnoreCase))
 893        {
 894            // lavc only support encoding DTS core profile
 0895            string? profile = EncodingHelper.IsCopyCodec(state.OutputAudioCodec) ? state.AudioStream?.Profile : "DTS";
 896
 0897            return HlsCodecStringHelpers.GetDTSString(profile);
 898        }
 899
 0900        return string.Empty;
 901    }
 902
 903    /// <summary>
 904    /// Gets a formatted string of the output video codec, for use in the CODECS field.
 905    /// </summary>
 906    /// <seealso cref="AppendPlaylistCodecsField(StringBuilder, StreamState)"/>
 907    /// <seealso cref="GetPlaylistAudioCodecs(StreamState)"/>
 908    /// <param name="state">StreamState of the current stream.</param>
 909    /// <param name="codec">Video codec.</param>
 910    /// <param name="level">Video level.</param>
 911    /// <returns>Formatted video codec string.</returns>
 912    private string GetPlaylistVideoCodecs(StreamState state, string codec, int level)
 913    {
 0914        if (level == 0)
 915        {
 916            // This is 0 when there's no requested level in the device profile
 917            // and the source is not encoded in H.26X or AV1
 0918            _logger.LogError("Got invalid level when building CODECS field for HLS master playlist");
 0919            return string.Empty;
 920        }
 921
 0922        if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
 923        {
 0924            string profile = GetOutputVideoCodecProfile(state, "h264");
 0925            return HlsCodecStringHelpers.GetH264String(profile, level);
 926        }
 927
 0928        if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase)
 0929            || string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase))
 930        {
 0931            string profile = GetOutputVideoCodecProfile(state, "hevc");
 0932            return HlsCodecStringHelpers.GetH265String(profile, level);
 933        }
 934
 0935        if (string.Equals(codec, "av1", StringComparison.OrdinalIgnoreCase))
 936        {
 0937            string profile = GetOutputVideoCodecProfile(state, "av1");
 938
 939            // Currently we only transcode to 8 bits AV1
 0940            int bitDepth = 8;
 0941            if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec)
 0942                && state.VideoStream is not null
 0943                && state.VideoStream.BitDepth.HasValue)
 944            {
 0945                bitDepth = state.VideoStream.BitDepth.Value;
 946            }
 947
 0948            return HlsCodecStringHelpers.GetAv1String(profile, level, false, bitDepth);
 949        }
 950
 951        // VP9 HLS is for video remuxing only, everything is probed from the original video
 0952        if (string.Equals(codec, "vp9", StringComparison.OrdinalIgnoreCase))
 953        {
 0954            var width = state.VideoStream.Width ?? 0;
 0955            var height = state.VideoStream.Height ?? 0;
 0956            var framerate = state.VideoStream.ReferenceFrameRate ?? 30;
 0957            var bitDepth = state.VideoStream.BitDepth ?? 8;
 0958            return HlsCodecStringHelpers.GetVp9String(
 0959                width,
 0960                height,
 0961                state.VideoStream.PixelFormat,
 0962                framerate,
 0963                bitDepth);
 964        }
 965
 0966        return string.Empty;
 967    }
 968
 969    private int GetBitrateVariation(int bitrate)
 970    {
 971        // By default, vary by just 50k
 0972        var variation = 50000;
 973
 0974        if (bitrate >= 10000000)
 975        {
 0976            variation = 2000000;
 977        }
 0978        else if (bitrate >= 5000000)
 979        {
 0980            variation = 1500000;
 981        }
 0982        else if (bitrate >= 3000000)
 983        {
 0984            variation = 1000000;
 985        }
 0986        else if (bitrate >= 2000000)
 987        {
 0988            variation = 500000;
 989        }
 0990        else if (bitrate >= 1000000)
 991        {
 0992            variation = 300000;
 993        }
 0994        else if (bitrate >= 600000)
 995        {
 0996            variation = 200000;
 997        }
 0998        else if (bitrate >= 400000)
 999        {
 01000            variation = 100000;
 1001        }
 1002
 01003        return variation;
 1004    }
 1005
 1006    private string ReplacePlaylistCodecsField(StringBuilder playlist, StringBuilder oldValue, StringBuilder newValue)
 1007    {
 01008        var oldPlaylist = playlist.ToString();
 01009        return oldPlaylist.Replace(
 01010            oldValue.ToString(),
 01011            newValue.ToString(),
 01012            StringComparison.Ordinal);
 1013    }
 1014}

Methods/Properties

.ctor(MediaBrowser.Controller.Library.ILibraryManager,MediaBrowser.Controller.Library.IUserManager,MediaBrowser.Controller.Library.IMediaSourceManager,MediaBrowser.Controller.Configuration.IServerConfigurationManager,MediaBrowser.Controller.MediaEncoding.IMediaEncoder,MediaBrowser.Controller.MediaEncoding.ITranscodeManager,MediaBrowser.Common.Net.INetworkManager,Microsoft.Extensions.Logging.ILogger`1<Jellyfin.Api.Helpers.DynamicHlsHelper>,Microsoft.AspNetCore.Http.IHttpContextAccessor,MediaBrowser.Controller.MediaEncoding.EncodingHelper,MediaBrowser.Controller.Trickplay.ITrickplayManager)
GetMasterHlsPlaylist()
GetMasterPlaylistInternal()
AppendPlaylist(System.Text.StringBuilder,MediaBrowser.Controller.Streaming.StreamState,System.String,System.Int32,System.String)
AppendDoviPlaylist(System.Text.StringBuilder,MediaBrowser.Controller.Streaming.StreamState,System.String,System.Int32,System.String)
AppendPlaylistVideoRangeField(System.Text.StringBuilder,MediaBrowser.Controller.Streaming.StreamState)
AppendPlaylistCodecsField(System.Text.StringBuilder,MediaBrowser.Controller.Streaming.StreamState)
AppendPlaylistSupplementalCodecsField(System.Text.StringBuilder,MediaBrowser.Controller.Streaming.StreamState)
AppendPlaylistResolutionField(System.Text.StringBuilder,MediaBrowser.Controller.Streaming.StreamState)
AppendPlaylistFramerateField(System.Text.StringBuilder,MediaBrowser.Controller.Streaming.StreamState)
EnableAdaptiveBitrateStreaming(MediaBrowser.Controller.Streaming.StreamState,System.Boolean,System.Boolean,System.Net.IPAddress)
AddSubtitles(MediaBrowser.Controller.Streaming.StreamState,System.Collections.Generic.IEnumerable`1<MediaBrowser.Model.Entities.MediaStream>,System.Text.StringBuilder,System.Security.Claims.ClaimsPrincipal)
GetVttTimestampMapMpegts(System.String)
AddTrickplay(MediaBrowser.Controller.Streaming.StreamState,System.Collections.Generic.Dictionary`2<System.Int32,Jellyfin.Database.Implementations.Entities.TrickplayInfo>,System.Text.StringBuilder,System.Security.Claims.ClaimsPrincipal)
GetOutputVideoCodecLevel(MediaBrowser.Controller.Streaming.StreamState)
GetOutputVideoCodecProfile(MediaBrowser.Controller.Streaming.StreamState,System.String)
GetPlaylistAudioCodecs(MediaBrowser.Controller.Streaming.StreamState)
GetPlaylistVideoCodecs(MediaBrowser.Controller.Streaming.StreamState,System.String,System.Int32)
GetBitrateVariation(System.Int32)
ReplacePlaylistCodecsField(System.Text.StringBuilder,System.Text.StringBuilder,System.Text.StringBuilder)