| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/android/media_codec_bridge.h" | 5 #include "media/base/android/media_codec_bridge.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 MediaCodecBridge::~MediaCodecBridge() { | 260 MediaCodecBridge::~MediaCodecBridge() { |
| 261 JNIEnv* env = AttachCurrentThread(); | 261 JNIEnv* env = AttachCurrentThread(); |
| 262 CHECK(env); | 262 CHECK(env); |
| 263 if (j_media_codec_.obj()) | 263 if (j_media_codec_.obj()) |
| 264 Java_MediaCodecBridge_release(env, j_media_codec_.obj()); | 264 Java_MediaCodecBridge_release(env, j_media_codec_.obj()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 bool MediaCodecBridge::StartInternal() { | 267 bool MediaCodecBridge::StartInternal() { |
| 268 JNIEnv* env = AttachCurrentThread(); | 268 JNIEnv* env = AttachCurrentThread(); |
| 269 return Java_MediaCodecBridge_start(env, j_media_codec_.obj()) && | 269 return Java_MediaCodecBridge_start(env, j_media_codec_.obj()); |
| 270 GetOutputBuffers(); | |
| 271 } | 270 } |
| 272 | 271 |
| 273 MediaCodecStatus MediaCodecBridge::Reset() { | 272 MediaCodecStatus MediaCodecBridge::Reset() { |
| 274 JNIEnv* env = AttachCurrentThread(); | 273 JNIEnv* env = AttachCurrentThread(); |
| 275 return static_cast<MediaCodecStatus>( | 274 return static_cast<MediaCodecStatus>( |
| 276 Java_MediaCodecBridge_flush(env, j_media_codec_.obj())); | 275 Java_MediaCodecBridge_flush(env, j_media_codec_.obj())); |
| 277 } | 276 } |
| 278 | 277 |
| 279 void MediaCodecBridge::Stop() { | 278 void MediaCodecBridge::Stop() { |
| 280 JNIEnv* env = AttachCurrentThread(); | 279 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 | 441 |
| 443 void MediaCodecBridge::ReleaseOutputBuffer(int index, bool render) { | 442 void MediaCodecBridge::ReleaseOutputBuffer(int index, bool render) { |
| 444 DVLOG(3) << __PRETTY_FUNCTION__ << ": " << index; | 443 DVLOG(3) << __PRETTY_FUNCTION__ << ": " << index; |
| 445 JNIEnv* env = AttachCurrentThread(); | 444 JNIEnv* env = AttachCurrentThread(); |
| 446 CHECK(env); | 445 CHECK(env); |
| 447 | 446 |
| 448 Java_MediaCodecBridge_releaseOutputBuffer( | 447 Java_MediaCodecBridge_releaseOutputBuffer( |
| 449 env, j_media_codec_.obj(), index, render); | 448 env, j_media_codec_.obj(), index, render); |
| 450 } | 449 } |
| 451 | 450 |
| 452 int MediaCodecBridge::GetInputBuffersCount() { | |
| 453 JNIEnv* env = AttachCurrentThread(); | |
| 454 return Java_MediaCodecBridge_getInputBuffersCount(env, j_media_codec_.obj()); | |
| 455 } | |
| 456 | |
| 457 int MediaCodecBridge::GetOutputBuffersCount() { | 451 int MediaCodecBridge::GetOutputBuffersCount() { |
| 458 JNIEnv* env = AttachCurrentThread(); | 452 JNIEnv* env = AttachCurrentThread(); |
| 459 return Java_MediaCodecBridge_getOutputBuffersCount(env, j_media_codec_.obj()); | 453 return Java_MediaCodecBridge_getOutputBuffersCount(env, j_media_codec_.obj()); |
| 460 } | 454 } |
| 461 | 455 |
| 462 size_t MediaCodecBridge::GetOutputBuffersCapacity() { | 456 size_t MediaCodecBridge::GetOutputBuffersCapacity() { |
| 463 JNIEnv* env = AttachCurrentThread(); | 457 JNIEnv* env = AttachCurrentThread(); |
| 464 return Java_MediaCodecBridge_getOutputBuffersCapacity(env, | 458 return Java_MediaCodecBridge_getOutputBuffersCapacity(env, |
| 465 j_media_codec_.obj()); | 459 j_media_codec_.obj()); |
| 466 } | 460 } |
| 467 | 461 |
| 468 bool MediaCodecBridge::GetOutputBuffers() { | |
| 469 JNIEnv* env = AttachCurrentThread(); | |
| 470 return Java_MediaCodecBridge_getOutputBuffers(env, j_media_codec_.obj()); | |
| 471 } | |
| 472 | |
| 473 void MediaCodecBridge::GetInputBuffer(int input_buffer_index, | 462 void MediaCodecBridge::GetInputBuffer(int input_buffer_index, |
| 474 uint8** data, | 463 uint8** data, |
| 475 size_t* capacity) { | 464 size_t* capacity) { |
| 476 JNIEnv* env = AttachCurrentThread(); | 465 JNIEnv* env = AttachCurrentThread(); |
| 477 ScopedJavaLocalRef<jobject> j_buffer(Java_MediaCodecBridge_getInputBuffer( | 466 ScopedJavaLocalRef<jobject> j_buffer(Java_MediaCodecBridge_getInputBuffer( |
| 478 env, j_media_codec_.obj(), input_buffer_index)); | 467 env, j_media_codec_.obj(), input_buffer_index)); |
| 479 *data = static_cast<uint8*>(env->GetDirectBufferAddress(j_buffer.obj())); | 468 *data = static_cast<uint8*>(env->GetDirectBufferAddress(j_buffer.obj())); |
| 480 *capacity = base::checked_cast<size_t>( | 469 *capacity = base::checked_cast<size_t>( |
| 481 env->GetDirectBufferCapacity(j_buffer.obj())); | 470 env->GetDirectBufferCapacity(j_buffer.obj())); |
| 482 } | 471 } |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 JNIEnv* env = AttachCurrentThread(); | 790 JNIEnv* env = AttachCurrentThread(); |
| 802 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( | 791 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( |
| 803 env, media_codec(), width, height); | 792 env, media_codec(), width, height); |
| 804 } | 793 } |
| 805 | 794 |
| 806 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { | 795 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { |
| 807 return RegisterNativesImpl(env); | 796 return RegisterNativesImpl(env); |
| 808 } | 797 } |
| 809 | 798 |
| 810 } // namespace media | 799 } // namespace media |
| OLD | NEW |