res_stasis_answer.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * David M. Lee, II <dlee@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. /*! \file
  19. *
  20. * \brief Stasis application control support.
  21. *
  22. * \author David M. Lee, II <dlee@digium.com>
  23. */
  24. /*** MODULEINFO
  25. <depend type="module">res_stasis</depend>
  26. <support_level>core</support_level>
  27. ***/
  28. #include "asterisk.h"
  29. #include "asterisk/module.h"
  30. #include "asterisk/stasis_app_impl.h"
  31. static int app_control_answer(struct stasis_app_control *control,
  32. struct ast_channel *chan, void *data)
  33. {
  34. ast_debug(3, "%s: Answering\n",
  35. stasis_app_control_get_channel_id(control));
  36. return ast_raw_answer(chan);
  37. }
  38. int stasis_app_control_answer(struct stasis_app_control *control)
  39. {
  40. int retval;
  41. ast_debug(3, "%s: Sending answer command\n",
  42. stasis_app_control_get_channel_id(control));
  43. retval = stasis_app_send_command(control, app_control_answer, NULL, NULL);
  44. if (retval != 0) {
  45. ast_log(LOG_WARNING, "%s: Failed to answer channel\n",
  46. stasis_app_control_get_channel_id(control));
  47. return -1;
  48. }
  49. return 0;
  50. }
  51. static int load_module(void)
  52. {
  53. return AST_MODULE_LOAD_SUCCESS;
  54. }
  55. static int unload_module(void)
  56. {
  57. return 0;
  58. }
  59. AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Stasis application answer support",
  60. .support_level = AST_MODULE_SUPPORT_CORE,
  61. .load = load_module,
  62. .unload = unload_module,
  63. .requires = "res_stasis",
  64. );