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

Side by Side Diff: content/renderer/media/video_capture_impl.h

Issue 1267883002: Pass GpuMemoryBuffer backed VideoFrame from browser to renderer processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmbtracker-multiple
Patch Set: Rebase Created 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 10
(...skipping 22 matching lines...) Expand all
33 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which relays 33 // VideoCaptureImpl is also a delegate of VideoCaptureMessageFilter which relays
34 // operation of a capture device to the browser process and receives responses 34 // operation of a capture device to the browser process and receives responses
35 // from browser process. 35 // from browser process.
36 // 36 //
37 // VideoCaptureImpl is an IO thread only object. See the comments in 37 // VideoCaptureImpl is an IO thread only object. See the comments in
38 // video_capture_impl_manager.cc for the lifetime of this object. 38 // video_capture_impl_manager.cc for the lifetime of this object.
39 // All methods must be called on the IO thread. 39 // All methods must be called on the IO thread.
40 // 40 //
41 // This is an internal class used by VideoCaptureImplManager only. Do not access 41 // This is an internal class used by VideoCaptureImplManager only. Do not access
42 // this directly. 42 // this directly.
43 class CONTENT_EXPORT VideoCaptureImpl 43 class CONTENT_EXPORT VideoCaptureImpl
mcasas 2015/08/21 03:57:25 final : public...?
emircan 2015/08/22 03:13:27 Tried, but the bots turn red as unit tests derive
44 : public VideoCaptureMessageFilter::Delegate { 44 : public VideoCaptureMessageFilter::Delegate {
45 public: 45 public:
46 ~VideoCaptureImpl() override; 46 ~VideoCaptureImpl() override;
47 47
48 VideoCaptureImpl(media::VideoCaptureSessionId session_id, 48 VideoCaptureImpl(media::VideoCaptureSessionId session_id,
49 VideoCaptureMessageFilter* filter); 49 VideoCaptureMessageFilter* filter);
50 50
51 // Start listening to IPC messages. 51 // Start listening to IPC messages.
52 void Init(); 52 void Init();
53 53
(...skipping 23 matching lines...) Expand all
77 77
78 media::VideoCaptureSessionId session_id() const { return session_id_; } 78 media::VideoCaptureSessionId session_id() const { return session_id_; }
79 79
80 private: 80 private:
81 friend class VideoCaptureImplTest; 81 friend class VideoCaptureImplTest;
82 friend class MockVideoCaptureImpl; 82 friend class MockVideoCaptureImpl;
83 83
84 // Carries a shared memory for transferring video frames from browser to 84 // Carries a shared memory for transferring video frames from browser to
85 // renderer. 85 // renderer.
86 class ClientBuffer; 86 class ClientBuffer;
87 // Carries GpuMemoryBuffers for transferring video frames from browser to
88 // renderer.
89 class ClientGpuMemoryBuffer;
87 90
88 // VideoCaptureMessageFilter::Delegate interface. 91 // VideoCaptureMessageFilter::Delegate interface.
89 void OnBufferCreated(base::SharedMemoryHandle handle, 92 void OnBufferCreated(
mcasas 2015/08/21 03:57:25 Don't change the indent.
emircan 2015/08/22 03:13:26 Done.
90 int length, 93 base::SharedMemoryHandle handle,
91 int buffer_id) override; 94 int length,
95 int buffer_id) override;
96 void OnGpuMemoryBufferCreated(
97 const std::vector<gfx::GpuMemoryBufferHandle>& gmb_handles,
98 const gfx::Size& size,
99 int buffer_id) override;
92 void OnBufferDestroyed(int buffer_id) override; 100 void OnBufferDestroyed(int buffer_id) override;
93 void OnBufferReceived(int buffer_id, 101 void OnBufferReceived(
94 base::TimeTicks timestamp, 102 int buffer_id,
95 const base::DictionaryValue& metadata, 103 base::TimeTicks timestamp,
96 media::VideoPixelFormat pixel_format, 104 const base::DictionaryValue& metadata,
97 media::VideoFrame::StorageType storage_type, 105 media::VideoPixelFormat pixel_format,
98 const gfx::Size& coded_size, 106 media::VideoFrame::StorageType storage_type,
99 const gfx::Rect& visible_rect, 107 const gfx::Size& coded_size,
100 const gpu::MailboxHolder& mailbox_holder) override; 108 const gfx::Rect& visible_rect,
109 const std::vector<gpu::MailboxHolder>& mailbox_holders) override;
101 void OnStateChanged(VideoCaptureState state) override; 110 void OnStateChanged(VideoCaptureState state) override;
102 void OnDeviceSupportedFormatsEnumerated( 111 void OnDeviceSupportedFormatsEnumerated(
103 const media::VideoCaptureFormats& supported_formats) override; 112 const media::VideoCaptureFormats& supported_formats) override;
104 void OnDeviceFormatsInUseReceived( 113 void OnDeviceFormatsInUseReceived(
105 const media::VideoCaptureFormats& formats_in_use) override; 114 const media::VideoCaptureFormats& formats_in_use) override;
106 void OnDelegateAdded(int32 device_id) override; 115 void OnDelegateAdded(int32 device_id) override;
107 116
108 // Sends an IPC message to browser process when all clients are done with the 117 // Sends an IPC message to browser process when all clients are done with the
109 // buffer. 118 // buffer.
110 void OnClientBufferFinished(int buffer_id, 119 void OnClientBufferFinished(
111 const scoped_refptr<ClientBuffer>& buffer, 120 int buffer_id,
112 uint32 release_sync_point, 121 const scoped_refptr<ClientBuffer>& buffer,
113 double consumer_resource_utilization); 122 uint32 release_sync_point,
123 double consumer_resource_utilization);
124 void OnClientGpuMemoryBufferFinished(
125 int buffer_id,
126 const scoped_refptr<ClientGpuMemoryBuffer>& gpu_memory_buffer,
127 uint32 release_sync_point,
128 double consumer_resource_utilization);
114 129
115 void StopDevice(); 130 void StopDevice();
116 void RestartCapture(); 131 void RestartCapture();
117 void StartCaptureInternal(); 132 void StartCaptureInternal();
118 133
119 virtual void Send(IPC::Message* message); 134 virtual void Send(IPC::Message* message);
120 135
121 // Helpers. 136 // Helpers.
122 // Called (by an unknown thread) when all consumers are done with a VideoFrame 137 // Called (by an unknown thread) when all consumers are done with a VideoFrame
123 // and its ref-count has gone to zero. This helper function grabs the 138 // and its ref-count has gone to zero. This helper function grabs the
(...skipping 16 matching lines...) Expand all
140 const int session_id_; 155 const int session_id_;
141 156
142 // Vector of callbacks to be notified of device format enumerations, used only 157 // Vector of callbacks to be notified of device format enumerations, used only
143 // on IO Thread. 158 // on IO Thread.
144 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_; 159 std::vector<VideoCaptureDeviceFormatsCB> device_formats_cb_queue_;
145 // Vector of callbacks to be notified of a device's in use capture format(s), 160 // Vector of callbacks to be notified of a device's in use capture format(s),
146 // used only on IO Thread. 161 // used only on IO Thread.
147 std::vector<VideoCaptureDeviceFormatsCB> device_formats_in_use_cb_queue_; 162 std::vector<VideoCaptureDeviceFormatsCB> device_formats_in_use_cb_queue_;
148 163
149 // Buffers available for sending to the client. 164 // Buffers available for sending to the client.
150 typedef std::map<int32, scoped_refptr<ClientBuffer> > ClientBufferMap; 165 typedef std::map<int32, scoped_refptr<ClientBuffer>> ClientBufferMap;
151 ClientBufferMap client_buffers_; 166 ClientBufferMap client_buffers_;
167 typedef std::map<int32, scoped_refptr<ClientGpuMemoryBuffer>>
168 ClientGpuMemoryBuffersMap;
169 ClientGpuMemoryBuffersMap client_gmb_buffers_;
152 170
153 // Track information for the video capture client, consisting of parameters 171 // Track information for the video capture client, consisting of parameters
154 // for capturing and callbacks to the client. 172 // for capturing and callbacks to the client.
155 media::VideoCaptureParams client_params_; 173 media::VideoCaptureParams client_params_;
156 VideoCaptureStateUpdateCB state_update_cb_; 174 VideoCaptureStateUpdateCB state_update_cb_;
157 VideoCaptureDeliverFrameCB deliver_frame_cb_; 175 VideoCaptureDeliverFrameCB deliver_frame_cb_;
158 176
159 // The device's first captured frame timestamp sent from browser process side. 177 // The device's first captured frame timestamp sent from browser process side.
160 base::TimeTicks first_frame_timestamp_; 178 base::TimeTicks first_frame_timestamp_;
161 179
162 // State of this VideoCaptureImpl. 180 // State of this VideoCaptureImpl.
163 VideoCaptureState state_; 181 VideoCaptureState state_;
164 182
165 // IO message loop reference for checking correct class operation. 183 // IO message loop reference for checking correct class operation.
166 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 184 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
167 185
168 // WeakPtrFactory pointing back to |this| object, for use with 186 // WeakPtrFactory pointing back to |this| object, for use with
169 // media::VideoFrames constructed in OnBufferReceived() from buffers cached 187 // media::VideoFrames constructed in OnBufferReceived() from buffers cached
170 // in |client_buffers_|. 188 // in |client_buffers_|.
171 // NOTE: Weak pointers must be invalidated before all other member variables. 189 // NOTE: Weak pointers must be invalidated before all other member variables.
172 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_; 190 base::WeakPtrFactory<VideoCaptureImpl> weak_factory_;
173 191
174 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl); 192 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl);
175 }; 193 };
176 194
177 } // namespace content 195 } // namespace content
178 196
179 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_ 197 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698