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
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_
6 #define CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_
10 #include "base/android/scoped_java_ref.h"
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "content/public/browser/android/external_video_surface_container.h"
15 namespace chromecast
{
18 class ExternalVideoSurfaceContainerImpl
19 : public content::ExternalVideoSurfaceContainer
{
21 typedef base::Callback
<void(int, jobject
)> SurfaceCreatedCB
;
22 typedef base::Callback
<void(int)> SurfaceDestroyedCB
;
24 static ExternalVideoSurfaceContainerImpl
* Create(
25 content::WebContents
* web_contents
);
27 // ExternalVideoSurfaceContainer implementation.
28 void RequestExternalVideoSurface(
30 const SurfaceCreatedCB
& surface_created_cb
,
31 const SurfaceDestroyedCB
& surface_destroyed_cb
) override
;
32 int GetCurrentPlayerId() override
;
33 void ReleaseExternalVideoSurface(int player_id
) override
;
34 void OnFrameInfoUpdated() override
;
35 void OnExternalVideoSurfacePositionChanged(
36 int player_id
, const gfx::RectF
& rect
) override
;
38 // Methods called from Java.
40 JNIEnv
* env
, jobject obj
, jint player_id
, jobject jsurface
);
41 void SurfaceDestroyed(JNIEnv
* env
, jobject obj
, jint player_id
);
44 explicit ExternalVideoSurfaceContainerImpl(
45 base::android::ScopedJavaLocalRef
<jobject
> java_content_view_core
);
46 ~ExternalVideoSurfaceContainerImpl() override
;
48 base::android::ScopedJavaGlobalRef
<jobject
> jobject_
;
50 SurfaceCreatedCB surface_created_cb_
;
51 SurfaceDestroyedCB surface_destroyed_cb_
;
53 DISALLOW_COPY_AND_ASSIGN(ExternalVideoSurfaceContainerImpl
);
56 bool RegisterExternalVideoSurfaceContainer(JNIEnv
* env
);
59 } // namespace chromecast
61 #endif // CHROMECAST_BROWSER_ANDROID_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_