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

Side by Side Diff: trunk/src/content/browser/renderer_host/media/video_capture_device_impl.cc

Issue 132233058: Revert 247164 "Implement browser-side logging to WebRtc log" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/renderer_host/media/video_capture_device_impl.h" 5 #include "content/browser/renderer_host/media/video_capture_device_impl.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_forward.h" 9 #include "base/callback_forward.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 capture_size_updated_ = true; 149 capture_size_updated_ = true;
150 } 150 }
151 } 151 }
152 152
153 void ThreadSafeCaptureOracle::Stop() { 153 void ThreadSafeCaptureOracle::Stop() {
154 base::AutoLock guard(lock_); 154 base::AutoLock guard(lock_);
155 client_.reset(); 155 client_.reset();
156 } 156 }
157 157
158 void ThreadSafeCaptureOracle::ReportError(const std::string& reason) { 158 void ThreadSafeCaptureOracle::ReportError() {
159 base::AutoLock guard(lock_); 159 base::AutoLock guard(lock_);
160 if (client_) 160 if (client_)
161 client_->OnError(reason); 161 client_->OnError();
162 } 162 }
163 163
164 void ThreadSafeCaptureOracle::DidCaptureFrame( 164 void ThreadSafeCaptureOracle::DidCaptureFrame(
165 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer, 165 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> buffer,
166 int frame_number, 166 int frame_number,
167 base::TimeTicks timestamp, 167 base::TimeTicks timestamp,
168 bool success) { 168 bool success) {
169 base::AutoLock guard(lock_); 169 base::AutoLock guard(lock_);
170 TRACE_EVENT_ASYNC_END2("mirroring", "Capture", buffer.get(), 170 TRACE_EVENT_ASYNC_END2("mirroring", "Capture", buffer.get(),
171 "success", success, 171 "success", success,
(...skipping 17 matching lines...) Expand all
189 const media::VideoCaptureParams& params, 189 const media::VideoCaptureParams& params,
190 scoped_ptr<media::VideoCaptureDevice::Client> client) { 190 scoped_ptr<media::VideoCaptureDevice::Client> client) {
191 DCHECK(thread_checker_.CalledOnValidThread()); 191 DCHECK(thread_checker_.CalledOnValidThread());
192 192
193 if (state_ != kIdle) { 193 if (state_ != kIdle) {
194 DVLOG(1) << "Allocate() invoked when not in state Idle."; 194 DVLOG(1) << "Allocate() invoked when not in state Idle.";
195 return; 195 return;
196 } 196 }
197 197
198 if (params.requested_format.frame_rate <= 0) { 198 if (params.requested_format.frame_rate <= 0) {
199 std::string error_msg = base::StringPrintf( 199 DVLOG(1) << "invalid frame_rate: " << params.requested_format.frame_rate;
200 "invalid frame_rate: %d", params.requested_format.frame_rate); 200 client->OnError();
201 DVLOG(1) << error_msg;
202 client->OnError(error_msg);
203 return; 201 return;
204 } 202 }
205 203
206 if (params.requested_format.frame_size.width() < kMinFrameWidth || 204 if (params.requested_format.frame_size.width() < kMinFrameWidth ||
207 params.requested_format.frame_size.height() < kMinFrameHeight) { 205 params.requested_format.frame_size.height() < kMinFrameHeight) {
208 std::string error_msg = 206 DVLOG(1) << "invalid frame size: "
209 "invalid frame size: " + params.requested_format.frame_size.ToString(); 207 << params.requested_format.frame_size.ToString();
210 DVLOG(1) << error_msg; 208 client->OnError();
211 client->OnError(error_msg);
212 return; 209 return;
213 } 210 }
214 211
215 base::TimeDelta capture_period = base::TimeDelta::FromMicroseconds( 212 base::TimeDelta capture_period = base::TimeDelta::FromMicroseconds(
216 1000000.0 / params.requested_format.frame_rate + 0.5); 213 1000000.0 / params.requested_format.frame_rate + 0.5);
217 214
218 scoped_ptr<VideoCaptureOracle> oracle( 215 scoped_ptr<VideoCaptureOracle> oracle(
219 new VideoCaptureOracle(capture_period, 216 new VideoCaptureOracle(capture_period,
220 kAcceleratedSubscriberIsSupported)); 217 kAcceleratedSubscriberIsSupported));
221 oracle_proxy_ = 218 oracle_proxy_ =
(...skipping 26 matching lines...) Expand all
248 BrowserThread::PostTask( 245 BrowserThread::PostTask(
249 BrowserThread::UI, FROM_HERE, base::Bind( 246 BrowserThread::UI, FROM_HERE, base::Bind(
250 &VideoCaptureMachine::Stop, 247 &VideoCaptureMachine::Stop,
251 base::Unretained(capture_machine_.get()), 248 base::Unretained(capture_machine_.get()),
252 base::Bind(&base::DoNothing))); 249 base::Bind(&base::DoNothing)));
253 } 250 }
254 251
255 void VideoCaptureDeviceImpl::CaptureStarted(bool success) { 252 void VideoCaptureDeviceImpl::CaptureStarted(bool success) {
256 DCHECK(thread_checker_.CalledOnValidThread()); 253 DCHECK(thread_checker_.CalledOnValidThread());
257 if (!success) { 254 if (!success) {
258 std::string reason("Failed to start capture machine."); 255 DVLOG(1) << "Failed to start capture machine.";
259 DVLOG(1) << reason; 256 Error();
260 Error(reason);
261 } 257 }
262 } 258 }
263 259
264 VideoCaptureDeviceImpl::VideoCaptureDeviceImpl( 260 VideoCaptureDeviceImpl::VideoCaptureDeviceImpl(
265 scoped_ptr<VideoCaptureMachine> capture_machine) 261 scoped_ptr<VideoCaptureMachine> capture_machine)
266 : state_(kIdle), 262 : state_(kIdle),
267 capture_machine_(capture_machine.Pass()) {} 263 capture_machine_(capture_machine.Pass()) {}
268 264
269 VideoCaptureDeviceImpl::~VideoCaptureDeviceImpl() { 265 VideoCaptureDeviceImpl::~VideoCaptureDeviceImpl() {
270 // If capture_machine is not NULL, then we need to return to the UI thread to 266 // If capture_machine is not NULL, then we need to return to the UI thread to
(...skipping 17 matching lines...) Expand all
288 static const char* kStateNames[] = { 284 static const char* kStateNames[] = {
289 "Idle", "Allocated", "Capturing", "Error" 285 "Idle", "Allocated", "Capturing", "Error"
290 }; 286 };
291 DVLOG(1) << "State change: " << kStateNames[state_] 287 DVLOG(1) << "State change: " << kStateNames[state_]
292 << " --> " << kStateNames[next_state]; 288 << " --> " << kStateNames[next_state];
293 #endif 289 #endif
294 290
295 state_ = next_state; 291 state_ = next_state;
296 } 292 }
297 293
298 void VideoCaptureDeviceImpl::Error(const std::string& reason) { 294 void VideoCaptureDeviceImpl::Error() {
299 DCHECK(thread_checker_.CalledOnValidThread()); 295 DCHECK(thread_checker_.CalledOnValidThread());
300 296
301 if (state_ == kIdle) 297 if (state_ == kIdle)
302 return; 298 return;
303 299
304 if (oracle_proxy_) 300 if (oracle_proxy_)
305 oracle_proxy_->ReportError(reason); 301 oracle_proxy_->ReportError();
306 302
307 StopAndDeAllocate(); 303 StopAndDeAllocate();
308 TransitionStateTo(kError); 304 TransitionStateTo(kError);
309 } 305 }
310 306
311 } // namespace content 307 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698