summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/_private.h12
-rw-r--r--include/asterisk/audiohook.h12
-rw-r--r--include/asterisk/format.h162
-rw-r--r--include/asterisk/format_cap.h29
-rw-r--r--include/asterisk/frame.h70
-rw-r--r--include/asterisk/rtp_engine.h22
-rw-r--r--include/asterisk/silk.h44
-rw-r--r--include/asterisk/slinfactory.h4
-rw-r--r--include/asterisk/time.h2
-rw-r--r--include/asterisk/translate.h10
10 files changed, 270 insertions, 97 deletions
diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h
index 560c8c169..a0b171254 100644
--- a/include/asterisk/_private.h
+++ b/include/asterisk/_private.h
@@ -90,4 +90,16 @@ int ast_xmldoc_load_documentation(void);
*/
int ast_plc_reload(void);
+/*!
+ * \brief Init the ast_format attribute interface register container.
+ */
+int ast_format_attr_init(void);
+
+/*!
+ * \brief Init the Asterisk global format list after all format attribute modules have been loaded
+ */
+int ast_format_list_init(void);
+
+/*! \brief initializes the rtp engine arrays */
+int ast_rtp_engine_init(void);
#endif /* _ASTERISK__PRIVATE_H */
diff --git a/include/asterisk/audiohook.h b/include/asterisk/audiohook.h
index 75e2c8763..798a6d6e0 100644
--- a/include/asterisk/audiohook.h
+++ b/include/asterisk/audiohook.h
@@ -65,7 +65,12 @@ enum ast_audiohook_flags {
AST_AUDIOHOOK_MUTE_WRITE = (1 << 5), /*!< audiohook should be mute frames written */
};
-#define AST_AUDIOHOOK_SYNC_TOLERANCE 100 /*< Tolerance in milliseconds for audiohooks synchronization */
+enum ast_audiohook_init_flags {
+ /*! Audiohook manipulate callback is capable of handling slinear at any sample rate.
+ * Without enabling this flag on initialization the manipulation callback is guaranteed
+ * 8khz audio only. */
+ AST_AUDIOHOOK_MANIPULATE_ALL_RATES = (1 << 0),
+};
struct ast_audiohook;
@@ -97,6 +102,7 @@ struct ast_audiohook {
ast_cond_t trigger; /*!< Trigger condition (if enabled) */
enum ast_audiohook_type type; /*!< Type of audiohook */
enum ast_audiohook_status status; /*!< Status of the audiohook */
+ enum ast_audiohook_init_flags init_flags; /*!< Init flags */
const char *source; /*!< Who this audiohook ultimately belongs to */
unsigned int flags; /*!< Flags on the audiohook */
struct ast_slinfactory read_factory; /*!< Factory where frames read from the channel, or read from the whisper source will go through */
@@ -107,6 +113,7 @@ struct ast_audiohook {
struct ast_trans_pvt *trans_pvt; /*!< Translation path for reading frames */
ast_audiohook_manipulate_callback manipulate_callback; /*!< Manipulation callback */
struct ast_audiohook_options options; /*!< Applicable options */
+ unsigned int hook_internal_samp_rate; /*!< internal read/write sample rate on the audiohook.*/
AST_LIST_ENTRY(ast_audiohook) list; /*!< Linked list information */
};
@@ -116,9 +123,10 @@ struct ast_audiohook_list;
* \param audiohook Audiohook structure
* \param type Type of audiohook to initialize this as
* \param source Who is initializing this audiohook
+ * \param init flags
* \return Returns 0 on success, -1 on failure
*/
-int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source);
+int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source, enum ast_audiohook_init_flags flags);
/*! \brief Destroys an audiohook structure
* \param audiohook Audiohook structure
diff --git a/include/asterisk/format.h b/include/asterisk/format.h
index 09212abc8..67e4178a2 100644
--- a/include/asterisk/format.h
+++ b/include/asterisk/format.h
@@ -26,8 +26,9 @@
#ifndef _AST_FORMAT_H_
#define _AST_FORMAT_H_
+#include "asterisk/astobj2.h"
+#include "asterisk/silk.h"
#define AST_FORMAT_ATTR_SIZE 128
-
#define AST_FORMAT_INC 100000
/*! This is the value that ends a var list of format attribute
@@ -55,32 +56,49 @@ enum ast_format_id {
AST_FORMAT_G726_AAL2 = 5 + AST_FORMAT_TYPE_AUDIO,
/*! ADPCM (IMA) */
AST_FORMAT_ADPCM = 6 + AST_FORMAT_TYPE_AUDIO,
- /*! Raw 16-bit Signed Linear (8000 Hz) PCM */
- AST_FORMAT_SLINEAR = 7 + AST_FORMAT_TYPE_AUDIO,
/*! LPC10, 180 samples/frame */
- AST_FORMAT_LPC10 = 8 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_LPC10 = 7 + AST_FORMAT_TYPE_AUDIO,
/*! G.729A audio */
- AST_FORMAT_G729A = 9 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_G729A = 8 + AST_FORMAT_TYPE_AUDIO,
/*! SpeeX Free Compression */
- AST_FORMAT_SPEEX = 10 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_SPEEX = 9 + AST_FORMAT_TYPE_AUDIO,
/*! iLBC Free Compression */
- AST_FORMAT_ILBC = 11 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_ILBC = 10 + AST_FORMAT_TYPE_AUDIO,
/*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
- AST_FORMAT_G726 = 12 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_G726 = 11 + AST_FORMAT_TYPE_AUDIO,
/*! G.722 */
- AST_FORMAT_G722 = 13 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_G722 = 12 + AST_FORMAT_TYPE_AUDIO,
/*! G.722.1 (also known as Siren7, 32kbps assumed) */
- AST_FORMAT_SIREN7 = 14 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_SIREN7 = 13 + AST_FORMAT_TYPE_AUDIO,
/*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
- AST_FORMAT_SIREN14 = 15 + AST_FORMAT_TYPE_AUDIO,
- /*! Raw 16-bit Signed Linear (16000 Hz) PCM */
- AST_FORMAT_SLINEAR16 = 16 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_SIREN14 = 14 + AST_FORMAT_TYPE_AUDIO,
/*! G.719 (64 kbps assumed) */
- AST_FORMAT_G719 = 17 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_G719 = 15 + AST_FORMAT_TYPE_AUDIO,
/*! SpeeX Wideband (16kHz) Free Compression */
- AST_FORMAT_SPEEX16 = 18 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_SPEEX16 = 16 + AST_FORMAT_TYPE_AUDIO,
/*! Raw mu-law data (G.711) */
- AST_FORMAT_TESTLAW = 19 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_TESTLAW = 17 + AST_FORMAT_TYPE_AUDIO,
+ /*! SILK format */
+ AST_FORMAT_SILK = 18 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (8000 Hz) PCM */
+ AST_FORMAT_SLINEAR = 19 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (12000 Hz) PCM */
+ AST_FORMAT_SLINEAR12 = 20 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (16000 Hz) PCM */
+ AST_FORMAT_SLINEAR16 = 21 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (24000 Hz) PCM */
+ AST_FORMAT_SLINEAR24 = 22 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (32000 Hz) PCM */
+ AST_FORMAT_SLINEAR32 = 23 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (44100 Hz) PCM just because we can. */
+ AST_FORMAT_SLINEAR44 = 24 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (48000 Hz) PCM */
+ AST_FORMAT_SLINEAR48 = 25 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (96000 Hz) PCM */
+ AST_FORMAT_SLINEAR96 = 26 + AST_FORMAT_TYPE_AUDIO,
+ /*! Raw 16-bit Signed Linear (192000 Hz) PCM. maybe we're taking this too far. */
+ AST_FORMAT_SLINEAR192 = 27 + AST_FORMAT_TYPE_AUDIO,
+ AST_FORMAT_SPEEX32 = 28 + AST_FORMAT_TYPE_AUDIO,
/*! H.261 Video */
AST_FORMAT_H261 = 1 + AST_FORMAT_TYPE_VIDEO,
@@ -107,6 +125,7 @@ enum ast_format_id {
/*! Determine what type of media a ast_format_id is. */
#define AST_FORMAT_GET_TYPE(id) (((int) (id / AST_FORMAT_INC)) * AST_FORMAT_INC)
+
/*! \brief This structure contains the buffer used for format attributes */
struct ast_format_attr {
/*! The buffer formats can use to represent attributes */
@@ -133,6 +152,22 @@ enum ast_format_cmp_res {
AST_FORMAT_CMP_SUBSET,
};
+/*! \brief Definition of supported media formats (codecs) */
+struct ast_format_list {
+ struct ast_format format; /*!< The unique format. */
+ char name[64]; /*!< short name */
+ unsigned int samplespersecond; /*!< Number of samples per second (8000/16000) */
+ char desc[128]; /*!< Description */
+ int fr_len; /*!< Single frame length in bytes */
+ int min_ms; /*!< Min value */
+ int max_ms; /*!< Max value */
+ int inc_ms; /*!< Increment */
+ int def_ms; /*!< Default value */
+ unsigned int flags; /*!< Smoother flags */
+ int cur_ms; /*!< Current value */
+ int custom_entry;
+};
+
/*! \brief A format must register an attribute interface if it requires the use of the format attributes void pointer */
struct ast_format_attr_interface {
/*! format type */
@@ -154,6 +189,34 @@ struct ast_format_attr_interface {
/*! \brief Set format capabilities from a list of key value pairs ending with AST_FORMAT_ATTR_END.
* \note This function does not need to call va_end of the va_list. */
void (* const format_attr_set)(struct ast_format_attr *format_attr, va_list ap);
+
+ /*!
+ * \brief Find out if format capabilities in va_list are in format.
+ * \note This function does not need to call va_end of the va_list.
+ *
+ * \note This function is optional. In many cases the format_attr_cmp
+ * function can be used to derive these results. If it is possible
+ * that some format attributes have no bearing on the equality of two formats, this
+ * function must exist.
+ *
+ * \retval 0 if all attributes exist
+ * \retval -1 if any of the attributes not present
+ */
+ int (* const format_attr_isset)(const struct ast_format_attr *format_attr, va_list ap);
+
+ /*
+ * \brief Return a value for a specific format key. Return that value in the void pointer.
+ *
+ * \note It is not expected that all key value pairs can be returned, but those that can should
+ * be documented as such.
+ *
+ * \note This function is optional if key value pairs are not allowed to be accessed. This
+ * will result in -1 always being returned.
+ *
+ * \retval 0 Success, value was found and copied into void pointer.
+ * \retval -1 failure, Value was either not found, or not allowed to be accessed.
+ */
+ int (* const format_attr_get_val)(const struct ast_format_attr *format_attr, int key, void *val);
};
/*!
@@ -218,7 +281,18 @@ void ast_format_clear(struct ast_format *format);
* \return 0, The format key value pairs are within the capabilities defined in this structure.
* \return -1, The format key value pairs are _NOT_ within the capabilities of this structure.
*/
-int ast_format_isset(struct ast_format *format, ... );
+int ast_format_isset(const struct ast_format *format, ... );
+
+/*!
+ * \brief Get a value from a format containing attributes.
+ * \note The key represents the format attribute to be retrieved, and the void pointer
+ * is to the structure that value will be stored in. It must be known what structure a
+ * key represents.
+ *
+ * \retval 0, success
+ * \retval -1, failure
+ */
+int ast_format_get_value(const struct ast_format *format, int key, void *value);
/*!
* \brief Compare ast_formats structures
@@ -287,6 +361,52 @@ struct ast_format *ast_format_from_old_bitfield(struct ast_format *dst, uint64_t
enum ast_format_id ast_format_id_from_old_bitfield(uint64_t src);
/*!
+ * \brief Retrieve the global format list in a read only array.
+ * \note ast_format_list_destroy must be called on every format
+ * list retrieved from this function.
+ */
+const struct ast_format_list *ast_format_list_get(size_t *size);
+
+/*!
+ * \brief Destroy an ast_format_list gotten from ast_format_list_get()
+ */
+const struct ast_format_list *ast_format_list_destroy(const struct ast_format_list *list);
+
+/*! \brief Get the name of a format
+ * \param format id of format
+ * \return A static string containing the name of the format or "unknown" if unknown.
+ */
+const char* ast_getformatname(const struct ast_format *format);
+
+/*! \brief Returns a string containing all formats pertaining to an format id.
+ * \param buf a buffer for the output string
+ * \param size size of buf (bytes)
+ * \param format id.
+ * \return The return value is buf.
+ */
+char* ast_getformatname_multiple_byid(char *buf, size_t size, enum ast_format_id id);
+
+/*!
+ * \brief Gets a format from a name.
+ * \param name string of format
+ * \param format structure to return the format in.
+ * \return This returns the format pointer given to it on success and NULL on failure
+ */
+struct ast_format *ast_getformatbyname(const char *name, struct ast_format *format);
+
+/*!
+ * \brief Get a name from a format
+ * \param format to get name of
+ * \return This returns a static string identifying the format on success, 0 on error.
+ */
+const char *ast_codec2str(struct ast_format *format);
+
+/*!
+ * \brief Get the sample rate for a given format.
+ */
+int ast_format_rate(const struct ast_format *format);
+
+/*!
* \brief register ast_format_attr_interface with core.
*
* \retval 0 success
@@ -303,8 +423,12 @@ int ast_format_attr_reg_interface(const struct ast_format_attr_interface *interf
int ast_format_attr_unreg_interface(const struct ast_format_attr_interface *interface);
/*!
- * \brief Init the ast_format attribute interface register container.
+ * \brief Determine if a format is 16bit signed linear of any sample rate.
*/
-int ast_format_attr_init(void);
+int ast_format_is_slinear(const struct ast_format *format);
+/*!
+ * \brief Get the best slinear format id for a given sample rate
+ */
+enum ast_format_id ast_format_slin_by_rate(unsigned int rate);
#endif /* _AST_FORMAT_H */
diff --git a/include/asterisk/format_cap.h b/include/asterisk/format_cap.h
index cdb5421f9..234767685 100644
--- a/include/asterisk/format_cap.h
+++ b/include/asterisk/format_cap.h
@@ -70,7 +70,7 @@ void *ast_format_cap_destroy(struct ast_format_cap *cap);
* what is placed in the ast_format_cap structure. The actual
* input format ptr is not stored.
*/
-void ast_format_cap_add(struct ast_format_cap *cap, struct ast_format *format);
+void ast_format_cap_add(struct ast_format_cap *cap, const struct ast_format *format);
/*!
* \brief Add all formats Asterisk knows about for a specific type to
@@ -155,6 +155,15 @@ void ast_format_cap_remove_all(struct ast_format_cap *cap);
void ast_format_cap_set(struct ast_format_cap *cap, struct ast_format *format);
/*!
+ * \brief Find if input ast_format is within the capabilities of the ast_format_cap object
+ * then return the compatible format from the capabilities structure in the result.
+ *
+ * \retval 1 format is compatible with formats held in ast_format_cap object.
+ * \retval 0 format is not compatible with any formats in ast_format_cap object.
+ */
+int ast_format_cap_get_compatible_format(const struct ast_format_cap *cap, const struct ast_format *format, struct ast_format *result);
+
+/*!
* \brief Find if ast_format is within the capabilities of the ast_format_cap object.
*
* retval 1 format is compatible with formats held in ast_format_cap object.
@@ -163,6 +172,14 @@ void ast_format_cap_set(struct ast_format_cap *cap, struct ast_format *format);
int ast_format_cap_iscompatible(const struct ast_format_cap *cap, const struct ast_format *format);
/*!
+ * \brief Finds the best quality audio format for a given format id and returns it in result.
+ *
+ * \retval 1 format found and set to result structure.
+ * \retval 0 no format found, result structure is cleared.
+ */
+int ast_format_cap_best_byid(const struct ast_format_cap *cap, enum ast_format_id, struct ast_format *result);
+
+/*!
* \brief is cap1 identical to cap2
*
* retval 1 true, identical
@@ -278,4 +295,14 @@ uint64_t ast_format_cap_to_old_bitfield(const struct ast_format_cap *cap);
*/
void ast_format_cap_from_old_bitfield(struct ast_format_cap *dst, uint64_t src);
+/*! \brief Get the names of a set of formats
+ * \param buf a buffer for the output string
+ * \param size size of buf (bytes)
+ * \param format the format (combined IDs of codecs)
+ * Prints a list of readable codec names corresponding to "format".
+ * ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
+ * \return The return value is buf.
+ */
+char* ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap);
+
#endif /* _AST_FORMATCAP_H */
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index 63cbb952f..e02df42ed 100644
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -427,23 +427,6 @@ struct ast_option_header {
uint8_t data[0];
};
-
-/*! \brief Definition of supported media formats (codecs) */
-struct ast_format_list {
- enum ast_format_id id; /*!< The format unique id */
- char *name; /*!< short name */
- int samplespersecond; /*!< Number of samples per second (8000/16000) */
- char *desc; /*!< Description */
- int fr_len; /*!< Single frame length in bytes */
- int min_ms; /*!< Min value */
- int max_ms; /*!< Max value */
- int inc_ms; /*!< Increment */
- int def_ms; /*!< Default value */
- unsigned int flags; /*!< Smoother flags */
- int cur_ms; /*!< Current value */
-};
-
-
/*! \brief Requests a frame to be allocated
*
* \param source
@@ -505,37 +488,6 @@ void ast_swapcopy_samples(void *dst, const void *src, int samples);
*/
int ast_parse_allow_disallow(struct ast_codec_pref *pref, struct ast_format_cap *cap, const char *list, int allowing);
-/*! \brief Get the name of a format
- * \param format id of format
- * \return A static string containing the name of the format or "unknown" if unknown.
- */
-char* ast_getformatname(struct ast_format *format);
-
-/*! \brief Get the names of a set of formats
- * \param buf a buffer for the output string
- * \param size size of buf (bytes)
- * \param format the format (combined IDs of codecs)
- * Prints a list of readable codec names corresponding to "format".
- * ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)"
- * \return The return value is buf.
- */
-char* ast_getformatname_multiple(char *buf, size_t size, struct ast_format_cap *cap);
-
-/*!
- * \brief Gets a format from a name.
- * \param name string of format
- * \param format structure to return the format in.
- * \return This returns the format pointer given to it on success and NULL on failure
- */
-struct ast_format *ast_getformatbyname(const char *name, struct ast_format *format);
-
-/*! \brief Get a name from a format
- * Gets a name from a format
- * \param format to get name of
- * \return This returns a static string identifying the format on success, 0 on error.
- */
-char *ast_codec2str(struct ast_format *format);
-
/*! \name AST_Smoother
*/
/*@{ */
@@ -582,8 +534,6 @@ struct ast_frame *ast_smoother_read(struct ast_smoother *s);
#endif
/*@} Doxygen marker */
-const struct ast_format_list *ast_get_format_list_index(int index);
-const struct ast_format_list *ast_get_format_list(size_t *size);
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix);
/*! \brief Returns the number of samples contained in the frame */
@@ -622,26 +572,6 @@ int ast_frame_adjust_volume(struct ast_frame *f, int adjustment);
int ast_frame_slinear_sum(struct ast_frame *f1, struct ast_frame *f2);
/*!
- * \brief Get the sample rate for a given format.
- */
-static force_inline int ast_format_rate(struct ast_format *format)
-{
- switch (format->id) {
- case AST_FORMAT_G722:
- case AST_FORMAT_SLINEAR16:
- case AST_FORMAT_SIREN7:
- case AST_FORMAT_SPEEX16:
- return 16000;
- case AST_FORMAT_SIREN14:
- return 32000;
- case AST_FORMAT_G719:
- return 48000;
- default:
- return 8000;
- }
-}
-
-/*!
* \brief Clear all audio samples from an ast_frame. The frame must be AST_FRAME_VOICE and AST_FORMAT_SLINEAR
*/
int ast_frame_clear(struct ast_frame *frame);
diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h
index f13538321..4c5753e84 100644
--- a/include/asterisk/rtp_engine.h
+++ b/include/asterisk/rtp_engine.h
@@ -1048,6 +1048,19 @@ void ast_rtp_codecs_payloads_unset(struct ast_rtp_codecs *codecs, struct ast_rtp
struct ast_rtp_payload_type ast_rtp_codecs_payload_lookup(struct ast_rtp_codecs *codecs, int payload);
/*!
+ * \brief Retrieve the actual ast_format stored on the codecs structure for a specific payload
+ *
+ * \param codecs Codecs structure to look in
+ * \param payload Numerical payload to look up
+ *
+ * \retval pointer to format structure on success
+ * \retval NULL on failure
+ *
+ * \since 1.10
+ */
+struct ast_format *ast_rtp_codecs_get_payload_format(struct ast_rtp_codecs *codecs, int payload);
+
+/*!
* \brief Get the sample rate associated with known RTP payload types
*
* \param asterisk_format True if the value in format is to be used.
@@ -1798,6 +1811,15 @@ struct ast_channel *ast_rtp_instance_get_chan(struct ast_rtp_instance *instance)
int ast_rtp_instance_add_srtp_policy(struct ast_rtp_instance *instance, struct ast_srtp_policy *policy);
struct ast_srtp *ast_rtp_instance_get_srtp(struct ast_rtp_instance *instance);
+/*! \brief Custom formats declared in codecs.conf at startup must be communicated to the rtp_engine
+ * so their mime type can payload number can be initialized. */
+int ast_rtp_engine_load_format(const struct ast_format *format);
+
+/*! \brief Formats requiring the use of a format attribute interface must have that
+ * interface registered in order for the rtp engine to handle it correctly. If an
+ * attribute interface is unloaded, this function must be called to notify the rtp_engine. */
+int ast_rtp_engine_unload_format(const struct ast_format *format);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
diff --git a/include/asterisk/silk.h b/include/asterisk/silk.h
new file mode 100644
index 000000000..5da827e7e
--- /dev/null
+++ b/include/asterisk/silk.h
@@ -0,0 +1,44 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * David Vossel <dvossel@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief SILK Format Attributes
+ *
+ * \author David Vossel <dvossel@digium.com>
+ */
+#ifndef _AST_FORMAT_SILK_H_
+#define _AST_FORMAT_SILK_H_
+
+/*! SILK format attribute key value pairs, all are accessible through ast_format_get_value()*/
+enum silk_attr_keys {
+ SILK_ATTR_KEY_SAMP_RATE, /*!< value is silk_attr_vals enum */
+ SILK_ATTR_KEY_DTX, /*!< value is an int, 1 dtx is enabled, 0 dtx not enabled. */
+ SILK_ATTR_KEY_FEC, /*!< value is an int, 1 encode with FEC, 0 do not use FEC. */
+ SILK_ATTR_KEY_PACKETLOSS_PERCENTAGE, /*!< value is an int (0-100), Represents estimated packetloss in uplink direction.*/
+ SILK_ATTR_KEY_MAX_BITRATE, /*!< value is an int */
+};
+
+enum silk_attr_vals {
+ SILK_ATTR_VAL_SAMP_8KHZ = (1 << 0),
+ SILK_ATTR_VAL_SAMP_12KHZ = (1 << 1),
+ SILK_ATTR_VAL_SAMP_16KHZ = (1 << 2),
+ SILK_ATTR_VAL_SAMP_24KHZ = (1 << 3),
+};
+
+#endif /* _AST_FORMAT_SILK_H */
diff --git a/include/asterisk/slinfactory.h b/include/asterisk/slinfactory.h
index 003c6ac28..324c0ae28 100644
--- a/include/asterisk/slinfactory.h
+++ b/include/asterisk/slinfactory.h
@@ -56,11 +56,11 @@ void ast_slinfactory_init(struct ast_slinfactory *sf);
* \brief Initialize a slinfactory
*
* \param sf The slinfactory to initialize
- * \param sample_rate The output sample rate desired
+ * \param slin_out the slinear output format desired.
*
* \return 0 on success, non-zero on failure
*/
-int ast_slinfactory_init_rate(struct ast_slinfactory *sf, unsigned int sample_rate);
+int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, const struct ast_format *slin_out);
/*!
* \brief Destroy the contents of a slinfactory
diff --git a/include/asterisk/time.h b/include/asterisk/time.h
index 2ffc691b8..c78ff2db0 100644
--- a/include/asterisk/time.h
+++ b/include/asterisk/time.h
@@ -171,7 +171,7 @@ struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec),
AST_INLINE_API(
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate),
{
- return ast_tv(_nsamp / _rate, ((_nsamp % _rate) * (4000000 / _rate)) / 4); /* this calculation is accurate up to 32000Hz. */
+ return ast_tv(_nsamp / _rate, (_nsamp % _rate) * (1000000 / (float) _rate));
}
)
diff --git a/include/asterisk/translate.h b/include/asterisk/translate.h
index 7e73cd1b1..8545f0ae5 100644
--- a/include/asterisk/translate.h
+++ b/include/asterisk/translate.h
@@ -133,7 +133,7 @@ enum ast_trans_cost_table {
* Generic plc is only available for dstfmt = SLINEAR
*/
struct ast_translator {
- const char name[80]; /*!< Name of translator */
+ char name[80]; /*!< Name of translator */
struct ast_format src_format; /*!< Source format */
struct ast_format dst_format; /*!< Destination format */
@@ -204,6 +204,12 @@ struct ast_translator {
struct ast_trans_pvt {
struct ast_translator *t;
struct ast_frame f; /*!< used in frameout */
+ /*! If a translation path using a format with attributes requires the output
+ * to be a specific set of attributes, this variable will be set describing those
+ * attributes to the translator. Otherwise, the translator must choose a set
+ * of format attributes for the destination that preserves the quality of the
+ * audio in the best way possible. */
+ struct ast_format explicit_dst;
int samples; /*!< samples available in outbuf */
/*! \brief actual space used in outbuf */
int datalen;
@@ -213,7 +219,7 @@ struct ast_trans_pvt {
unsigned char *uc; /*!< the useful portion of the buffer */
int16_t *i16;
uint8_t *ui8;
- } outbuf;
+ } outbuf;
plc_state_t *plc; /*!< optional plc pointer */
struct ast_trans_pvt *next; /*!< next in translator chain */
struct timeval nextin;