diff options
author | Gaurav Khurana <gkhurana@godaddy.com> | 2018-02-13 10:55:47 -0800 |
---|---|---|
committer | Sean Bright <sean.bright@gmail.com> | 2018-04-30 16:30:44 -0400 |
commit | 0827d5cc53c2609231c4ef9bc92f321f258c4af2 (patch) | |
tree | 0cc7847c1f82ee6da71ea3d34223b55502d26702 /include | |
parent | f633af89c1d69734589dac2cb16f6de46301c9d6 (diff) |
Add the ability to read the media file type from HTTP header for playback
How it works today:
media_cache tries to parse out the extension of the media file to be played
from the URI provided to Asterisk while caching the file.
What's expected:
Better will be to have Asterisk get extension from other ways too. One of the
common ways is to get the type of content from the CONTENT-TYPE header in the
HTTP response for fetching the media file using the URI provided.
Steps to Reproduce:
Provide a URL of the form: http://host/media/1234 to Asterisk for media
playback. It fails to play and logs show the following error line:
[Sep 15 15:48:05] WARNING [29148] [C-00000092] file.c:
File http://host/media/1234 does not exist in any format
Scenario this issue is blocking:
In the case where the media files are stored in some cloud object store,
following can block the media being played via Asterisk:
Cloud storage generally needs authenticated access to the storage. The way
to do that is by using signed URIs. With the signed URIs there's no way to
preserve the name of the file.
In most cases Cloud storage returns a key to access the object and preserving
file name is also not a thing there
ASTERISK-27286
Reporter: Gaurav Khurana
Change-Id: I1b14692a49b2c1ac67688f58757184122e92ba89
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/file.h | 12 | ||||
-rw-r--r-- | include/asterisk/mod_format.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/asterisk/file.h b/include/asterisk/file.h index c17cb327b..1c2c7a84a 100644 --- a/include/asterisk/file.h +++ b/include/asterisk/file.h @@ -427,6 +427,18 @@ char *ast_format_str_reduce(char *fmts); */ struct ast_format *ast_get_format_for_file_ext(const char *file_ext); +/*! + * \brief Get a suitable filename extension for the given MIME type + * + * \param mime_type The MIME type for which to find extensions + * \param buffer A pointer to a buffer to receive the extension + * \param capacity The size of 'buffer' in bytes + * + * \retval 1 if an extension was found for the provided MIME type + * \retval 0 if the MIME type was not found + */ +int ast_get_extension_for_mime_type(const char *mime_type, char *buffer, size_t capacity); + #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/include/asterisk/mod_format.h b/include/asterisk/mod_format.h index 5f93ea442..6e772f05b 100644 --- a/include/asterisk/mod_format.h +++ b/include/asterisk/mod_format.h @@ -44,6 +44,7 @@ struct ast_format_def { char name[80]; /*!< Name of format */ char exts[80]; /*!< Extensions (separated by | if more than one) * this format can read. First is assumed for writing (e.g. .mp3) */ + char mime_types[80]; /*!< MIME Types related to the format (separated by | if more than one)*/ struct ast_format *format; /*!< Format of frames it uses/provides (one only) */ /*! * \brief Prepare an input stream for playback. |