예제 #1
0
        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)));
        }
예제 #2
0
 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)));
     }));
 }
예제 #3
0
 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)));
     }));
 }
예제 #4
0
 public IObservable <Packet> PacketReady()
 {
     return(packetReadySubject.AsObservable()
            .Select(packet => packet == null ? EOSPacket.Create(StreamType) : packet)
            .Where(packet => PacketPredicate == null || PacketPredicate.Invoke(packet)));
 }