VideoEncoder extends Encoder implements ITransform { @Override public void setMediaFormat(MediaFormat inputMediaFormat) { this.mediaFormat = inputMediaFormat; getVideoFormat().setColorFormat(MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface); } VideoEncoder(IMediaCodec mediaCodec); @Override void setMediaFormat(MediaFormat inputMediaFormat); void setBitRateInKBytes(int bitRate); int getBitRateInKBytes(); void setFrameRate(int frameRate); int getFrameRate(); void setIFrameInterval(int iFrameInterval); int getIFrameInterval(); @Override boolean isLastFile(); @Override void setOutputSurface(ISurface surface); @Override void waitForSurface(long pts); @Override void drain(int bufferIndex); @Override void push(Frame frame); @Override void notifySurfaceReady(ISurface surface); @Override void releaseOutputBuffer(int outputBufferIndex);  }
@Test public void canConfigure() { IMediaCodec mediaCodec = create.mediaCodec().construct(); VideoFormat videoFormat = create.videoFormat() .withFrameSize(1024, 768) .withBitRate(100) .withFrameRate(10) .withIFrameInterval(1) .construct(); MediaCodecInfo.CodecCapabilities codecCapabilities = new MediaCodecInfo.CodecCapabilities(); videoFormat.setColorFormat(codecCapabilities.COLOR_FormatSurface); VideoEncoder encoder = new VideoEncoder(mediaCodec); encoder.setMediaFormat(videoFormat); encoder.configure(); ArgumentCaptor<VideoFormat> actualVideoFormat = ArgumentCaptor.forClass(VideoFormat.class); verify(mediaCodec).configure(actualVideoFormat.capture(), any(ISurfaceWrapper.class), anyInt()); assertEquals(100, actualVideoFormat.getValue().getVideoBitRateInKBytes()); assertEquals(10, actualVideoFormat.getValue().getVideoFrameRate()); assertEquals(1, actualVideoFormat.getValue().getVideoIFrameInterval()); assertEquals(2130708361, actualVideoFormat.getValue().getInteger("color-format")); }