1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker *
4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker */
10*d9f75844SAndroid Build Coastguard Worker
11*d9f75844SAndroid Build Coastguard Worker #include "test/fake_texture_frame.h"
12*d9f75844SAndroid Build Coastguard Worker
13*d9f75844SAndroid Build Coastguard Worker #include "api/video/i420_buffer.h"
14*d9f75844SAndroid Build Coastguard Worker
15*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
16*d9f75844SAndroid Build Coastguard Worker namespace test {
17*d9f75844SAndroid Build Coastguard Worker
CreateFrame(int width,int height,uint32_t timestamp,int64_t render_time_ms,VideoRotation rotation)18*d9f75844SAndroid Build Coastguard Worker VideoFrame FakeNativeBuffer::CreateFrame(int width,
19*d9f75844SAndroid Build Coastguard Worker int height,
20*d9f75844SAndroid Build Coastguard Worker uint32_t timestamp,
21*d9f75844SAndroid Build Coastguard Worker int64_t render_time_ms,
22*d9f75844SAndroid Build Coastguard Worker VideoRotation rotation) {
23*d9f75844SAndroid Build Coastguard Worker return VideoFrame::Builder()
24*d9f75844SAndroid Build Coastguard Worker .set_video_frame_buffer(
25*d9f75844SAndroid Build Coastguard Worker rtc::make_ref_counted<FakeNativeBuffer>(width, height))
26*d9f75844SAndroid Build Coastguard Worker .set_timestamp_rtp(timestamp)
27*d9f75844SAndroid Build Coastguard Worker .set_timestamp_ms(render_time_ms)
28*d9f75844SAndroid Build Coastguard Worker .set_rotation(rotation)
29*d9f75844SAndroid Build Coastguard Worker .build();
30*d9f75844SAndroid Build Coastguard Worker }
31*d9f75844SAndroid Build Coastguard Worker
type() const32*d9f75844SAndroid Build Coastguard Worker VideoFrameBuffer::Type FakeNativeBuffer::type() const {
33*d9f75844SAndroid Build Coastguard Worker return Type::kNative;
34*d9f75844SAndroid Build Coastguard Worker }
35*d9f75844SAndroid Build Coastguard Worker
width() const36*d9f75844SAndroid Build Coastguard Worker int FakeNativeBuffer::width() const {
37*d9f75844SAndroid Build Coastguard Worker return width_;
38*d9f75844SAndroid Build Coastguard Worker }
39*d9f75844SAndroid Build Coastguard Worker
height() const40*d9f75844SAndroid Build Coastguard Worker int FakeNativeBuffer::height() const {
41*d9f75844SAndroid Build Coastguard Worker return height_;
42*d9f75844SAndroid Build Coastguard Worker }
43*d9f75844SAndroid Build Coastguard Worker
ToI420()44*d9f75844SAndroid Build Coastguard Worker rtc::scoped_refptr<I420BufferInterface> FakeNativeBuffer::ToI420() {
45*d9f75844SAndroid Build Coastguard Worker rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(width_, height_);
46*d9f75844SAndroid Build Coastguard Worker I420Buffer::SetBlack(buffer.get());
47*d9f75844SAndroid Build Coastguard Worker return buffer;
48*d9f75844SAndroid Build Coastguard Worker }
49*d9f75844SAndroid Build Coastguard Worker
50*d9f75844SAndroid Build Coastguard Worker } // namespace test
51*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc
52