Chromium Code Reviews| Index: webrtc/media/base/fakevideocapturer.h |
| diff --git a/webrtc/media/base/fakevideocapturer.h b/webrtc/media/base/fakevideocapturer.h |
| index 026bf80a7b15f0f83f94bf66a9fe52eb23bc7cd5..54eb258636848033658444dd8da44b92c65dcafe 100644 |
| --- a/webrtc/media/base/fakevideocapturer.h |
| +++ b/webrtc/media/base/fakevideocapturer.h |
| @@ -20,9 +20,6 @@ |
| #include "webrtc/media/base/videocapturer.h" |
| #include "webrtc/media/base/videocommon.h" |
| #include "webrtc/media/base/videoframe.h" |
| -#ifdef HAVE_WEBRTC_VIDEO |
| -#include "webrtc/media/engine/webrtcvideoframefactory.h" |
| -#endif |
| namespace cricket { |
| @@ -35,9 +32,6 @@ class FakeVideoCapturer : public cricket::VideoCapturer { |
| next_timestamp_(rtc::kNumNanosecsPerMillisec), |
| is_screencast_(is_screencast), |
| rotation_(webrtc::kVideoRotation_0) { |
| -#ifdef HAVE_WEBRTC_VIDEO |
| - set_frame_factory(new cricket::WebRtcVideoFrameFactory()); |
| -#endif |
| // Default supported formats. Use ResetSupportedFormats to over write. |
| std::vector<cricket::VideoFormat> formats; |
| formats.push_back(cricket::VideoFormat(1280, 720, |
| @@ -81,46 +75,38 @@ class FakeVideoCapturer : public cricket::VideoCapturer { |
| if (!running_) { |
| return false; |
| } |
| - // Currently, |fourcc| is always I420 or ARGB. |
| - uint32_t size = 0u; |
| - if (fourcc == cricket::FOURCC_ARGB) { |
| - size = width * 4 * height; |
| - } else if (fourcc == cricket::FOURCC_I420) { |
| - size = width * height + 2 * ((width + 1) / 2) * ((height + 1) / 2); |
| - } else { |
| - return false; // Unsupported FOURCC. |
| + RTC_CHECK(fourcc == FOURCC_I420); |
| + RTC_CHECK(width > 0); |
| + RTC_CHECK(height > 0); |
| + |
| + int adapted_width; |
| + int adapted_height; |
| + int crop_width; |
| + int crop_height; |
| + int crop_x; |
| + int crop_y; |
| + |
| + // TODO(nisse): It's a bit silly to have this logic in a fake |
| + // class. Child classes of VideoFrameFactory are expected to call |
|
perkj_webrtc
2016/09/14 07:12:28
This comment is a bit confusing if you delete Vide
nisse-webrtc
2016/09/14 07:58:14
Should be "Child classes of VideoCapturer". Good c
|
| + // AdaptFrame, and the test case |
| + // VideoCapturerTest.SinkWantsMaxPixelAndMaxPixelCountStepUp |
| + // depends on this. |
| + if (AdaptFrame(width, height, 0, 0, &adapted_width, &adapted_height, |
| + &crop_width, &crop_height, &crop_x, &crop_y, nullptr)) { |
| + rtc::scoped_refptr<webrtc::I420Buffer> buffer( |
|
perkj_webrtc
2016/09/14 07:12:28
nit : use I420Buffer::Create
nisse-webrtc
2016/09/14 07:58:15
Done.
|
| + new rtc::RefCountedObject<webrtc::I420Buffer>(adapted_width, |
| + adapted_height)); |
| + buffer->InitializeData(); |
| + |
| + OnFrame(WebRtcVideoFrame(buffer, rotation_, |
| + next_timestamp_ / rtc::kNumNanosecsPerMicrosec), |
| + width, height); |
| } |
| - if (size == 0u) { |
| - return false; // Width and/or Height were zero. |
| - } |
| - |
| - cricket::CapturedFrame frame; |
| - frame.width = width; |
| - frame.height = height; |
| - frame.fourcc = fourcc; |
| - frame.data_size = size; |
| - frame.time_stamp = initial_timestamp_ + next_timestamp_; |
| next_timestamp_ += timestamp_interval; |
| - std::unique_ptr<char[]> data(new char[size]); |
| - frame.data = data.get(); |
| - // Copy something non-zero into the buffer so Validate wont complain that |
| - // the frame is all duplicate. |
| - memset(frame.data, 1, size / 2); |
| - memset(reinterpret_cast<uint8_t*>(frame.data) + (size / 2), 2, |
| - size - (size / 2)); |
| - memcpy(frame.data, reinterpret_cast<const uint8_t*>(&fourcc), 4); |
| - frame.rotation = rotation_; |
| - // TODO(zhurunz): SignalFrameCaptured carry returned value to be able to |
| - // capture results from downstream. |
| - SignalFrameCaptured(this, &frame); |
| return true; |
| } |
| - void SignalCapturedFrame(cricket::CapturedFrame* frame) { |
| - SignalFrameCaptured(this, frame); |
| - } |
| - |
| sigslot::signal1<FakeVideoCapturer*> SignalDestroyed; |
| virtual cricket::CaptureState Start(const cricket::VideoFormat& format) { |