| 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" |
| 11 | 11 |
| 12 namespace chromecast { | 12 namespace chromecast { |
| 13 namespace shell { | 13 namespace shell { |
| 14 | 14 // static |
| 15 ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl( | 15 ExternalVideoSurfaceContainerImpl* ExternalVideoSurfaceContainerImpl::Create( |
| 16 content::WebContents* web_contents) { | 16 content::WebContents* web_contents) { |
| 17 content::ContentViewCore* cvc = | 17 content::ContentViewCore* cvc = |
| 18 content::ContentViewCore::FromWebContents(web_contents); | 18 content::ContentViewCore::FromWebContents(web_contents); |
| 19 if (cvc) { | 19 if (!cvc) |
| 20 JNIEnv* env = base::android::AttachCurrentThread(); | 20 return nullptr; |
| 21 jobject_.Reset( | 21 base::android::ScopedJavaLocalRef<jobject> jcvc = cvc->GetJavaObject(); |
| 22 Java_ExternalVideoSurfaceContainer_create( | 22 if (jcvc.is_null()) |
| 23 env, reinterpret_cast<intptr_t>(this), cvc->GetJavaObject().obj())); | 23 return nullptr; |
| 24 } | 24 return new ExternalVideoSurfaceContainerImpl(jcvc); |
| 25 } |
| 26 |
| 27 ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl( |
| 28 base::android::ScopedJavaLocalRef<jobject> java_content_view_core) { |
| 29 JNIEnv* env = base::android::AttachCurrentThread(); |
| 30 jobject_.Reset(Java_ExternalVideoSurfaceContainer_create( |
| 31 env, reinterpret_cast<intptr_t>(this), java_content_view_core.obj())); |
| 25 } | 32 } |
| 26 | 33 |
| 27 ExternalVideoSurfaceContainerImpl::~ExternalVideoSurfaceContainerImpl() { | 34 ExternalVideoSurfaceContainerImpl::~ExternalVideoSurfaceContainerImpl() { |
| 28 JNIEnv* env = base::android::AttachCurrentThread(); | 35 JNIEnv* env = base::android::AttachCurrentThread(); |
| 29 Java_ExternalVideoSurfaceContainer_destroy(env, jobject_.obj()); | 36 Java_ExternalVideoSurfaceContainer_destroy(env, jobject_.obj()); |
| 30 jobject_.Reset(); | 37 jobject_.Reset(); |
| 31 } | 38 } |
| 32 | 39 |
| 33 void ExternalVideoSurfaceContainerImpl::RequestExternalVideoSurface( | 40 void ExternalVideoSurfaceContainerImpl::RequestExternalVideoSurface( |
| 34 int player_id, | 41 int player_id, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (!surface_destroyed_cb_.is_null()) | 102 if (!surface_destroyed_cb_.is_null()) |
| 96 surface_destroyed_cb_.Run(static_cast<int>(player_id)); | 103 surface_destroyed_cb_.Run(static_cast<int>(player_id)); |
| 97 } | 104 } |
| 98 | 105 |
| 99 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { | 106 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { |
| 100 return RegisterNativesImpl(env); | 107 return RegisterNativesImpl(env); |
| 101 } | 108 } |
| 102 | 109 |
| 103 } // namespace shell | 110 } // namespace shell |
| 104 } // namespace chromecast | 111 } // namespace chromecast |
| OLD | NEW |