fake_rtp.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. // Fake RTP and RTCP packets to use in unit tests.
  11. #ifndef MEDIA_BASE_FAKE_RTP_H_
  12. #define MEDIA_BASE_FAKE_RTP_H_
  13. #include <cstddef> // size_t
  14. #include <vector>
  15. // A typical PCMU RTP packet.
  16. // PT=0, SN=1, TS=0, SSRC=1
  17. // all data FF
  18. static const unsigned char kPcmuFrame[] = {
  19. 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  20. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  21. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  22. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  23. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  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,
  34. };
  35. static const int kHeaderExtensionIDs[] = {1, 4};
  36. // A typical PCMU RTP packet with header extensions.
  37. // PT=0, SN=1, TS=0, SSRC=1
  38. // all data FF
  39. static const unsigned char kPcmuFrameWithExtensions[] = {
  40. 0x90,
  41. 0x00,
  42. 0x00,
  43. 0x01,
  44. 0x00,
  45. 0x00,
  46. 0x00,
  47. 0x00,
  48. 0x00,
  49. 0x00,
  50. 0x00,
  51. 0x01,
  52. // RFC 5285, section 4.2. One-Byte Header.
  53. 0xBE,
  54. 0xDE,
  55. // Header extension length 6 * 32 bits.
  56. 0x00,
  57. 0x06,
  58. // 8 bytes header id 1.
  59. 0x17,
  60. 0x41,
  61. 0x42,
  62. 0x73,
  63. 0xA4,
  64. 0x75,
  65. 0x26,
  66. 0x27,
  67. 0x48,
  68. // 3 bytes header id 2.
  69. 0x22,
  70. 0x00,
  71. 0x00,
  72. 0xC8,
  73. // 1 byte header id 3.
  74. 0x30,
  75. 0x8E,
  76. // 7 bytes header id 4.
  77. 0x46,
  78. 0x55,
  79. 0x99,
  80. 0x63,
  81. 0x86,
  82. 0xB3,
  83. 0x95,
  84. 0xFB,
  85. // 1 byte header padding.
  86. 0x00,
  87. // Payload data.
  88. 0xFF,
  89. 0xFF,
  90. 0xFF,
  91. 0xFF,
  92. 0xFF,
  93. 0xFF,
  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. };
  249. // A typical Receiver Report RTCP packet.
  250. // PT=RR, LN=1, SSRC=1
  251. // send SSRC=2, all other fields 0
  252. static const unsigned char kRtcpReport[] = {
  253. 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  254. 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  255. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  256. // PT = 97, TS = 0, Seq = 1, SSRC = 2
  257. // H264 - NRI = 1, Type = 1, bit stream = FF
  258. static const unsigned char kH264Packet[] = {
  259. 0x80, 0x61, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
  260. 0x21, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  261. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  262. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  263. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  264. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  265. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  266. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  267. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  268. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  269. 0xFF, 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,
  274. };
  275. // PT= 101, SN=2, TS=3, SSRC = 4
  276. static const unsigned char kDataPacket[] = {
  277. 0x80, 0x65, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04,
  278. 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
  279. };
  280. // This expects both packets to be based on kPcmuFrameWithExtensions.
  281. // Header extensions with an id in "encrypted_headers" are expected to be
  282. // different in the packets unless "expect_equal" is set to "true".
  283. void CompareHeaderExtensions(const char* packet1,
  284. size_t packet1_size,
  285. const char* packet2,
  286. size_t packet2_size,
  287. const std::vector<int> encrypted_headers,
  288. bool expect_equal);
  289. #endif // MEDIA_BASE_FAKE_RTP_H_