Extract the code to produce a stream of frames to its own class, FakeFrameSource. Use in VideoAdapter unittests, to make the code simpler and not depend on the deprecated cricket::VideoCapturer. Bug: webrtc:6353 Change-Id: Ib5c34c6a0bd7f4338650459873ddc94b12d0c569 Reviewed-on: https://webrtc-review.googlesource.com/49740 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21995}
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "media/base/fakeframesource.h"
|
|
|
|
#include "api/video/i420_buffer.h"
|
|
|
|
namespace cricket {
|
|
|
|
FakeFrameSource::FakeFrameSource(int width, int height, int interval_us)
|
|
: width_(width), height_(height), interval_us_(interval_us) {
|
|
RTC_CHECK_GT(width_, 0);
|
|
RTC_CHECK_GT(height_, 0);
|
|
RTC_CHECK_GT(interval_us_, 0);
|
|
}
|
|
|
|
webrtc::VideoRotation FakeFrameSource::GetRotation() {
|
|
return rotation_;
|
|
}
|
|
|
|
void FakeFrameSource::SetRotation(webrtc::VideoRotation rotation) {
|
|
rotation_ = rotation;
|
|
}
|
|
|
|
webrtc::VideoFrame FakeFrameSource::GetFrame() {
|
|
return GetFrame(width_, height_, interval_us_);
|
|
}
|
|
|
|
webrtc::VideoFrame FakeFrameSource::GetFrame(int width,
|
|
int height,
|
|
int interval_us) {
|
|
RTC_CHECK_GT(width, 0);
|
|
RTC_CHECK_GT(height, 0);
|
|
RTC_CHECK_GT(interval_us, 0);
|
|
|
|
rtc::scoped_refptr<webrtc::I420Buffer> buffer(
|
|
webrtc::I420Buffer::Create(width, height));
|
|
|
|
buffer->InitializeData();
|
|
webrtc::VideoFrame frame =
|
|
webrtc::VideoFrame(buffer, rotation_, next_timestamp_us_);
|
|
|
|
next_timestamp_us_ += interval_us;
|
|
return frame;
|
|
}
|
|
|
|
} // namespace cricket
|