2 * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef TEST_FAKE_ENCODED_FRAME_H_
12 #define TEST_FAKE_ENCODED_FRAME_H_
15 #include <ostream> // no-presubmit-check TODO(webrtc:8982)
18 #include "api/rtp_packet_infos.h"
19 #include "api/video/encoded_frame.h"
20 #include "api/video/video_rotation.h"
21 #include "test/gmock.h"
26 void PrintTo(const EncodedFrame
& frame
,
27 std::ostream
* os
); // no-presubmit-check TODO(webrtc:8982)
31 class FakeEncodedFrame
: public EncodedFrame
{
33 // Always 10ms delay and on time.
34 int64_t ReceivedTime() const override
;
35 int64_t RenderTime() const override
;
37 // Setters for protected variables.
38 void SetReceivedTime(int64_t received_time
);
39 void SetPayloadType(int payload_type
);
42 int64_t received_time_
;
45 MATCHER_P(WithId
, id
, "") {
46 return ::testing::Matches(::testing::Eq(id
))(arg
.Id());
49 MATCHER_P(FrameWithSize
, id
, "") {
50 return ::testing::Matches(::testing::Eq(id
))(arg
.size());
53 MATCHER_P(RtpTimestamp
, ts
, "") {
54 return ts
== arg
.Timestamp();
57 class FakeFrameBuilder
{
59 FakeFrameBuilder
& Time(uint32_t rtp_timestamp
);
60 FakeFrameBuilder
& Id(int64_t frame_id
);
61 FakeFrameBuilder
& AsLast();
62 FakeFrameBuilder
& Refs(const std::vector
<int64_t>& references
);
63 FakeFrameBuilder
& PlayoutDelay(VideoPlayoutDelay playout_delay
);
64 FakeFrameBuilder
& SpatialLayer(int spatial_layer
);
65 FakeFrameBuilder
& ReceivedTime(Timestamp receive_time
);
66 FakeFrameBuilder
& Size(size_t size
);
67 FakeFrameBuilder
& PayloadType(int payload_type
);
68 FakeFrameBuilder
& NtpTime(Timestamp ntp_time
);
69 FakeFrameBuilder
& Rotation(VideoRotation rotation
);
70 FakeFrameBuilder
& PacketInfos(RtpPacketInfos packet_infos
);
71 std::unique_ptr
<FakeEncodedFrame
> Build();
74 absl::optional
<uint32_t> rtp_timestamp_
;
75 absl::optional
<int64_t> frame_id_
;
76 absl::optional
<VideoPlayoutDelay
> playout_delay_
;
77 absl::optional
<int> spatial_layer_
;
78 absl::optional
<Timestamp
> received_time_
;
79 absl::optional
<int> payload_type_
;
80 absl::optional
<Timestamp
> ntp_time_
;
81 absl::optional
<VideoRotation
> rotation_
;
82 absl::optional
<RtpPacketInfos
> packet_infos_
;
83 std::vector
<int64_t> references_
;
84 bool last_spatial_layer_
= false;
91 #endif // TEST_FAKE_ENCODED_FRAME_H_