blob: 08b4d4f4bd4ed56ab4ab0e06a330146d4ebf6c98 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
10
Steve Antone78bcb92017-10-31 09:53:08 -070011#include <vector>
12
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "media/base/fakertp.h"
Yves Gerey665174f2018-06-19 15:03:05 +020014#include "media/base/rtputils.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "rtc_base/asyncpacketsocket.h"
16#include "rtc_base/gunit.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000017
18namespace cricket {
19
Sergey Ulanovdc305db2016-01-14 17:14:54 -080020static const uint8_t kRtpPacketWithMarker[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020021 0x80, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000022// 3 CSRCs (0x01020304, 0x12345678, 0xAABBCCDD)
23// Extension (0xBEDE, 0x1122334455667788)
Sergey Ulanovdc305db2016-01-14 17:14:54 -080024static const uint8_t kRtpPacketWithMarkerAndCsrcAndExtension[] = {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000025 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
26 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD,
Yves Gerey665174f2018-06-19 15:03:05 +020027 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
28static const uint8_t kInvalidPacket[] = {0x80, 0x00};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080029static const uint8_t kInvalidPacketWithCsrc[] = {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030 0x83, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
Yves Gerey665174f2018-06-19 15:03:05 +020031 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080032static const uint8_t kInvalidPacketWithCsrcAndExtension1[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020033 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34,
35 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD, 0xBE, 0xDE, 0x00};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080036static const uint8_t kInvalidPacketWithCsrcAndExtension2[] = {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
38 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD,
Yves Gerey665174f2018-06-19 15:03:05 +020039 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040
41// PT = 206, FMT = 1, Sender SSRC = 0x1111, Media SSRC = 0x1111
42// No FCI information is needed for PLI.
Sergey Ulanovdc305db2016-01-14 17:14:54 -080043static const uint8_t kNonCompoundRtcpPliFeedbackPacket[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020044 0x81, 0xCE, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x11, 0x11};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000045
46// Packet has only mandatory fixed RTCP header
47// PT = 204, SSRC = 0x1111
Yves Gerey665174f2018-06-19 15:03:05 +020048static const uint8_t kNonCompoundRtcpAppPacket[] = {0x81, 0xCC, 0x00, 0x0C,
49 0x00, 0x00, 0x11, 0x11};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000050
51// PT = 202, Source count = 0
Yves Gerey665174f2018-06-19 15:03:05 +020052static const uint8_t kNonCompoundRtcpSDESPacket[] = {0x80, 0xCA, 0x00, 0x00};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053
Yves Gerey665174f2018-06-19 15:03:05 +020054static uint8_t kFakeTag[4] = {0xba, 0xdd, 0xba, 0xdd};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080055static uint8_t kTestKey[] = "12345678901234567890";
Yves Gerey665174f2018-06-19 15:03:05 +020056static uint8_t kTestAstValue[3] = {0xaa, 0xbb, 0xcc};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080057
58// Valid rtp Message with 2 byte header extension.
59static uint8_t kRtpMsgWith2ByteExtnHeader[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020060 // clang-format off
61 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -080062 0x90, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00,
64 0xAA, 0xBB, 0xCC, 0XDD, // SSRC
65 0x10, 0x00, 0x00, 0x01, // 2 Byte header extension
66 0x01, 0x00, 0x00, 0x00
Yves Gerey665174f2018-06-19 15:03:05 +020067 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -080068};
69
70// RTP packet with single byte extension header of length 4 bytes.
71// Extension id = 3 and length = 3
72static uint8_t kRtpMsgWithAbsSendTimeExtension[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020073 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0xBE, 0xDE, 0x00, 0x02, 0x22, 0x00, 0x02, 0x1c, 0x32, 0xaa, 0xbb, 0xcc,
Sergey Ulanovdc305db2016-01-14 17:14:54 -080075};
76
77// Index of AbsSendTimeExtn data in message |kRtpMsgWithAbsSendTimeExtension|.
78static const int kAstIndexInRtpMsg = 21;
79
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080TEST(RtpUtilsTest, GetRtp) {
pkasting@chromium.org0e81fdf2015-02-02 23:54:03 +000081 EXPECT_TRUE(IsRtpPacket(kPcmuFrame, sizeof(kPcmuFrame)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +000082
83 int pt;
84 EXPECT_TRUE(GetRtpPayloadType(kPcmuFrame, sizeof(kPcmuFrame), &pt));
85 EXPECT_EQ(0, pt);
86 EXPECT_TRUE(GetRtpPayloadType(kRtpPacketWithMarker,
87 sizeof(kRtpPacketWithMarker), &pt));
88 EXPECT_EQ(0, pt);
89
90 int seq_num;
91 EXPECT_TRUE(GetRtpSeqNum(kPcmuFrame, sizeof(kPcmuFrame), &seq_num));
92 EXPECT_EQ(1, seq_num);
93
Peter Boström0c4e06b2015-10-07 12:23:21 +020094 uint32_t ts;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000095 EXPECT_TRUE(GetRtpTimestamp(kPcmuFrame, sizeof(kPcmuFrame), &ts));
96 EXPECT_EQ(0u, ts);
97
Peter Boström0c4e06b2015-10-07 12:23:21 +020098 uint32_t ssrc;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000099 EXPECT_TRUE(GetRtpSsrc(kPcmuFrame, sizeof(kPcmuFrame), &ssrc));
100 EXPECT_EQ(1u, ssrc);
101
102 RtpHeader header;
103 EXPECT_TRUE(GetRtpHeader(kPcmuFrame, sizeof(kPcmuFrame), &header));
104 EXPECT_EQ(0, header.payload_type);
105 EXPECT_EQ(1, header.seq_num);
106 EXPECT_EQ(0u, header.timestamp);
107 EXPECT_EQ(1u, header.ssrc);
108
109 EXPECT_FALSE(GetRtpPayloadType(kInvalidPacket, sizeof(kInvalidPacket), &pt));
110 EXPECT_FALSE(GetRtpSeqNum(kInvalidPacket, sizeof(kInvalidPacket), &seq_num));
111 EXPECT_FALSE(GetRtpTimestamp(kInvalidPacket, sizeof(kInvalidPacket), &ts));
112 EXPECT_FALSE(GetRtpSsrc(kInvalidPacket, sizeof(kInvalidPacket), &ssrc));
113}
114
pkasting@chromium.org0e81fdf2015-02-02 23:54:03 +0000115TEST(RtpUtilsTest, SetRtpHeader) {
Yves Gerey665174f2018-06-19 15:03:05 +0200116 uint8_t packet[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
117 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000118
Yves Gerey665174f2018-06-19 15:03:05 +0200119 RtpHeader header = {9, 1111, 2222u, 3333u};
pkasting@chromium.org0e81fdf2015-02-02 23:54:03 +0000120 EXPECT_TRUE(SetRtpHeader(packet, sizeof(packet), header));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000121
122 // Bits: 10 0 0 0000
123 EXPECT_EQ(128u, packet[0]);
124 size_t len;
125 EXPECT_TRUE(GetRtpHeaderLen(packet, sizeof(packet), &len));
126 EXPECT_EQ(12U, len);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000127 EXPECT_TRUE(GetRtpHeader(packet, sizeof(packet), &header));
128 EXPECT_EQ(9, header.payload_type);
129 EXPECT_EQ(1111, header.seq_num);
130 EXPECT_EQ(2222u, header.timestamp);
131 EXPECT_EQ(3333u, header.ssrc);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000132}
133
134TEST(RtpUtilsTest, GetRtpHeaderLen) {
135 size_t len;
136 EXPECT_TRUE(GetRtpHeaderLen(kPcmuFrame, sizeof(kPcmuFrame), &len));
137 EXPECT_EQ(12U, len);
138
139 EXPECT_TRUE(GetRtpHeaderLen(kRtpPacketWithMarkerAndCsrcAndExtension,
140 sizeof(kRtpPacketWithMarkerAndCsrcAndExtension),
141 &len));
142 EXPECT_EQ(sizeof(kRtpPacketWithMarkerAndCsrcAndExtension), len);
143
144 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacket, sizeof(kInvalidPacket), &len));
145 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacketWithCsrc,
146 sizeof(kInvalidPacketWithCsrc), &len));
147 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacketWithCsrcAndExtension1,
148 sizeof(kInvalidPacketWithCsrcAndExtension1),
149 &len));
150 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacketWithCsrcAndExtension2,
151 sizeof(kInvalidPacketWithCsrcAndExtension2),
152 &len));
153}
154
155TEST(RtpUtilsTest, GetRtcp) {
156 int pt;
157 EXPECT_TRUE(GetRtcpType(kRtcpReport, sizeof(kRtcpReport), &pt));
158 EXPECT_EQ(0xc9, pt);
159
160 EXPECT_FALSE(GetRtcpType(kInvalidPacket, sizeof(kInvalidPacket), &pt));
161
Peter Boström0c4e06b2015-10-07 12:23:21 +0200162 uint32_t ssrc;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000163 EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpPliFeedbackPacket,
Yves Gerey665174f2018-06-19 15:03:05 +0200164 sizeof(kNonCompoundRtcpPliFeedbackPacket), &ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000165 EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpAppPacket,
Yves Gerey665174f2018-06-19 15:03:05 +0200166 sizeof(kNonCompoundRtcpAppPacket), &ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000167 EXPECT_FALSE(GetRtcpSsrc(kNonCompoundRtcpSDESPacket,
Yves Gerey665174f2018-06-19 15:03:05 +0200168 sizeof(kNonCompoundRtcpSDESPacket), &ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000169}
170
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800171// Invalid RTP packets.
172TEST(RtpUtilsTest, InvalidRtpHeader) {
173 // Rtp message with invalid length.
174 const uint8_t kRtpMsgWithInvalidLength[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200175 // clang-format off
176 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800177 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0xAA, 0xBB, 0xCC, 0XDD, // SSRC
179 0xDD, 0xCC, 0xBB, 0xAA, // Only 1 CSRC, but CC count is 4.
Yves Gerey665174f2018-06-19 15:03:05 +0200180 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800181 };
182 EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidLength,
183 sizeof(kRtpMsgWithInvalidLength), nullptr));
184
185 // Rtp message with single byte header extension, invalid extension length.
186 const uint8_t kRtpMsgWithInvalidExtnLength[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200187 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
188 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE, 0x0A, 0x00, // Extn length - 0x0A00
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800189 };
190 EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidExtnLength,
191 sizeof(kRtpMsgWithInvalidExtnLength),
192 nullptr));
193}
194
195// Valid RTP packet with a 2byte header extension.
196TEST(RtpUtilsTest, Valid2ByteExtnHdrRtpMessage) {
197 EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWith2ByteExtnHeader,
198 sizeof(kRtpMsgWith2ByteExtnHeader), nullptr));
199}
200
201// Valid RTP packet which has 1 byte header AbsSendTime extension in it.
202TEST(RtpUtilsTest, ValidRtpPacketWithAbsSendTimeExtension) {
203 EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWithAbsSendTimeExtension,
204 sizeof(kRtpMsgWithAbsSendTimeExtension),
205 nullptr));
206}
207
208// Verify handling of a 2 byte extension header RTP messsage. Currently these
209// messages are not supported.
210TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionIn2ByteHeaderExtn) {
211 std::vector<uint8_t> data(
212 kRtpMsgWith2ByteExtnHeader,
213 kRtpMsgWith2ByteExtnHeader + sizeof(kRtpMsgWith2ByteExtnHeader));
214 EXPECT_FALSE(UpdateRtpAbsSendTimeExtension(&data[0], data.size(), 3, 0));
215}
216
217// Verify finding an extension ID in the TURN send indication message.
218TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) {
219 // A valid STUN indication message with a valid RTP header in data attribute
220 // payload field and no extension bit set.
221 uint8_t message_without_extension[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200222 // clang-format off
223 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800224 0x00, 0x16, 0x00, 0x18, // length of
225 0x21, 0x12, 0xA4, 0x42, // magic cookie
226 '0', '1', '2', '3', // transaction id
227 '4', '5', '6', '7',
228 '8', '9', 'a', 'b',
229 0x00, 0x20, 0x00, 0x04, // Mapped address.
230 0x00, 0x00, 0x00, 0x00,
231 0x00, 0x13, 0x00, 0x0C, // Data attribute.
232 0x80, 0x00, 0x00, 0x00, // RTP packet.
233 0x00, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00,
Yves Gerey665174f2018-06-19 15:03:05 +0200235 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800236 };
237 EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(
238 message_without_extension, sizeof(message_without_extension), 3, 0));
239
240 // A valid STUN indication message with a valid RTP header and a extension
241 // header.
242 uint8_t message[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200243 // clang-format off
244 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800245 0x00, 0x16, 0x00, 0x24, // length of
246 0x21, 0x12, 0xA4, 0x42, // magic cookie
247 '0', '1', '2', '3', // transaction id
248 '4', '5', '6', '7',
249 '8', '9', 'a', 'b',
250 0x00, 0x20, 0x00, 0x04, // Mapped address.
251 0x00, 0x00, 0x00, 0x00,
252 0x00, 0x13, 0x00, 0x18, // Data attribute.
253 0x90, 0x00, 0x00, 0x00, // RTP packet.
254 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE,
255 0x00, 0x02, 0x22, 0xaa, 0xbb, 0xcc, 0x32, 0xaa, 0xbb, 0xcc,
Yves Gerey665174f2018-06-19 15:03:05 +0200256 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800257 };
258 EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(message, sizeof(message), 3, 0));
259}
260
261// Test without any packet options variables set. This method should return
262// without HMAC value in the packet.
263TEST(RtpUtilsTest, ApplyPacketOptionsWithDefaultValues) {
264 rtc::PacketTimeUpdateParams packet_time_params;
265 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
266 kRtpMsgWithAbsSendTimeExtension +
267 sizeof(kRtpMsgWithAbsSendTimeExtension));
268 rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag));
269 EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(),
270 packet_time_params, 0));
271
272 // Making sure HMAC wasn't updated..
273 EXPECT_EQ(0, memcmp(&rtp_packet[sizeof(kRtpMsgWithAbsSendTimeExtension)],
274 kFakeTag, 4));
275
276 // Verify AbsouluteSendTime extension field wasn't modified.
277 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kTestAstValue,
278 sizeof(kTestAstValue)));
279}
280
281// Veirfy HMAC is updated when packet option parameters are set.
282TEST(RtpUtilsTest, ApplyPacketOptionsWithAuthParams) {
283 rtc::PacketTimeUpdateParams packet_time_params;
284 packet_time_params.srtp_auth_key.assign(kTestKey,
285 kTestKey + sizeof(kTestKey));
286 packet_time_params.srtp_auth_tag_len = 4;
287
288 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
289 kRtpMsgWithAbsSendTimeExtension +
290 sizeof(kRtpMsgWithAbsSendTimeExtension));
291 rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag));
292 EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(),
293 packet_time_params, 0));
294
295 uint8_t kExpectedTag[] = {0xc1, 0x7a, 0x8c, 0xa0};
296 EXPECT_EQ(0, memcmp(&rtp_packet[sizeof(kRtpMsgWithAbsSendTimeExtension)],
297 kExpectedTag, sizeof(kExpectedTag)));
298
299 // Verify AbsouluteSendTime extension field is not modified.
300 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kTestAstValue,
301 sizeof(kTestAstValue)));
302}
303
304// Verify finding an extension ID in a raw rtp message.
305TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInRtpPacket) {
306 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
307 kRtpMsgWithAbsSendTimeExtension +
308 sizeof(kRtpMsgWithAbsSendTimeExtension));
309
310 EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(&rtp_packet[0], rtp_packet.size(),
311 3, 51183266));
312
313 // Verify that the timestamp was updated.
314 const uint8_t kExpectedTimestamp[3] = {0xcc, 0xbb, 0xaa};
315 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kExpectedTimestamp,
316 sizeof(kExpectedTimestamp)));
317}
318
319// Verify we update both AbsSendTime extension header and HMAC.
320TEST(RtpUtilsTest, ApplyPacketOptionsWithAuthParamsAndAbsSendTime) {
321 rtc::PacketTimeUpdateParams packet_time_params;
322 packet_time_params.srtp_auth_key.assign(kTestKey,
323 kTestKey + sizeof(kTestKey));
324 packet_time_params.srtp_auth_tag_len = 4;
325 packet_time_params.rtp_sendtime_extension_id = 3;
326 // 3 is also present in the test message.
327
328 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
329 kRtpMsgWithAbsSendTimeExtension +
330 sizeof(kRtpMsgWithAbsSendTimeExtension));
331 rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag));
332 EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(),
333 packet_time_params, 51183266));
334
335 const uint8_t kExpectedTag[] = {0x81, 0xd1, 0x2c, 0x0e};
336 EXPECT_EQ(0, memcmp(&rtp_packet[sizeof(kRtpMsgWithAbsSendTimeExtension)],
337 kExpectedTag, sizeof(kExpectedTag)));
338
339 // Verify that the timestamp was updated.
340 const uint8_t kExpectedTimestamp[3] = {0xcc, 0xbb, 0xaa};
341 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kExpectedTimestamp,
342 sizeof(kExpectedTimestamp)));
343}
344
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000345} // namespace cricket