Exemplo n.º 1
0
        public void Dispose()
        {
            eventSubscription?.Dispose();

            // dbgSaveTga?.Dispose();
            decoded?.Dispose();
            decoded = null;

            encoded?.Dispose();
            encoded = null;
        }
Exemplo n.º 2
0
        public void initialize(iVideoTrack videoTrack, int encodedBuffersCount)
        {
            // dbgPrintEncodedFormats();

            // Determine format of the encoded video
            sPixelFormatMP encodedFormat = videoTrack.getEncodedFormat();

            // Set format of the first and the only plane of the compressed video.
            encodedFormat.numPlanes = 1;
            encodedFormat.setPlaneFormat(0, new sPlanePixelFormat()
            {
                sizeImage = EncodedQueue.encodedVideoBufferSize(videoTrack)
            });

            // 4.5.1.5. Initialization

            // 1. Set the coded format on OUTPUT via VIDIOC_S_FMT()
            sStreamDataFormat sdf = new sStreamDataFormat()
            {
                bufferType = eBufferType.VideoOutputMPlane,
                pix_mp     = encodedFormat
            };

            device.file.call(eControlCode.S_FMT, ref sdf);

            // Logger.logVerbose( "eControlCode.S_FMT completed OK for encoded format: {0}", sdf.pix_mp );

            // 2 Allocate source (bytestream) buffers via VIDIOC_REQBUFS() on OUTPUT
            encoded = new EncodedQueue(device, encodedBuffersCount, ref encodedFormat);

            // 3 Start streaming on the OUTPUT queue via VIDIOC_STREAMON()
            device.startStreaming(eBufferType.VideoOutputMPlane);

            // Continue queuing/dequeuing bytestream buffers to/from the OUTPUT queue via VIDIOC_QBUF() and VIDIOC_DQBUF().
            // The buffers will be processed and returned to the client in order, until required metadata to configure the CAPTURE queue are found.
            // This is indicated by the decoder sending a V4L2_EVENT_SOURCE_CHANGE event with changes set to V4L2_EVENT_SRC_CH_RESOLUTION.
            eventSubscription = new EventSubscription(device);

            // Linux kernel on Pi4 appears to be too old and does not implement that spec. The event never arrives, while the encoded buffers are stuck in the Queued state.
            // For this reason, we have to deal with dynamic resolution changes instead :-(
            // WaitForResolution.wait( device, encoded, reader, waitForResolutionTimeout );
        }
Exemplo n.º 3
0
        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();
        }