public IObservable <Packet> PacketReady() { return(packetReadySubject.AsObservable() .Select(packet => { if (packet == null) { return EOSPacket.Create(StreamType); } AdjustDemuxerTimeStampIfNeeded(packet); // Sometimes we can receive invalid timestamp from demuxer // eg during encrypted content seek or live video. // Adjust timestamps to avoid playback problems packet += demuxerClock; packet -= trimOffset.Value; if (packet.Pts < TimeSpan.Zero || packet.Dts < TimeSpan.Zero) { packet.Pts = TimeSpan.Zero; packet.Dts = TimeSpan.Zero; } Logger.Debug($"{StreamType} {packet.Pts}"); // Don't convert packet here, use assignment (less costly) lastPushedClock.SetClock(packet); return packet; }).Where(packet => PacketPredicate == null || PacketPredicate.Invoke(packet))); }
public IObservable <Packet> PacketReady() { return(demuxerController.PacketReady() .Do(packet => { if (packet == null) { return; } lastReceivedPts = packet.Pts; if (ShouldPauseDemuxer()) { demuxerController.Pause(); } }).SelectMany(packet => { if (packet != null) { return Observable.Return(packet); } // found empty packet which means EOS. We need to send two fake // eos packets, one for audio and one for video return Observable.Return(EOSPacket.Create(StreamType.Audio)) .Merge(Observable.Return(EOSPacket.Create(StreamType.Video))); })); }
public IObservable <Packet> PacketReady() { return(demuxerController.PacketReady() .SelectMany(packet => { if (packet != null) { return Observable.Return(packet); } // found empty packet which means EOS. We need to send two fake // eos packets, one for audio and one for video return Observable.Return(EOSPacket.Create(StreamType.Audio)) .Merge(Observable.Return(EOSPacket.Create(StreamType.Video))); })); }
public IObservable <Packet> PacketReady() { return(packetReadySubject.AsObservable() .Select(packet => packet == null ? EOSPacket.Create(StreamType) : packet) .Where(packet => PacketPredicate == null || PacketPredicate.Invoke(packet))); }