OLD | NEW |
(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 rtc::Optional<VideoFrame> out_frame; |
| 23 int cropped_width = 0; |
| 24 int cropped_height = 0; |
| 25 int out_width = 0; |
| 26 int out_height = 0; |
| 27 |
| 28 if (!video_adapter_->AdaptFrameResolution( |
| 29 frame.width(), frame.height(), frame.timestamp_us() * 1000, |
| 30 &cropped_width, &cropped_height, &out_width, &out_height)) { |
| 31 return out_frame; |
| 32 } |
| 33 |
| 34 if (out_height != frame.height() || out_width != frame.width()) { |
| 35 rtc::scoped_refptr<I420Buffer> scaled_buffer = |
| 36 I420Buffer::Create(out_width, out_height); |
| 37 scaled_buffer->ScaleFrom(*frame.video_frame_buffer().get()); |
| 38 out_frame.emplace( |
| 39 VideoFrame(scaled_buffer, kVideoRotation_0, frame.timestamp_us())); |
| 40 } else { |
| 41 out_frame.emplace(frame); |
| 42 } |
| 43 |
| 44 return out_frame; |
| 45 } |
| 46 |
| 47 void VideoCapturer::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink, |
| 48 const rtc::VideoSinkWants& wants) { |
| 49 video_adapter_->OnResolutionFramerateRequest( |
| 50 wants.target_pixel_count, wants.max_pixel_count, wants.max_framerate_fps); |
| 51 } |
| 52 |
| 53 } // namespace test |
| 54 } // namespace webrtc |
OLD | NEW |