| 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 #ifndef CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_ | 5 #ifndef CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_ |
| 6 #define CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_ | 6 #define CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "content/public/browser/android/external_video_surface_container.h" | 13 #include "content/public/browser/android/external_video_surface_container.h" |
| 14 | 14 |
| 15 namespace chromecast { | 15 namespace chromecast { |
| 16 namespace shell { | 16 namespace shell { |
| 17 | 17 |
| 18 class ExternalVideoSurfaceContainerImpl | 18 class ExternalVideoSurfaceContainerImpl |
| 19 : public content::ExternalVideoSurfaceContainer { | 19 : public content::ExternalVideoSurfaceContainer { |
| 20 public: | 20 public: |
| 21 typedef base::Callback<void(int, jobject)> SurfaceCreatedCB; | 21 typedef base::Callback<void(int, jobject)> SurfaceCreatedCB; |
| 22 typedef base::Callback<void(int)> SurfaceDestroyedCB; | 22 typedef base::Callback<void(int)> SurfaceDestroyedCB; |
| 23 | 23 |
| 24 ExternalVideoSurfaceContainerImpl(content::WebContents* contents); | 24 static ExternalVideoSurfaceContainerImpl* Create( |
| 25 content::WebContents* web_contents); |
| 25 | 26 |
| 26 // ExternalVideoSurfaceContainer implementation. | 27 // ExternalVideoSurfaceContainer implementation. |
| 27 void RequestExternalVideoSurface( | 28 void RequestExternalVideoSurface( |
| 28 int player_id, | 29 int player_id, |
| 29 const SurfaceCreatedCB& surface_created_cb, | 30 const SurfaceCreatedCB& surface_created_cb, |
| 30 const SurfaceDestroyedCB& surface_destroyed_cb) override; | 31 const SurfaceDestroyedCB& surface_destroyed_cb) override; |
| 31 int GetCurrentPlayerId() override; | 32 int GetCurrentPlayerId() override; |
| 32 void ReleaseExternalVideoSurface(int player_id) override; | 33 void ReleaseExternalVideoSurface(int player_id) override; |
| 33 void OnFrameInfoUpdated() override; | 34 void OnFrameInfoUpdated() override; |
| 34 void OnExternalVideoSurfacePositionChanged( | 35 void OnExternalVideoSurfacePositionChanged( |
| 35 int player_id, const gfx::RectF& rect) override; | 36 int player_id, const gfx::RectF& rect) override; |
| 36 | 37 |
| 37 // Methods called from Java. | 38 // Methods called from Java. |
| 38 void SurfaceCreated( | 39 void SurfaceCreated( |
| 39 JNIEnv* env, jobject obj, jint player_id, jobject jsurface); | 40 JNIEnv* env, jobject obj, jint player_id, jobject jsurface); |
| 40 void SurfaceDestroyed(JNIEnv* env, jobject obj, jint player_id); | 41 void SurfaceDestroyed(JNIEnv* env, jobject obj, jint player_id); |
| 41 | 42 |
| 42 private: | 43 private: |
| 44 explicit ExternalVideoSurfaceContainerImpl( |
| 45 base::android::ScopedJavaLocalRef<jobject> java_content_view_core); |
| 43 ~ExternalVideoSurfaceContainerImpl() override; | 46 ~ExternalVideoSurfaceContainerImpl() override; |
| 44 | 47 |
| 45 base::android::ScopedJavaGlobalRef<jobject> jobject_; | 48 base::android::ScopedJavaGlobalRef<jobject> jobject_; |
| 46 | 49 |
| 47 SurfaceCreatedCB surface_created_cb_; | 50 SurfaceCreatedCB surface_created_cb_; |
| 48 SurfaceDestroyedCB surface_destroyed_cb_; | 51 SurfaceDestroyedCB surface_destroyed_cb_; |
| 49 | 52 |
| 50 DISALLOW_COPY_AND_ASSIGN(ExternalVideoSurfaceContainerImpl); | 53 DISALLOW_COPY_AND_ASSIGN(ExternalVideoSurfaceContainerImpl); |
| 51 }; | 54 }; |
| 52 | 55 |
| 53 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env); | 56 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env); |
| 54 | 57 |
| 55 } // namespace shell | 58 } // namespace shell |
| 56 } // namespace chromecast | 59 } // namespace chromecast |
| 57 | 60 |
| 58 #endif // CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_ | 61 #endif // CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_ |
| OLD | NEW |