blob: 44cbcd5b64ad43cb500b43bbbf224b817da5179e [file] [log] [blame]
Stefan Holmerf7044682018-07-17 10:16:41 +02001/*
2 * Copyright (c) 2018 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
Yves Gerey3e707812018-11-28 16:47:49 +010011#include <string.h>
12#include <map>
philipelbf2b6202018-08-27 14:33:18 +020013#include <set>
Stefan Holmerf7044682018-07-17 10:16:41 +020014
Yves Gerey3e707812018-11-28 16:47:49 +010015#include "absl/container/inlined_vector.h"
16#include "absl/types/optional.h"
17#include "absl/types/variant.h"
18#include "api/video/video_content_type.h"
19#include "api/video/video_rotation.h"
Stefan Holmer9416ef82018-07-19 10:34:38 +020020#include "call/rtp_payload_params.h"
Yves Gerey3e707812018-11-28 16:47:49 +010021#include "common_types.h" // NOLINT(build/include)
22#include "modules/video_coding/codecs/h264/include/h264_globals.h"
23#include "modules/video_coding/codecs/interface/common_constants.h"
24#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
25#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
Stefan Holmerf7044682018-07-17 10:16:41 +020026#include "modules/video_coding/include/video_codec_interface.h"
philipelbf2b6202018-08-27 14:33:18 +020027#include "test/field_trial.h"
Stefan Holmerf7044682018-07-17 10:16:41 +020028#include "test/gtest.h"
29
30namespace webrtc {
31namespace {
32const uint32_t kSsrc1 = 12345;
33const uint32_t kSsrc2 = 23456;
34const int16_t kPictureId = 123;
35const int16_t kTl0PicIdx = 20;
36const uint8_t kTemporalIdx = 1;
37const int16_t kInitialPictureId1 = 222;
38const int16_t kInitialTl0PicIdx1 = 99;
philipelbf2b6202018-08-27 14:33:18 +020039const int64_t kDontCare = 0;
Stefan Holmerf7044682018-07-17 10:16:41 +020040} // namespace
41
42TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp8) {
43 RtpPayloadState state2;
44 state2.picture_id = kPictureId;
45 state2.tl0_pic_idx = kTl0PicIdx;
46 std::map<uint32_t, RtpPayloadState> states = {{kSsrc2, state2}};
47
48 RtpPayloadParams params(kSsrc2, &state2);
49 EncodedImage encoded_image;
50 encoded_image.rotation_ = kVideoRotation_90;
51 encoded_image.content_type_ = VideoContentType::SCREENSHARE;
Niels Möllerd3b8c632018-08-27 15:33:42 +020052 encoded_image.SetSpatialIndex(1);
Stefan Holmerf7044682018-07-17 10:16:41 +020053
54 CodecSpecificInfo codec_info;
55 memset(&codec_info, 0, sizeof(CodecSpecificInfo));
56 codec_info.codecType = kVideoCodecVP8;
philipelbf2b6202018-08-27 14:33:18 +020057 codec_info.codecSpecific.VP8.temporalIdx = 0;
Stefan Holmerf7044682018-07-17 10:16:41 +020058 codec_info.codecSpecific.VP8.keyIdx = kNoKeyIdx;
philipelbf2b6202018-08-27 14:33:18 +020059 codec_info.codecSpecific.VP8.layerSync = false;
Stefan Holmerf7044682018-07-17 10:16:41 +020060 codec_info.codecSpecific.VP8.nonReference = true;
61
philipelbf2b6202018-08-27 14:33:18 +020062 RTPVideoHeader header =
63 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
64
65 codec_info.codecType = kVideoCodecVP8;
philipelbf2b6202018-08-27 14:33:18 +020066 codec_info.codecSpecific.VP8.temporalIdx = 1;
67 codec_info.codecSpecific.VP8.layerSync = true;
68
69 header = params.GetRtpVideoHeader(encoded_image, &codec_info, 1);
Stefan Holmerf7044682018-07-17 10:16:41 +020070
71 EXPECT_EQ(kVideoRotation_90, header.rotation);
72 EXPECT_EQ(VideoContentType::SCREENSHARE, header.content_type);
73 EXPECT_EQ(1, header.simulcastIdx);
74 EXPECT_EQ(kVideoCodecVP8, header.codec);
Philip Eliassond52a1a62018-09-07 13:03:55 +000075 const auto& vp8_header =
76 absl::get<RTPVideoHeaderVP8>(header.video_type_header);
77 EXPECT_EQ(kPictureId + 2, vp8_header.pictureId);
78 EXPECT_EQ(kTemporalIdx, vp8_header.temporalIdx);
79 EXPECT_EQ(kTl0PicIdx + 1, vp8_header.tl0PicIdx);
80 EXPECT_EQ(kNoKeyIdx, vp8_header.keyIdx);
81 EXPECT_TRUE(vp8_header.layerSync);
82 EXPECT_TRUE(vp8_header.nonReference);
Stefan Holmerf7044682018-07-17 10:16:41 +020083}
84
85TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp9) {
86 RtpPayloadState state;
87 state.picture_id = kPictureId;
88 state.tl0_pic_idx = kTl0PicIdx;
89 RtpPayloadParams params(kSsrc1, &state);
90
91 EncodedImage encoded_image;
92 encoded_image.rotation_ = kVideoRotation_90;
93 encoded_image.content_type_ = VideoContentType::SCREENSHARE;
Niels Möllerd3b8c632018-08-27 15:33:42 +020094 encoded_image.SetSpatialIndex(0);
Stefan Holmerf7044682018-07-17 10:16:41 +020095 CodecSpecificInfo codec_info;
96 memset(&codec_info, 0, sizeof(CodecSpecificInfo));
97 codec_info.codecType = kVideoCodecVP9;
98 codec_info.codecSpecific.VP9.num_spatial_layers = 3;
99 codec_info.codecSpecific.VP9.first_frame_in_picture = true;
Stefan Holmerf7044682018-07-17 10:16:41 +0200100 codec_info.codecSpecific.VP9.temporal_idx = 2;
101 codec_info.codecSpecific.VP9.end_of_picture = false;
102
philipelbf2b6202018-08-27 14:33:18 +0200103 RTPVideoHeader header =
104 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200105
106 EXPECT_EQ(kVideoRotation_90, header.rotation);
107 EXPECT_EQ(VideoContentType::SCREENSHARE, header.content_type);
108 EXPECT_EQ(kVideoCodecVP9, header.codec);
philipel29d88462018-08-08 14:26:00 +0200109 const auto& vp9_header =
110 absl::get<RTPVideoHeaderVP9>(header.video_type_header);
111 EXPECT_EQ(kPictureId + 1, vp9_header.picture_id);
112 EXPECT_EQ(kTl0PicIdx, vp9_header.tl0_pic_idx);
113 EXPECT_EQ(vp9_header.temporal_idx, codec_info.codecSpecific.VP9.temporal_idx);
Niels Möllerd3b8c632018-08-27 15:33:42 +0200114 EXPECT_EQ(vp9_header.spatial_idx, encoded_image.SpatialIndex());
philipel29d88462018-08-08 14:26:00 +0200115 EXPECT_EQ(vp9_header.num_spatial_layers,
Stefan Holmerf7044682018-07-17 10:16:41 +0200116 codec_info.codecSpecific.VP9.num_spatial_layers);
philipel29d88462018-08-08 14:26:00 +0200117 EXPECT_EQ(vp9_header.end_of_picture,
Stefan Holmerf7044682018-07-17 10:16:41 +0200118 codec_info.codecSpecific.VP9.end_of_picture);
119
120 // Next spatial layer.
121 codec_info.codecSpecific.VP9.first_frame_in_picture = false;
Stefan Holmerf7044682018-07-17 10:16:41 +0200122 codec_info.codecSpecific.VP9.end_of_picture = true;
123
Niels Möllerd3b8c632018-08-27 15:33:42 +0200124 encoded_image.SetSpatialIndex(1);
philipelbf2b6202018-08-27 14:33:18 +0200125 header = params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200126
127 EXPECT_EQ(kVideoRotation_90, header.rotation);
128 EXPECT_EQ(VideoContentType::SCREENSHARE, header.content_type);
129 EXPECT_EQ(kVideoCodecVP9, header.codec);
philipel29d88462018-08-08 14:26:00 +0200130 EXPECT_EQ(kPictureId + 1, vp9_header.picture_id);
131 EXPECT_EQ(kTl0PicIdx, vp9_header.tl0_pic_idx);
132 EXPECT_EQ(vp9_header.temporal_idx, codec_info.codecSpecific.VP9.temporal_idx);
Niels Möllerd3b8c632018-08-27 15:33:42 +0200133 EXPECT_EQ(vp9_header.spatial_idx, encoded_image.SpatialIndex());
philipel29d88462018-08-08 14:26:00 +0200134 EXPECT_EQ(vp9_header.num_spatial_layers,
Stefan Holmerf7044682018-07-17 10:16:41 +0200135 codec_info.codecSpecific.VP9.num_spatial_layers);
philipel29d88462018-08-08 14:26:00 +0200136 EXPECT_EQ(vp9_header.end_of_picture,
Stefan Holmerf7044682018-07-17 10:16:41 +0200137 codec_info.codecSpecific.VP9.end_of_picture);
138}
139
140TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_H264) {
141 RtpPayloadParams params(kSsrc1, {});
142
143 EncodedImage encoded_image;
144 CodecSpecificInfo codec_info;
145 memset(&codec_info, 0, sizeof(CodecSpecificInfo));
146 codec_info.codecType = kVideoCodecH264;
147 codec_info.codecSpecific.H264.packetization_mode =
148 H264PacketizationMode::SingleNalUnit;
149
philipelbf2b6202018-08-27 14:33:18 +0200150 RTPVideoHeader header =
151 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200152
153 EXPECT_EQ(0, header.simulcastIdx);
154 EXPECT_EQ(kVideoCodecH264, header.codec);
155 const auto& h264 = absl::get<RTPVideoHeaderH264>(header.video_type_header);
156 EXPECT_EQ(H264PacketizationMode::SingleNalUnit, h264.packetization_mode);
157}
158
159TEST(RtpPayloadParamsTest, PictureIdIsSetForVp8) {
160 RtpPayloadState state;
161 state.picture_id = kInitialPictureId1;
162 state.tl0_pic_idx = kInitialTl0PicIdx1;
163
164 EncodedImage encoded_image;
165 CodecSpecificInfo codec_info;
166 memset(&codec_info, 0, sizeof(CodecSpecificInfo));
167 codec_info.codecType = kVideoCodecVP8;
Stefan Holmerf7044682018-07-17 10:16:41 +0200168
169 RtpPayloadParams params(kSsrc1, &state);
philipelbf2b6202018-08-27 14:33:18 +0200170 RTPVideoHeader header =
171 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200172 EXPECT_EQ(kVideoCodecVP8, header.codec);
Philip Eliassond52a1a62018-09-07 13:03:55 +0000173 EXPECT_EQ(kInitialPictureId1 + 1,
174 absl::get<RTPVideoHeaderVP8>(header.video_type_header).pictureId);
Stefan Holmerf7044682018-07-17 10:16:41 +0200175
176 // State should hold latest used picture id and tl0_pic_idx.
177 state = params.state();
178 EXPECT_EQ(kInitialPictureId1 + 1, state.picture_id);
179 EXPECT_EQ(kInitialTl0PicIdx1 + 1, state.tl0_pic_idx);
180}
181
182TEST(RtpPayloadParamsTest, PictureIdWraps) {
183 RtpPayloadState state;
184 state.picture_id = kMaxTwoBytePictureId;
185 state.tl0_pic_idx = kInitialTl0PicIdx1;
186
187 EncodedImage encoded_image;
188 CodecSpecificInfo codec_info;
189 memset(&codec_info, 0, sizeof(CodecSpecificInfo));
190 codec_info.codecType = kVideoCodecVP8;
191 codec_info.codecSpecific.VP8.temporalIdx = kNoTemporalIdx;
192
193 RtpPayloadParams params(kSsrc1, &state);
philipelbf2b6202018-08-27 14:33:18 +0200194 RTPVideoHeader header =
195 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200196 EXPECT_EQ(kVideoCodecVP8, header.codec);
Philip Eliassond52a1a62018-09-07 13:03:55 +0000197 EXPECT_EQ(0,
198 absl::get<RTPVideoHeaderVP8>(header.video_type_header).pictureId);
Stefan Holmerf7044682018-07-17 10:16:41 +0200199
200 // State should hold latest used picture id and tl0_pic_idx.
201 EXPECT_EQ(0, params.state().picture_id); // Wrapped.
202 EXPECT_EQ(kInitialTl0PicIdx1, params.state().tl0_pic_idx);
203}
204
205TEST(RtpPayloadParamsTest, Tl0PicIdxUpdatedForVp8) {
206 RtpPayloadState state;
207 state.picture_id = kInitialPictureId1;
208 state.tl0_pic_idx = kInitialTl0PicIdx1;
209
210 EncodedImage encoded_image;
211 // Modules are sending for this test.
212 // OnEncodedImage, temporalIdx: 1.
213 CodecSpecificInfo codec_info;
214 memset(&codec_info, 0, sizeof(CodecSpecificInfo));
215 codec_info.codecType = kVideoCodecVP8;
216 codec_info.codecSpecific.VP8.temporalIdx = 1;
217
218 RtpPayloadParams params(kSsrc1, &state);
philipelbf2b6202018-08-27 14:33:18 +0200219 RTPVideoHeader header =
220 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200221
222 EXPECT_EQ(kVideoCodecVP8, header.codec);
Philip Eliassond52a1a62018-09-07 13:03:55 +0000223 const auto& vp8_header =
224 absl::get<RTPVideoHeaderVP8>(header.video_type_header);
225 EXPECT_EQ(kInitialPictureId1 + 1, vp8_header.pictureId);
226 EXPECT_EQ(kInitialTl0PicIdx1, vp8_header.tl0PicIdx);
Stefan Holmerf7044682018-07-17 10:16:41 +0200227
228 // OnEncodedImage, temporalIdx: 0.
229 codec_info.codecSpecific.VP8.temporalIdx = 0;
230
philipelbf2b6202018-08-27 14:33:18 +0200231 header = params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200232 EXPECT_EQ(kVideoCodecVP8, header.codec);
Philip Eliassond52a1a62018-09-07 13:03:55 +0000233 EXPECT_EQ(kInitialPictureId1 + 2, vp8_header.pictureId);
234 EXPECT_EQ(kInitialTl0PicIdx1 + 1, vp8_header.tl0PicIdx);
Stefan Holmerf7044682018-07-17 10:16:41 +0200235
236 // State should hold latest used picture id and tl0_pic_idx.
237 EXPECT_EQ(kInitialPictureId1 + 2, params.state().picture_id);
238 EXPECT_EQ(kInitialTl0PicIdx1 + 1, params.state().tl0_pic_idx);
239}
240
241TEST(RtpPayloadParamsTest, Tl0PicIdxUpdatedForVp9) {
242 RtpPayloadState state;
243 state.picture_id = kInitialPictureId1;
244 state.tl0_pic_idx = kInitialTl0PicIdx1;
245
246 EncodedImage encoded_image;
247 // Modules are sending for this test.
248 // OnEncodedImage, temporalIdx: 1.
249 CodecSpecificInfo codec_info;
250 memset(&codec_info, 0, sizeof(CodecSpecificInfo));
251 codec_info.codecType = kVideoCodecVP9;
252 codec_info.codecSpecific.VP9.temporal_idx = 1;
253 codec_info.codecSpecific.VP9.first_frame_in_picture = true;
254
255 RtpPayloadParams params(kSsrc1, &state);
philipelbf2b6202018-08-27 14:33:18 +0200256 RTPVideoHeader header =
257 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200258
259 EXPECT_EQ(kVideoCodecVP9, header.codec);
philipel29d88462018-08-08 14:26:00 +0200260 const auto& vp9_header =
261 absl::get<RTPVideoHeaderVP9>(header.video_type_header);
262 EXPECT_EQ(kInitialPictureId1 + 1, vp9_header.picture_id);
263 EXPECT_EQ(kInitialTl0PicIdx1, vp9_header.tl0_pic_idx);
Stefan Holmerf7044682018-07-17 10:16:41 +0200264
265 // OnEncodedImage, temporalIdx: 0.
266 codec_info.codecSpecific.VP9.temporal_idx = 0;
267
philipelbf2b6202018-08-27 14:33:18 +0200268 header = params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200269
270 EXPECT_EQ(kVideoCodecVP9, header.codec);
philipel29d88462018-08-08 14:26:00 +0200271 EXPECT_EQ(kInitialPictureId1 + 2, vp9_header.picture_id);
272 EXPECT_EQ(kInitialTl0PicIdx1 + 1, vp9_header.tl0_pic_idx);
Stefan Holmerf7044682018-07-17 10:16:41 +0200273
274 // OnEncodedImage, first_frame_in_picture = false
275 codec_info.codecSpecific.VP9.first_frame_in_picture = false;
276
philipelbf2b6202018-08-27 14:33:18 +0200277 header = params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
Stefan Holmerf7044682018-07-17 10:16:41 +0200278
279 EXPECT_EQ(kVideoCodecVP9, header.codec);
philipel29d88462018-08-08 14:26:00 +0200280 EXPECT_EQ(kInitialPictureId1 + 2, vp9_header.picture_id);
281 EXPECT_EQ(kInitialTl0PicIdx1 + 1, vp9_header.tl0_pic_idx);
Stefan Holmerf7044682018-07-17 10:16:41 +0200282
283 // State should hold latest used picture id and tl0_pic_idx.
284 EXPECT_EQ(kInitialPictureId1 + 2, params.state().picture_id);
285 EXPECT_EQ(kInitialTl0PicIdx1 + 1, params.state().tl0_pic_idx);
286}
philipelbf2b6202018-08-27 14:33:18 +0200287
288TEST(RtpPayloadParamsTest, PictureIdForOldGenericFormat) {
289 test::ScopedFieldTrials generic_picture_id(
290 "WebRTC-GenericPictureId/Enabled/");
291 RtpPayloadState state{};
292
293 EncodedImage encoded_image;
294 CodecSpecificInfo codec_info{};
295 codec_info.codecType = kVideoCodecGeneric;
296
297 RtpPayloadParams params(kSsrc1, &state);
298 RTPVideoHeader header =
299 params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
300
301 EXPECT_EQ(kVideoCodecGeneric, header.codec);
302 ASSERT_TRUE(header.generic);
303 EXPECT_EQ(0, header.generic->frame_id);
304
305 header = params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
306 ASSERT_TRUE(header.generic);
307 EXPECT_EQ(1, header.generic->frame_id);
308}
309
310class RtpPayloadParamsVp8ToGenericTest : public ::testing::Test {
311 public:
312 enum LayerSync { kNoSync, kSync };
313
philipel569397f2018-09-26 12:25:31 +0200314 RtpPayloadParamsVp8ToGenericTest()
315 : generic_descriptor_field_trial_("WebRTC-GenericDescriptor/Enabled/"),
316 state_(),
317 params_(123, &state_) {}
philipelbf2b6202018-08-27 14:33:18 +0200318
319 void ConvertAndCheck(int temporal_index,
320 int64_t shared_frame_id,
321 FrameType frame_type,
322 LayerSync layer_sync,
philipelfab91292018-10-17 14:36:08 +0200323 const std::set<int64_t>& expected_deps,
324 uint16_t width = 0,
325 uint16_t height = 0) {
philipelbf2b6202018-08-27 14:33:18 +0200326 EncodedImage encoded_image;
327 encoded_image._frameType = frame_type;
philipelfab91292018-10-17 14:36:08 +0200328 encoded_image._encodedWidth = width;
329 encoded_image._encodedHeight = height;
philipelbf2b6202018-08-27 14:33:18 +0200330
331 CodecSpecificInfo codec_info{};
332 codec_info.codecType = kVideoCodecVP8;
333 codec_info.codecSpecific.VP8.temporalIdx = temporal_index;
334 codec_info.codecSpecific.VP8.layerSync = layer_sync == kSync;
335
336 RTPVideoHeader header =
337 params_.GetRtpVideoHeader(encoded_image, &codec_info, shared_frame_id);
338
339 ASSERT_TRUE(header.generic);
340 EXPECT_TRUE(header.generic->higher_spatial_layers.empty());
341 EXPECT_EQ(header.generic->spatial_index, 0);
342
343 EXPECT_EQ(header.generic->frame_id, shared_frame_id);
344 EXPECT_EQ(header.generic->temporal_index, temporal_index);
345 std::set<int64_t> actual_deps(header.generic->dependencies.begin(),
346 header.generic->dependencies.end());
347 EXPECT_EQ(expected_deps, actual_deps);
philipelfab91292018-10-17 14:36:08 +0200348
349 EXPECT_EQ(header.width, width);
350 EXPECT_EQ(header.height, height);
philipelbf2b6202018-08-27 14:33:18 +0200351 }
352
353 protected:
philipel569397f2018-09-26 12:25:31 +0200354 test::ScopedFieldTrials generic_descriptor_field_trial_;
philipelbf2b6202018-08-27 14:33:18 +0200355 RtpPayloadState state_;
356 RtpPayloadParams params_;
357};
358
359TEST_F(RtpPayloadParamsVp8ToGenericTest, Keyframe) {
philipelfab91292018-10-17 14:36:08 +0200360 ConvertAndCheck(0, 0, kVideoFrameKey, kNoSync, {}, 480, 360);
philipelbf2b6202018-08-27 14:33:18 +0200361 ConvertAndCheck(0, 1, kVideoFrameDelta, kNoSync, {0});
philipelfab91292018-10-17 14:36:08 +0200362 ConvertAndCheck(0, 2, kVideoFrameKey, kNoSync, {}, 480, 360);
philipelbf2b6202018-08-27 14:33:18 +0200363}
364
365TEST_F(RtpPayloadParamsVp8ToGenericTest, TooHighTemporalIndex) {
philipelfab91292018-10-17 14:36:08 +0200366 ConvertAndCheck(0, 0, kVideoFrameKey, kNoSync, {}, 480, 360);
philipelbf2b6202018-08-27 14:33:18 +0200367
368 EncodedImage encoded_image;
369 encoded_image._frameType = kVideoFrameDelta;
370 CodecSpecificInfo codec_info{};
371 codec_info.codecType = kVideoCodecVP8;
372 codec_info.codecSpecific.VP8.temporalIdx =
373 RtpGenericFrameDescriptor::kMaxTemporalLayers;
374 codec_info.codecSpecific.VP8.layerSync = false;
375
376 RTPVideoHeader header =
377 params_.GetRtpVideoHeader(encoded_image, &codec_info, 1);
378 EXPECT_FALSE(header.generic);
379}
380
381TEST_F(RtpPayloadParamsVp8ToGenericTest, LayerSync) {
382 // 02120212 pattern
philipelfab91292018-10-17 14:36:08 +0200383 ConvertAndCheck(0, 0, kVideoFrameKey, kNoSync, {}, 480, 360);
philipelbf2b6202018-08-27 14:33:18 +0200384 ConvertAndCheck(2, 1, kVideoFrameDelta, kNoSync, {0});
385 ConvertAndCheck(1, 2, kVideoFrameDelta, kNoSync, {0});
386 ConvertAndCheck(2, 3, kVideoFrameDelta, kNoSync, {0, 1, 2});
387
388 ConvertAndCheck(0, 4, kVideoFrameDelta, kNoSync, {0});
389 ConvertAndCheck(2, 5, kVideoFrameDelta, kNoSync, {2, 3, 4});
390 ConvertAndCheck(1, 6, kVideoFrameDelta, kSync, {4}); // layer sync
391 ConvertAndCheck(2, 7, kVideoFrameDelta, kNoSync, {4, 5, 6});
392}
393
394TEST_F(RtpPayloadParamsVp8ToGenericTest, FrameIdGaps) {
395 // 0101 pattern
philipelfab91292018-10-17 14:36:08 +0200396 ConvertAndCheck(0, 0, kVideoFrameKey, kNoSync, {}, 480, 360);
philipelbf2b6202018-08-27 14:33:18 +0200397 ConvertAndCheck(1, 1, kVideoFrameDelta, kNoSync, {0});
398
399 ConvertAndCheck(0, 5, kVideoFrameDelta, kNoSync, {0});
400 ConvertAndCheck(1, 10, kVideoFrameDelta, kNoSync, {1, 5});
401
402 ConvertAndCheck(0, 15, kVideoFrameDelta, kNoSync, {5});
403 ConvertAndCheck(1, 20, kVideoFrameDelta, kNoSync, {10, 15});
404}
405
Stefan Holmerf7044682018-07-17 10:16:41 +0200406} // namespace webrtc