Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_payload_registry_unittest.cc

Issue 1649493004: Support multiple rtx codecs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 uint16_t original_sequence_number = 1234; 296 uint16_t original_sequence_number = 1234;
297 uint32_t original_ssrc = 500; 297 uint32_t original_ssrc = 500;
298 298
299 rtc::scoped_ptr<const uint8_t[]> packet(GenerateRtxPacket( 299 rtc::scoped_ptr<const uint8_t[]> packet(GenerateRtxPacket(
300 header_length, payload_length, original_sequence_number)); 300 header_length, payload_length, original_sequence_number));
301 rtc::scoped_ptr<uint8_t[]> restored_packet( 301 rtc::scoped_ptr<uint8_t[]> restored_packet(
302 new uint8_t[header_length + payload_length]); 302 new uint8_t[header_length + payload_length]);
303 size_t length = original_length; 303 size_t length = original_length;
304 bool success = rtp_payload_registry->RestoreOriginalPacket( 304 bool success = rtp_payload_registry->RestoreOriginalPacket(
305 restored_packet.get(), packet.get(), &length, original_ssrc, header); 305 restored_packet.get(), packet.get(), &length, original_ssrc, header);
306 ASSERT_EQ(should_succeed, success) 306 EXPECT_EQ(should_succeed, success)
307 << "Test success should match should_succeed."; 307 << "Test success should match should_succeed.";
308 if (!success) { 308 if (!success) {
309 return; 309 return;
310 } 310 }
311 311
312 EXPECT_EQ(original_length - kRtxHeaderSize, length) 312 EXPECT_EQ(original_length - kRtxHeaderSize, length)
313 << "The restored packet should be exactly kRtxHeaderSize smaller."; 313 << "The restored packet should be exactly kRtxHeaderSize smaller.";
314 314
315 rtc::scoped_ptr<RtpHeaderParser> header_parser(RtpHeaderParser::Create()); 315 rtc::scoped_ptr<RtpHeaderParser> header_parser(RtpHeaderParser::Create());
316 RTPHeader restored_header; 316 RTPHeader restored_header;
(...skipping 11 matching lines...) Expand all
328 TEST_F(RtpPayloadRegistryTest, MultipleRtxPayloadTypes) { 328 TEST_F(RtpPayloadRegistryTest, MultipleRtxPayloadTypes) {
329 // Set the incoming payload type to 90. 329 // Set the incoming payload type to 90.
330 RTPHeader header; 330 RTPHeader header;
331 header.payloadType = 90; 331 header.payloadType = 90;
332 header.ssrc = 1; 332 header.ssrc = 1;
333 rtp_payload_registry_->SetIncomingPayloadType(header); 333 rtp_payload_registry_->SetIncomingPayloadType(header);
334 rtp_payload_registry_->SetRtxSsrc(100); 334 rtp_payload_registry_->SetRtxSsrc(100);
335 // Map two RTX payload types. 335 // Map two RTX payload types.
336 rtp_payload_registry_->SetRtxPayloadType(105, 95); 336 rtp_payload_registry_->SetRtxPayloadType(105, 95);
337 rtp_payload_registry_->SetRtxPayloadType(106, 96); 337 rtp_payload_registry_->SetRtxPayloadType(106, 96);
338 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true);
339
340 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true);
341 TestRtxPacket(rtp_payload_registry_.get(), 106, 96, true);
342
343 // If the option is off, the map will be ignored.
344 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(false);
345 TestRtxPacket(rtp_payload_registry_.get(), 105, 90, true);
346 TestRtxPacket(rtp_payload_registry_.get(), 106, 90, true);
347 }
348
349 // TODO(holmer): Ignored by default for compatibility with misconfigured RTX
350 // streams in Chrome. When that is fixed, remove this.
351 TEST_F(RtpPayloadRegistryTest, IgnoresRtxPayloadTypeMappingByDefault) {
352 // Set the incoming payload type to 90.
353 RTPHeader header;
354 header.payloadType = 90;
355 header.ssrc = 1;
356 rtp_payload_registry_->SetIncomingPayloadType(header);
357 rtp_payload_registry_->SetRtxSsrc(100);
358 // Map two RTX payload types.
359 rtp_payload_registry_->SetRtxPayloadType(105, 95);
360 rtp_payload_registry_->SetRtxPayloadType(106, 96);
361 338
362 TestRtxPacket(rtp_payload_registry_.get(), 105, 90, true);
363 TestRtxPacket(rtp_payload_registry_.get(), 106, 90, true);
364 }
365
366 TEST_F(RtpPayloadRegistryTest, InferLastReceivedPacketIfPayloadTypeUnknown) {
367 rtp_payload_registry_->SetRtxSsrc(100);
368 // Set the incoming payload type to 90.
369 RTPHeader header;
370 header.payloadType = 90;
371 header.ssrc = 1;
372 rtp_payload_registry_->SetIncomingPayloadType(header);
373 rtp_payload_registry_->SetRtxPayloadType(105, 95);
374 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true);
375 // Mapping respected for known type.
376 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); 339 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true);
377 // Mapping ignored for unknown type, even though the option is on. 340 TestRtxPacket(rtp_payload_registry_.get(), 106, 96, true);
378 TestRtxPacket(rtp_payload_registry_.get(), 106, 90, true);
379 } 341 }
380 342
381 TEST_F(RtpPayloadRegistryTest, InvalidRtxConfiguration) { 343 TEST_F(RtpPayloadRegistryTest, InvalidRtxConfiguration) {
382 rtp_payload_registry_->SetRtxSsrc(100); 344 rtp_payload_registry_->SetRtxSsrc(100);
383 // Fails because no mappings exist and the incoming payload type isn't known. 345 // Fails because no mappings exist and the incoming payload type isn't known.
384 TestRtxPacket(rtp_payload_registry_.get(), 105, 0, false); 346 TestRtxPacket(rtp_payload_registry_.get(), 105, 0, false);
385 // Succeeds when the mapping is used, but fails for the implicit fallback. 347 // Succeeds when the mapping is used, but fails for the implicit fallback.
386 rtp_payload_registry_->SetRtxPayloadType(105, 95); 348 rtp_payload_registry_->SetRtxPayloadType(105, 95);
387 rtp_payload_registry_->set_use_rtx_payload_mapping_on_restore(true);
388 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true); 349 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true);
389 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false); 350 TestRtxPacket(rtp_payload_registry_.get(), 106, 0, false);
390 } 351 }
391 352
353 TEST_F(RtpPayloadRegistryTest, AssumeRtxWrappingRed) {
354 rtp_payload_registry_->SetRtxSsrc(100);
355 // Succeeds when the mapping is used, but fails for the implicit fallback.
356 rtp_payload_registry_->SetRtxPayloadType(105, 95);
357 // Set the incoming payload type to 96, which we assume is red.
358 RTPHeader header;
359 header.payloadType = 96;
360 header.ssrc = 1;
361 rtp_payload_registry_->SetIncomingPayloadType(header);
362 // Recovers with correct, but unexpected, payload type since we haven't
363 // configured red.
364 TestRtxPacket(rtp_payload_registry_.get(), 105, 95, true);
365 bool created_new_payload;
366 rtp_payload_registry_->RegisterReceivePayload(
367 "RED", header.payloadType, 90000, 1, 0, &created_new_payload);
368 // Now that red is configured we expect to get the red payload type back on
369 // recovery because of the workaround to always recover red when configured.
370 TestRtxPacket(rtp_payload_registry_.get(), 105, header.payloadType, true);
371 }
372
392 INSTANTIATE_TEST_CASE_P(TestDynamicRange, 373 INSTANTIATE_TEST_CASE_P(TestDynamicRange,
393 RtpPayloadRegistryGenericTest, 374 RtpPayloadRegistryGenericTest,
394 testing::Range(96, 127 + 1)); 375 testing::Range(96, 127 + 1));
395 376
396 } // namespace webrtc 377 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_payload_registry.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698