Inheritance: BaseComponent, IPipe, IDecoder
Exemple #1
0
        private void RenderFile()
        {
            FFmpeg.AVFormatContext context = pFormatCtx.Handle;
            for (int index = 0; index < context.nb_streams; index++)
            {
                NativeWrapper<FFmpeg.AVStream> stream = new NativeWrapper<FFmpeg.AVStream>(context.streams[index]);
                NativeWrapper<FFmpeg.AVCodecContext> codec = new NativeWrapper<FFmpeg.AVCodecContext>(stream.Handle.codec);
                FFmpeg.AVCodecContext codecContext = codec.Handle;
                if (codecContext.codec_type == FFmpeg.CodecType.CODEC_TYPE_AUDIO)
                {
                    audioDecoder = new AvDecoder(stream, codec, index);
                }
                else if (codecContext.codec_type == FFmpeg.CodecType.CODEC_TYPE_VIDEO)
                {
                    videoDecoder = new AvDecoder(stream, codec, index);

                }
            }
            fileReader = new FileReader(pFormatCtx);
            demux = new Demux(pFormatCtx);
            audioRender = new AudioRender();
            videoRender = new VideoRender();

            //connect pipe
            fileReader.ConnectTo(demux);
            demux.ConnectTo(audioDecoder);
            demux.ConnectTo(videoDecoder);
            audioDecoder.ConnectTo(audioRender);
            videoDecoder.ConnectTo(videoRender);

        }
Exemple #2
0
 private void GeneratePipesFromFile(string fileName)
 {
     audioDecoder = new AvDecoder(AVFrameType.Audio);
     videoDecoder = new AvDecoder(AVFrameType.Video);
     reader       = new FileReader(ffmpegBase, fileName);
     demux        = new Demux();
 }
Exemple #3
0
        public bool OnReceiveData(object obj)
        {
            IAVFrame packet = (IAVFrame)obj;

            if (packet == null)
            {
                return(false);
            }
            IPipe pipe = null;

            lock (router)
            {
                if (router.ContainsKey(packet.FrameType))
                {
                    pipe = router[packet.FrameType];
                }
            }
            if (pipe == null)
            {
                List <IPipe> list = null;
                lock (nextComponents)
                {
                    list = new List <IPipe>(nextComponents);
                }
                foreach (IPipe p in list)
                {
                    AvDecoder decoder = p as AvDecoder;
                    if (decoder == null)
                    {
                        continue;
                    }
                    lock (router)
                    {
                        router.Add(decoder.FrameType, p);
                    }
                    if (decoder.FrameType == packet.FrameType)
                    {
                        pipe = p;
                    }
                }
            }
            if (pipe == null)
            {
                return(false);
            }
            RecordLog();
            pipe.OnReceiveData(obj);

            return(true);
        }
Exemple #4
0
 private void GeneratePipesFromFile(string fileName)
 {
     audioDecoder = new AvDecoder(AVFrameType.Audio);
     videoDecoder = new AvDecoder(AVFrameType.Video);
     reader = new FileReader(ffmpegBase, fileName);
     demux = new Demux();
 }