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

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

Issue 2805023002: Add read support of RtpStreamId/RepairedRtpStreamId header extensions. (Closed)
Patch Set: +rtp_header_fuzzer Created 3 years, 8 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" 10 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 EXPECT_TRUE(packet.HasRawExtension(kTransmissionOffsetExtensionId)); 356 EXPECT_TRUE(packet.HasRawExtension(kTransmissionOffsetExtensionId));
357 357
358 int32_t time_offset = 0; 358 int32_t time_offset = 0;
359 auto raw_extension = packet.GetRawExtension(kTransmissionOffsetExtensionId); 359 auto raw_extension = packet.GetRawExtension(kTransmissionOffsetExtensionId);
360 EXPECT_EQ(raw_extension.size(), TransmissionOffset::kValueSizeBytes); 360 EXPECT_EQ(raw_extension.size(), TransmissionOffset::kValueSizeBytes);
361 EXPECT_TRUE(TransmissionOffset::Parse(raw_extension, &time_offset)); 361 EXPECT_TRUE(TransmissionOffset::Parse(raw_extension, &time_offset));
362 362
363 EXPECT_EQ(time_offset, kTimeOffset); 363 EXPECT_EQ(time_offset, kTimeOffset);
364 } 364 }
365 365
366 TEST(RtpPacketTest, ParseDynamicSizeExtension) {
367 // clang-format off
368 const uint8_t kPacket1[] = {
369 0x90, kPayloadType, 0x00, kSeqNum,
370 0x65, 0x43, 0x12, 0x78, // Timestamp.
371 0x12, 0x34, 0x56, 0x78, // Ssrc.
372 0xbe, 0xde, 0x00, 0x02, // Extensions block of size 2x32bit words.
373 0x21, 'H', 'D', // Extension with id = 2, size = (1+1).
374 0x12, 'r', 't', 'x', // Extension with id = 1, size = (2+1).
375 0x00}; // Extension padding.
376 const uint8_t kPacket2[] = {
377 0x90, kPayloadType, 0x00, kSeqNum,
378 0x65, 0x43, 0x12, 0x78, // Timestamp.
379 0x12, 0x34, 0x56, 0x79, // Ssrc.
380 0xbe, 0xde, 0x00, 0x01, // Extensions block of size 1x32bit words.
381 0x11, 'H', 'D', // Extension with id = 1, size = (1+1).
382 0x00}; // Extension padding.
383 // clang-format on
384 RtpPacketReceived::ExtensionManager extensions;
385 extensions.Register<RtpStreamId>(1);
386 extensions.Register<RepairedRtpStreamId>(2);
387 RtpPacketReceived packet(&extensions);
388 ASSERT_TRUE(packet.Parse(kPacket1, sizeof(kPacket1)));
389
390 std::string rsid;
391 EXPECT_TRUE(packet.GetExtension<RtpStreamId>(&rsid));
392 EXPECT_EQ(rsid, "rtx");
393
394 std::string repaired_rsid;
395 EXPECT_TRUE(packet.GetExtension<RepairedRtpStreamId>(&repaired_rsid));
396 EXPECT_EQ(repaired_rsid, "HD");
397
398 // Parse another packet with RtpStreamId extension of different size.
399 ASSERT_TRUE(packet.Parse(kPacket2, sizeof(kPacket2)));
400 EXPECT_TRUE(packet.GetExtension<RtpStreamId>(&rsid));
401 EXPECT_EQ(rsid, "HD");
402 EXPECT_FALSE(packet.GetExtension<RepairedRtpStreamId>(&repaired_rsid));
403 }
404
366 } // namespace webrtc 405 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698