OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |