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

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

Issue 140633004: Reland CL to implement browser-side logging to WebRtc log. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: These are the changes that should fix crbug.com/338848 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() { 158 void ThreadSafeCaptureOracle::ReportError(const std::string& reason) {
159 base::AutoLock guard(lock_); 159 base::AutoLock guard(lock_);
160 if (client_) 160 if (client_)
161 client_->OnError(); 161 client_->OnError(reason);
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 DVLOG(1) << "invalid frame_rate: " << params.requested_format.frame_rate; 199 std::string error_msg = base::StringPrintf(
200 client->OnError(); 200 "invalid frame_rate: %d", params.requested_format.frame_rate);
201 DVLOG(1) << error_msg;
202 client->OnError(error_msg);
201 return; 203 return;
202 } 204 }
203 205
204 if (params.requested_format.frame_size.width() < kMinFrameWidth || 206 if (params.requested_format.frame_size.width() < kMinFrameWidth ||
205 params.requested_format.frame_size.height() < kMinFrameHeight) { 207 params.requested_format.frame_size.height() < kMinFrameHeight) {
206 DVLOG(1) << "invalid frame size: " 208 std::string error_msg =
207 << params.requested_format.frame_size.ToString(); 209 "invalid frame size: " + params.requested_format.frame_size.ToString();
208 client->OnError(); 210 DVLOG(1) << error_msg;
211 client->OnError(error_msg);
209 return; 212 return;
210 } 213 }
211 214
212 base::TimeDelta capture_period = base::TimeDelta::FromMicroseconds( 215 base::TimeDelta capture_period = base::TimeDelta::FromMicroseconds(
213 1000000.0 / params.requested_format.frame_rate + 0.5); 216 1000000.0 / params.requested_format.frame_rate + 0.5);
214 217
215 scoped_ptr<VideoCaptureOracle> oracle( 218 scoped_ptr<VideoCaptureOracle> oracle(
216 new VideoCaptureOracle(capture_period, 219 new VideoCaptureOracle(capture_period,
217 kAcceleratedSubscriberIsSupported)); 220 kAcceleratedSubscriberIsSupported));
218 oracle_proxy_ = 221 oracle_proxy_ =
(...skipping 26 matching lines...) Expand all
245 BrowserThread::PostTask( 248 BrowserThread::PostTask(
246 BrowserThread::UI, FROM_HERE, base::Bind( 249 BrowserThread::UI, FROM_HERE, base::Bind(
247 &VideoCaptureMachine::Stop, 250 &VideoCaptureMachine::Stop,
248 base::Unretained(capture_machine_.get()), 251 base::Unretained(capture_machine_.get()),
249 base::Bind(&base::DoNothing))); 252 base::Bind(&base::DoNothing)));
250 } 253 }
251 254
252 void VideoCaptureDeviceImpl::CaptureStarted(bool success) { 255 void VideoCaptureDeviceImpl::CaptureStarted(bool success) {
253 DCHECK(thread_checker_.CalledOnValidThread()); 256 DCHECK(thread_checker_.CalledOnValidThread());
254 if (!success) { 257 if (!success) {
255 DVLOG(1) << "Failed to start capture machine."; 258 std::string reason("Failed to start capture machine.");
256 Error(); 259 DVLOG(1) << reason;
260 Error(reason);
257 } 261 }
258 } 262 }
259 263
260 VideoCaptureDeviceImpl::VideoCaptureDeviceImpl( 264 VideoCaptureDeviceImpl::VideoCaptureDeviceImpl(
261 scoped_ptr<VideoCaptureMachine> capture_machine) 265 scoped_ptr<VideoCaptureMachine> capture_machine)
262 : state_(kIdle), 266 : state_(kIdle),
263 capture_machine_(capture_machine.Pass()) {} 267 capture_machine_(capture_machine.Pass()) {}
264 268
265 VideoCaptureDeviceImpl::~VideoCaptureDeviceImpl() { 269 VideoCaptureDeviceImpl::~VideoCaptureDeviceImpl() {
266 // If capture_machine is not NULL, then we need to return to the UI thread to 270 // If capture_machine is not NULL, then we need to return to the UI thread to
(...skipping 17 matching lines...) Expand all
284 static const char* kStateNames[] = { 288 static const char* kStateNames[] = {
285 "Idle", "Allocated", "Capturing", "Error" 289 "Idle", "Allocated", "Capturing", "Error"
286 }; 290 };
287 DVLOG(1) << "State change: " << kStateNames[state_] 291 DVLOG(1) << "State change: " << kStateNames[state_]
288 << " --> " << kStateNames[next_state]; 292 << " --> " << kStateNames[next_state];
289 #endif 293 #endif
290 294
291 state_ = next_state; 295 state_ = next_state;
292 } 296 }
293 297
294 void VideoCaptureDeviceImpl::Error() { 298 void VideoCaptureDeviceImpl::Error(const std::string& reason) {
295 DCHECK(thread_checker_.CalledOnValidThread()); 299 DCHECK(thread_checker_.CalledOnValidThread());
296 300
297 if (state_ == kIdle) 301 if (state_ == kIdle)
298 return; 302 return;
299 303
300 if (oracle_proxy_) 304 if (oracle_proxy_)
301 oracle_proxy_->ReportError(); 305 oracle_proxy_->ReportError(reason);
302 306
303 StopAndDeAllocate(); 307 StopAndDeAllocate();
304 TransitionStateTo(kError); 308 TransitionStateTo(kError);
305 } 309 }
306 310
307 } // namespace content 311 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698