예제 #1
0
        private void ClearProgram(TsProgramMapTable.ProgramMap program)
        {
            this._decoder.UnregisterHandler(program.Pid);
            TsPacketizedElementaryStream elementaryStream = program.Stream;

            if (null != elementaryStream)
            {
                elementaryStream.Clear();
            }
            Debug.Assert(this._programStreamMap.Remove(program.Pid));
        }
예제 #2
0
        TsPacketizedElementaryStream CreatePacketizedElementaryStream(TsStreamType streamType, uint pid, IMediaStreamMetadata mediaStreamMetadata)
        {
            var streamBuffer = _bufferingManager.CreateStreamBuffer(streamType);

            MediaStream mediaStream = null;

            var pesStreamHandler = _pesHandlers.GetPesHandler(streamType, pid, mediaStreamMetadata, packet =>
            {
                // ReSharper disable AccessToModifiedClosure
                if (null != mediaStream)
                    mediaStream.EnqueuePacket(packet);
                else if (null != packet)
                    _tsPesPacketPool.FreePesPacket(packet);
                // ReSharper restore AccessToModifiedClosure
            });

            var pes = new TsPacketizedElementaryStream(_bufferPool, _tsPesPacketPool, pesStreamHandler.PacketHandler, streamType, pid);

            var configurator = pesStreamHandler.Configurator;

            if (null != configurator)
            {
                EventHandler configuratorOnConfigurationComplete = null;

                configuratorOnConfigurationComplete = (o, e) =>
                {
                    configurator.ConfigurationComplete -= configuratorOnConfigurationComplete;

                    CheckConfigurationComplete();
                };

                configurator.ConfigurationComplete += configuratorOnConfigurationComplete;
            }

            mediaStream = new MediaStream(configurator, streamBuffer, _tsPesPacketPool.FreePesPacket);

            AddMediaStream(mediaStream);

            _tsTimemestamp.RegisterMediaStream(mediaStream, pesStreamHandler.GetDuration);

            if (null == configurator)
                CheckConfigurationComplete();

            return pes;
        }