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

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

Issue 1829193003: Request frame for new sinks from MediaStreamVideoTrack (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: miu@ nit. Created 4 years, 9 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/mock_media_stream_video_source.h" 5 #include "content/renderer/media/mock_media_stream_video_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 MockMediaStreamVideoSource::MockMediaStreamVideoSource( 13 MockMediaStreamVideoSource::MockMediaStreamVideoSource(
14 bool manual_get_supported_formats) 14 bool manual_get_supported_formats)
15 : MockMediaStreamVideoSource(manual_get_supported_formats, false) {}
16
17 MockMediaStreamVideoSource::MockMediaStreamVideoSource(
18 bool manual_get_supported_formats,
19 bool respond_to_request_refresh_frame)
15 : manual_get_supported_formats_(manual_get_supported_formats), 20 : manual_get_supported_formats_(manual_get_supported_formats),
21 respond_to_request_refresh_frame_(respond_to_request_refresh_frame),
16 max_requested_height_(0), 22 max_requested_height_(0),
17 max_requested_width_(0), 23 max_requested_width_(0),
18 max_requested_frame_rate_(0.0), 24 max_requested_frame_rate_(0.0),
19 attempted_to_start_(false) { 25 attempted_to_start_(false) {
20 supported_formats_.push_back(media::VideoCaptureFormat( 26 supported_formats_.push_back(media::VideoCaptureFormat(
21 gfx::Size(MediaStreamVideoSource::kDefaultWidth, 27 gfx::Size(MediaStreamVideoSource::kDefaultWidth,
22 MediaStreamVideoSource::kDefaultHeight), 28 MediaStreamVideoSource::kDefaultHeight),
23 MediaStreamVideoSource::kDefaultFrameRate, 29 MediaStreamVideoSource::kDefaultFrameRate, media::PIXEL_FORMAT_I420));
24 media::PIXEL_FORMAT_I420));
25 } 30 }
26 31
27 MockMediaStreamVideoSource::~MockMediaStreamVideoSource() {} 32 MockMediaStreamVideoSource::~MockMediaStreamVideoSource() {}
28 33
29 void MockMediaStreamVideoSource::StartMockedSource() { 34 void MockMediaStreamVideoSource::StartMockedSource() {
30 DCHECK(attempted_to_start_); 35 DCHECK(attempted_to_start_);
31 attempted_to_start_ = false; 36 attempted_to_start_ = false;
32 OnStartDone(MEDIA_DEVICE_OK); 37 OnStartDone(MEDIA_DEVICE_OK);
33 } 38 }
34 39
35 void MockMediaStreamVideoSource::FailToStartMockedSource() { 40 void MockMediaStreamVideoSource::FailToStartMockedSource() {
36 DCHECK(attempted_to_start_); 41 DCHECK(attempted_to_start_);
37 attempted_to_start_ = false; 42 attempted_to_start_ = false;
38 OnStartDone(MEDIA_DEVICE_TRACK_START_FAILURE); 43 OnStartDone(MEDIA_DEVICE_TRACK_START_FAILURE);
39 } 44 }
40 45
41 void MockMediaStreamVideoSource::CompleteGetSupportedFormats() { 46 void MockMediaStreamVideoSource::CompleteGetSupportedFormats() {
42 DCHECK(!formats_callback_.is_null()); 47 DCHECK(!formats_callback_.is_null());
43 base::ResetAndReturn(&formats_callback_).Run(supported_formats_); 48 base::ResetAndReturn(&formats_callback_).Run(supported_formats_);
44 } 49 }
45 50
51 void MockMediaStreamVideoSource::RequestRefreshFrame() {
52 DCHECK(!frame_callback_.is_null());
53 if (respond_to_request_refresh_frame_) {
54 const scoped_refptr<media::VideoFrame> frame =
55 media::VideoFrame::CreateColorFrame(format_.frame_size, 0, 0, 0,
56 base::TimeDelta());
57 io_task_runner()->PostTask(
58 FROM_HERE, base::Bind(frame_callback_, frame, base::TimeTicks()));
59 }
60 }
61
46 void MockMediaStreamVideoSource::GetCurrentSupportedFormats( 62 void MockMediaStreamVideoSource::GetCurrentSupportedFormats(
47 int max_requested_height, 63 int max_requested_height,
48 int max_requested_width, 64 int max_requested_width,
49 double max_requested_frame_rate, 65 double max_requested_frame_rate,
50 const VideoCaptureDeviceFormatsCB& callback) { 66 const VideoCaptureDeviceFormatsCB& callback) {
51 DCHECK(formats_callback_.is_null()); 67 DCHECK(formats_callback_.is_null());
52 max_requested_height_ = max_requested_height; 68 max_requested_height_ = max_requested_height;
53 max_requested_width_ = max_requested_width; 69 max_requested_width_ = max_requested_width;
54 max_requested_frame_rate_ = max_requested_frame_rate; 70 max_requested_frame_rate_ = max_requested_frame_rate;
55 71
(...skipping 18 matching lines...) Expand all
74 } 90 }
75 91
76 void MockMediaStreamVideoSource::DeliverVideoFrame( 92 void MockMediaStreamVideoSource::DeliverVideoFrame(
77 const scoped_refptr<media::VideoFrame>& frame) { 93 const scoped_refptr<media::VideoFrame>& frame) {
78 DCHECK(!frame_callback_.is_null()); 94 DCHECK(!frame_callback_.is_null());
79 io_task_runner()->PostTask( 95 io_task_runner()->PostTask(
80 FROM_HERE, base::Bind(frame_callback_, frame, base::TimeTicks())); 96 FROM_HERE, base::Bind(frame_callback_, frame, base::TimeTicks()));
81 } 97 }
82 98
83 } // namespace content 99 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/mock_media_stream_video_source.h ('k') | media/base/video_capturer_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698