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 "chromecast/browser/android/external_video_surface_container_impl.h" | 5 #include "chromecast/browser/android/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 24 matching lines...) Expand all Loading... |
35 const SurfaceCreatedCB& surface_created_cb, | 35 const SurfaceCreatedCB& surface_created_cb, |
36 const SurfaceDestroyedCB& surface_destroyed_cb) { | 36 const SurfaceDestroyedCB& surface_destroyed_cb) { |
37 surface_created_cb_ = surface_created_cb; | 37 surface_created_cb_ = surface_created_cb; |
38 surface_destroyed_cb_ = surface_destroyed_cb; | 38 surface_destroyed_cb_ = surface_destroyed_cb; |
39 | 39 |
40 JNIEnv* env = base::android::AttachCurrentThread(); | 40 JNIEnv* env = base::android::AttachCurrentThread(); |
41 Java_ExternalVideoSurfaceContainer_requestExternalVideoSurface( | 41 Java_ExternalVideoSurfaceContainer_requestExternalVideoSurface( |
42 env, jobject_.obj(), static_cast<jint>(player_id)); | 42 env, jobject_.obj(), static_cast<jint>(player_id)); |
43 } | 43 } |
44 | 44 |
| 45 int ExternalVideoSurfaceContainerImpl::GetCurrentPlayerId() { |
| 46 JNIEnv* env = AttachCurrentThread(); |
| 47 |
| 48 int current_player = static_cast<int>( |
| 49 Java_ExternalVideoSurfaceContainer_getCurrentPlayerId( |
| 50 env, jobject_.obj())); |
| 51 |
| 52 if (current_player < 0) |
| 53 return kInvalidPlayerId; |
| 54 else |
| 55 return current_player; |
| 56 } |
| 57 |
45 void ExternalVideoSurfaceContainerImpl::ReleaseExternalVideoSurface( | 58 void ExternalVideoSurfaceContainerImpl::ReleaseExternalVideoSurface( |
46 int player_id) { | 59 int player_id) { |
47 JNIEnv* env = base::android::AttachCurrentThread(); | 60 JNIEnv* env = base::android::AttachCurrentThread(); |
48 Java_ExternalVideoSurfaceContainer_releaseExternalVideoSurface( | 61 Java_ExternalVideoSurfaceContainer_releaseExternalVideoSurface( |
49 env, jobject_.obj(), static_cast<jint>(player_id)); | 62 env, jobject_.obj(), static_cast<jint>(player_id)); |
50 | 63 |
51 surface_created_cb_.Reset(); | 64 surface_created_cb_.Reset(); |
52 surface_destroyed_cb_.Reset(); | 65 surface_destroyed_cb_.Reset(); |
53 } | 66 } |
54 | 67 |
(...skipping 27 matching lines...) Expand all Loading... |
82 if (!surface_destroyed_cb_.is_null()) | 95 if (!surface_destroyed_cb_.is_null()) |
83 surface_destroyed_cb_.Run(static_cast<int>(player_id)); | 96 surface_destroyed_cb_.Run(static_cast<int>(player_id)); |
84 } | 97 } |
85 | 98 |
86 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { | 99 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { |
87 return RegisterNativesImpl(env); | 100 return RegisterNativesImpl(env); |
88 } | 101 } |
89 | 102 |
90 } // namespace shell | 103 } // namespace shell |
91 } // namespace chromecast | 104 } // namespace chromecast |
OLD | NEW |