use of android.media.MediaCodec.CodecException in project robolectric by robolectric.
the class ShadowMediaCodecTest method inSyncMode_afterFlushCannotQueueInputBufferThatIsNotDequeued.
@Test
public void inSyncMode_afterFlushCannotQueueInputBufferThatIsNotDequeued() throws IOException {
MediaCodec codec = createSyncEncoder();
int inputIndex = codec.dequeueInputBuffer(/* timeoutUs= */
0);
codec.getInputBuffer(inputIndex).put(generateByteArray(/* size= */
128));
codec.flush();
try {
codec.queueInputBuffer(inputIndex, /* offset= */
0, /* size= */
128, /* presentationTimeUs= */
0, /* flags= */
0);
fail();
} catch (CodecException expected) {
}
}
use of android.media.MediaCodec.CodecException in project robolectric by robolectric.
the class ShadowMediaCodecTest method queueInputBuffer_withInvalidIndex_throws.
@Test
public void queueInputBuffer_withInvalidIndex_throws() throws IOException {
List<Integer> inputBuffers = new ArrayList<>();
MediaCodecCallback callback = new MediaCodecCallback() {
@Override
public void onInputBufferAvailable(MediaCodec codec, int inputBufferId) {
inputBuffers.add(inputBufferId);
}
};
MediaCodec codec = createAsyncEncoder(callback);
int invalidInputIndex = inputBuffers.isEmpty() ? 0 : max(inputBuffers) + 1;
try {
codec.queueInputBuffer(invalidInputIndex, /* offset= */
0, /* size= */
128, /* presentationTimeUs= */
0, /* flags= */
0);
fail();
} catch (CodecException expected) {
}
}
use of android.media.MediaCodec.CodecException in project robolectric by robolectric.
the class ShadowMediaCodecTest method inSyncMode_queueInputBufferTwice_throws.
@Test
public void inSyncMode_queueInputBufferTwice_throws() throws IOException {
MediaCodec codec = createSyncEncoder();
int inputIndex = codec.dequeueInputBuffer(/* timeoutUs= */
0);
codec.getInputBuffer(inputIndex).put(generateByteArray(/* size= */
128));
codec.queueInputBuffer(inputIndex, /* offset= */
0, /* size= */
128, /* presentationTimeUs= */
0, /* flags= */
0);
try {
codec.queueInputBuffer(inputIndex, /* offset= */
0, /* size= */
128, /* presentationTimeUs= */
0, /* flags= */
0);
fail();
} catch (CodecException expected) {
}
}
use of android.media.MediaCodec.CodecException in project robolectric by robolectric.
the class ShadowMediaCodecTest method inSyncMode_queueingInputBufferWithoutDequeue_throws.
@Test
public void inSyncMode_queueingInputBufferWithoutDequeue_throws() throws IOException {
MediaCodec codec = createSyncEncoder();
try {
codec.queueInputBuffer(/* index= */
0, /* offset= */
0, /* size= */
0, /* presentationTimeUs= */
0, /* flags= */
0);
fail();
} catch (CodecException expected) {
}
}
Aggregations