OLD | NEW |
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 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 ExpectBirateItemEquals(BitrateItem(0, 0, 0x010203), bitrates[0]); | 47 ExpectBirateItemEquals(BitrateItem(0, 0, 0x010203), bitrates[0]); |
48 ExpectBirateItemEquals(BitrateItem(0, 1, 0x020304), bitrates[1]); | 48 ExpectBirateItemEquals(BitrateItem(0, 1, 0x020304), bitrates[1]); |
49 ExpectBirateItemEquals(BitrateItem(1, 0, 0x030405), bitrates[2]); | 49 ExpectBirateItemEquals(BitrateItem(1, 0, 0x030405), bitrates[2]); |
50 ExpectBirateItemEquals(BitrateItem(1, 1, 0x040506), bitrates[3]); | 50 ExpectBirateItemEquals(BitrateItem(1, 1, 0x040506), bitrates[3]); |
51 } | 51 } |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 TEST(TargetBitrateTest, Parse) { | 55 TEST(TargetBitrateTest, Parse) { |
56 TargetBitrate target_bitrate; | 56 TargetBitrate target_bitrate; |
57 EXPECT_TRUE(target_bitrate.Parse(kPacket, kPacketLengthBlocks)); | 57 target_bitrate.Parse(kPacket, kPacketLengthBlocks); |
58 CheckBitrateItems(target_bitrate.GetTargetBitrates()); | 58 CheckBitrateItems(target_bitrate.GetTargetBitrates()); |
59 } | 59 } |
60 | 60 |
61 TEST(TargetBitrateTest, FullPacket) { | 61 TEST(TargetBitrateTest, FullPacket) { |
62 const size_t kXRHeaderSize = 8; // RTCP header (4) + SSRC (4). | 62 const size_t kXRHeaderSize = 8; // RTCP header (4) + SSRC (4). |
63 const size_t kTotalSize = kXRHeaderSize + sizeof(kPacket); | 63 const size_t kTotalSize = kXRHeaderSize + sizeof(kPacket); |
64 uint8_t kRtcpPacket[kTotalSize] = {2 << 6, 207, 0x00, (kTotalSize / 4) - 1, | 64 uint8_t kRtcpPacket[kTotalSize] = {2 << 6, 207, 0x00, (kTotalSize / 4) - 1, |
65 0x12, 0x34, 0x56, 0x78}; // SSRC. | 65 0x12, 0x34, 0x56, 0x78}; // SSRC. |
66 memcpy(&kRtcpPacket[kXRHeaderSize], kPacket, sizeof(kPacket)); | 66 memcpy(&kRtcpPacket[kXRHeaderSize], kPacket, sizeof(kPacket)); |
67 rtcp::ExtendedReports xr; | 67 rtcp::ExtendedReports xr; |
(...skipping 11 matching lines...) Expand all Loading... |
79 target_bitrate.AddTargetBitrate(1, 0, 0x030405); | 79 target_bitrate.AddTargetBitrate(1, 0, 0x030405); |
80 target_bitrate.AddTargetBitrate(1, 1, 0x040506); | 80 target_bitrate.AddTargetBitrate(1, 1, 0x040506); |
81 | 81 |
82 uint8_t buffer[sizeof(kPacket)] = {}; | 82 uint8_t buffer[sizeof(kPacket)] = {}; |
83 ASSERT_EQ(sizeof(kPacket), target_bitrate.BlockLength()); | 83 ASSERT_EQ(sizeof(kPacket), target_bitrate.BlockLength()); |
84 target_bitrate.Create(buffer); | 84 target_bitrate.Create(buffer); |
85 | 85 |
86 EXPECT_EQ(0, memcmp(kPacket, buffer, sizeof(kPacket))); | 86 EXPECT_EQ(0, memcmp(kPacket, buffer, sizeof(kPacket))); |
87 } | 87 } |
88 | 88 |
| 89 TEST(TargetBitrateTest, ParseNullBitratePacket) { |
| 90 const uint8_t kNullPacket[] = {TargetBitrate::kBlockType, 0x00, 0x00, 0x00}; |
| 91 TargetBitrate target_bitrate; |
| 92 target_bitrate.Parse(kNullPacket, 0); |
| 93 EXPECT_TRUE(target_bitrate.GetTargetBitrates().empty()); |
| 94 } |
| 95 |
89 } // namespace webrtc | 96 } // namespace webrtc |
OLD | NEW |