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); }
public bool Render() { if (reader == null) { throw new Exception("No reader pip!"); } if (demux == null) { throw new Exception("No demux pip!"); } if (videoDecoder == null && audioDecoder == null) { throw new Exception("No decoder pip!"); } reader.ConnectTo(demux); if (videoDecoder != null) { demux.ConnectTo(videoDecoder); if (videoRender != null) { videoDecoder.ConnectTo(videoRender); } } if (audioDecoder != null) { demux.ConnectTo(audioDecoder); if (audioRender != null) { audioDecoder.ConnectTo(audioRender); } } return(true); }