switch_core_video.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  3. * Copyright (C) 2005-2018, Anthony Minessale II <anthm@freeswitch.org>
  4. *
  5. * Version: MPL 1.1
  6. *
  7. * The contents of this file are subject to the Mozilla Public License Version
  8. * 1.1 (the "License"); you may not use this file except in compliance with
  9. * the License. You may obtain a copy of the License at
  10. * http://www.mozilla.org/MPL/
  11. *
  12. * Software distributed under the License is distributed on an "AS IS" basis,
  13. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14. * for the specific language governing rights and limitations under the
  15. * License.
  16. *
  17. * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
  18. *
  19. * The Initial Developer of the Original Code is
  20. * Anthony Minessale II <anthm@freeswitch.org>
  21. * Portions created by the Initial Developer are Copyright (C)
  22. * the Initial Developer. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. * Chris Rienzo <chris@signalwire.com>
  26. * Seven Du <seven@signalwire.com>
  27. *
  28. *
  29. * switch_core_video.c -- tests core_video
  30. *
  31. */
  32. #include <switch.h>
  33. #include <stdlib.h>
  34. #include <test/switch_test.h>
  35. FST_CORE_BEGIN("./conf")
  36. {
  37. FST_SUITE_BEGIN(switch_ivr_originate)
  38. {
  39. FST_SETUP_BEGIN()
  40. {
  41. }
  42. FST_SETUP_END()
  43. FST_TEARDOWN_BEGIN()
  44. {
  45. }
  46. FST_TEARDOWN_END()
  47. FST_TEST_BEGIN(data_url_test)
  48. {
  49. switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_I420, 120, 60, 1);
  50. switch_image_t *argb_img = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, 120, 60, 1);
  51. switch_rgb_color_t color = { 0 };
  52. color.r = 255;
  53. // color.g = 255;
  54. // color.b = 255;
  55. char *data_url = NULL;
  56. switch_img_fill(img, 0, 0, img->d_w, img->d_h, &color);
  57. switch_img_add_text(img->planes[0], img->d_w, 10, 10, "-1234567890");
  58. switch_img_write_png(img, "test-rgb.png");
  59. switch_img_data_url_png(img, &data_url);
  60. switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "I420: %s\n", data_url);
  61. free(data_url);
  62. data_url = NULL;
  63. switch_img_copy(img, &argb_img);
  64. {
  65. uint8_t *p = argb_img->planes[0];
  66. switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%d %d %d %d\n", *p, *(p+1), *(p+2), *(p+3));
  67. }
  68. switch_img_write_png(argb_img, "test-argb.png");
  69. switch_img_data_url_png(argb_img, &data_url);
  70. switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ARGB: %s\n", data_url);
  71. free(data_url);
  72. switch_img_free(&img);
  73. switch_img_free(&argb_img);
  74. }
  75. FST_TEST_END()
  76. }
  77. FST_SUITE_END()
  78. }
  79. FST_CORE_END()