private bool AddTsPacket(TsPacket ts) { if (ts.PID != PID.H264Video) { CheckCustomPIDs(ts); // reclaim buffer bufferPool.Push(ts); return(true);//not video, so ignore it for now, it is a valid packet. } //if (pes == null && ts.IsPayloadUnitStart) // pes = new MpegTS.PacketizedElementaryStream(ts); if (ts.IsPayloadUnitStart && pes != null) { //let's take care of the old (complete) one now: push out buffers //TODO: provide the time stamp/PES with this buffer, or, just provide the //PES? if (pes.IsValid && pes.IsComplete) { //lock (outBuffers) { outBuffers.Enqueue(pes); //SampleCount = outBuffers.Count; } long pts = 0; if (pes.HasPts) { pts = pes.PTS; } OnSampleReady(SampleCount, pts); ++good; } else { ++bad; } pes = new MpegTS.PacketizedElementaryStream(this, ts); //we have the new pes } else if (pes != null) //we have already found the beginning of the stream and are building a pes { pes.Add(ts); } else//looking for a start packet { pes = new PacketizedElementaryStream(this, ts);// } return(true); }
public PacketizedElementaryStream DequeueNextPacket() { PacketizedElementaryStream pes = null; lock (outBuffers) { if (outBuffers.Count > 0) { pes = outBuffers.Dequeue(); SampleCount = outBuffers.Count; } } return(pes); }
private bool AddTsPacket(TsPacket ts) { if (ts.PID != PID.H264Video) { CheckCustomPIDs(ts); return true;//not video, so ignore it for now, it is a valid packet. } //if (pes == null && ts.IsPayloadUnitStart) // pes = new MpegTS.PacketizedElementaryStream(ts); if (ts.IsPayloadUnitStart && pes != null) { //let's take care of the old (complete) one now: push out buffers //TODO: provide the time stamp/PES with this buffer, or, just provide the //PES? if (pes.IsValid && pes.IsComplete) { lock (outBuffers) { outBuffers.Enqueue(pes); SampleCount = outBuffers.Count; } long pts = 0; if (pes.HasPts) pts = pes.PTS; OnSampleReady(SampleCount, pts); ++good; } else ++bad; pes = new MpegTS.PacketizedElementaryStream(ts);//we have the new pes } else if (pes != null)//we have already found the beginning of the stream and are building a pes { pes.Add(ts); } else//looking for a start packet pes = new PacketizedElementaryStream(ts);// return true; }
public PacketizedElementaryStream DequeueNextPacket() { PacketizedElementaryStream pes = null; lock (outBuffers) { if (outBuffers.Count > 0) { pes = outBuffers.Dequeue(); SampleCount = outBuffers.Count; } } return pes; }