internal static VideoStreamInfo ESVideoStreamInfo(this Common.StreamConfig streamConfig) { if (!(streamConfig is Common.VideoStreamConfig)) { throw new ArgumentException("StreamConfig is not of VideoStreamConfig Type"); } var videoConfig = (Common.VideoStreamConfig)streamConfig; // Sort configuration by FPS (lowest first) & get an entry matching codec & FPS var fpsOrderedConfigs = VideoConfigurations.OrderBy(entry => entry.Fps); var configParameters = fpsOrderedConfigs.FirstOrDefault(entry => videoConfig.Codec == entry.Codec && entry.Fps >= videoConfig.FrameRate) ?? fpsOrderedConfigs.LastOrDefault(entry => videoConfig.Codec == entry.Codec); if (configParameters == null) { throw new UnsupportedStreamException($"Unsupported codec {videoConfig.Codec}"); } return(new VideoStreamInfo { codecData = videoConfig.CodecExtraData, mimeType = EsPlayerUtils.GetCodecMimeType(videoConfig.Codec), width = videoConfig.Size.Width, maxWidth = configParameters.Width, height = videoConfig.Size.Height, maxHeight = configParameters.Height, num = videoConfig.FrameRateNum, den = videoConfig.FrameRateDen }); }
internal static ESPlayer.AudioStreamInfo ESAudioStreamInfo(this Common.StreamConfig streamConfig) { if (!(streamConfig is Common.AudioStreamConfig)) throw new ArgumentException("StreamConfig is not of AudioStreamConfig Type"); var audioConfig = (Common.AudioStreamConfig)streamConfig; return new ESPlayer.AudioStreamInfo { codecData = audioConfig.CodecExtraData, mimeType = EsPlayerUtils.GetCodecMimeType(audioConfig.Codec), sampleRate = audioConfig.SampleRate, channels = audioConfig.ChannelLayout }; }