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

Unified Diff: webrtc/test/vcm_capturer.cc

Issue 2716643002: Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Changed AdaptUp behavior, respect SinkWants in test capturers, manual testing facilitated Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/test/vcm_capturer.h ('k') | webrtc/video/overuse_frame_detector.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/vcm_capturer.cc
diff --git a/webrtc/test/vcm_capturer.cc b/webrtc/test/vcm_capturer.cc
index 535e9bf219db24f370bd547e4d617eb8df724c1d..e243583d20cc3548528f8a6a684fb30fd960f07c 100644
--- a/webrtc/test/vcm_capturer.cc
+++ b/webrtc/test/vcm_capturer.cc
@@ -10,13 +10,19 @@
#include "webrtc/test/vcm_capturer.h"
+#include "webrtc/api/video/i420_buffer.h"
+#include "webrtc/media/base/videoadapter.h"
#include "webrtc/modules/video_capture/video_capture_factory.h"
#include "webrtc/video_send_stream.h"
namespace webrtc {
namespace test {
-VcmCapturer::VcmCapturer() : started_(false), sink_(nullptr), vcm_(NULL) {}
+VcmCapturer::VcmCapturer()
+ : started_(false),
+ sink_(nullptr),
+ vcm_(nullptr),
+ video_adpter_(new cricket::VideoAdapter()) {}
bool VcmCapturer::Init(size_t width, size_t height, size_t target_fps) {
VideoCaptureModule::DeviceInfo* device_info =
@@ -80,6 +86,9 @@ void VcmCapturer::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
rtc::CritScope lock(&crit_);
RTC_CHECK(!sink_ || sink_ == sink);
sink_ = sink;
+ video_adpter_->OnResolutionFramerateRequest(wants.target_pixel_count,
+ wants.max_pixel_count,
+ wants.max_framerate_fps_);
}
void VcmCapturer::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
@@ -102,8 +111,29 @@ VcmCapturer::~VcmCapturer() { Destroy(); }
void VcmCapturer::OnFrame(const VideoFrame& frame) {
rtc::CritScope lock(&crit_);
- if (started_ && sink_)
+ if (started_ && sink_) {
+ int cropped_width = 0;
nisse-webrtc 2017/03/09 13:33:18 Adding adaptation here makes some sense. Just curi
sprang_webrtc 2017/03/09 13:42:26 It's not technically. I just that now we have usag
+ int cropped_height = 0;
+ int out_width = 0;
+ int out_height = 0;
+ if (!video_adpter_->AdaptFrameResolution(
+ frame.width(), frame.height(), frame.timestamp_us() * 1000,
+ &cropped_width, &cropped_height, &out_width, &out_height)) {
+ return;
+ }
+
+ if (out_height != frame.height() || out_width != frame.width()) {
+ rtc::scoped_refptr<I420Buffer> scaled_buffer =
+ I420Buffer::Create(out_width, out_height);
+ scaled_buffer->ScaleFrom(*frame.video_frame_buffer().get());
+ VideoFrame adapted_frame(scaled_buffer, kVideoRotation_0,
+ frame.timestamp_us());
+ sink_->OnFrame(adapted_frame);
+ return;
+ }
+
sink_->OnFrame(frame);
+ }
}
} // test
« no previous file with comments | « webrtc/test/vcm_capturer.h ('k') | webrtc/video/overuse_frame_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698