media_index.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * Kinsey Moore <kmoore@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. * \brief Media file format and description indexing engine.
  20. */
  21. #ifndef _ASTERISK_MEDIA_INDEX_H
  22. #define _ASTERISK_MEDIA_INDEX_H
  23. #if defined(__cplusplus) || defined(c_plusplus)
  24. extern "C" {
  25. #endif
  26. struct ast_format_cap;
  27. /*!
  28. * \brief Object representing a media index
  29. */
  30. struct ast_media_index;
  31. /*!
  32. * \brief Creates a new media index
  33. *
  34. * \param base_dir Base directory for indexing
  35. *
  36. * \retval NULL on error
  37. * \retval A new AO2 refcounted media index
  38. */
  39. struct ast_media_index *ast_media_index_create(
  40. const char *base_dir);
  41. /*!
  42. * \brief Get the description for a media file
  43. *
  44. * \param index Media index in which to query information
  45. * \param filename Name of the file for which to get the description
  46. * \param variant Media variant for which to get the description
  47. *
  48. * \retval NULL if not found
  49. * \return The description requested (must be copied to be kept)
  50. */
  51. const char *ast_media_get_description(struct ast_media_index *index, const char *filename, const char *variant);
  52. /*!
  53. * \brief Get the ast_format_cap for a media file
  54. *
  55. * \param index Media index in which to query information
  56. * \param filename Name of the file for which to get the description
  57. * \param variant Media variant for which to get the description
  58. *
  59. * \retval NULL if not found
  60. * \return a copy of the format capabilities (must be destroyed with ast_format_cap_destroy)
  61. */
  62. struct ast_format_cap *ast_media_get_format_cap(struct ast_media_index *index, const char *filename, const char *variant);
  63. /*!
  64. * \brief Get the languages in which a media file is available
  65. *
  66. * \param index Media index in which to query information
  67. * \param filename Name of the file for which to get available languages
  68. *
  69. * \retval NULL on error
  70. * \return an ast_str_container filled with language strings
  71. */
  72. struct ao2_container *ast_media_get_variants(struct ast_media_index *index, const char *filename);
  73. /*!
  74. * \brief Get the a container of all media available on the system
  75. *
  76. * \param index Media index in which to query information
  77. *
  78. * \retval NULL on error
  79. * \return an ast_str_container filled with media file name strings
  80. */
  81. struct ao2_container *ast_media_get_media(struct ast_media_index *index);
  82. /*!
  83. * \brief Update a media index
  84. *
  85. * \param index Media index in which to query information
  86. * \param variant Media variant for which to get the description
  87. *
  88. * \retval non-zero on error
  89. * \return zero on success
  90. */
  91. int ast_media_index_update(struct ast_media_index *index,
  92. const char *variant);
  93. /*!
  94. * \brief Update a media index for a specific sound file
  95. *
  96. * \since 13.25.0
  97. * \since 16.2.0
  98. *
  99. * \param index Media index in which to query information
  100. * \param variant Media variant for which to get the description
  101. * \param filename Sound file name without extension
  102. *
  103. * \note If filename is NULL, this function will act as
  104. * \ref ast_media_index_update and add all sound files to the index.
  105. *
  106. * \retval non-zero on error
  107. * \return zero on success
  108. */
  109. int ast_media_index_update_for_file(struct ast_media_index *index,
  110. const char *variant, const char *filename);
  111. #if defined(__cplusplus) || defined(c_plusplus)
  112. }
  113. #endif
  114. #endif /* _ASTERISK_MEDIA_INDEX_H */