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

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
« no previous file with comments | « media/base/android/media_codec_bridge.h ('k') | media/base/android/media_codec_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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
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
OLDNEW
« no previous file with comments | « media/base/android/media_codec_bridge.h ('k') | media/base/android/media_codec_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698