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

Side by Side Diff: webrtc/test/video_capturer.cc

Issue 2716643002: Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Comments 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/video_capturer.h ('k') | webrtc/video/end_to_end_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/test/video_capturer.h"
12
13 #include "webrtc/base/basictypes.h"
14 #include "webrtc/base/constructormagic.h"
15
16 namespace webrtc {
17 namespace test {
18 VideoCapturer::VideoCapturer() : video_adapter_(new cricket::VideoAdapter()) {}
19 VideoCapturer::~VideoCapturer() {}
20
21 rtc::Optional<VideoFrame> VideoCapturer::AdaptFrame(const VideoFrame& frame) {
22 int cropped_width = 0;
23 int cropped_height = 0;
24 int out_width = 0;
25 int out_height = 0;
26
27 if (!video_adapter_->AdaptFrameResolution(
28 frame.width(), frame.height(), frame.timestamp_us() * 1000,
29 &cropped_width, &cropped_height, &out_width, &out_height)) {
30 // Drop frame in order to respect frame rate constraint.
31 return rtc::Optional<VideoFrame>();
32 }
33
34 rtc::Optional<VideoFrame> out_frame;
35 if (out_height != frame.height() || out_width != frame.width()) {
36 // Video adapter has requested a down-scale. Allocate a new buffer and
37 // return scaled version.
38 rtc::scoped_refptr<I420Buffer> scaled_buffer =
39 I420Buffer::Create(out_width, out_height);
40 scaled_buffer->ScaleFrom(*frame.video_frame_buffer().get());
41 out_frame.emplace(
42 VideoFrame(scaled_buffer, kVideoRotation_0, frame.timestamp_us()));
43 } else {
44 // No adaptations needed, just return the frame as is.
45 out_frame.emplace(frame);
46 }
47
48 return out_frame;
49 }
50
51 void VideoCapturer::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
52 const rtc::VideoSinkWants& wants) {
53 video_adapter_->OnResolutionFramerateRequest(
54 wants.target_pixel_count, wants.max_pixel_count, wants.max_framerate_fps);
55 }
56
57 } // namespace test
58 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/video_capturer.h ('k') | webrtc/video/end_to_end_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698