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

Side by Side Diff: android_webview/native/external_video_surface_container_impl.cc

Issue 714643002: Pause EME player whose external surface is stolen by another player (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "android_webview/native/external_video_surface_container_impl.h" 5 #include "android_webview/native/external_video_surface_container_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "content/public/browser/android/content_view_core.h" 8 #include "content/public/browser/android/content_view_core.h"
9 #include "jni/ExternalVideoSurfaceContainer_jni.h" 9 #include "jni/ExternalVideoSurfaceContainer_jni.h"
10 #include "ui/gfx/geometry/rect_f.h" 10 #include "ui/gfx/geometry/rect_f.h"
(...skipping 25 matching lines...) Expand all
36 const SurfaceCreatedCB& surface_created_cb, 36 const SurfaceCreatedCB& surface_created_cb,
37 const SurfaceDestroyedCB& surface_destroyed_cb) { 37 const SurfaceDestroyedCB& surface_destroyed_cb) {
38 surface_created_cb_ = surface_created_cb; 38 surface_created_cb_ = surface_created_cb;
39 surface_destroyed_cb_ = surface_destroyed_cb; 39 surface_destroyed_cb_ = surface_destroyed_cb;
40 40
41 JNIEnv* env = AttachCurrentThread(); 41 JNIEnv* env = AttachCurrentThread();
42 Java_ExternalVideoSurfaceContainer_requestExternalVideoSurface( 42 Java_ExternalVideoSurfaceContainer_requestExternalVideoSurface(
43 env, jobject_.obj(), static_cast<jint>(player_id)); 43 env, jobject_.obj(), static_cast<jint>(player_id));
44 } 44 }
45 45
46 int ExternalVideoSurfaceContainerImpl::GetCurrentPlayerId() {
47 JNIEnv* env = AttachCurrentThread();
48
49 int current_player = static_cast<int>(
50 Java_ExternalVideoSurfaceContainer_getCurrentPlayerId(
51 env, jobject_.obj()));
52
53 if (current_player < 0)
54 return kInvalidPlayerId;
55 else
56 return current_player;
57 }
58
46 void ExternalVideoSurfaceContainerImpl::ReleaseExternalVideoSurface( 59 void ExternalVideoSurfaceContainerImpl::ReleaseExternalVideoSurface(
47 int player_id) { 60 int player_id) {
48 JNIEnv* env = AttachCurrentThread(); 61 JNIEnv* env = AttachCurrentThread();
49 Java_ExternalVideoSurfaceContainer_releaseExternalVideoSurface( 62 Java_ExternalVideoSurfaceContainer_releaseExternalVideoSurface(
50 env, jobject_.obj(), static_cast<jint>(player_id)); 63 env, jobject_.obj(), static_cast<jint>(player_id));
51 64
52 surface_created_cb_.Reset(); 65 surface_created_cb_.Reset();
53 surface_destroyed_cb_.Reset(); 66 surface_destroyed_cb_.Reset();
54 } 67 }
55 68
(...skipping 26 matching lines...) Expand all
82 JNIEnv* env, jobject obj, jint player_id) { 95 JNIEnv* env, jobject obj, jint player_id) {
83 if (!surface_destroyed_cb_.is_null()) 96 if (!surface_destroyed_cb_.is_null())
84 surface_destroyed_cb_.Run(static_cast<int>(player_id)); 97 surface_destroyed_cb_.Run(static_cast<int>(player_id));
85 } 98 }
86 99
87 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { 100 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) {
88 return RegisterNativesImpl(env); 101 return RegisterNativesImpl(env);
89 } 102 }
90 103
91 } // namespace android_webview 104 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698