res_format_attr_g729.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. ASTERISK_REGISTER_FILE()
  23. #include "asterisk/module.h"
  24. #include "asterisk/format.h"
  25. /* Destroy is a required callback and must exist */
  26. static void g729_destroy(struct ast_format *format)
  27. {
  28. }
  29. /* Clone is a required callback and must exist */
  30. static int g729_clone(const struct ast_format *src, struct ast_format *dst)
  31. {
  32. return 0;
  33. }
  34. static void g729_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
  35. {
  36. /*
  37. * According to the rfc the joint annexb format parameter should be set to 'yes'
  38. * or 'no' based on the answerer (rfc7261 - 3.3). However, Asterisk being a B2BUA
  39. * makes things tricky. So for now Asterisk will set annexb=no.
  40. */
  41. ast_str_append(str, 0, "a=fmtp:%u annexb=no\r\n", payload);
  42. }
  43. static struct ast_format_interface g729_interface = {
  44. .format_destroy = g729_destroy,
  45. .format_clone = g729_clone,
  46. .format_generate_sdp_fmtp = g729_generate_sdp_fmtp,
  47. };
  48. static int load_module(void)
  49. {
  50. if (ast_format_interface_register("g729", &g729_interface)) {
  51. return AST_MODULE_LOAD_DECLINE;
  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_LOAD_ORDER, "G.729 Format Attribute Module",
  60. .support_level = AST_MODULE_SUPPORT_CORE,
  61. .load = load_module,
  62. .unload = unload_module,
  63. .load_pri = AST_MODPRI_CHANNEL_DEPEND,
  64. );