private async ValueTask StartTransfer(ESPlayer.StreamType stream, CancellationToken token) { logger.Info($"{stream}"); // Audio packet must be started after video packets. if (stream != ESPlayer.StreamType.Video) { return; } var videoPacketTask = esStreams[(int)StreamType.Video].PacketProcessed() .FirstAsync(pt => pt != typeof(BufferConfigurationPacket)) .ToTask(token); esStreams[(int)StreamType.Video].Start(token); try { logger.Info("Waiting for first video packet"); var firstPacketType = await videoPacketTask.ConfigureAwait(false); logger.Info($"First packet is {firstPacketType}"); if (firstPacketType == typeof(EOSPacket)) { logger.Info("Won't start audio"); return; } esStreams[(int)StreamType.Audio].Start(token); } catch (TaskCanceledException) { logger.Info("Operation cancelled"); } }
private async void OnReadyToSeekStream(ESPlayer.StreamType esPlayerStreamType, TimeSpan time) { logger.Info($"{esPlayerStreamType}: {time}"); OnReadyToStartStream(esPlayerStreamType); await Task.Yield(); }
/// <summary> /// ESPlayer event handler. Issued after calling AsyncPrepare. Stream type /// passed as an argument indicates stream for which data transfer has be started. /// This effectively starts playback. /// </summary> /// <param name="esPlayerStreamType">ESPlayer.StreamType</param> private async void OnReadyToStartStream(ESPlayer.StreamType esPlayerStreamType) { var streamType = esPlayerStreamType.JuvoStreamType(); logger.Info(streamType.ToString()); esStreams[(int)streamType].Start(); logger.Info($"{streamType}: Completed"); await Task.Yield(); }
internal static Common.StreamType JuvoStreamType(this StreamType esStreamType) { return(esStreamType == StreamType.Video ? Common.StreamType.Video : Common.StreamType.Audio); }
private void EnableTransfer(ESPlayer.StreamType stream) => EnableTransfer(stream.JuvoStreamType());
private void EnableTransfer(ESPlayer.StreamType stream, TimeSpan time) => EnableTransfer(stream.JuvoStreamType());
internal static Demuxer.Common.StreamType JuvoStreamType(this StreamType esStreamType) { return(esStreamType == StreamType.Video ? Demuxer.Common.StreamType.Video : Demuxer.Common.StreamType.Audio); }