コード例 #1
0
        public void SendPacket_ThrowsOnSendPacketFail()
        {
            var ffmpegMock = new Mock <FFmpegClient>();

            ffmpegMock
            .Setup(c => c.IsCodecOpen(It.IsAny <IntPtr>()))
            .Returns(true)
            .Verifiable();

            ffmpegMock
            .Setup(c => c.IsDecoder(It.IsAny <IntPtr>()))
            .Returns(true)
            .Verifiable();

            ffmpegMock
            .Setup(c => c.SendPacket(It.IsAny <IntPtr>(), It.IsAny <IntPtr>()))
            .Returns(-100)
            .Verifiable();
            ffmpegMock
            .Setup(c => c.ThrowOnAVError(-100, true))
            .Verifiable();

            var ffmpeg = ffmpegMock.Object;

            var nativeCodec        = ffmpeg.FindDecoder(AVCodecID.AV_CODEC_ID_H264);
            var nativeCodecContext = new NativeAVCodecContext
            {
            };

            var codec = new AVCodec(ffmpeg, &nativeCodecContext, (NativeAVCodec *)nativeCodec);

            codec.SendPacket(new AVPacket(ffmpeg));
        }
コード例 #2
0
        public void SendPacket_ThrowsOnNoDecoder()
        {
            var ffmpegMock = new Mock <FFmpegClient>();

            ffmpegMock
            .Setup(c => c.IsCodecOpen(It.IsAny <IntPtr>()))
            .Returns(true)
            .Verifiable();

            ffmpegMock
            .Setup(c => c.IsDecoder(It.IsAny <IntPtr>()))
            .Returns(false)
            .Verifiable();

            ffmpegMock
            .Setup(c => c.SendPacket(It.IsAny <IntPtr>(), It.IsAny <IntPtr>()))
            .Returns(0)
            .Verifiable();

            var ffmpeg = ffmpegMock.Object;

            var nativeCodec        = ffmpeg.FindDecoder(AVCodecID.AV_CODEC_ID_H264);
            var nativeCodecContext = new NativeAVCodecContext
            {
            };

            var codec = new AVCodec(ffmpeg, &nativeCodecContext, (NativeAVCodec *)nativeCodec);

            Assert.Throws <InvalidOperationException>(() => codec.SendPacket(new AVPacket(ffmpeg)));
        }