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_MEDIA_GL_SURFACE_CAPTURER_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_GL_SURFACE_CAPTURER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/containers/small_map.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 13 #include "content/common/gpu/surface_capturer.h" |
| 14 #include "ipc/ipc_listener.h" |
| 15 #include "ipc/ipc_sender.h" |
| 16 |
| 17 namespace gfx { |
| 18 |
| 19 class Size; |
| 20 class Rect; |
| 21 |
| 22 } // namespace gfx |
| 23 |
| 24 namespace content { |
| 25 |
| 26 class GpuChannelHost; |
| 27 |
| 28 // This class implements the GPU process side of a SurfaceCapturer, |
| 29 // communicating over IPC with a GLSurfaceCapturerHost on the browser process. |
| 30 class GLSurfaceCapturer : public IPC::Listener, |
| 31 public SurfaceCapturer::Client, |
| 32 public GpuCommandBufferStub::DestructionObserver { |
| 33 public: |
| 34 GLSurfaceCapturer(int32 route_id, GpuCommandBufferStub* stub); |
| 35 virtual ~GLSurfaceCapturer(); |
| 36 |
| 37 // IPC::Listener implementation. |
| 38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 39 |
| 40 // SurfaceCapturer::Client implementation. |
| 41 virtual void NotifyCaptureParameters(const gfx::Size& buffer_size, |
| 42 const gfx::Rect& visible_rect) OVERRIDE; |
| 43 virtual void NotifyCopyCaptureDone( |
| 44 const scoped_refptr<media::VideoFrame>& frame) OVERRIDE; |
| 45 virtual void NotifyError(SurfaceCapturer::Error error) OVERRIDE; |
| 46 |
| 47 // GpuCommandBufferStub::DestructionObserver implementation. |
| 48 virtual void OnWillDestroyStub() OVERRIDE; |
| 49 |
| 50 private: |
| 51 // Handlers for IPC messages. |
| 52 void OnInitialize(media::VideoFrame::Format format); |
| 53 void OnCopyCaptureToVideoFrame(int32 frame_id, |
| 54 base::SharedMemoryHandle buffer_shm, |
| 55 uint32 buffer_size); |
| 56 void OnTryCapture(); |
| 57 void OnDestroy(); |
| 58 |
| 59 void Send(IPC::Message* message); |
| 60 |
| 61 const base::ThreadChecker thread_checker_; |
| 62 |
| 63 // Route ID assigned by the GpuCommandBufferStub. |
| 64 const int32 route_id_; |
| 65 |
| 66 // The GpuCommandBufferStub this instance belongs to, as an unowned pointer |
| 67 // since |stub_| will own (and outlive) this. |
| 68 GpuCommandBufferStub* const stub_; |
| 69 |
| 70 // media::VideoFrames received from the host side. |
| 71 typedef base::SmallMap<std::map<scoped_refptr<media::VideoFrame>, int32> > |
| 72 FrameIdMap; |
| 73 FrameIdMap frame_id_map_; |
| 74 |
| 75 // The underlying capturer we delegate to. |
| 76 scoped_ptr<SurfaceCapturer> surface_capturer_; |
| 77 |
| 78 // The capture output parameters that the capturer informs us of. |
| 79 media::VideoFrame::Format output_format_; |
| 80 gfx::Size output_buffer_size_; |
| 81 gfx::Rect output_visible_rect_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(GLSurfaceCapturer); |
| 84 }; |
| 85 |
| 86 } // namespace content |
| 87 |
| 88 #endif // CONTENT_COMMON_GPU_MEDIA_GL_SURFACE_CAPTURER_H_ |
OLD | NEW |