Пример #1
0
        /// <summary>
        /// Gets a formatted string of the output video codec, for use in the CODECS field.
        /// </summary>
        /// <seealso cref="AppendPlaylistCodecsField(StringBuilder, StreamState)"/>
        /// <seealso cref="GetPlaylistAudioCodecs(StreamState)"/>
        /// <param name="state">StreamState of the current stream.</param>
        /// <returns>Formatted video codec string.</returns>
        private string GetPlaylistVideoCodecs(StreamState state, string codec, int level)
        {
            if (level == 0)
            {
                // This is 0 when there's no requested H.26X level in the device profile
                // and the source is not encoded in H.26X
                Logger.LogError("Got invalid H.26X level when building CODECS field for HLS master playlist");
                return(string.Empty);
            }

            if (string.Equals(codec, "h264", StringComparison.OrdinalIgnoreCase))
            {
                string profile = state.GetRequestedProfiles("h264").FirstOrDefault();

                return(HlsCodecStringFactory.GetH264String(profile, level));
            }
            else if (string.Equals(codec, "h265", StringComparison.OrdinalIgnoreCase) ||
                     string.Equals(codec, "hevc", StringComparison.OrdinalIgnoreCase))
            {
                string profile = state.GetRequestedProfiles("h265").FirstOrDefault();

                return(HlsCodecStringFactory.GetH265String(profile, level));
            }

            return(string.Empty);
        }
Пример #2
0
        /// <summary>
        /// Gets a formatted string of the output audio codec, for use in the CODECS field.
        /// </summary>
        /// <seealso cref="AppendPlaylistCodecsField(StringBuilder, StreamState)"/>
        /// <seealso cref="GetPlaylistVideoCodecs(StreamState, string, int)"/>
        /// <param name="state">StreamState of the current stream.</param>
        /// <returns>Formatted audio codec string.</returns>
        private string GetPlaylistAudioCodecs(StreamState state)
        {
            if (string.Equals(state.ActualOutputAudioCodec, "aac", StringComparison.OrdinalIgnoreCase))
            {
                string?profile = state.GetRequestedProfiles("aac").FirstOrDefault();
                return(HlsCodecStringHelpers.GetAACString(profile));
            }

            if (string.Equals(state.ActualOutputAudioCodec, "mp3", StringComparison.OrdinalIgnoreCase))
            {
                return(HlsCodecStringHelpers.GetMP3String());
            }

            if (string.Equals(state.ActualOutputAudioCodec, "ac3", StringComparison.OrdinalIgnoreCase))
            {
                return(HlsCodecStringHelpers.GetAC3String());
            }

            if (string.Equals(state.ActualOutputAudioCodec, "eac3", StringComparison.OrdinalIgnoreCase))
            {
                return(HlsCodecStringHelpers.GetEAC3String());
            }

            if (string.Equals(state.ActualOutputAudioCodec, "flac", StringComparison.OrdinalIgnoreCase))
            {
                return(HlsCodecStringHelpers.GetFLACString());
            }

            if (string.Equals(state.ActualOutputAudioCodec, "alac", StringComparison.OrdinalIgnoreCase))
            {
                return(HlsCodecStringHelpers.GetALACString());
            }

            return(string.Empty);
        }
Пример #3
0
        /// <summary>
        /// Get the H.26X profile of the output video stream.
        /// </summary>
        /// <param name="state">StreamState of the current stream.</param>
        /// <param name="codec">Video codec.</param>
        /// <returns>H.26X profile of the output video stream.</returns>
        private string GetOutputVideoCodecProfile(StreamState state, string codec)
        {
            string profileString = string.Empty;

            if (EncodingHelper.IsCopyCodec(state.OutputVideoCodec) &&
                !string.IsNullOrEmpty(state.VideoStream.Profile))
            {
                profileString = state.VideoStream.Profile;
            }
            else if (!string.IsNullOrEmpty(codec))
            {
                profileString = state.GetRequestedProfiles(codec).FirstOrDefault() ?? string.Empty;
                if (string.Equals(state.ActualOutputVideoCodec, "h264", StringComparison.OrdinalIgnoreCase))
                {
                    profileString ??= "high";
                }

                if (string.Equals(state.ActualOutputVideoCodec, "h265", StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(state.ActualOutputVideoCodec, "hevc", StringComparison.OrdinalIgnoreCase))
                {
                    profileString ??= "main";
                }
            }

            return(profileString);
        }