Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Unified Diff: media/base/android/java/src/org/chromium/media/MediaCodecBridge.java

Issue 669623004: Switch to Lollipop APIs for MediaCodec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
index 11cff4baf9cb6e8bc28fc97b11f84b5b1994bbf5..ebfa5925c5df334d34fc9bcb92d2efda46fa139b 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java
@@ -351,7 +351,10 @@ class MediaCodecBridge {
private boolean start() {
try {
mMediaCodec.start();
- mInputBuffers = mMediaCodec.getInputBuffers();
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
+ mInputBuffers = mMediaCodec.getInputBuffers();
+ mOutputBuffers = mMediaCodec.getOutputBuffers();
+ }
} catch (IllegalStateException e) {
Log.e(TAG, "Cannot start the media codec", e);
return false;
@@ -429,20 +432,21 @@ class MediaCodecBridge {
@CalledByNative
private ByteBuffer getInputBuffer(int index) {
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
+ return mMediaCodec.getInputBuffer(index);
+ }
return mInputBuffers[index];
}
@CalledByNative
private ByteBuffer getOutputBuffer(int index) {
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
+ return mMediaCodec.getOutputBuffer(index);
+ }
return mOutputBuffers[index];
}
@CalledByNative
- private int getInputBuffersCount() {
- return mInputBuffers.length;
- }
-
- @CalledByNative
private int getOutputBuffersCount() {
return mOutputBuffers != null ? mOutputBuffers.length : -1;
}
@@ -452,23 +456,14 @@ class MediaCodecBridge {
return mOutputBuffers != null ? mOutputBuffers[0].capacity() : -1;
}
- @SuppressWarnings("deprecation")
- @CalledByNative
- private boolean getOutputBuffers() {
- try {
- mOutputBuffers = mMediaCodec.getOutputBuffers();
- } catch (IllegalStateException e) {
- Log.e(TAG, "Cannot get output buffers", e);
- return false;
- }
- return true;
- }
-
@CalledByNative
private int queueInputBuffer(
int index, int offset, int size, long presentationTimeUs, int flags) {
resetLastPresentationTimeIfNeeded(presentationTimeUs);
try {
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
+ mMediaCodec.getInputBuffer(index);
+ }
mMediaCodec.queueInputBuffer(index, offset, size, presentationTimeUs, flags);
} catch (Exception e) {
Log.e(TAG, "Failed to queue input buffer", e);
@@ -519,6 +514,9 @@ class MediaCodecBridge {
@CalledByNative
private void releaseOutputBuffer(int index, boolean render) {
try {
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
+ mMediaCodec.getOutputBuffer(index);
+ }
mMediaCodec.releaseOutputBuffer(index, render);
} catch (IllegalStateException e) {
// TODO(qinmin): May need to report the error to the caller. crbug.com/356498.
@@ -546,6 +544,7 @@ class MediaCodecBridge {
status = MEDIA_CODEC_OK;
index = indexOrStatus;
} else if (indexOrStatus == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
+ mOutputBuffers = mMediaCodec.getOutputBuffers();
status = MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED;
} else if (indexOrStatus == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
status = MEDIA_CODEC_OUTPUT_FORMAT_CHANGED;
« no previous file with comments | « content/common/gpu/media/android_video_encode_accelerator.cc ('k') | media/base/android/media_codec_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698