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

Side by Side Diff: content/renderer/media/video_capture_module_impl.cc

Issue 8304017: enable video capture to support sharing across multiple renderer processes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/video_capture_module_impl.h ('k') | media/video/capture/video_capture.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "content/renderer/media/video_capture_module_impl.h" 5 #include "content/renderer/media/video_capture_module_impl.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "content/renderer/media/video_capture_impl_manager.h" 9 #include "content/renderer/media/video_capture_impl_manager.h"
10 10
11 VideoCaptureModuleImpl::VideoCaptureModuleImpl( 11 VideoCaptureModuleImpl::VideoCaptureModuleImpl(
12 const media::VideoCaptureSessionId id, 12 const media::VideoCaptureSessionId id,
13 VideoCaptureImplManager* vc_manager) 13 VideoCaptureImplManager* vc_manager)
14 : webrtc::videocapturemodule::VideoCaptureImpl(id), 14 : webrtc::videocapturemodule::VideoCaptureImpl(id),
15 session_id_(id), 15 session_id_(id),
16 thread_("VideoCaptureModuleImpl"), 16 thread_("VideoCaptureModuleImpl"),
17 vc_manager_(vc_manager), 17 vc_manager_(vc_manager),
18 state_(media::VideoCapture::kStopped), 18 state_(media::VideoCapture::kStopped),
19 got_first_frame_(false),
20 width_(-1), 19 width_(-1),
21 height_(-1), 20 height_(-1),
22 frame_rate_(-1), 21 frame_rate_(-1),
23 video_type_(webrtc::kVideoI420), 22 video_type_(webrtc::kVideoI420),
24 capture_engine_(NULL), 23 capture_engine_(NULL),
25 pending_start_(false), 24 pending_start_(false),
26 ref_count_(0) { 25 ref_count_(0) {
27 DCHECK(vc_manager_); 26 DCHECK(vc_manager_);
28 Init(); 27 Init();
29 } 28 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 width_ = capability.width; 152 width_ = capability.width;
154 height_ = capability.height; 153 height_ = capability.height;
155 frame_rate_ = capability.maxFPS; 154 frame_rate_ = capability.maxFPS;
156 state_ = media::VideoCapture::kStarted; 155 state_ = media::VideoCapture::kStarted;
157 156
158 media::VideoCapture::VideoCaptureCapability cap; 157 media::VideoCapture::VideoCaptureCapability cap;
159 cap.width = capability.width; 158 cap.width = capability.width;
160 cap.height = capability.height; 159 cap.height = capability.height;
161 cap.max_fps = capability.maxFPS; 160 cap.max_fps = capability.maxFPS;
162 cap.raw_type = media::VideoFrame::I420; 161 cap.raw_type = media::VideoFrame::I420;
163 cap.resolution_fixed = true;
164 capture_engine_->StartCapture(this, cap); 162 capture_engine_->StartCapture(this, cap);
165 } 163 }
166 164
167 void VideoCaptureModuleImpl::StopCaptureOnCaptureThread() { 165 void VideoCaptureModuleImpl::StopCaptureOnCaptureThread() {
168 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 166 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
169 167
170 if (pending_start_) { 168 if (pending_start_) {
171 VLOG(1) << "Got a StopCapture with one pending start!!! "; 169 VLOG(1) << "Got a StopCapture with one pending start!!! ";
172 pending_start_ = false; 170 pending_start_ = false;
173 return; 171 return;
(...skipping 10 matching lines...) Expand all
184 capture_engine_->StopCapture(this); 182 capture_engine_->StopCapture(this);
185 return; 183 return;
186 } 184 }
187 185
188 void VideoCaptureModuleImpl::OnStoppedOnCaptureThread( 186 void VideoCaptureModuleImpl::OnStoppedOnCaptureThread(
189 media::VideoCapture* capture) { 187 media::VideoCapture* capture) {
190 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 188 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
191 189
192 VLOG(1) << "Capture Stopped!!! "; 190 VLOG(1) << "Capture Stopped!!! ";
193 state_ = media::VideoCapture::kStopped; 191 state_ = media::VideoCapture::kStopped;
194 got_first_frame_ = false;
195 width_ = -1; 192 width_ = -1;
196 height_ = -1; 193 height_ = -1;
197 frame_rate_ = -1; 194 frame_rate_ = -1;
198 195
199 if (pending_start_) { 196 if (pending_start_) {
200 VLOG(1) << "restart pending start "; 197 VLOG(1) << "restart pending start ";
201 pending_start_ = false; 198 pending_start_ = false;
202 StartCaptureInternal(pending_cap_); 199 StartCaptureInternal(pending_cap_);
203 } 200 }
204 } 201 }
205 202
206 void VideoCaptureModuleImpl::OnBufferReadyOnCaptureThread( 203 void VideoCaptureModuleImpl::OnBufferReadyOnCaptureThread(
207 media::VideoCapture* capture, 204 media::VideoCapture* capture,
208 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) { 205 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
209 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 206 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
207 DCHECK_GE(buf->width, static_cast<int>(width_));
208 DCHECK_GE(buf->height, static_cast<int>(height_));
210 209
211 if (state_ != media::VideoCapture::kStarted) 210 if (state_ != media::VideoCapture::kStarted)
212 return; 211 return;
213 212
214 if (!got_first_frame_) {
215 got_first_frame_ = true;
216 start_time_ = buf->timestamp;
217 }
218
219 frameInfo_.width = buf->width; 213 frameInfo_.width = buf->width;
220 frameInfo_.height = buf->height; 214 frameInfo_.height = buf->height;
221 frameInfo_.rawType = video_type_; 215 frameInfo_.rawType = video_type_;
222 216
223 IncomingFrame( 217 IncomingFrame(
224 static_cast<WebRtc_UWord8*>(buf->memory_pointer), 218 static_cast<WebRtc_UWord8*>(buf->memory_pointer),
225 static_cast<WebRtc_Word32>(buf->buffer_size), 219 static_cast<WebRtc_Word32>(buf->buffer_size),
226 frameInfo_, 220 frameInfo_,
227 static_cast<WebRtc_Word64>( 221 static_cast<WebRtc_Word64>(
228 (buf->timestamp - start_time_).InMicroseconds())); 222 (buf->timestamp - start_time_).InMicroseconds()));
229 223
230 capture->FeedBuffer(buf); 224 capture->FeedBuffer(buf);
231 } 225 }
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_module_impl.h ('k') | media/video/capture/video_capture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698