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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/test/vcm_capturer.h" 11 #include "webrtc/test/vcm_capturer.h"
12 12
13 #include "webrtc/api/video/i420_buffer.h"
14 #include "webrtc/media/base/videoadapter.h"
13 #include "webrtc/modules/video_capture/video_capture_factory.h" 15 #include "webrtc/modules/video_capture/video_capture_factory.h"
14 #include "webrtc/video_send_stream.h" 16 #include "webrtc/video_send_stream.h"
15 17
16 namespace webrtc { 18 namespace webrtc {
17 namespace test { 19 namespace test {
18 20
19 VcmCapturer::VcmCapturer() : started_(false), sink_(nullptr), vcm_(NULL) {} 21 VcmCapturer::VcmCapturer()
22 : started_(false),
23 sink_(nullptr),
24 vcm_(nullptr),
25 video_adpter_(new cricket::VideoAdapter()) {}
20 26
21 bool VcmCapturer::Init(size_t width, size_t height, size_t target_fps) { 27 bool VcmCapturer::Init(size_t width, size_t height, size_t target_fps) {
22 VideoCaptureModule::DeviceInfo* device_info = 28 VideoCaptureModule::DeviceInfo* device_info =
23 VideoCaptureFactory::CreateDeviceInfo(); 29 VideoCaptureFactory::CreateDeviceInfo();
24 30
25 char device_name[256]; 31 char device_name[256];
26 char unique_name[256]; 32 char unique_name[256];
27 if (device_info->GetDeviceName(0, device_name, sizeof(device_name), 33 if (device_info->GetDeviceName(0, device_name, sizeof(device_name),
28 unique_name, sizeof(unique_name)) != 34 unique_name, sizeof(unique_name)) !=
29 0) { 35 0) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void VcmCapturer::Stop() { 79 void VcmCapturer::Stop() {
74 rtc::CritScope lock(&crit_); 80 rtc::CritScope lock(&crit_);
75 started_ = false; 81 started_ = false;
76 } 82 }
77 83
78 void VcmCapturer::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, 84 void VcmCapturer::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
79 const rtc::VideoSinkWants& wants) { 85 const rtc::VideoSinkWants& wants) {
80 rtc::CritScope lock(&crit_); 86 rtc::CritScope lock(&crit_);
81 RTC_CHECK(!sink_ || sink_ == sink); 87 RTC_CHECK(!sink_ || sink_ == sink);
82 sink_ = sink; 88 sink_ = sink;
89 video_adpter_->OnResolutionFramerateRequest(wants.target_pixel_count,
90 wants.max_pixel_count,
91 wants.max_framerate_fps_);
83 } 92 }
84 93
85 void VcmCapturer::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) { 94 void VcmCapturer::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
86 rtc::CritScope lock(&crit_); 95 rtc::CritScope lock(&crit_);
87 RTC_CHECK(sink_ == sink); 96 RTC_CHECK(sink_ == sink);
88 sink_ = nullptr; 97 sink_ = nullptr;
89 } 98 }
90 99
91 void VcmCapturer::Destroy() { 100 void VcmCapturer::Destroy() {
92 if (!vcm_) 101 if (!vcm_)
93 return; 102 return;
94 103
95 vcm_->StopCapture(); 104 vcm_->StopCapture();
96 vcm_->DeRegisterCaptureDataCallback(); 105 vcm_->DeRegisterCaptureDataCallback();
97 // Release reference to VCM. 106 // Release reference to VCM.
98 vcm_ = nullptr; 107 vcm_ = nullptr;
99 } 108 }
100 109
101 VcmCapturer::~VcmCapturer() { Destroy(); } 110 VcmCapturer::~VcmCapturer() { Destroy(); }
102 111
103 void VcmCapturer::OnFrame(const VideoFrame& frame) { 112 void VcmCapturer::OnFrame(const VideoFrame& frame) {
104 rtc::CritScope lock(&crit_); 113 rtc::CritScope lock(&crit_);
105 if (started_ && sink_) 114 if (started_ && sink_) {
115 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
116 int cropped_height = 0;
117 int out_width = 0;
118 int out_height = 0;
119 if (!video_adpter_->AdaptFrameResolution(
120 frame.width(), frame.height(), frame.timestamp_us() * 1000,
121 &cropped_width, &cropped_height, &out_width, &out_height)) {
122 return;
123 }
124
125 if (out_height != frame.height() || out_width != frame.width()) {
126 rtc::scoped_refptr<I420Buffer> scaled_buffer =
127 I420Buffer::Create(out_width, out_height);
128 scaled_buffer->ScaleFrom(*frame.video_frame_buffer().get());
129 VideoFrame adapted_frame(scaled_buffer, kVideoRotation_0,
130 frame.timestamp_us());
131 sink_->OnFrame(adapted_frame);
132 return;
133 }
134
106 sink_->OnFrame(frame); 135 sink_->OnFrame(frame);
136 }
107 } 137 }
108 138
109 } // test 139 } // test
110 } // webrtc 140 } // webrtc
OLDNEW
« 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