blob: 8ac68a44724a76e313ca9321065d2d96b922a97b [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
Yves Gerey3e707812018-11-28 16:47:49 +010011#include <string.h>
12#include <cstdint>
Steve Antone78bcb92017-10-31 09:53:08 -070013#include <vector>
14
Steve Anton10542f22019-01-11 09:11:00 -080015#include "media/base/fake_rtp.h"
16#include "media/base/rtp_utils.h"
17#include "rtc_base/async_packet_socket.h"
Yves Gerey3e707812018-11-28 16:47:49 +010018#include "test/gtest.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000019
20namespace cricket {
21
Sergey Ulanovdc305db2016-01-14 17:14:54 -080022static const uint8_t kRtpPacketWithMarker[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020023 0x80, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000024// 3 CSRCs (0x01020304, 0x12345678, 0xAABBCCDD)
25// Extension (0xBEDE, 0x1122334455667788)
Sergey Ulanovdc305db2016-01-14 17:14:54 -080026static const uint8_t kRtpPacketWithMarkerAndCsrcAndExtension[] = {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000027 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
28 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD,
Yves Gerey665174f2018-06-19 15:03:05 +020029 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
30static const uint8_t kInvalidPacket[] = {0x80, 0x00};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080031static const uint8_t kInvalidPacketWithCsrc[] = {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000032 0x83, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
Yves Gerey665174f2018-06-19 15:03:05 +020033 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080034static const uint8_t kInvalidPacketWithCsrcAndExtension1[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020035 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34,
37 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD, 0xBE, 0xDE, 0x00};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080038static const uint8_t kInvalidPacketWithCsrcAndExtension2[] = {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039 0x93, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
40 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x56, 0x78, 0xAA, 0xBB, 0xCC, 0xDD,
Yves Gerey665174f2018-06-19 15:03:05 +020041 0xBE, 0xDE, 0x00, 0x02, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000042
43// PT = 206, FMT = 1, Sender SSRC = 0x1111, Media SSRC = 0x1111
44// No FCI information is needed for PLI.
Sergey Ulanovdc305db2016-01-14 17:14:54 -080045static const uint8_t kNonCompoundRtcpPliFeedbackPacket[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020046 0x81, 0xCE, 0x00, 0x0C, 0x00, 0x00, 0x11, 0x11, 0x00, 0x00, 0x11, 0x11};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000047
48// Packet has only mandatory fixed RTCP header
49// PT = 204, SSRC = 0x1111
Yves Gerey665174f2018-06-19 15:03:05 +020050static const uint8_t kNonCompoundRtcpAppPacket[] = {0x81, 0xCC, 0x00, 0x0C,
51 0x00, 0x00, 0x11, 0x11};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000052
53// PT = 202, Source count = 0
Yves Gerey665174f2018-06-19 15:03:05 +020054static const uint8_t kNonCompoundRtcpSDESPacket[] = {0x80, 0xCA, 0x00, 0x00};
henrike@webrtc.org28e20752013-07-10 00:45:36 +000055
Yves Gerey665174f2018-06-19 15:03:05 +020056static uint8_t kFakeTag[4] = {0xba, 0xdd, 0xba, 0xdd};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080057static uint8_t kTestKey[] = "12345678901234567890";
Yves Gerey665174f2018-06-19 15:03:05 +020058static uint8_t kTestAstValue[3] = {0xaa, 0xbb, 0xcc};
Sergey Ulanovdc305db2016-01-14 17:14:54 -080059
60// Valid rtp Message with 2 byte header extension.
61static uint8_t kRtpMsgWith2ByteExtnHeader[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020062 // clang-format off
63 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -080064 0x90, 0x00, 0x00, 0x00,
65 0x00, 0x00, 0x00, 0x00,
66 0xAA, 0xBB, 0xCC, 0XDD, // SSRC
67 0x10, 0x00, 0x00, 0x01, // 2 Byte header extension
68 0x01, 0x00, 0x00, 0x00
Yves Gerey665174f2018-06-19 15:03:05 +020069 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -080070};
71
72// RTP packet with single byte extension header of length 4 bytes.
73// Extension id = 3 and length = 3
74static uint8_t kRtpMsgWithAbsSendTimeExtension[] = {
Yves Gerey665174f2018-06-19 15:03:05 +020075 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 0xBE, 0xDE, 0x00, 0x02, 0x22, 0x00, 0x02, 0x1c, 0x32, 0xaa, 0xbb, 0xcc,
Sergey Ulanovdc305db2016-01-14 17:14:54 -080077};
78
79// Index of AbsSendTimeExtn data in message |kRtpMsgWithAbsSendTimeExtension|.
80static const int kAstIndexInRtpMsg = 21;
81
henrike@webrtc.org28e20752013-07-10 00:45:36 +000082TEST(RtpUtilsTest, GetRtp) {
pkasting@chromium.org0e81fdf2015-02-02 23:54:03 +000083 EXPECT_TRUE(IsRtpPacket(kPcmuFrame, sizeof(kPcmuFrame)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +000084
85 int pt;
86 EXPECT_TRUE(GetRtpPayloadType(kPcmuFrame, sizeof(kPcmuFrame), &pt));
87 EXPECT_EQ(0, pt);
88 EXPECT_TRUE(GetRtpPayloadType(kRtpPacketWithMarker,
89 sizeof(kRtpPacketWithMarker), &pt));
90 EXPECT_EQ(0, pt);
91
92 int seq_num;
93 EXPECT_TRUE(GetRtpSeqNum(kPcmuFrame, sizeof(kPcmuFrame), &seq_num));
94 EXPECT_EQ(1, seq_num);
95
Peter Boström0c4e06b2015-10-07 12:23:21 +020096 uint32_t ts;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000097 EXPECT_TRUE(GetRtpTimestamp(kPcmuFrame, sizeof(kPcmuFrame), &ts));
98 EXPECT_EQ(0u, ts);
99
Peter Boström0c4e06b2015-10-07 12:23:21 +0200100 uint32_t ssrc;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101 EXPECT_TRUE(GetRtpSsrc(kPcmuFrame, sizeof(kPcmuFrame), &ssrc));
102 EXPECT_EQ(1u, ssrc);
103
104 RtpHeader header;
105 EXPECT_TRUE(GetRtpHeader(kPcmuFrame, sizeof(kPcmuFrame), &header));
106 EXPECT_EQ(0, header.payload_type);
107 EXPECT_EQ(1, header.seq_num);
108 EXPECT_EQ(0u, header.timestamp);
109 EXPECT_EQ(1u, header.ssrc);
110
111 EXPECT_FALSE(GetRtpPayloadType(kInvalidPacket, sizeof(kInvalidPacket), &pt));
112 EXPECT_FALSE(GetRtpSeqNum(kInvalidPacket, sizeof(kInvalidPacket), &seq_num));
113 EXPECT_FALSE(GetRtpTimestamp(kInvalidPacket, sizeof(kInvalidPacket), &ts));
114 EXPECT_FALSE(GetRtpSsrc(kInvalidPacket, sizeof(kInvalidPacket), &ssrc));
115}
116
pkasting@chromium.org0e81fdf2015-02-02 23:54:03 +0000117TEST(RtpUtilsTest, SetRtpHeader) {
Yves Gerey665174f2018-06-19 15:03:05 +0200118 uint8_t packet[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000120
Yves Gerey665174f2018-06-19 15:03:05 +0200121 RtpHeader header = {9, 1111, 2222u, 3333u};
pkasting@chromium.org0e81fdf2015-02-02 23:54:03 +0000122 EXPECT_TRUE(SetRtpHeader(packet, sizeof(packet), header));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123
124 // Bits: 10 0 0 0000
125 EXPECT_EQ(128u, packet[0]);
126 size_t len;
127 EXPECT_TRUE(GetRtpHeaderLen(packet, sizeof(packet), &len));
128 EXPECT_EQ(12U, len);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000129 EXPECT_TRUE(GetRtpHeader(packet, sizeof(packet), &header));
130 EXPECT_EQ(9, header.payload_type);
131 EXPECT_EQ(1111, header.seq_num);
132 EXPECT_EQ(2222u, header.timestamp);
133 EXPECT_EQ(3333u, header.ssrc);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000134}
135
136TEST(RtpUtilsTest, GetRtpHeaderLen) {
137 size_t len;
138 EXPECT_TRUE(GetRtpHeaderLen(kPcmuFrame, sizeof(kPcmuFrame), &len));
139 EXPECT_EQ(12U, len);
140
141 EXPECT_TRUE(GetRtpHeaderLen(kRtpPacketWithMarkerAndCsrcAndExtension,
142 sizeof(kRtpPacketWithMarkerAndCsrcAndExtension),
143 &len));
144 EXPECT_EQ(sizeof(kRtpPacketWithMarkerAndCsrcAndExtension), len);
145
146 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacket, sizeof(kInvalidPacket), &len));
147 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacketWithCsrc,
148 sizeof(kInvalidPacketWithCsrc), &len));
149 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacketWithCsrcAndExtension1,
150 sizeof(kInvalidPacketWithCsrcAndExtension1),
151 &len));
152 EXPECT_FALSE(GetRtpHeaderLen(kInvalidPacketWithCsrcAndExtension2,
153 sizeof(kInvalidPacketWithCsrcAndExtension2),
154 &len));
155}
156
157TEST(RtpUtilsTest, GetRtcp) {
158 int pt;
159 EXPECT_TRUE(GetRtcpType(kRtcpReport, sizeof(kRtcpReport), &pt));
160 EXPECT_EQ(0xc9, pt);
161
162 EXPECT_FALSE(GetRtcpType(kInvalidPacket, sizeof(kInvalidPacket), &pt));
163
Peter Boström0c4e06b2015-10-07 12:23:21 +0200164 uint32_t ssrc;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000165 EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpPliFeedbackPacket,
Yves Gerey665174f2018-06-19 15:03:05 +0200166 sizeof(kNonCompoundRtcpPliFeedbackPacket), &ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000167 EXPECT_TRUE(GetRtcpSsrc(kNonCompoundRtcpAppPacket,
Yves Gerey665174f2018-06-19 15:03:05 +0200168 sizeof(kNonCompoundRtcpAppPacket), &ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000169 EXPECT_FALSE(GetRtcpSsrc(kNonCompoundRtcpSDESPacket,
Yves Gerey665174f2018-06-19 15:03:05 +0200170 sizeof(kNonCompoundRtcpSDESPacket), &ssrc));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000171}
172
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800173// Invalid RTP packets.
174TEST(RtpUtilsTest, InvalidRtpHeader) {
175 // Rtp message with invalid length.
176 const uint8_t kRtpMsgWithInvalidLength[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200177 // clang-format off
178 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800179 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 0xAA, 0xBB, 0xCC, 0XDD, // SSRC
181 0xDD, 0xCC, 0xBB, 0xAA, // Only 1 CSRC, but CC count is 4.
Yves Gerey665174f2018-06-19 15:03:05 +0200182 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800183 };
184 EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidLength,
185 sizeof(kRtpMsgWithInvalidLength), nullptr));
186
187 // Rtp message with single byte header extension, invalid extension length.
188 const uint8_t kRtpMsgWithInvalidExtnLength[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200189 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE, 0x0A, 0x00, // Extn length - 0x0A00
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800191 };
192 EXPECT_FALSE(ValidateRtpHeader(kRtpMsgWithInvalidExtnLength,
193 sizeof(kRtpMsgWithInvalidExtnLength),
194 nullptr));
195}
196
197// Valid RTP packet with a 2byte header extension.
198TEST(RtpUtilsTest, Valid2ByteExtnHdrRtpMessage) {
199 EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWith2ByteExtnHeader,
200 sizeof(kRtpMsgWith2ByteExtnHeader), nullptr));
201}
202
203// Valid RTP packet which has 1 byte header AbsSendTime extension in it.
204TEST(RtpUtilsTest, ValidRtpPacketWithAbsSendTimeExtension) {
205 EXPECT_TRUE(ValidateRtpHeader(kRtpMsgWithAbsSendTimeExtension,
206 sizeof(kRtpMsgWithAbsSendTimeExtension),
207 nullptr));
208}
209
210// Verify handling of a 2 byte extension header RTP messsage. Currently these
211// messages are not supported.
212TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionIn2ByteHeaderExtn) {
213 std::vector<uint8_t> data(
214 kRtpMsgWith2ByteExtnHeader,
215 kRtpMsgWith2ByteExtnHeader + sizeof(kRtpMsgWith2ByteExtnHeader));
216 EXPECT_FALSE(UpdateRtpAbsSendTimeExtension(&data[0], data.size(), 3, 0));
217}
218
219// Verify finding an extension ID in the TURN send indication message.
220TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInTurnSendIndication) {
221 // A valid STUN indication message with a valid RTP header in data attribute
222 // payload field and no extension bit set.
223 uint8_t message_without_extension[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200224 // clang-format off
225 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800226 0x00, 0x16, 0x00, 0x18, // length of
227 0x21, 0x12, 0xA4, 0x42, // magic cookie
228 '0', '1', '2', '3', // transaction id
229 '4', '5', '6', '7',
230 '8', '9', 'a', 'b',
231 0x00, 0x20, 0x00, 0x04, // Mapped address.
232 0x00, 0x00, 0x00, 0x00,
233 0x00, 0x13, 0x00, 0x0C, // Data attribute.
234 0x80, 0x00, 0x00, 0x00, // RTP packet.
235 0x00, 0x00, 0x00, 0x00,
236 0x00, 0x00, 0x00, 0x00,
Yves Gerey665174f2018-06-19 15:03:05 +0200237 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800238 };
239 EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(
240 message_without_extension, sizeof(message_without_extension), 3, 0));
241
242 // A valid STUN indication message with a valid RTP header and a extension
243 // header.
244 uint8_t message[] = {
Yves Gerey665174f2018-06-19 15:03:05 +0200245 // clang-format off
246 // clang formatting doesn't respect inline comments.
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800247 0x00, 0x16, 0x00, 0x24, // length of
248 0x21, 0x12, 0xA4, 0x42, // magic cookie
249 '0', '1', '2', '3', // transaction id
250 '4', '5', '6', '7',
251 '8', '9', 'a', 'b',
252 0x00, 0x20, 0x00, 0x04, // Mapped address.
253 0x00, 0x00, 0x00, 0x00,
254 0x00, 0x13, 0x00, 0x18, // Data attribute.
255 0x90, 0x00, 0x00, 0x00, // RTP packet.
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xBE, 0xDE,
257 0x00, 0x02, 0x22, 0xaa, 0xbb, 0xcc, 0x32, 0xaa, 0xbb, 0xcc,
Yves Gerey665174f2018-06-19 15:03:05 +0200258 // clang-format on
Sergey Ulanovdc305db2016-01-14 17:14:54 -0800259 };
260 EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(message, sizeof(message), 3, 0));
261}
262
263// Test without any packet options variables set. This method should return
264// without HMAC value in the packet.
265TEST(RtpUtilsTest, ApplyPacketOptionsWithDefaultValues) {
266 rtc::PacketTimeUpdateParams packet_time_params;
267 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
268 kRtpMsgWithAbsSendTimeExtension +
269 sizeof(kRtpMsgWithAbsSendTimeExtension));
270 rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag));
271 EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(),
272 packet_time_params, 0));
273
274 // Making sure HMAC wasn't updated..
275 EXPECT_EQ(0, memcmp(&rtp_packet[sizeof(kRtpMsgWithAbsSendTimeExtension)],
276 kFakeTag, 4));
277
278 // Verify AbsouluteSendTime extension field wasn't modified.
279 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kTestAstValue,
280 sizeof(kTestAstValue)));
281}
282
283// Veirfy HMAC is updated when packet option parameters are set.
284TEST(RtpUtilsTest, ApplyPacketOptionsWithAuthParams) {
285 rtc::PacketTimeUpdateParams packet_time_params;
286 packet_time_params.srtp_auth_key.assign(kTestKey,
287 kTestKey + sizeof(kTestKey));
288 packet_time_params.srtp_auth_tag_len = 4;
289
290 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
291 kRtpMsgWithAbsSendTimeExtension +
292 sizeof(kRtpMsgWithAbsSendTimeExtension));
293 rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag));
294 EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(),
295 packet_time_params, 0));
296
297 uint8_t kExpectedTag[] = {0xc1, 0x7a, 0x8c, 0xa0};
298 EXPECT_EQ(0, memcmp(&rtp_packet[sizeof(kRtpMsgWithAbsSendTimeExtension)],
299 kExpectedTag, sizeof(kExpectedTag)));
300
301 // Verify AbsouluteSendTime extension field is not modified.
302 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kTestAstValue,
303 sizeof(kTestAstValue)));
304}
305
306// Verify finding an extension ID in a raw rtp message.
307TEST(RtpUtilsTest, UpdateAbsSendTimeExtensionInRtpPacket) {
308 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
309 kRtpMsgWithAbsSendTimeExtension +
310 sizeof(kRtpMsgWithAbsSendTimeExtension));
311
312 EXPECT_TRUE(UpdateRtpAbsSendTimeExtension(&rtp_packet[0], rtp_packet.size(),
313 3, 51183266));
314
315 // Verify that the timestamp was updated.
316 const uint8_t kExpectedTimestamp[3] = {0xcc, 0xbb, 0xaa};
317 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kExpectedTimestamp,
318 sizeof(kExpectedTimestamp)));
319}
320
321// Verify we update both AbsSendTime extension header and HMAC.
322TEST(RtpUtilsTest, ApplyPacketOptionsWithAuthParamsAndAbsSendTime) {
323 rtc::PacketTimeUpdateParams packet_time_params;
324 packet_time_params.srtp_auth_key.assign(kTestKey,
325 kTestKey + sizeof(kTestKey));
326 packet_time_params.srtp_auth_tag_len = 4;
327 packet_time_params.rtp_sendtime_extension_id = 3;
328 // 3 is also present in the test message.
329
330 std::vector<uint8_t> rtp_packet(kRtpMsgWithAbsSendTimeExtension,
331 kRtpMsgWithAbsSendTimeExtension +
332 sizeof(kRtpMsgWithAbsSendTimeExtension));
333 rtp_packet.insert(rtp_packet.end(), kFakeTag, kFakeTag + sizeof(kFakeTag));
334 EXPECT_TRUE(ApplyPacketOptions(&rtp_packet[0], rtp_packet.size(),
335 packet_time_params, 51183266));
336
337 const uint8_t kExpectedTag[] = {0x81, 0xd1, 0x2c, 0x0e};
338 EXPECT_EQ(0, memcmp(&rtp_packet[sizeof(kRtpMsgWithAbsSendTimeExtension)],
339 kExpectedTag, sizeof(kExpectedTag)));
340
341 // Verify that the timestamp was updated.
342 const uint8_t kExpectedTimestamp[3] = {0xcc, 0xbb, 0xaa};
343 EXPECT_EQ(0, memcmp(&rtp_packet[kAstIndexInRtpMsg], kExpectedTimestamp,
344 sizeof(kExpectedTimestamp)));
345}
346
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000347} // namespace cricket