| 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/rect_f.h" | 10 #include "ui/gfx/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 int current_player = static_cast<int>( |
| 49 Java_ExternalVideoSurfaceContainer_getCurrentPlayerId( |
| 50 env, jobject_.obj())); |
| 51 return current_player; |
| 52 } |
| 53 |
| 46 void ExternalVideoSurfaceContainerImpl::ReleaseExternalVideoSurface( | 54 void ExternalVideoSurfaceContainerImpl::ReleaseExternalVideoSurface( |
| 47 int player_id) { | 55 int player_id) { |
| 48 JNIEnv* env = AttachCurrentThread(); | 56 JNIEnv* env = AttachCurrentThread(); |
| 49 Java_ExternalVideoSurfaceContainer_releaseExternalVideoSurface( | 57 Java_ExternalVideoSurfaceContainer_releaseExternalVideoSurface( |
| 50 env, jobject_.obj(), static_cast<jint>(player_id)); | 58 env, jobject_.obj(), static_cast<jint>(player_id)); |
| 51 | 59 |
| 52 surface_created_cb_.Reset(); | 60 surface_created_cb_.Reset(); |
| 53 surface_destroyed_cb_.Reset(); | 61 surface_destroyed_cb_.Reset(); |
| 54 } | 62 } |
| 55 | 63 |
| 64 void ExternalVideoSurfaceContainerImpl::ReleaseCurrentExternalVideoSurface() { |
| 65 JNIEnv* env = AttachCurrentThread(); |
| 66 Java_ExternalVideoSurfaceContainer_destroy(env, jobject_.obj()); |
| 67 |
| 68 surface_created_cb_.Reset(); |
| 69 surface_destroyed_cb_.Reset(); |
| 70 } |
| 71 |
| 56 void ExternalVideoSurfaceContainerImpl::OnFrameInfoUpdated() { | 72 void ExternalVideoSurfaceContainerImpl::OnFrameInfoUpdated() { |
| 57 JNIEnv* env = AttachCurrentThread(); | 73 JNIEnv* env = AttachCurrentThread(); |
| 58 Java_ExternalVideoSurfaceContainer_onFrameInfoUpdated(env, jobject_.obj()); | 74 Java_ExternalVideoSurfaceContainer_onFrameInfoUpdated(env, jobject_.obj()); |
| 59 } | 75 } |
| 60 | 76 |
| 61 void ExternalVideoSurfaceContainerImpl::OnExternalVideoSurfacePositionChanged( | 77 void ExternalVideoSurfaceContainerImpl::OnExternalVideoSurfacePositionChanged( |
| 62 int player_id, const gfx::RectF& rect) { | 78 int player_id, const gfx::RectF& rect) { |
| 63 JNIEnv* env = AttachCurrentThread(); | 79 JNIEnv* env = AttachCurrentThread(); |
| 64 Java_ExternalVideoSurfaceContainer_onExternalVideoSurfacePositionChanged( | 80 Java_ExternalVideoSurfaceContainer_onExternalVideoSurfacePositionChanged( |
| 65 env, | 81 env, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 82 JNIEnv* env, jobject obj, jint player_id) { | 98 JNIEnv* env, jobject obj, jint player_id) { |
| 83 if (!surface_destroyed_cb_.is_null()) | 99 if (!surface_destroyed_cb_.is_null()) |
| 84 surface_destroyed_cb_.Run(static_cast<int>(player_id)); | 100 surface_destroyed_cb_.Run(static_cast<int>(player_id)); |
| 85 } | 101 } |
| 86 | 102 |
| 87 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { | 103 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { |
| 88 return RegisterNativesImpl(env); | 104 return RegisterNativesImpl(env); |
| 89 } | 105 } |
| 90 | 106 |
| 91 } // namespace android_webview | 107 } // namespace android_webview |
| OLD | NEW |