1 /* 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 3 * 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 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. 9 */ 10 11 // Fake RTP and RTCP packets to use in unit tests. 12 13 #ifndef MEDIA_BASE_FAKE_RTP_H_ 14 #define MEDIA_BASE_FAKE_RTP_H_ 15 16 #include <cstddef> // size_t 17 #include <vector> 18 19 // A typical PCMU RTP packet. 20 // PT=0, SN=1, TS=0, SSRC=1 21 // all data FF 22 static const unsigned char kPcmuFrame[] = { 23 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 24 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 25 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 26 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 27 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 28 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 29 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 30 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 31 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 32 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 33 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 34 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 35 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 36 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 37 0xFF, 0xFF, 0xFF, 0xFF, 38 }; 39 40 static const int kHeaderExtensionIDs[] = {1, 4}; 41 42 // A typical PCMU RTP packet with header extensions. 43 // PT=0, SN=1, TS=0, SSRC=1 44 // all data FF 45 static const unsigned char kPcmuFrameWithExtensions[] = { 46 0x90, 47 0x00, 48 0x00, 49 0x01, 50 0x00, 51 0x00, 52 0x00, 53 0x00, 54 0x00, 55 0x00, 56 0x00, 57 0x01, 58 // RFC 5285, section 4.2. One-Byte Header. 59 0xBE, 60 0xDE, 61 // Header extension length 6 * 32 bits. 62 0x00, 63 0x06, 64 // 8 bytes header id 1. 65 0x17, 66 0x41, 67 0x42, 68 0x73, 69 0xA4, 70 0x75, 71 0x26, 72 0x27, 73 0x48, 74 // 3 bytes header id 2. 75 0x22, 76 0x00, 77 0x00, 78 0xC8, 79 // 1 byte header id 3. 80 0x30, 81 0x8E, 82 // 7 bytes header id 4. 83 0x46, 84 0x55, 85 0x99, 86 0x63, 87 0x86, 88 0xB3, 89 0x95, 90 0xFB, 91 // 1 byte header padding. 92 0x00, 93 // Payload data. 94 0xFF, 95 0xFF, 96 0xFF, 97 0xFF, 98 0xFF, 99 0xFF, 100 0xFF, 101 0xFF, 102 0xFF, 103 0xFF, 104 0xFF, 105 0xFF, 106 0xFF, 107 0xFF, 108 0xFF, 109 0xFF, 110 0xFF, 111 0xFF, 112 0xFF, 113 0xFF, 114 0xFF, 115 0xFF, 116 0xFF, 117 0xFF, 118 0xFF, 119 0xFF, 120 0xFF, 121 0xFF, 122 0xFF, 123 0xFF, 124 0xFF, 125 0xFF, 126 0xFF, 127 0xFF, 128 0xFF, 129 0xFF, 130 0xFF, 131 0xFF, 132 0xFF, 133 0xFF, 134 0xFF, 135 0xFF, 136 0xFF, 137 0xFF, 138 0xFF, 139 0xFF, 140 0xFF, 141 0xFF, 142 0xFF, 143 0xFF, 144 0xFF, 145 0xFF, 146 0xFF, 147 0xFF, 148 0xFF, 149 0xFF, 150 0xFF, 151 0xFF, 152 0xFF, 153 0xFF, 154 0xFF, 155 0xFF, 156 0xFF, 157 0xFF, 158 0xFF, 159 0xFF, 160 0xFF, 161 0xFF, 162 0xFF, 163 0xFF, 164 0xFF, 165 0xFF, 166 0xFF, 167 0xFF, 168 0xFF, 169 0xFF, 170 0xFF, 171 0xFF, 172 0xFF, 173 0xFF, 174 0xFF, 175 0xFF, 176 0xFF, 177 0xFF, 178 0xFF, 179 0xFF, 180 0xFF, 181 0xFF, 182 0xFF, 183 0xFF, 184 0xFF, 185 0xFF, 186 0xFF, 187 0xFF, 188 0xFF, 189 0xFF, 190 0xFF, 191 0xFF, 192 0xFF, 193 0xFF, 194 0xFF, 195 0xFF, 196 0xFF, 197 0xFF, 198 0xFF, 199 0xFF, 200 0xFF, 201 0xFF, 202 0xFF, 203 0xFF, 204 0xFF, 205 0xFF, 206 0xFF, 207 0xFF, 208 0xFF, 209 0xFF, 210 0xFF, 211 0xFF, 212 0xFF, 213 0xFF, 214 0xFF, 215 0xFF, 216 0xFF, 217 0xFF, 218 0xFF, 219 0xFF, 220 0xFF, 221 0xFF, 222 0xFF, 223 0xFF, 224 0xFF, 225 0xFF, 226 0xFF, 227 0xFF, 228 0xFF, 229 0xFF, 230 0xFF, 231 0xFF, 232 0xFF, 233 0xFF, 234 0xFF, 235 0xFF, 236 0xFF, 237 0xFF, 238 0xFF, 239 0xFF, 240 0xFF, 241 0xFF, 242 0xFF, 243 0xFF, 244 0xFF, 245 0xFF, 246 0xFF, 247 0xFF, 248 0xFF, 249 0xFF, 250 0xFF, 251 0xFF, 252 0xFF, 253 0xFF, 254 }; 255 256 // A typical Receiver Report RTCP packet. 257 // PT=RR, LN=1, SSRC=1 258 // send SSRC=2, all other fields 0 259 static const unsigned char kRtcpReport[] = { 260 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 261 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 263 264 // PT = 97, TS = 0, Seq = 1, SSRC = 2 265 // H264 - NRI = 1, Type = 1, bit stream = FF 266 267 static const unsigned char kH264Packet[] = { 268 0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 269 0x21, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 270 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 271 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 272 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 273 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 274 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 275 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 276 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 277 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 278 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 279 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 280 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 281 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 282 0xFF, 0xFF, 0xFF, 0xFF, 283 }; 284 285 // PT= 101, SN=2, TS=3, SSRC = 4 286 static const unsigned char kDataPacket[] = { 287 0x80, 0x65, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 288 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 289 }; 290 291 // This expects both packets to be based on kPcmuFrameWithExtensions. 292 // Header extensions with an id in "encrypted_headers" are expected to be 293 // different in the packets unless "expect_equal" is set to "true". 294 void CompareHeaderExtensions(const char* packet1, 295 size_t packet1_size, 296 const char* packet2, 297 size_t packet2_size, 298 const std::vector<int> encrypted_headers, 299 bool expect_equal); 300 301 #endif // MEDIA_BASE_FAKE_RTP_H_ 302