Asterisk - The Open Source Telephony Project  18.5.0
media_index.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2013, Digium, Inc.
5  *
6  * Kinsey Moore <[email protected]>
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 
19 /*! \file
20  * \brief Media file format and description indexing engine.
21  */
22 
23 #ifndef _ASTERISK_MEDIA_INDEX_H
24 #define _ASTERISK_MEDIA_INDEX_H
25 
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
29 
30 struct ast_format_cap;
31 
32 /*!
33  * \brief Object representing a media index
34  */
35 struct ast_media_index;
36 
37 /*!
38  * \brief Creates a new media index
39  *
40  * \param base_dir Base directory for indexing
41  *
42  * \retval NULL on error
43  * \retval A new AO2 refcounted media index
44  */
46  const char *base_dir);
47 
48 /*!
49  * \brief Get the description for a media file
50  *
51  * \param index Media index in which to query information
52  * \param filename Name of the file for which to get the description
53  * \param variant Media variant for which to get the description
54  *
55  * \retval NULL if not found
56  * \return The description requested (must be copied to be kept)
57  */
58 const char *ast_media_get_description(struct ast_media_index *index, const char *filename, const char *variant);
59 
60 /*!
61  * \brief Get the ast_format_cap for a media file
62  *
63  * \param index Media index in which to query information
64  * \param filename Name of the file for which to get the description
65  * \param variant Media variant for which to get the description
66  *
67  * \retval NULL if not found
68  * \return a copy of the format capabilities (must be destroyed with ast_format_cap_destroy)
69  */
70 struct ast_format_cap *ast_media_get_format_cap(struct ast_media_index *index, const char *filename, const char *variant);
71 
72 /*!
73  * \brief Get the languages in which a media file is available
74  *
75  * \param index Media index in which to query information
76  * \param filename Name of the file for which to get available languages
77  *
78  * \retval NULL on error
79  * \return an ast_str_container filled with language strings
80  */
81 struct ao2_container *ast_media_get_variants(struct ast_media_index *index, const char *filename);
82 
83 /*!
84  * \brief Get the a container of all media available on the system
85  *
86  * \param index Media index in which to query information
87  *
88  * \retval NULL on error
89  * \return an ast_str_container filled with media file name strings
90  */
92 
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  */
110  const char *variant, const char *filename);
111 
112 /*!
113  * \brief Update a media index
114  *
115  * \param index Media index in which to query information
116  * \param variant Media variant for which to get the description
117  *
118  * \retval non-zero on error
119  * \return zero on success
120  */
121 #define ast_media_index_update(index, variant) \
122  ast_media_index_update_for_file(index, variant, NULL)
123 
124 #if defined(__cplusplus) || defined(c_plusplus)
125 }
126 #endif
127 
128 #endif /* _ASTERISK_MEDIA_INDEX_H */
const char * ast_media_get_description(struct ast_media_index *index, const char *filename, const char *variant)
Get the description for a media file.
Definition: media_index.c:230
struct ao2_container * ast_media_get_media(struct ast_media_index *index)
Get the a container of all media available on the system.
Definition: media_index.c:307
struct ao2_container * ast_media_get_variants(struct ast_media_index *index, const char *filename)
Get the languages in which a media file is available.
Definition: media_index.c:274
int ast_media_index_update_for_file(struct ast_media_index *index, const char *variant, const char *filename)
Update a media index for a specific sound file.
Definition: media_index.c:587
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
struct ast_media_index * ast_media_index_create(const char *base_dir)
Creates a new media index.
Definition: media_index.c:162
struct ao2_container * index
Definition: media_index.c:149
char base_dir[0]
Definition: media_index.c:151
Generic container type.
struct ast_format_cap * ast_media_get_format_cap(struct ast_media_index *index, const char *filename, const char *variant)
Get the ast_format_cap for a media file.
Definition: media_index.c:245