test_abstract_jb.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2012, Matt Jordan
  5. *
  6. * Matt Jordan <mjordan@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*!
  19. * \file
  20. * \brief Abstract Jitterbuffer Tests
  21. *
  22. * \author \verbatim Matt Jordan <mjordan@digium.com> \endverbatim
  23. *
  24. * Tests the abstract jitter buffer API. This tests both adaptive and fixed
  25. * jitter buffers. Functions defined in abstract_jb that are not part of the
  26. * abstract jitter buffer API are not tested by this unit test.
  27. *
  28. * \ingroup tests
  29. */
  30. /*** MODULEINFO
  31. <depend>TEST_FRAMEWORK</depend>
  32. <support_level>core</support_level>
  33. ***/
  34. #include "asterisk.h"
  35. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  36. #include "asterisk/utils.h"
  37. #include "asterisk/module.h"
  38. #include "asterisk/test.h"
  39. #include "asterisk/abstract_jb.h"
  40. #include "asterisk/frame.h"
  41. #include "asterisk/format_cache.h"
  42. #define DEFAULT_FRAME_MS 160
  43. #define DEFAULT_CONFIG_FLAGS 0
  44. #define DEFAULT_CONFIG_SIZE (DEFAULT_FRAME_MS) * 10
  45. #define DEFAULT_CONFIG_RESYNC_THRESHOLD (DEFAULT_FRAME_MS) * 2
  46. #define DEFAULT_CONFIG_TARGET_EXTRA -1
  47. /*!
  48. * \internal
  49. * \brief Destructor for a jitter buffer
  50. *
  51. * \param jb The jitter buffer to destroy
  52. *
  53. * \note This will destroy all frames still in the jitter buffer
  54. */
  55. static void dispose_jitterbuffer(struct ast_jb *jb)
  56. {
  57. if (!jb || !jb->impl || !jb->jbobj) {
  58. return;
  59. }
  60. jb->impl->empty_and_reset(jb->jbobj);
  61. jb->impl->destroy(jb->jbobj);
  62. jb->impl = NULL;
  63. jb->jbobj = NULL;
  64. }
  65. /*!
  66. * \internal
  67. * \brief Create a test frame
  68. *
  69. * \param timestamp the time in ms of the frame
  70. * \param seqno the frame's sequence number
  71. *
  72. * \returns a malloc'd frame
  73. */
  74. static struct ast_frame *create_test_frame(long timestamp,
  75. int seqno)
  76. {
  77. struct ast_frame f = {0};
  78. f.subclass.format = ast_format_slin;
  79. f.frametype = AST_FRAME_VOICE;
  80. f.src = "TEST";
  81. f.ts = timestamp;
  82. f.len = DEFAULT_FRAME_MS;
  83. f.seqno = seqno;
  84. return ast_frisolate(&f);
  85. }
  86. /*! \internal
  87. * \brief Test two numeric (long int) values.
  88. */
  89. #define LONG_INT_TEST(actual, expected) do { \
  90. if ((actual) != (expected)) { \
  91. ast_test_status_update(test, #actual ": expected [%ld]; actual [%ld]\n", (long int)(expected), (long int)(actual)); \
  92. return AST_TEST_FAIL; \
  93. } } while (0)
  94. /*! \internal
  95. * \brief Test two numeric (int) values.
  96. */
  97. #define INT_TEST(actual, expected) do { \
  98. if ((actual) != (expected)) { \
  99. ast_test_status_update(test, #actual ": expected [%d]; actual [%d]\n", (expected), (actual)); \
  100. return AST_TEST_FAIL; \
  101. } } while (0)
  102. /*! \internal
  103. * \brief Test two numeric (unsigned int) values.
  104. */
  105. #define UINT_TEST(actual, expected) do { \
  106. if ((actual) != (expected)) { \
  107. ast_test_status_update(test, #actual ": expected [%u]; actual [%u]\n", (expected), (actual)); \
  108. return AST_TEST_FAIL; \
  109. } } while (0)
  110. /*! \internal
  111. * \brief Test two string values
  112. */
  113. #define STRING_TEST(actual, expected) do { \
  114. if (strcmp((actual), (expected))) { \
  115. ast_test_status_update(test, #actual ": expected [%s]; actual [%s]\n", (expected), (actual)); \
  116. return AST_TEST_FAIL; \
  117. } } while (0)
  118. /*! \internal
  119. * \brief Verify that two frames have the same properties
  120. */
  121. #define VERIFY_FRAME(actual, expected) do { \
  122. UINT_TEST((actual)->frametype, (expected)->frametype); \
  123. INT_TEST((actual)->seqno, (expected)->seqno); \
  124. LONG_INT_TEST((actual)->ts, (expected)->ts); \
  125. LONG_INT_TEST((actual)->len, (expected)->len); \
  126. STRING_TEST((actual)->src, (expected)->src); \
  127. } while (0)
  128. /*! \internal
  129. * \brief Get the implementation for a jitter buffer
  130. */
  131. #define OBTAIN_JITTERBUFFER_IMPL(impl, ast_jb_type, literal_name) do { \
  132. (impl) = ast_jb_get_impl((ast_jb_type)); \
  133. if (!(impl)) { \
  134. ast_test_status_update(test, "Error: no %s jitterbuffer defined\n", (literal_name)); \
  135. return AST_TEST_FAIL; \
  136. } \
  137. if (strcmp((impl)->name, (literal_name))) { \
  138. ast_test_status_update(test, "Error: requested %s jitterbuffer and received %s\n", (literal_name), (impl)->name); \
  139. return AST_TEST_FAIL; \
  140. } } while (0)
  141. /*! \internal
  142. * \brief Make a jitter buffer configuration object with default values
  143. */
  144. #define MAKE_DEFAULT_CONFIG(conf, impl) do { \
  145. (conf)->flags = DEFAULT_CONFIG_FLAGS; \
  146. strcpy((conf)->impl, (impl)->name); \
  147. (conf)->max_size = DEFAULT_CONFIG_SIZE; \
  148. (conf)->resync_threshold = DEFAULT_CONFIG_RESYNC_THRESHOLD; \
  149. (conf)->target_extra = DEFAULT_CONFIG_TARGET_EXTRA; \
  150. } while (0)
  151. /*!
  152. * \internal
  153. * \brief A container object for the jitter buffers, used for all tests
  154. */
  155. static struct ast_jb default_jb = {
  156. .impl = NULL,
  157. .jbobj = NULL
  158. };
  159. /*!
  160. * \internal
  161. * \brief Construct a test name
  162. */
  163. #define TEST_NAME(type_name, specifier) type_name ## _ ## specifier
  164. #define TEST_NAME2(test_name) #test_name
  165. #define STRINGIFY_TESTNAME(test_name) TEST_NAME2(test_name)
  166. /*!
  167. * \internal
  168. * \brief Test nominal construction of a jitter buffer
  169. *
  170. * \param type_name The enum type of the jitter buffer to create
  171. * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
  172. */
  173. #define test_create_nominal(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, create)) {\
  174. RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
  175. const struct ast_jb_impl *impl; \
  176. struct ast_jb_conf conf; \
  177. \
  178. switch (cmd) { \
  179. case TEST_INIT: \
  180. info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, create)); \
  181. info->category = "/main/abstract_jb/"; \
  182. info->summary = "Test nominal creation of a " literal_type_name " jitterbuffer"; \
  183. info->description = \
  184. "Tests nominal creation of a " literal_type_name " jitterbuffer using the " \
  185. " jitterbuffer API."; \
  186. return AST_TEST_NOT_RUN; \
  187. case TEST_EXECUTE: \
  188. break; \
  189. } \
  190. \
  191. ast_test_status_update(test, "Executing " STRINGIFY_TESTNAME(TEST_NAME(type_name, create))"...\n"); \
  192. OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
  193. MAKE_DEFAULT_CONFIG(&conf, impl); \
  194. \
  195. jb->jbobj = impl->create(&conf); \
  196. jb->impl = impl; \
  197. if (!jb->jbobj) { \
  198. ast_test_status_update(test, "Error: Failed to adaptive jitterbuffer\n"); \
  199. return AST_TEST_FAIL; \
  200. } \
  201. \
  202. return AST_TEST_PASS; \
  203. }
  204. /*!
  205. * \internal
  206. * \brief Test putting the initial frame into a jitter buffer
  207. *
  208. * \param type_name The enum type of the jitter buffer to create
  209. * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
  210. */
  211. #define test_put_first(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, put_first)) {\
  212. RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
  213. const struct ast_jb_impl *impl; \
  214. struct ast_jb_conf conf; \
  215. RAII_VAR(struct ast_frame *, expected_frame, NULL, ast_frame_dtor); \
  216. RAII_VAR(struct ast_frame *, actual_frame, NULL, ast_frame_dtor); \
  217. int res; \
  218. \
  219. switch (cmd) { \
  220. case TEST_INIT: \
  221. info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put_first)); \
  222. info->category = "/main/abstract_jb/"; \
  223. info->summary = "Test putting a frame into a " literal_type_name " jitterbuffer"; \
  224. info->description = \
  225. "This tests putting a single frame into a " literal_type_name " jitterbuffer " \
  226. "when the jitterbuffer is empty and verifying that it is indeed " \
  227. "the first frame on the jitterbufffer"; \
  228. return AST_TEST_NOT_RUN; \
  229. case TEST_EXECUTE: \
  230. break; \
  231. } \
  232. \
  233. ast_test_status_update(test, "Executing " STRINGIFY_TESTNAME(TEST_NAME(type_name, create))"...\n"); \
  234. OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
  235. MAKE_DEFAULT_CONFIG(&conf, impl); \
  236. jb->jbobj = impl->create(&conf); \
  237. jb->impl = impl; \
  238. if (!jb->jbobj) { \
  239. ast_test_status_update(test, "Error: Failed to adaptive jitterbuffer\n"); \
  240. return AST_TEST_FAIL; \
  241. } \
  242. \
  243. expected_frame = create_test_frame(1000, 0); \
  244. res = jb->impl->put_first(jb->jbobj, \
  245. expected_frame, \
  246. 1100); \
  247. if (res != AST_JB_IMPL_OK) { \
  248. ast_test_status_update(test, "Error: Got %d back from put_first (expected %d)\n", \
  249. res, AST_JB_IMPL_OK); \
  250. return AST_TEST_FAIL; \
  251. } \
  252. \
  253. res = jb->impl->remove(jb->jbobj, &actual_frame); \
  254. if (!actual_frame || res != AST_JB_IMPL_OK) { \
  255. ast_test_status_update(test, "Error: failed to retrieve first frame\n"); \
  256. return AST_TEST_FAIL; \
  257. } \
  258. expected_frame = create_test_frame(1000, 0); \
  259. VERIFY_FRAME(actual_frame, expected_frame); \
  260. return AST_TEST_PASS; \
  261. }
  262. /*!
  263. * \internal
  264. * \brief Test putting a voice frames into a jitter buffer
  265. *
  266. * \param type_name The enum type of the jitter buffer to create
  267. * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
  268. */
  269. #define test_put(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, put)) {\
  270. RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
  271. const struct ast_jb_impl *impl; \
  272. struct ast_jb_conf conf; \
  273. RAII_VAR(struct ast_frame *, expected_frame, NULL, ast_frame_dtor); \
  274. RAII_VAR(struct ast_frame *, actual_frame, NULL, ast_frame_dtor); \
  275. int res; \
  276. long next; \
  277. int i; \
  278. \
  279. switch (cmd) { \
  280. case TEST_INIT: \
  281. info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put)); \
  282. info->category = "/main/abstract_jb/"; \
  283. info->summary = "Test putting frames onto a " literal_type_name " jitterbuffer"; \
  284. info->description = \
  285. "This tests putting multiple frames into a " literal_type_name " jitterbuffer"; \
  286. return AST_TEST_NOT_RUN; \
  287. case TEST_EXECUTE: \
  288. break; \
  289. } \
  290. \
  291. ast_test_status_update(test, "Executing "STRINGIFY_TESTNAME(TEST_NAME(type_name, put))"...\n"); \
  292. OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
  293. MAKE_DEFAULT_CONFIG(&conf, impl); \
  294. jb->jbobj = impl->create(&conf); \
  295. jb->impl = impl; \
  296. \
  297. expected_frame = create_test_frame(1000, 0); \
  298. jb->impl->put_first(jb->jbobj, expected_frame, 1100); \
  299. for (i = 1; i < 10; i++) { \
  300. expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
  301. res = jb->impl->put(jb->jbobj, \
  302. expected_frame, \
  303. 1100 + i * DEFAULT_FRAME_MS); \
  304. if (res != AST_JB_IMPL_OK) { \
  305. ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
  306. i, res, AST_JB_IMPL_OK); \
  307. return AST_TEST_FAIL; \
  308. } \
  309. } \
  310. \
  311. for (i = 0; i < 10; i++) { \
  312. expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
  313. next = jb->impl->next(jb->jbobj); \
  314. res = jb->impl->get(jb->jbobj, &actual_frame, next, DEFAULT_FRAME_MS); \
  315. if (res != AST_JB_IMPL_OK) { \
  316. ast_test_status_update(test, "Error: failed to retrieve frame %i at time %ld\n", \
  317. i, next); \
  318. return AST_TEST_FAIL; \
  319. } \
  320. VERIFY_FRAME(actual_frame, expected_frame); \
  321. ast_frfree(expected_frame); \
  322. expected_frame = NULL; \
  323. } \
  324. return AST_TEST_PASS; \
  325. }
  326. /*!
  327. * \internal
  328. * \brief Test overflowing the limits of a jitter buffer
  329. *
  330. * \param type_name The enum type of the jitter buffer to create
  331. * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
  332. * \param overflow_limit The number of frames at which we expect the buffer to overflow
  333. */
  334. #define test_put_overflow(type_name, literal_type_name, overflow_limit) AST_TEST_DEFINE(TEST_NAME(type_name, put_overflow)) {\
  335. RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
  336. const struct ast_jb_impl *impl; \
  337. struct ast_jb_conf conf; \
  338. RAII_VAR(struct ast_frame *, expected_frame, NULL, ast_frame_dtor); \
  339. int res; \
  340. int i; \
  341. \
  342. switch (cmd) { \
  343. case TEST_INIT: \
  344. info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put_overflow)); \
  345. info->category = "/main/abstract_jb/"; \
  346. info->summary = "Test putting frames onto a " literal_type_name " jitterbuffer " \
  347. "that ends up overflowing the maximum allowed slots in the buffer"; \
  348. info->description = \
  349. "This tests putting multiple frames into a " literal_type_name " jitterbuffer " \
  350. "until the jitterbuffer overflows"; \
  351. return AST_TEST_NOT_RUN; \
  352. case TEST_EXECUTE: \
  353. break; \
  354. } \
  355. \
  356. ast_test_status_update(test, "Executing "STRINGIFY_TESTNAME(TEST_NAME(type_name, put_overflow))"...\n"); \
  357. OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
  358. MAKE_DEFAULT_CONFIG(&conf, impl); \
  359. jb->jbobj = impl->create(&conf); \
  360. jb->impl = impl; \
  361. \
  362. expected_frame = create_test_frame(1000, 0); \
  363. jb->impl->put_first(jb->jbobj, expected_frame, 1100); \
  364. for (i = 1; i <= (overflow_limit); i++) { \
  365. expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
  366. res = jb->impl->put(jb->jbobj, \
  367. expected_frame, \
  368. 1100 + i * DEFAULT_FRAME_MS); \
  369. if (res != AST_JB_IMPL_OK) { \
  370. ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
  371. i, res, AST_JB_IMPL_OK); \
  372. return AST_TEST_FAIL; \
  373. } \
  374. } \
  375. \
  376. for (i = (overflow_limit)+1; i < (overflow_limit) + 5; i++) { \
  377. expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
  378. res = jb->impl->put(jb->jbobj, \
  379. expected_frame, \
  380. 1100 + i * DEFAULT_FRAME_MS); \
  381. if (res != AST_JB_IMPL_DROP) { \
  382. expected_frame = NULL; \
  383. ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
  384. i, res, AST_JB_IMPL_DROP); \
  385. return AST_TEST_FAIL; \
  386. } \
  387. ast_frfree(expected_frame); \
  388. expected_frame = NULL;\
  389. } \
  390. \
  391. return AST_TEST_PASS; \
  392. }
  393. /*!
  394. * \internal
  395. * \brief Test putting voice frames into a jitter buffer out of order
  396. *
  397. * \param type_name The enum type of the jitter buffer to create
  398. * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
  399. * \param synch_limit The synchronization limit for this particular type of jitter buffer
  400. */
  401. #define test_put_out_of_order(type_name, literal_type_name, synch_limit) AST_TEST_DEFINE(TEST_NAME(type_name, put_out_of_order)) {\
  402. RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
  403. const struct ast_jb_impl *impl; \
  404. struct ast_jb_conf conf; \
  405. RAII_VAR(struct ast_frame *, actual_frame, NULL, ast_frame_dtor); \
  406. RAII_VAR(struct ast_frame *, expected_frame, NULL, ast_frame_dtor); \
  407. int res; \
  408. long next; \
  409. int i; \
  410. \
  411. switch (cmd) { \
  412. case TEST_INIT: \
  413. info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put_out_of_order)); \
  414. info->category = "/main/abstract_jb/"; \
  415. info->summary = "Test putting out of order frames onto a " literal_type_name " jitterbuffer"; \
  416. info->description = \
  417. "This tests putting multiple frames into a " literal_type_name " jitterbuffer " \
  418. "that arrive out of order. Every 3rd frame is put in out of order."; \
  419. return AST_TEST_NOT_RUN; \
  420. case TEST_EXECUTE: \
  421. break; \
  422. } \
  423. \
  424. ast_test_status_update(test, "Executing " STRINGIFY_TESTNAME(TEST_NAME(type_name, put_out_of_order)) "...\n"); \
  425. OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
  426. MAKE_DEFAULT_CONFIG(&conf, impl); \
  427. conf.resync_threshold = (synch_limit); \
  428. jb->jbobj = impl->create(&conf); \
  429. jb->impl = impl; \
  430. \
  431. expected_frame = create_test_frame(1000, 0); \
  432. jb->impl->put_first(jb->jbobj, expected_frame, 1100); \
  433. for (i = 1; i <= 10; i++) { \
  434. if (i % 3 == 1 && i != 10) { \
  435. expected_frame = create_test_frame(1000 + ((i + 1) * DEFAULT_FRAME_MS), 0); \
  436. } else if (i % 3 == 2) { \
  437. expected_frame = create_test_frame(1000 + ((i - 1) * DEFAULT_FRAME_MS), 0); \
  438. } else { \
  439. expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
  440. } \
  441. res = jb->impl->put(jb->jbobj, \
  442. expected_frame, \
  443. 1100 + i * DEFAULT_FRAME_MS); \
  444. if (res != AST_JB_IMPL_OK) { \
  445. ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
  446. i, res, AST_JB_IMPL_OK); \
  447. return AST_TEST_FAIL; \
  448. } \
  449. } \
  450. \
  451. for (i = 0; i <= 10; i++) { \
  452. expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
  453. next = jb->impl->next(jb->jbobj); \
  454. res = jb->impl->get(jb->jbobj, &actual_frame, next, DEFAULT_FRAME_MS); \
  455. if (res != AST_JB_IMPL_OK) { \
  456. ast_test_status_update(test, "Error: failed to retrieve frame at %ld\n", \
  457. next); \
  458. return AST_TEST_FAIL; \
  459. } \
  460. VERIFY_FRAME(actual_frame, expected_frame); \
  461. ast_frfree(expected_frame); \
  462. expected_frame = NULL; \
  463. } \
  464. \
  465. return AST_TEST_PASS; \
  466. }
  467. test_create_nominal(AST_JB_ADAPTIVE, "adaptive")
  468. test_put_first(AST_JB_ADAPTIVE, "adaptive")
  469. test_put(AST_JB_ADAPTIVE, "adaptive")
  470. test_put_overflow(AST_JB_ADAPTIVE, "adaptive", 10)
  471. test_put_out_of_order(AST_JB_ADAPTIVE, "adaptive", DEFAULT_FRAME_MS * 2)
  472. test_create_nominal(AST_JB_FIXED, "fixed")
  473. test_put_first(AST_JB_FIXED, "fixed")
  474. test_put(AST_JB_FIXED, "fixed")
  475. test_put_overflow(AST_JB_FIXED, "fixed", 12)
  476. test_put_out_of_order(AST_JB_FIXED, "fixed", DEFAULT_CONFIG_RESYNC_THRESHOLD)
  477. static int unload_module(void)
  478. {
  479. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, create));
  480. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_first));
  481. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put));
  482. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_overflow));
  483. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_out_of_order));
  484. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, create));
  485. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put_first));
  486. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put));
  487. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put_overflow));
  488. AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put_out_of_order));
  489. return 0;
  490. }
  491. static int load_module(void)
  492. {
  493. AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, create));
  494. AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_first));
  495. AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put));
  496. AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_overflow));
  497. AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_out_of_order));
  498. AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, create));
  499. AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_first));
  500. AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put));
  501. AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_overflow));
  502. AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_out_of_order));
  503. return AST_MODULE_LOAD_SUCCESS;
  504. }
  505. AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Abstract JitterBuffer API Tests");