| 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/sdk_media_codec_bridge.h" | 5 #include "media/base/android/sdk_media_codec_bridge.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 return MEDIA_CODEC_ERROR; | 327 return MEDIA_CODEC_ERROR; |
| 328 const size_t total_capacity = env->GetDirectBufferCapacity(j_buffer.obj()); | 328 const size_t total_capacity = env->GetDirectBufferCapacity(j_buffer.obj()); |
| 329 CHECK_GE(total_capacity, offset); | 329 CHECK_GE(total_capacity, offset); |
| 330 *addr = reinterpret_cast<const uint8_t*>( | 330 *addr = reinterpret_cast<const uint8_t*>( |
| 331 env->GetDirectBufferAddress(j_buffer.obj())) + | 331 env->GetDirectBufferAddress(j_buffer.obj())) + |
| 332 offset; | 332 offset; |
| 333 *capacity = total_capacity - offset; | 333 *capacity = total_capacity - offset; |
| 334 return MEDIA_CODEC_OK; | 334 return MEDIA_CODEC_OK; |
| 335 } | 335 } |
| 336 | 336 |
| 337 std::string SdkMediaCodecBridge::GetName() { |
| 338 if (base::android::BuildInfo::GetInstance()->sdk_int() < 18) |
| 339 return ""; |
| 340 JNIEnv* env = AttachCurrentThread(); |
| 341 ScopedJavaLocalRef<jstring> j_name = |
| 342 Java_MediaCodecBridge_getName(env, j_media_codec_.obj()); |
| 343 return ConvertJavaStringToUTF8(env, j_name.obj()); |
| 344 } |
| 345 |
| 337 // static | 346 // static |
| 338 bool SdkMediaCodecBridge::RegisterSdkMediaCodecBridge(JNIEnv* env) { | 347 bool SdkMediaCodecBridge::RegisterSdkMediaCodecBridge(JNIEnv* env) { |
| 339 return RegisterNativesImpl(env); | 348 return RegisterNativesImpl(env); |
| 340 } | 349 } |
| 341 | 350 |
| 342 // static | 351 // static |
| 343 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { | 352 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { |
| 344 if (!MediaCodecUtil::IsMediaCodecAvailable()) | 353 if (!MediaCodecUtil::IsMediaCodecAvailable()) |
| 345 return nullptr; | 354 return nullptr; |
| 346 | 355 |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 if (adaptive_playback_supported_for_testing_ == 0) | 709 if (adaptive_playback_supported_for_testing_ == 0) |
| 701 return false; | 710 return false; |
| 702 else if (adaptive_playback_supported_for_testing_ > 0) | 711 else if (adaptive_playback_supported_for_testing_ > 0) |
| 703 return true; | 712 return true; |
| 704 JNIEnv* env = AttachCurrentThread(); | 713 JNIEnv* env = AttachCurrentThread(); |
| 705 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), | 714 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), |
| 706 width, height); | 715 width, height); |
| 707 } | 716 } |
| 708 | 717 |
| 709 } // namespace media | 718 } // namespace media |
| OLD | NEW |