CopyDataCommandHandler implements ICommandHandler { @Override public void handle() { Frame encoderFrame = input.findFreeFrame(); if (encoderFrame == null) { restoreCommands(); return; } Frame decoderFrame = output.getFrame(); if (decoderFrame == null) return; encoderFrame.copyDataFrom(decoderFrame); input.push(encoderFrame); output.releaseOutputBuffer(decoderFrame.getBufferIndex()); } CopyDataCommandHandler(IPluginOutput output, MediaCodecPlugin input); @Override void handle();  }
@Test public void dequeueAndQueueInputBuffers() { new CopyDataCommandHandler(decoder, encoder).handle(); verify(mediaCodec, atLeastOnce()).dequeueInputBuffer(anyLong()); verify(mediaCodec).queueInputBuffer(eq(0), anyInt(), anyInt(), anyLong(), anyInt()); }
@Test public void handleEof() { decoder = create.videoDecoder().whichDecodesTo(Frame.EOF()).construct(); decoder.push(Frame.EOF()); decoder.start(); new CopyDataCommandHandler(decoder, encoder).handle(); verify(mediaCodec).queueInputBuffer(anyInt(), anyInt(), anyInt(), anyLong(), eq(IMediaCodec.BUFFER_FLAG_END_OF_STREAM)); }