e3469236fa33a48709a72331f98112607cc24153
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 2016 Samsung Electronics. 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.
4
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_PLAYER_RENDERER_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_PLAYER_RENDERER_HOST_H_
7
8 #include <string>
9 #include <memory>
10
11 #include "base/memory/weak_ptr.h"
12 #include "cc/layers/video_layer.h"
13 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
14 #include "media/blink/video_frame_compositor.h"
15 #include "ppapi/c/pp_rect.h"
16 #include "ppapi/c/samsung/pp_media_player_samsung.h"
17 #include "ppapi/host/resource_host.h"
18 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
19 #include "ui/gfx/geometry/size.h"
20 #include "ui/gfx/geometry/rect.h"
21
22 namespace blink {
23 class WebFrame;
24 class WebURLLoader;
25 }
26
27 namespace content {
28
29 class RendererPpapiHost;
30
31 class PepperMediaPlayerRendererHost
32     : public ppapi::host::ResourceHost,
33       public PepperPluginInstanceImpl::GeometryChangeListener {
34  public:
35   PepperMediaPlayerRendererHost(RendererPpapiHost*,
36                                 PP_Instance,
37                                 PP_Resource,
38                                 PP_MediaPlayerMode);
39   virtual ~PepperMediaPlayerRendererHost();
40
41   // PepperPluginInstanceImpl::GeometryChangeListener implementation
42   void GeometryDidChange(const PP_Rect&) override;
43
44   bool IsMediaPlayerRendererHost() override;
45   void ViewInitiatedPaint();
46   bool BindToInstance(PepperPluginInstanceImpl* new_instance);
47
48   scoped_refptr<cc::VideoLayer> video_layer() { return video_layer_; }
49
50  private:
51   PepperPluginInstanceImpl* GetPluginInstance();
52
53   // Update video rect position on the brwoser-side player host. This methods
54   // initiates an IPC data exchange with BROWSER process.
55   void UpdateVideoPosition(PepperPluginInstanceImpl* plugin,
56                            const PP_Rect& hole_rect,
57                            const PP_Rect& clip_rect);
58
59   // Compositor CBs:
60   void OnDrawableContentRectChanged(gfx::Rect rect);
61
62   RendererPpapiHost* renderer_ppapi_host_;
63   PepperPluginInstanceImpl* bound_instance_;
64   base::WeakPtrFactory<PepperMediaPlayerRendererHost> factory_;
65
66   scoped_refptr<cc::VideoLayer> video_layer_;
67   scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
68   media::VideoFrameCompositor* compositor_;
69
70   DISALLOW_COPY_AND_ASSIGN(PepperMediaPlayerRendererHost);
71 };
72
73 }  // namespace content
74
75 #endif  // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_PLAYER_RENDERER_HOST_H_