1 /* 2 * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 package org.webrtc; 12 13 import android.media.MediaCodec; 14 import android.media.MediaCrypto; 15 import android.media.MediaFormat; 16 import android.os.Bundle; 17 import android.view.Surface; 18 import java.nio.ByteBuffer; 19 20 /** 21 * Subset of methods defined in {@link android.media.MediaCodec} needed by 22 * {@link HardwareVideoEncoder} and {@link AndroidVideoDecoder}. This interface 23 * exists to allow mocking and using a fake implementation in tests. 24 */ 25 interface MediaCodecWrapper { configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags)26 void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags); 27 start()28 void start(); 29 flush()30 void flush(); 31 stop()32 void stop(); 33 release()34 void release(); 35 dequeueInputBuffer(long timeoutUs)36 int dequeueInputBuffer(long timeoutUs); 37 queueInputBuffer(int index, int offset, int size, long presentationTimeUs, int flags)38 void queueInputBuffer(int index, int offset, int size, long presentationTimeUs, int flags); 39 dequeueOutputBuffer(MediaCodec.BufferInfo info, long timeoutUs)40 int dequeueOutputBuffer(MediaCodec.BufferInfo info, long timeoutUs); 41 releaseOutputBuffer(int index, boolean render)42 void releaseOutputBuffer(int index, boolean render); 43 getOutputFormat()44 MediaFormat getOutputFormat(); 45 getInputBuffers()46 ByteBuffer[] getInputBuffers(); 47 getOutputBuffers()48 ByteBuffer[] getOutputBuffers(); 49 createInputSurface()50 Surface createInputSurface(); 51 setParameters(Bundle params)52 void setParameters(Bundle params); 53 } 54