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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 break; | 697 break; |
698 } | 698 } |
699 default: | 699 default: |
700 LOG(ERROR) << "Invalid header encountered for codec: " | 700 LOG(ERROR) << "Invalid header encountered for codec: " |
701 << AudioCodecToAndroidMimeType(codec); | 701 << AudioCodecToAndroidMimeType(codec); |
702 return false; | 702 return false; |
703 } | 703 } |
704 return true; | 704 return true; |
705 } | 705 } |
706 | 706 |
707 int64 AudioCodecBridge::PlayOutputBuffer( | 707 int64 AudioCodecBridge::PlayOutputBuffer(int index, |
708 int index, size_t size, size_t offset) { | 708 size_t size, |
| 709 size_t offset, |
| 710 bool postpone) { |
709 DCHECK_LE(0, index); | 711 DCHECK_LE(0, index); |
710 int numBytes = base::checked_cast<int>(size); | 712 int numBytes = base::checked_cast<int>(size); |
711 | 713 |
712 void* buffer = nullptr; | 714 void* buffer = nullptr; |
713 int capacity = GetOutputBufferAddress(index, offset, &buffer); | 715 int capacity = GetOutputBufferAddress(index, offset, &buffer); |
714 numBytes = std::min(capacity, numBytes); | 716 numBytes = std::min(capacity, numBytes); |
715 CHECK_GE(numBytes, 0); | 717 CHECK_GE(numBytes, 0); |
716 | 718 |
717 JNIEnv* env = AttachCurrentThread(); | 719 JNIEnv* env = AttachCurrentThread(); |
718 ScopedJavaLocalRef<jbyteArray> byte_array = base::android::ToJavaByteArray( | 720 ScopedJavaLocalRef<jbyteArray> byte_array = base::android::ToJavaByteArray( |
719 env, static_cast<uint8*>(buffer), numBytes); | 721 env, static_cast<uint8*>(buffer), numBytes); |
720 return Java_MediaCodecBridge_playOutputBuffer( | 722 return Java_MediaCodecBridge_playOutputBuffer(env, media_codec(), |
721 env, media_codec(), byte_array.obj()); | 723 byte_array.obj(), postpone); |
722 } | 724 } |
723 | 725 |
724 void AudioCodecBridge::SetVolume(double volume) { | 726 void AudioCodecBridge::SetVolume(double volume) { |
725 JNIEnv* env = AttachCurrentThread(); | 727 JNIEnv* env = AttachCurrentThread(); |
726 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); | 728 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); |
727 } | 729 } |
728 | 730 |
729 // static | 731 // static |
730 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { | 732 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { |
731 if (!MediaCodecBridge::IsAvailable()) | 733 if (!MediaCodecBridge::IsAvailable()) |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 JNIEnv* env = AttachCurrentThread(); | 853 JNIEnv* env = AttachCurrentThread(); |
852 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( | 854 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( |
853 env, media_codec(), width, height); | 855 env, media_codec(), width, height); |
854 } | 856 } |
855 | 857 |
856 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { | 858 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { |
857 return RegisterNativesImpl(env); | 859 return RegisterNativesImpl(env); |
858 } | 860 } |
859 | 861 |
860 } // namespace media | 862 } // namespace media |
OLD | NEW |