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 ANDROID_WEBVIEW_NATIVE_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_
6 #define ANDROID_WEBVIEW_NATIVE_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 android_webview
{
17 class ExternalVideoSurfaceContainerImpl
18 : public content::ExternalVideoSurfaceContainer
{
20 typedef base::Callback
<void(int, jobject
)> SurfaceCreatedCB
;
21 typedef base::Callback
<void(int)> SurfaceDestroyedCB
;
23 static ExternalVideoSurfaceContainerImpl
* Create(
24 content::WebContents
* web_contents
);
26 // ExternalVideoSurfaceContainer implementation.
27 void RequestExternalVideoSurface(
29 const SurfaceCreatedCB
& surface_created_cb
,
30 const SurfaceDestroyedCB
& surface_destroyed_cb
) override
;
31 int GetCurrentPlayerId() override
;
32 void ReleaseExternalVideoSurface(int player_id
) override
;
33 void OnFrameInfoUpdated() override
;
34 void OnExternalVideoSurfacePositionChanged(int player_id
,
35 const gfx::RectF
& rect
) override
;
37 // Methods called from Java.
39 JNIEnv
* env
, jobject obj
, jint player_id
, jobject jsurface
);
40 void SurfaceDestroyed(JNIEnv
* env
, jobject obj
, jint player_id
);
43 explicit ExternalVideoSurfaceContainerImpl(
44 base::android::ScopedJavaLocalRef
<jobject
> java_content_view_core
);
45 ~ExternalVideoSurfaceContainerImpl() override
;
47 base::android::ScopedJavaGlobalRef
<jobject
> jobject_
;
49 SurfaceCreatedCB surface_created_cb_
;
50 SurfaceDestroyedCB surface_destroyed_cb_
;
52 DISALLOW_COPY_AND_ASSIGN(ExternalVideoSurfaceContainerImpl
);
55 bool RegisterExternalVideoSurfaceContainer(JNIEnv
* env
);
57 } // namespace android_webview
59 #endif // ANDROID_WEBVIEW_NATIVE_EXTERNAL_VIDEO_SURFACE_CONTAINER_IMPL_H_