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/small_map.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 TryCapture() OVERRIDE; |
| 53 virtual void CopyCaptureToVideoFrame( |
| 54 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; |
| 55 virtual void Destroy() OVERRIDE; |
| 56 |
| 57 // CommandBufferProxyImpl::DeletionObserver implementation. |
| 58 virtual void OnWillDeleteImpl() OVERRIDE; |
| 59 |
| 60 private: |
| 61 virtual ~GLSurfaceCapturerHost(); |
| 62 |
| 63 // Notify |client_| when an error has occured. Used when notifying from |
| 64 // within a media::VideoEncodeAccelerator entry point, to avoid re-entrancy. |
| 65 void NotifyError(Error error); |
| 66 |
| 67 // IPC handlers, proxying SurfaceCapturer::Client for the GPU process. |
| 68 void OnNotifyCaptureParameters(const gfx::Size& buffer_size, |
| 69 const gfx::Rect& visible_rect); |
| 70 void OnNotifyCopyCaptureDone(int32 frame_id); |
| 71 void OnNotifyError(Error error); |
| 72 |
| 73 void Send(IPC::Message* message); |
| 74 |
| 75 const base::ThreadChecker thread_checker_; |
| 76 |
| 77 // Route ID for corresponding GLSurfaceCapturer in the GPU process. |
| 78 const int32 capturer_route_id_; |
| 79 |
| 80 // Weak pointer for registering as a listener for |channel_|. |
| 81 base::WeakPtrFactory<GLSurfaceCapturerHost> weak_this_factory_; |
| 82 |
| 83 // SurfaceEncoder::Client callbacks received over IPC are forwarded to |
| 84 // |client_|. |
| 85 SurfaceCapturer::Client* client_; |
| 86 |
| 87 // Unowned reference to the CommandBufferProxyImpl that created us. |
| 88 CommandBufferProxyImpl* impl_; |
| 89 |
| 90 // GPU process channel to send messages on. |
| 91 GpuChannelHost* channel_; |
| 92 |
| 93 // media::VideoFrames sent to the capturer. |
| 94 // base::IDMap not used here, since that takes pointers, not scoped_refptr. |
| 95 typedef base::SmallMap<std::map<int32, scoped_refptr<media::VideoFrame> > > |
| 96 FrameMap; |
| 97 FrameMap frame_map_; |
| 98 |
| 99 // ID serial number for next frame to send to the GPU process. |
| 100 int32 next_frame_id_; |
| 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(GLSurfaceCapturerHost); |
| 103 }; |
| 104 |
| 105 } // namespace content |
| 106 |
| 107 #endif // CONTENT_COMMON_GPU_CLIENT_GL_SURFACE_CAPTURER_HOST_H_ |
OLD | NEW |