Index: webrtc/media/base/fakevideocapturer.h |
diff --git a/webrtc/media/base/fakevideocapturer.h b/webrtc/media/base/fakevideocapturer.h |
index 8ba56f1e6f1971ee1e27aefcd823316598ff818d..0f2d8edc30a9d252bb5430b1e862a47c4e1e252f 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,37 @@ 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 VideoCapturer are expected to call |
+ // 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( |
+ webrtc::I420Buffer::Create(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; |
cricket::CaptureState Start(const cricket::VideoFormat& format) override { |