res_format_attr_g729.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2016, Digium, Inc.
  5. *
  6. * Jason Parker <jparker@sangoma.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. /*** MODULEINFO
  19. <support_level>core</support_level>
  20. ***/
  21. #include "asterisk.h"
  22. #include "asterisk/module.h"
  23. #include "asterisk/format.h"
  24. /* Destroy is a required callback and must exist */
  25. static void g729_destroy(struct ast_format *format)
  26. {
  27. }
  28. /* Clone is a required callback and must exist */
  29. static int g729_clone(const struct ast_format *src, struct ast_format *dst)
  30. {
  31. return 0;
  32. }
  33. static void g729_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
  34. {
  35. /*
  36. * According to the rfc the joint annexb format parameter should be set to 'yes'
  37. * or 'no' based on the answerer (rfc7261 - 3.3). However, Asterisk being a B2BUA
  38. * makes things tricky. So for now Asterisk will set annexb=no.
  39. */
  40. ast_str_append(str, 0, "a=fmtp:%u annexb=no\r\n", payload);
  41. }
  42. static struct ast_format_interface g729_interface = {
  43. .format_destroy = g729_destroy,
  44. .format_clone = g729_clone,
  45. .format_generate_sdp_fmtp = g729_generate_sdp_fmtp,
  46. };
  47. static int load_module(void)
  48. {
  49. if (ast_format_interface_register("g729", &g729_interface)) {
  50. return AST_MODULE_LOAD_DECLINE;
  51. }
  52. return AST_MODULE_LOAD_SUCCESS;
  53. }
  54. static int unload_module(void)
  55. {
  56. return 0;
  57. }
  58. AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "G.729 Format Attribute Module",
  59. .support_level = AST_MODULE_SUPPORT_CORE,
  60. .load = load_module,
  61. .unload = unload_module,
  62. .load_pri = AST_MODPRI_CHANNEL_DEPEND,
  63. );