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 COMPONENTS_EXTERNAL_VIDEO_SURFACE_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_
6 #define COMPONENTS_EXTERNAL_VIDEO_SURFACE_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 "base/macros.h"
14 #include "content/public/browser/android/external_video_surface_container.h"
16 namespace external_video_surface
{
18 class ExternalVideoSurfaceContainerImpl
19 : public content::ExternalVideoSurfaceContainer
{
21 static bool RegisterJni(JNIEnv
* env
);
23 typedef base::Callback
<void(int, jobject
)> SurfaceCreatedCB
;
24 typedef base::Callback
<void(int)> SurfaceDestroyedCB
;
26 static ExternalVideoSurfaceContainerImpl
* Create(
27 content::WebContents
* web_contents
);
29 // content::ExternalVideoSurfaceContainer implementation.
30 void RequestExternalVideoSurface(
32 const SurfaceCreatedCB
& surface_created_cb
,
33 const SurfaceDestroyedCB
& surface_destroyed_cb
) override
;
34 int GetCurrentPlayerId() override
;
35 void ReleaseExternalVideoSurface(int player_id
) override
;
36 void OnFrameInfoUpdated() override
;
37 void OnExternalVideoSurfacePositionChanged(int player_id
,
38 const gfx::RectF
& rect
) override
;
40 // Methods called from Java.
42 JNIEnv
* env
, jobject obj
, jint player_id
, jobject jsurface
);
43 void SurfaceDestroyed(JNIEnv
* env
, jobject obj
, jint player_id
);
46 explicit ExternalVideoSurfaceContainerImpl(
47 base::android::ScopedJavaLocalRef
<jobject
> java_content_view_core
);
48 ~ExternalVideoSurfaceContainerImpl() override
;
50 base::android::ScopedJavaGlobalRef
<jobject
> jobject_
;
52 SurfaceCreatedCB surface_created_cb_
;
53 SurfaceDestroyedCB surface_destroyed_cb_
;
55 DISALLOW_COPY_AND_ASSIGN(ExternalVideoSurfaceContainerImpl
);
58 } // namespace external_video_surface
60 #endif // COMPONENTS_EXTERNAL_VIDEO_SURFACE_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_