/// <summary>Create sample reader and enqueue initial batch of NALUs, starting from SPS and PPS.</summary> /// <remarks>This enqueues all buffers in the queue.</remarks> public iVideoTrackReader enqueueInitial(iVideoTrack track) { iVideoTrackReader reader = track.createReader(this); // Enqueue moar NALUs from the video to saturate the encoded buffers while (true) { var b = nextEnqueue; if (null != b) { var act = reader.writeNextNalu(b); if (act == eNaluAction.EOF) { throw new EndOfStreamException("Too few samples in the video"); } if (act == eNaluAction.Decode) { enqueue(b); } } else { return(reader); } } }
public void startDecoder(iMediaFile media, Audio.iDecoderQueues audioQueues) { iVideoTrackReader reader = encoded.enqueueInitial(media.videoTrack); var audioReader = media.audioTrack.createReader(); // Launch the thread m_thread = new DecoderThread(device, reader, encoded, decoded, shutdownHandle, this, audioReader, audioQueues); }
public DecoderThread(VideoDevice device, iVideoTrackReader reader, EncodedQueue encoded, DecodedQueue decoded, int shutdownEvent, iDecoderEvents eventsSink, iAudioTrackReader audioReader, Audio.iDecoderQueues audioQueue) { this.device = device; this.reader = reader; this.encoded = encoded; this.decoded = decoded; this.shutdownEvent = shutdownEvent; this.audioReader = audioReader; this.audioQueue = audioQueue; // Enqueue decoded buffers decoded.enqueueAll(); this.eventsSink = eventsSink; seekEventHandle = EventHandle.create(); // Remaining work is done in the thread thread = new Thread(threadMain); thread.IsBackground = true; thread.Name = "Media player thread"; Logger.logInfo("Launching the video decoding thread"); thread.Start(); }