OLD | NEW |
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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 max_requested_height_(0), | 22 max_requested_height_(0), |
23 max_requested_width_(0), | 23 max_requested_width_(0), |
24 max_requested_frame_rate_(0.0), | 24 max_requested_frame_rate_(0.0), |
25 attempted_to_start_(false) { | 25 attempted_to_start_(false) { |
26 supported_formats_.push_back(media::VideoCaptureFormat( | 26 supported_formats_.push_back(media::VideoCaptureFormat( |
27 gfx::Size(MediaStreamVideoSource::kDefaultWidth, | 27 gfx::Size(MediaStreamVideoSource::kDefaultWidth, |
28 MediaStreamVideoSource::kDefaultHeight), | 28 MediaStreamVideoSource::kDefaultHeight), |
29 MediaStreamVideoSource::kDefaultFrameRate, media::PIXEL_FORMAT_I420)); | 29 MediaStreamVideoSource::kDefaultFrameRate, media::PIXEL_FORMAT_I420)); |
30 } | 30 } |
31 | 31 |
| 32 MockMediaStreamVideoSource::MockMediaStreamVideoSource( |
| 33 const media::VideoCaptureFormat& format, |
| 34 bool respond_to_request_refresh_frame) |
| 35 : format_(format), |
| 36 manual_get_supported_formats_(false), |
| 37 respond_to_request_refresh_frame_(respond_to_request_refresh_frame), |
| 38 max_requested_height_(format.frame_size.height()), |
| 39 max_requested_width_(format.frame_size.width()), |
| 40 max_requested_frame_rate_(format.frame_rate), |
| 41 attempted_to_start_(false) {} |
| 42 |
32 MockMediaStreamVideoSource::~MockMediaStreamVideoSource() {} | 43 MockMediaStreamVideoSource::~MockMediaStreamVideoSource() {} |
33 | 44 |
34 void MockMediaStreamVideoSource::StartMockedSource() { | 45 void MockMediaStreamVideoSource::StartMockedSource() { |
35 DCHECK(attempted_to_start_); | 46 DCHECK(attempted_to_start_); |
36 attempted_to_start_ = false; | 47 attempted_to_start_ = false; |
37 OnStartDone(MEDIA_DEVICE_OK); | 48 OnStartDone(MEDIA_DEVICE_OK); |
38 } | 49 } |
39 | 50 |
40 void MockMediaStreamVideoSource::FailToStartMockedSource() { | 51 void MockMediaStreamVideoSource::FailToStartMockedSource() { |
41 DCHECK(attempted_to_start_); | 52 DCHECK(attempted_to_start_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return; | 85 return; |
75 } | 86 } |
76 callback.Run(supported_formats_); | 87 callback.Run(supported_formats_); |
77 } | 88 } |
78 | 89 |
79 void MockMediaStreamVideoSource::StartSourceImpl( | 90 void MockMediaStreamVideoSource::StartSourceImpl( |
80 const media::VideoCaptureFormat& format, | 91 const media::VideoCaptureFormat& format, |
81 const blink::WebMediaConstraints& constraints, | 92 const blink::WebMediaConstraints& constraints, |
82 const VideoCaptureDeliverFrameCB& frame_callback) { | 93 const VideoCaptureDeliverFrameCB& frame_callback) { |
83 DCHECK(frame_callback_.is_null()); | 94 DCHECK(frame_callback_.is_null()); |
84 format_ = format; | 95 if (IsOldVideoConstraints()) |
| 96 format_ = format; |
| 97 |
85 attempted_to_start_ = true; | 98 attempted_to_start_ = true; |
86 frame_callback_ = frame_callback; | 99 frame_callback_ = frame_callback; |
87 } | 100 } |
88 | 101 |
89 void MockMediaStreamVideoSource::StopSourceImpl() { | 102 void MockMediaStreamVideoSource::StopSourceImpl() { |
90 } | 103 } |
91 | 104 |
| 105 base::Optional<media::VideoCaptureFormat> |
| 106 MockMediaStreamVideoSource::GetCurrentFormatImpl() const { |
| 107 return format_; |
| 108 } |
| 109 |
92 void MockMediaStreamVideoSource::DeliverVideoFrame( | 110 void MockMediaStreamVideoSource::DeliverVideoFrame( |
93 const scoped_refptr<media::VideoFrame>& frame) { | 111 const scoped_refptr<media::VideoFrame>& frame) { |
94 DCHECK(!frame_callback_.is_null()); | 112 DCHECK(!frame_callback_.is_null()); |
95 io_task_runner()->PostTask( | 113 io_task_runner()->PostTask( |
96 FROM_HERE, base::Bind(frame_callback_, frame, base::TimeTicks())); | 114 FROM_HERE, base::Bind(frame_callback_, frame, base::TimeTicks())); |
97 } | 115 } |
98 | 116 |
99 } // namespace content | 117 } // namespace content |
OLD | NEW |