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

Side by Side Diff: media/base/android/media_codec_bridge.cc

Issue 1254293003: MediaCodecPlayer implementation (stage 4 - preroll) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-browserseek
Patch Set: Rebased Created 5 years, 4 months 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 unified diff | Download patch
OLDNEW
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 7
8 #include "base/android/build_info.h" 8 #include "base/android/build_info.h"
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h" 10 #include "base/android/jni_array.h"
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 break; 690 break;
691 } 691 }
692 default: 692 default:
693 LOG(ERROR) << "Invalid header encountered for codec: " 693 LOG(ERROR) << "Invalid header encountered for codec: "
694 << AudioCodecToAndroidMimeType(codec); 694 << AudioCodecToAndroidMimeType(codec);
695 return false; 695 return false;
696 } 696 }
697 return true; 697 return true;
698 } 698 }
699 699
700 int64 AudioCodecBridge::PlayOutputBuffer(int index, size_t size) { 700 int64 AudioCodecBridge::PlayOutputBuffer(int index,
701 size_t size,
702 bool postpone) {
701 DCHECK_LE(0, index); 703 DCHECK_LE(0, index);
702 int numBytes = base::checked_cast<int>(size); 704 int numBytes = base::checked_cast<int>(size);
703 JNIEnv* env = AttachCurrentThread(); 705 JNIEnv* env = AttachCurrentThread();
704 ScopedJavaLocalRef<jobject> buf = 706 ScopedJavaLocalRef<jobject> buf =
705 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index); 707 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index);
706 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj())); 708 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj()));
707 709
708 ScopedJavaLocalRef<jbyteArray> byte_array = 710 ScopedJavaLocalRef<jbyteArray> byte_array =
709 base::android::ToJavaByteArray(env, buffer, numBytes); 711 base::android::ToJavaByteArray(env, buffer, numBytes);
710 return Java_MediaCodecBridge_playOutputBuffer( 712 return Java_MediaCodecBridge_playOutputBuffer(env, media_codec(),
711 env, media_codec(), byte_array.obj()); 713 byte_array.obj(), postpone);
712 } 714 }
713 715
714 void AudioCodecBridge::SetVolume(double volume) { 716 void AudioCodecBridge::SetVolume(double volume) {
715 JNIEnv* env = AttachCurrentThread(); 717 JNIEnv* env = AttachCurrentThread();
716 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); 718 Java_MediaCodecBridge_setVolume(env, media_codec(), volume);
717 } 719 }
718 720
719 // static 721 // static
720 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { 722 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) {
721 if (!MediaCodecBridge::IsAvailable()) 723 if (!MediaCodecBridge::IsAvailable())
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 JNIEnv* env = AttachCurrentThread(); 843 JNIEnv* env = AttachCurrentThread();
842 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( 844 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(
843 env, media_codec(), width, height); 845 env, media_codec(), width, height);
844 } 846 }
845 847
846 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { 848 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) {
847 return RegisterNativesImpl(env); 849 return RegisterNativesImpl(env);
848 } 850 }
849 851
850 } // namespace media 852 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698