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

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

Issue 2609863004: Pass camera facing to WebKit (Closed)
Patch Set: use =default syntax Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/media_stream_video_capturer_source.h" 5 #include "content/renderer/media/media_stream_video_capturer_source.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 int max_requested_height, 209 int max_requested_height,
210 double max_requested_frame_rate, 210 double max_requested_frame_rate,
211 const VideoCaptureDeviceFormatsCB& callback) override; 211 const VideoCaptureDeviceFormatsCB& callback) override;
212 void StartCapture(const media::VideoCaptureParams& params, 212 void StartCapture(const media::VideoCaptureParams& params,
213 const VideoCaptureDeliverFrameCB& new_frame_callback, 213 const VideoCaptureDeliverFrameCB& new_frame_callback,
214 const RunningCallback& running_callback) override; 214 const RunningCallback& running_callback) override;
215 void RequestRefreshFrame() override; 215 void RequestRefreshFrame() override;
216 void MaybeSuspend() override; 216 void MaybeSuspend() override;
217 void Resume() override; 217 void Resume() override;
218 void StopCapture() override; 218 void StopCapture() override;
219 media::VideoFacingMode GetVideoFacing() const override;
219 220
220 private: 221 private:
221 void OnStateUpdate(VideoCaptureState state); 222 void OnStateUpdate(VideoCaptureState state);
222 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats); 223 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats);
223 void OnDeviceSupportedFormatsEnumerated( 224 void OnDeviceSupportedFormatsEnumerated(
224 const media::VideoCaptureFormats& formats); 225 const media::VideoCaptureFormats& formats);
225 226
226 // |session_id_| identifies the capture device used for this capture session. 227 // |session_id_| identifies the capture device used for this capture session.
227 const media::VideoCaptureSessionId session_id_; 228 const media::VideoCaptureSessionId session_id_;
228 229
230 const VideoFacingMode facing_;
231
229 VideoCaptureImplManager* const manager_; 232 VideoCaptureImplManager* const manager_;
230 233
231 const base::Closure release_device_cb_; 234 const base::Closure release_device_cb_;
232 235
233 // Indicates if we are capturing generated content, e.g. Tab or Desktop. 236 // Indicates if we are capturing generated content, e.g. Tab or Desktop.
234 const bool is_content_capture_; 237 const bool is_content_capture_;
235 238
236 // These two are valid between StartCapture() and StopCapture(). 239 // These two are valid between StartCapture() and StopCapture().
237 // |running_call_back_| is run when capture is successfully started, and when 240 // |running_call_back_| is run when capture is successfully started, and when
238 // it is stopped or error happens. 241 // it is stopped or error happens.
(...skipping 10 matching lines...) Expand all
249 base::WeakPtrFactory<LocalVideoCapturerSource> weak_factory_; 252 base::WeakPtrFactory<LocalVideoCapturerSource> weak_factory_;
250 253
251 DISALLOW_COPY_AND_ASSIGN(LocalVideoCapturerSource); 254 DISALLOW_COPY_AND_ASSIGN(LocalVideoCapturerSource);
252 }; 255 };
253 256
254 } // namespace 257 } // namespace
255 258
256 LocalVideoCapturerSource::LocalVideoCapturerSource( 259 LocalVideoCapturerSource::LocalVideoCapturerSource(
257 const StreamDeviceInfo& device_info) 260 const StreamDeviceInfo& device_info)
258 : session_id_(device_info.session_id), 261 : session_id_(device_info.session_id),
262 facing_(device_info.device.video_facing),
259 manager_(RenderThreadImpl::current()->video_capture_impl_manager()), 263 manager_(RenderThreadImpl::current()->video_capture_impl_manager()),
260 release_device_cb_(manager_->UseDevice(session_id_)), 264 release_device_cb_(manager_->UseDevice(session_id_)),
261 is_content_capture_(IsContentVideoCaptureDevice(device_info)), 265 is_content_capture_(IsContentVideoCaptureDevice(device_info)),
262 weak_factory_(this) { 266 weak_factory_(this) {
263 DCHECK(RenderThreadImpl::current()); 267 DCHECK(RenderThreadImpl::current());
264 } 268 }
265 269
266 LocalVideoCapturerSource::~LocalVideoCapturerSource() { 270 LocalVideoCapturerSource::~LocalVideoCapturerSource() {
267 DCHECK(thread_checker_.CalledOnValidThread()); 271 DCHECK(thread_checker_.CalledOnValidThread());
268 release_device_cb_.Run(); 272 release_device_cb_.Run();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 DVLOG(3) << __func__; 344 DVLOG(3) << __func__;
341 DCHECK(thread_checker_.CalledOnValidThread()); 345 DCHECK(thread_checker_.CalledOnValidThread());
342 // Immediately make sure we don't provide more frames. 346 // Immediately make sure we don't provide more frames.
343 if (!stop_capture_cb_.is_null()) 347 if (!stop_capture_cb_.is_null())
344 base::ResetAndReturn(&stop_capture_cb_).Run(); 348 base::ResetAndReturn(&stop_capture_cb_).Run();
345 running_callback_.Reset(); 349 running_callback_.Reset();
346 // Invalidate any potential format enumerations going on. 350 // Invalidate any potential format enumerations going on.
347 formats_enumerated_callback_.Reset(); 351 formats_enumerated_callback_.Reset();
348 } 352 }
349 353
354 media::VideoFacingMode LocalVideoCapturerSource::GetVideoFacing() const {
355 switch (facing_) {
356 case VideoFacingMode::MEDIA_VIDEO_FACING_USER:
357 return media::VideoFacingMode::USER;
358 case VideoFacingMode::MEDIA_VIDEO_FACING_ENVIRONMENT:
359 return media::VideoFacingMode::ENVIRONMENT;
360 default:
miu 2017/01/10 22:14:23 Again, please do not use default clauses when proc
shenghao 2017/01/11 12:00:53 Done.
361 return media::VideoFacingMode::USER;
362 }
363 }
364
350 void LocalVideoCapturerSource::OnStateUpdate(VideoCaptureState state) { 365 void LocalVideoCapturerSource::OnStateUpdate(VideoCaptureState state) {
351 DVLOG(3) << __func__ << " state = " << state; 366 DVLOG(3) << __func__ << " state = " << state;
352 DCHECK(thread_checker_.CalledOnValidThread()); 367 DCHECK(thread_checker_.CalledOnValidThread());
353 if (running_callback_.is_null()) 368 if (running_callback_.is_null())
354 return; 369 return;
355 switch (state) { 370 switch (state) {
356 case VIDEO_CAPTURE_STATE_STARTED: 371 case VIDEO_CAPTURE_STATE_STARTED:
357 running_callback_.Run(true); 372 running_callback_.Run(true);
358 break; 373 break;
359 374
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 RenderFrame* render_frame) 448 RenderFrame* render_frame)
434 : RenderFrameObserver(render_frame), 449 : RenderFrameObserver(render_frame),
435 source_(new LocalVideoCapturerSource(device_info)) { 450 source_(new LocalVideoCapturerSource(device_info)) {
436 SetStopCallback(stop_callback); 451 SetStopCallback(stop_callback);
437 SetDeviceInfo(device_info); 452 SetDeviceInfo(device_info);
438 } 453 }
439 454
440 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { 455 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() {
441 } 456 }
442 457
458 media::VideoFacingMode MediaStreamVideoCapturerSource::GetVideoFacing() {
459 return source_->GetVideoFacing();
460 }
461
443 void MediaStreamVideoCapturerSource::RequestRefreshFrame() { 462 void MediaStreamVideoCapturerSource::RequestRefreshFrame() {
444 source_->RequestRefreshFrame(); 463 source_->RequestRefreshFrame();
445 } 464 }
446 465
447 void MediaStreamVideoCapturerSource::OnHasConsumers(bool has_consumers) { 466 void MediaStreamVideoCapturerSource::OnHasConsumers(bool has_consumers) {
448 if (has_consumers) 467 if (has_consumers)
449 source_->Resume(); 468 source_->Resume();
450 else 469 else
451 source_->MaybeSuspend(); 470 source_->MaybeSuspend();
452 } 471 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 StopSource(); 520 StopSource();
502 } 521 }
503 } 522 }
504 523
505 const char* 524 const char*
506 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const { 525 MediaStreamVideoCapturerSource::GetPowerLineFrequencyForTesting() const {
507 return kPowerLineFrequency; 526 return kPowerLineFrequency;
508 } 527 }
509 528
510 } // namespace content 529 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698