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

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: Save the first post-preroll audio buffer and replay it when preroll is done 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 ScopedJavaLocalRef<jobject> buf = 704 ScopedJavaLocalRef<jobject> buf =
705 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index); 705 Java_MediaCodecBridge_getOutputBuffer(env, media_codec(), index);
706 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj())); 706 uint8* buffer = static_cast<uint8*>(env->GetDirectBufferAddress(buf.obj()));
707 707
708 ScopedJavaLocalRef<jbyteArray> byte_array = 708 ScopedJavaLocalRef<jbyteArray> byte_array =
709 base::android::ToJavaByteArray(env, buffer, numBytes); 709 base::android::ToJavaByteArray(env, buffer, numBytes);
710 return Java_MediaCodecBridge_playOutputBuffer( 710 return Java_MediaCodecBridge_playOutputBuffer(
711 env, media_codec(), byte_array.obj()); 711 env, media_codec(), byte_array.obj());
712 } 712 }
713 713
714 int64 AudioCodecBridge::PlayOutputBuffer(uint8* buffer, size_t size) {
715 DCHECK(buffer);
716 DCHECK_NE(0u, size);
717 int numBytes = base::checked_cast<int>(size);
718 JNIEnv* env = AttachCurrentThread();
719
720 ScopedJavaLocalRef<jbyteArray> byte_array =
721 base::android::ToJavaByteArray(env, buffer, numBytes);
722 return Java_MediaCodecBridge_playOutputBuffer(env, media_codec(),
723 byte_array.obj());
724 }
725
714 void AudioCodecBridge::SetVolume(double volume) { 726 void AudioCodecBridge::SetVolume(double volume) {
715 JNIEnv* env = AttachCurrentThread(); 727 JNIEnv* env = AttachCurrentThread();
716 Java_MediaCodecBridge_setVolume(env, media_codec(), volume); 728 Java_MediaCodecBridge_setVolume(env, media_codec(), volume);
717 } 729 }
718 730
719 // static 731 // static
720 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) { 732 AudioCodecBridge* AudioCodecBridge::Create(const AudioCodec& codec) {
721 if (!MediaCodecBridge::IsAvailable()) 733 if (!MediaCodecBridge::IsAvailable())
722 return NULL; 734 return NULL;
723 735
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 JNIEnv* env = AttachCurrentThread(); 853 JNIEnv* env = AttachCurrentThread();
842 return Java_MediaCodecBridge_isAdaptivePlaybackSupported( 854 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(
843 env, media_codec(), width, height); 855 env, media_codec(), width, height);
844 } 856 }
845 857
846 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { 858 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) {
847 return RegisterNativesImpl(env); 859 return RegisterNativesImpl(env);
848 } 860 }
849 861
850 } // namespace media 862 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698