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

Unified Diff: content/browser/android/external_video_surface_view_holder.cc

Issue 12443003: Implement out-of-band video compositing on Android: Step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit2 Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/external_video_surface_view_holder.cc
diff --git a/content/browser/android/external_video_surface_view_holder.cc b/content/browser/android/external_video_surface_view_holder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..78f9e033abdbfa9bf168d93bda504b4e9906227b
--- /dev/null
+++ b/content/browser/android/external_video_surface_view_holder.cc
@@ -0,0 +1,84 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/android/external_video_surface_view_holder.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
+#include "base/android/scoped_java_ref.h"
+#include "base/bind.h"
+#include "base/lazy_instance.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop.h"
+#include "jni/ExternalVideoSurfaceViewHolder_jni.h"
+#include "media/base/android/media_player_bridge.h"
+
+using base::android::AttachCurrentThread;
+using media::MediaPlayerBridge;
+
+namespace content {
+
+// static
+bool ExternalVideoSurfaceViewHolder::RegisterExternalVideoSurfaceViewHolder(
+ JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+ExternalVideoSurfaceViewHolder::ExternalVideoSurfaceViewHolder(JNIEnv* env,
+ jobject obj)
+ : java_ref_(env, obj),
+ player_(NULL) {
+}
+
+ExternalVideoSurfaceViewHolder::~ExternalVideoSurfaceViewHolder() {
+}
+
+void ExternalVideoSurfaceViewHolder::registerPlayer(MediaPlayerBridge* player) {
+ DCHECK(player);
+
+ if (player_) {
+ unregisterPlayer(player_);
+ }
+ player_ = player;
+
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
+ if (obj.is_null())
+ return;
+ Java_ExternalVideoSurfaceViewHolder_requestExternalVideoSurface(
+ env, obj.obj());
+}
+
+void ExternalVideoSurfaceViewHolder::unregisterPlayer(
+ MediaPlayerBridge* player) {
+ if (player_ == player) {
+ player_->SetVideoSurface(NULL);
+ player_ = NULL;
+ }
+}
+
+// static
+jint Init(JNIEnv* env, jobject obj) {
+ ExternalVideoSurfaceViewHolder* external_video_surface_view_holder =
+ new ExternalVideoSurfaceViewHolder(env, obj);
+ return reinterpret_cast<jint>(external_video_surface_view_holder);
+}
+
+void ExternalVideoSurfaceViewHolder::Destroy(JNIEnv* env, jobject obj) {
+ delete this;
+}
+
+void ExternalVideoSurfaceViewHolder::AttachExternalVideoSurface(
+ JNIEnv* env, jobject obj, jobject jsurface) {
+ if (player_)
+ player_->SetVideoSurface(jsurface);
+}
+
+void ExternalVideoSurfaceViewHolder::DetachExternalVideoSurface(
+ JNIEnv* env, jobject obj) {
+ if (player_)
+ player_->SetVideoSurface(NULL);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698