OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 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. | |
4 | |
5 #ifndef CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_ | |
6 #define CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_ | |
7 | |
8 #include "base/containers/hash_tables.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/threading/thread_checker.h" | |
12 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | |
13 #include "content/common/gpu/surface_capturer.h" | |
14 #include "ipc/ipc_listener.h" | |
15 | |
16 namespace gfx { | |
17 | |
18 class Rect; | |
19 class Size; | |
20 | |
21 } // namespace gfx | |
22 | |
23 namespace media { | |
24 | |
25 class VideoFrame; | |
26 | |
27 } // namespace media | |
28 | |
29 namespace content { | |
30 | |
31 class GpuChannelHost; | |
32 | |
33 // This class is the browser-side host for the SurfaceCapturer in the GPU | |
34 // process, coordinated over IPC. | |
35 class GLSurfaceCapturerHost : public IPC::Listener, | |
36 public SurfaceCapturer, | |
37 public CommandBufferProxyImpl::DeletionObserver { | |
38 public: | |
39 // |client| is expected to outlive this object. We are registered as a | |
40 // DeletionObserver with |impl|, so it will notify us when it is about to | |
41 // be destroyed. | |
42 GLSurfaceCapturerHost(int32 capturer_route_id, | |
43 SurfaceCapturer::Client* client, | |
44 CommandBufferProxyImpl* impl); | |
45 | |
46 // IPC::Listener implementation. | |
47 virtual void OnChannelError() OVERRIDE; | |
48 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
49 | |
50 // SurfaceCapturer implementation. | |
51 virtual void Initialize(media::VideoFrame::Format format) OVERRIDE; | |
52 virtual void Capture(const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; | |
53 virtual void Destroy() OVERRIDE; | |
54 | |
55 // CommandBufferProxyImpl::DeletionObserver implementation. | |
56 virtual void OnWillDeleteImpl() OVERRIDE; | |
57 | |
58 private: | |
59 virtual ~GLSurfaceCapturerHost(); | |
60 | |
61 // Notify |client_| when an error has occured. Used when notifying from | |
62 // within a media::VideoEncodeAccelerator entry point, to avoid re-entrancy. | |
63 void NotifyError(Error error); | |
64 | |
65 // IPC handlers, proxying SurfaceCapturer::Client for the GPU process. | |
66 void OnNotifyCaptureParameters(const gfx::Size& buffer_size, | |
67 const gfx::Rect& visible_rect); | |
68 void OnNotifyCaptureDone(int32 frame_id); | |
69 void OnNotifyError(Error error); | |
70 | |
71 void Send(IPC::Message* message); | |
72 | |
73 const base::ThreadChecker thread_checker_; | |
hshi1
2013/08/15 19:40:18
const thread_checker_ not initialized in ctor.
miu
2013/08/15 20:22:08
Is this in the C++ style guide? On the surface, t
hshi1
2013/08/15 20:45:29
Not a style violation but compile fails with messa
| |
74 | |
75 // Route ID for corresponding GLSurfaceCapturer in the GPU process. | |
76 const int32 capturer_route_id_; | |
77 | |
78 // SurfaceEncoder::Client callbacks received over IPC are forwarded to | |
79 // |client_|. |client_ptr_factory_| is used for calls originating directly | |
80 // from a SurfaceEncoder interface function, that require an extra PostTask() | |
81 // back on its own thread to avoid re-entrancy. | |
82 // hop. | |
83 base::WeakPtrFactory<SurfaceCapturer::Client> client_ptr_factory_; | |
84 SurfaceCapturer::Client* client_; | |
85 | |
86 // Unowned reference to the CommandBufferProxyImpl that created us. | |
87 CommandBufferProxyImpl* impl_; | |
88 | |
89 // GPU process channel to send messages on. | |
90 GpuChannelHost* channel_; | |
91 | |
92 // media::VideoFrames sent to the capturer. | |
93 // base::IDMap not used here, since that takes pointers, not scoped_refptr. | |
94 typedef base::hash_map<int32, scoped_refptr<media::VideoFrame> > FrameMap; | |
95 FrameMap frame_map_; | |
96 | |
97 // ID serial number for next frame to send to the GPU process. | |
98 int32 next_frame_id_; | |
99 | |
100 DISALLOW_COPY_AND_ASSIGN(GLSurfaceCapturerHost); | |
101 }; | |
102 | |
103 } // namespace content | |
104 | |
105 #endif // CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_ | |
OLD | NEW |