Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: content/common/gpu/media/gl_surface_capturer.h

Issue 22935009: Add content::SurfaceCapturer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screencast_stride
Patch Set: cff149b4 WIP Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/memory/scoped_ptr.h"
10 #include "base/memory/weak_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 NotifyError(SurfaceCapturer::Error error) OVERRIDE;
44
45 // GpuCommandBufferStub::DestructionObserver implementation.
46 virtual void OnWillDestroyStub() OVERRIDE;
47
48 private:
49 // Handlers for IPC messages.
50 void OnInitialize(media::VideoFrame::Format format);
51 void OnCapture(int32 frame_id,
52 base::SharedMemoryHandle buffer_shm,
53 uint32 buffer_size);
54 void OnDestroy();
55
56 // Callback to bind to the media::VideoFrames we send to the encoder, called
57 // when the frame is finished.
58 void CaptureFrameFinished(int32 frame_id, scoped_ptr<base::SharedMemory> shm);
59
60 void Send(IPC::Message* message);
61
62 const base::ThreadChecker thread_checker_;
hshi1 2013/08/15 19:40:18 const thread_checker_ not initialized in ctor.
63
64 // Weak pointer for media::VideoFrames that refer back to |this|.
65 base::WeakPtrFactory<GLSurfaceCapturer> weak_this_factory_;
66
67 // Route ID assigned by the GpuCommandBufferStub.
68 const int32 route_id_;
69
70 // The GpuCommandBufferStub this instance belongs to, as an unowned pointer
71 // since |stub_| will own (and outlive) this.
72 GpuCommandBufferStub* const stub_;
73
74 // The underlying capturer we delegate to.
75 scoped_ptr<SurfaceCapturer> surface_capturer_;
76
77 // The capture output parameters that the capturer informs us of.
78 media::VideoFrame::Format output_format_;
79 gfx::Size output_buffer_size_;
80 gfx::Rect output_visible_rect_;
81
82 DISALLOW_COPY_AND_ASSIGN(GLSurfaceCapturer);
83 };
84
85 } // namespace content
86
87 #endif // CONTENT_COMMON_GPU_MEDIA_GL_SURFACE_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698