blob: 7ab63cbc76dc08a7d920468a4d01ccb01f63b9b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/*
* Copyright (c) 2022 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 "test/fake_encoded_frame.h"
#include <memory>
#include "api/video/video_frame_type.h"
namespace webrtc {
void PrintTo(const EncodedFrame& frame,
std::ostream* os) /* no-presubmit-check TODO(webrtc:8982) */ {
*os << "EncodedFrame with id=" << frame.Id()
<< " rtp=" << frame.RtpTimestamp() << " size=" << frame.size()
<< " refs=[";
for (size_t ref = 0; ref < frame.num_references; ++ref) {
*os << frame.references[ref] << ",";
}
*os << "]";
}
namespace test {
int64_t FakeEncodedFrame::ReceivedTime() const {
return received_time_;
}
int64_t FakeEncodedFrame::RenderTime() const {
return _renderTimeMs;
}
void FakeEncodedFrame::SetReceivedTime(int64_t received_time) {
received_time_ = received_time;
}
void FakeEncodedFrame::SetPayloadType(int payload_type) {
_payloadType = payload_type;
}
FakeFrameBuilder& FakeFrameBuilder::Time(uint32_t rtp_timestamp) {
rtp_timestamp_ = rtp_timestamp;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::Id(int64_t frame_id) {
frame_id_ = frame_id;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::AsLast() {
last_spatial_layer_ = true;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::Refs(
const std::vector<int64_t>& references) {
references_ = references;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::PlayoutDelay(
VideoPlayoutDelay playout_delay) {
playout_delay_ = playout_delay;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::SpatialLayer(int spatial_layer) {
spatial_layer_ = spatial_layer;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::ReceivedTime(Timestamp receive_time) {
received_time_ = receive_time;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::Size(size_t size) {
size_ = size;
return *this;
}
std::unique_ptr<FakeEncodedFrame> FakeFrameBuilder::Build() {
RTC_CHECK_LE(references_.size(), EncodedFrame::kMaxFrameReferences);
auto frame = std::make_unique<FakeEncodedFrame>();
frame->is_last_spatial_layer = last_spatial_layer_;
frame->SetEncodedData(EncodedImageBuffer::Create(size_));
if (rtp_timestamp_)
frame->SetRtpTimestamp(*rtp_timestamp_);
if (frame_id_)
frame->SetId(*frame_id_);
if (playout_delay_)
frame->SetPlayoutDelay(*playout_delay_);
frame->SetFrameType(references_.empty() ? VideoFrameType::kVideoFrameKey
: VideoFrameType::kVideoFrameDelta);
for (int64_t ref : references_) {
frame->references[frame->num_references] = ref;
frame->num_references++;
}
if (spatial_layer_)
frame->SetSpatialIndex(spatial_layer_);
if (received_time_)
frame->SetReceivedTime(received_time_->ms());
if (payload_type_)
frame->SetPayloadType(*payload_type_);
if (ntp_time_)
frame->ntp_time_ms_ = ntp_time_->ms();
if (rotation_)
frame->rotation_ = *rotation_;
if (packet_infos_)
frame->SetPacketInfos(*packet_infos_);
return frame;
}
FakeFrameBuilder& FakeFrameBuilder::PayloadType(int payload_type) {
payload_type_ = payload_type;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::NtpTime(Timestamp ntp_time) {
ntp_time_ = ntp_time;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::Rotation(VideoRotation rotation) {
rotation_ = rotation;
return *this;
}
FakeFrameBuilder& FakeFrameBuilder::PacketInfos(RtpPacketInfos packet_infos) {
packet_infos_ = packet_infos;
return *this;
}
} // namespace test
} // namespace webrtc
|