test.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include "test.h"
  20. #define THIS_FILE "test.c"
  21. #define DO_TEST(test) do { \
  22. PJ_LOG(3, (THIS_FILE, "Running %s...", #test)); \
  23. rc = test; \
  24. PJ_LOG(3, (THIS_FILE, \
  25. "%s(%d)", \
  26. (rc ? "..ERROR" : "..success"), rc)); \
  27. if (rc!=0) goto on_return; \
  28. } while (0)
  29. pj_pool_factory *mem;
  30. void app_perror(pj_status_t status, const char *msg)
  31. {
  32. char errbuf[PJ_ERR_MSG_SIZE];
  33. pjmedia_strerror(status, errbuf, sizeof(errbuf));
  34. PJ_LOG(3,(THIS_FILE, "%s: %s", msg, errbuf));
  35. }
  36. /* Force linking PLC stuff if G.711 is disabled. See:
  37. * https://github.com/pjsip/pjproject/issues/1337
  38. */
  39. #if PJMEDIA_HAS_G711_CODEC==0
  40. void *dummy()
  41. {
  42. // Dummy
  43. return &pjmedia_plc_save;
  44. }
  45. #endif
  46. int test_main(void)
  47. {
  48. int rc = 0;
  49. pj_caching_pool caching_pool;
  50. pj_pool_t *pool;
  51. pj_init();
  52. pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);
  53. pool = pj_pool_create(&caching_pool.factory, "test", 1000, 512, NULL);
  54. pj_log_set_decor(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_TIME |
  55. PJ_LOG_HAS_MICRO_SEC | PJ_LOG_HAS_INDENT);
  56. pj_log_set_level(3);
  57. mem = &caching_pool.factory;
  58. pjmedia_event_mgr_create(pool, 0, NULL);
  59. #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
  60. pjmedia_video_format_mgr_create(pool, 64, 0, NULL);
  61. pjmedia_converter_mgr_create(pool, NULL);
  62. pjmedia_vid_codec_mgr_create(pool, NULL);
  63. #endif
  64. #if HAS_VID_PORT_TEST
  65. DO_TEST(vid_port_test());
  66. #endif
  67. #if HAS_VID_DEV_TEST
  68. DO_TEST(vid_dev_test());
  69. #endif
  70. #if HAS_VID_CODEC_TEST
  71. DO_TEST(vid_codec_test());
  72. #endif
  73. #if HAS_SDP_NEG_TEST
  74. DO_TEST(sdp_neg_test());
  75. #endif
  76. //DO_TEST(sdp_test (&caching_pool.factory));
  77. //DO_TEST(rtp_test(&caching_pool.factory));
  78. //DO_TEST(session_test (&caching_pool.factory));
  79. #if HAS_JBUF_TEST
  80. DO_TEST(jbuf_main());
  81. #endif
  82. #if HAS_MIPS_TEST
  83. DO_TEST(mips_test());
  84. #endif
  85. #if HAS_CODEC_VECTOR_TEST
  86. DO_TEST(codec_test_vectors());
  87. #endif
  88. PJ_LOG(3,(THIS_FILE," "));
  89. on_return:
  90. if (rc != 0) {
  91. PJ_LOG(3,(THIS_FILE,"Test completed with error(s)!"));
  92. } else {
  93. PJ_LOG(3,(THIS_FILE,"Looks like everything is okay!"));
  94. }
  95. #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
  96. pjmedia_video_format_mgr_destroy(pjmedia_video_format_mgr_instance());
  97. pjmedia_converter_mgr_destroy(pjmedia_converter_mgr_instance());
  98. pjmedia_vid_codec_mgr_destroy(pjmedia_vid_codec_mgr_instance());
  99. #endif
  100. pjmedia_event_mgr_destroy(pjmedia_event_mgr_instance());
  101. pj_pool_release(pool);
  102. pj_caching_pool_destroy(&caching_pool);
  103. return rc;
  104. }