| Index: media/base/android/sdk_media_codec_bridge.cc
|
| diff --git a/media/base/android/sdk_media_codec_bridge.cc b/media/base/android/sdk_media_codec_bridge.cc
|
| index 6a04a34eceaf8b428c39dbe7c792a782893ba900..5dd7d539244b68046f5dd14085592e9d764d8682 100644
|
| --- a/media/base/android/sdk_media_codec_bridge.cc
|
| +++ b/media/base/android/sdk_media_codec_bridge.cc
|
| @@ -314,11 +314,25 @@
|
| return MEDIA_CODEC_OK;
|
| }
|
|
|
| -MediaCodecStatus SdkMediaCodecBridge::GetOutputBufferAddress(
|
| - int index,
|
| - size_t offset,
|
| - const uint8_t** addr,
|
| - size_t* capacity) {
|
| +MediaCodecStatus SdkMediaCodecBridge::CopyFromOutputBuffer(int index,
|
| + size_t offset,
|
| + void* dst,
|
| + size_t num) {
|
| + void* src_data = nullptr;
|
| + size_t src_capacity = 0;
|
| + MediaCodecStatus status =
|
| + GetOutputBufferAddress(index, offset, &src_data, &src_capacity);
|
| + if (status == MEDIA_CODEC_OK) {
|
| + CHECK_GE(src_capacity, num);
|
| + memcpy(dst, src_data, num);
|
| + }
|
| + return status;
|
| +}
|
| +
|
| +MediaCodecStatus SdkMediaCodecBridge::GetOutputBufferAddress(int index,
|
| + size_t offset,
|
| + void** addr,
|
| + size_t* capacity) {
|
| JNIEnv* env = AttachCurrentThread();
|
| ScopedJavaLocalRef<jobject> j_buffer(
|
| Java_MediaCodecBridge_getOutputBuffer(env, j_media_codec_.obj(), index));
|
| @@ -326,9 +340,9 @@
|
| return MEDIA_CODEC_ERROR;
|
| const size_t total_capacity = env->GetDirectBufferCapacity(j_buffer.obj());
|
| CHECK_GE(total_capacity, offset);
|
| - *addr = reinterpret_cast<const uint8_t*>(
|
| - env->GetDirectBufferAddress(j_buffer.obj())) +
|
| - offset;
|
| + *addr =
|
| + reinterpret_cast<uint8_t*>(env->GetDirectBufferAddress(j_buffer.obj())) +
|
| + offset;
|
| *capacity = total_capacity - offset;
|
| return MEDIA_CODEC_OK;
|
| }
|
| @@ -565,7 +579,7 @@
|
| DCHECK_LE(0, index);
|
| int numBytes = base::checked_cast<int>(size);
|
|
|
| - const uint8_t* buffer = nullptr;
|
| + void* buffer = nullptr;
|
| size_t capacity = 0;
|
| MediaCodecStatus status =
|
| GetOutputBufferAddress(index, offset, &buffer, &capacity);
|
| @@ -576,8 +590,8 @@
|
| CHECK_GE(numBytes, 0);
|
|
|
| JNIEnv* env = AttachCurrentThread();
|
| - ScopedJavaLocalRef<jbyteArray> byte_array =
|
| - base::android::ToJavaByteArray(env, buffer, numBytes);
|
| + ScopedJavaLocalRef<jbyteArray> byte_array = base::android::ToJavaByteArray(
|
| + env, static_cast<uint8_t*>(buffer), numBytes);
|
| *playback_pos = Java_MediaCodecBridge_playOutputBuffer(
|
| env, media_codec(), byte_array.obj(), postpone);
|
| return status;
|
|
|