[asterisk-commits] file: branch file/media_formats-impl r407675 - in /team/file/media_formats-im...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Feb 7 07:44:51 CST 2014
Author: file
Date: Fri Feb 7 07:44:46 2014
New Revision: 407675
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407675
Log:
Incorporate review feedback.
Modified:
team/file/media_formats-impl/include/asterisk/codec.h
team/file/media_formats-impl/include/asterisk/format_cap_ng.h
team/file/media_formats-impl/include/asterisk/format_ng.h
team/file/media_formats-impl/include/asterisk/vector.h
team/file/media_formats-impl/main/asterisk.c
team/file/media_formats-impl/main/codec.c
team/file/media_formats-impl/main/codec_builtin.c
team/file/media_formats-impl/main/format_cache.c
team/file/media_formats-impl/main/format_cap_ng.c
team/file/media_formats-impl/tests/test_core_codec.c
team/file/media_formats-impl/tests/test_format_cap.c
Modified: team/file/media_formats-impl/include/asterisk/codec.h
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/include/asterisk/codec.h?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/include/asterisk/codec.h (original)
+++ team/file/media_formats-impl/include/asterisk/codec.h Fri Feb 7 07:44:46 2014
@@ -47,19 +47,29 @@
const char *description;
/*! \brief Type of media this codec contains */
enum ast_media_type type;
- /*! \brief Sample rate */
+ /*! \brief Sample rate (number of samples carried in a second) */
unsigned int sample_rate;
- /*! \brief Minimum length of media that can be carried (in milliseconds) */
+ /*! \brief Minimum length of media that can be carried (in milliseconds) in a frame */
unsigned int minimum_ms;
- /*! \brief Maximum length of media that can be carried (in milliseconds) */
+ /*! \brief Maximum length of media that can be carried (in milliseconds) in a frame */
unsigned int maximum_ms;
- /*! \brief The number of milliseconds the length can be incremented by */
- unsigned int increment_ms;
- /*! \brief Default length of media carried (in milliseconds) */
+ /*! \brief Default length of media carried (in milliseconds) in a frame */
unsigned int default_ms;
- /*! \brief Callback function for getting the number of samples in a frame */
- int (*get_samples)(struct ast_frame *frame);
- /*! \brief Callback function for getting the length of media based on number of samples */
+ /*!
+ * \brief Retrieve the number of samples in a frame
+ *
+ * \param frame The frame to examine
+ *
+ * \return the number of samples
+ */
+ int (*samples_count)(struct ast_frame *frame);
+ /*!
+ * \brief Retrieve the length of media from number of samples
+ *
+ * \param samples The number of samples
+ *
+ * \return The length of media in milliseconds
+ */
int (*get_length)(unsigned int samples);
/*! \brief Whether the media can be smoothed or not */
unsigned int smooth:1;
Modified: team/file/media_formats-impl/include/asterisk/format_cap_ng.h
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/include/asterisk/format_cap_ng.h?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/include/asterisk/format_cap_ng.h (original)
+++ team/file/media_formats-impl/include/asterisk/format_cap_ng.h Fri Feb 7 07:44:46 2014
@@ -53,6 +53,8 @@
*
* \param cap The capabilities structure.
* \param framing The framing value (in milliseconds).
+ *
+ * \note This is used if a format does not provide a framing itself.
*/
void ast_format_cap_ng_set_framing(struct ast_format_cap *cap, unsigned int framing);
@@ -69,6 +71,8 @@
* \note A reference to the format is taken and used in the capabilities structure.
*
* \note The order in which add is called determines the format preference order.
+ *
+ * \note If framing is specified here it overrides any global framing that has been set.
*/
int ast_format_cap_ng_add(struct ast_format_cap *cap, struct ast_format *format, unsigned int framing);
@@ -89,13 +93,15 @@
int ast_format_cap_ng_add_all_by_type(struct ast_format_cap *cap, enum ast_media_type type);
/*!
- * \brief Append the formats in src to dst
+ * \brief Copy all formats in src to dst
*
* \param dst The destination capabilities structure
* \param src The source capabilities structure
*
* \retval 0 success
* \retval -1 failure
+ *
+ * \note The source capabilities structure is left alone and remains valid afterwards.
*/
int ast_format_cap_ng_append(struct ast_format_cap *dst, const struct ast_format_cap *src);
@@ -109,7 +115,7 @@
size_t ast_format_cap_ng_count(const struct ast_format_cap *cap);
/*!
- * \brief Get the format at a specific position
+ * \brief Get the format at a specific index
*
* \param cap The capabilities structure
* \param position The position to get
@@ -117,6 +123,8 @@
* \retval non-NULL success
* \retval NULL failure
*
+ * \note This is a zero based index.
+ *
* \note Formats are returned in order of preference.
*
* \note The reference count of the returned format is increased. It must be released using ao2_ref
@@ -137,8 +145,7 @@
/*!
* \brief Remove format capability from capability structure.
*
- * \note format must match Exactly to format in ast_format_cap object in order
- * to be removed.
+ * \note format must be an exact pointer match to remove from capabilities structure.
*
* \retval 0, remove was successful
* \retval -1, remove failed. Could not find format to remove
@@ -150,15 +157,10 @@
*
* \param cap The capabilities structure
* \param type The media type to remove formats of
+ *
+ * \note All formats can be removed by using the AST_MEDIA_TYPE_UNKNOWN type.
*/
void ast_format_cap_ng_remove_bytype(struct ast_format_cap *cap, enum ast_media_type type);
-
-/*!
- * \brief Remove all format capabilities from capability structure
- *
- * \param cap The capabilities structure
- */
-void ast_format_cap_ng_remove_all(struct ast_format_cap *cap);
/*!
* \brief Find if input ast_format is within the capabilities of the ast_format_cap object
@@ -184,7 +186,7 @@
*
* \param cap1 The first capabilities structure
* \param cap2 The second capabilities structure
- * \param result The capabilities structure to place the results into
+ * \param[out] result The capabilities structure to place the results into
*
* \retval 0 success
* \retval -1 failure
Modified: team/file/media_formats-impl/include/asterisk/format_ng.h
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/include/asterisk/format_ng.h?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/include/asterisk/format_ng.h (original)
+++ team/file/media_formats-impl/include/asterisk/format_ng.h Fri Feb 7 07:44:46 2014
@@ -31,11 +31,11 @@
/*! \brief Format comparison results */
enum ast_format_cmp_res {
- /*! structure 1 is identical to structure 2. */
+ /*! Both formats are equivalent to eachother */
AST_FORMAT_CMP_EQUAL = 0,
- /*! structure 1 contains elements not in structure 2. */
+ /*! Both formats are completely different and not the same in any way */
AST_FORMAT_CMP_NOT_EQUAL,
- /*! structure 1 is a proper subset of the elements in structure 2.*/
+ /*! Both formats are similar but not equivalent */
AST_FORMAT_CMP_SUBSET,
};
@@ -43,11 +43,16 @@
struct ast_format_interface {
/*!
* \brief Callback for when the format is destroyed, used to release attribute resources
+ *
+ * \param format The format structure to destroy
*/
void (*const format_destroy)(struct ast_format *format);
/*!
* \brief Determine if format 1 is a subset of format 2.
+ *
+ * \param format1 First format to compare
+ * \param format2 Second format which the first is compared against
*
* \retval ast_format_cmp_res representing the result of comparing format1 and format2.
*/
@@ -55,7 +60,10 @@
const struct ast_format *format2);
/*!
- * \brief Get joint attributes of same format type if they exist.
+ * \brief Get a format with the joint compatible attributes of both provided formats.
+ *
+ * \param format1 The first format
+ * \param format2 The second format
*
* \retval non-NULL if joint format
* \retval NULL if no joint format
@@ -63,17 +71,26 @@
* \note The returned format has its reference count incremented and must be released using
* ao2_ref or ao2_cleanup.
*/
- struct ast_format *(* const format_get_joint)(const struct ast_format *format1,
- const struct ast_format *format2);
+ struct ast_format *(* const format_get_joint)(const struct ast_format *format1,
+ const struct ast_format *format2);
/*!
* \brief Set an attribute on a format
+ *
+ * \param name The name of the attribute
+ * \param value The value of the attribute
+ *
+ * \retval 0 success
+ * \retval -1 failure
*/
int (* const format_attribute_set)(struct ast_format *format, const char *name, const char *value);
/*
* \brief Parse SDP attribute information, interpret it, and store it in the format structure.
*
+ * \param format Format to set attributes on
+ * \param attributes A string containing only the attributes from the fmtp line
+ *
* \retval 0 Success, values were valid
* \retval -1 Failure, some values were not acceptable
*/
@@ -81,6 +98,10 @@
/*!
* \brief Generate SDP attribute information from an ast_format_attr structure.
+ *
+ * \param format The format containing attributes
+ * \param payload The payload number to place into the fmtp line
+ * \param str The generated fmtp line
*
* \note This callback should generate a full fmtp line using the provided payload number.
*/
Modified: team/file/media_formats-impl/include/asterisk/vector.h
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/include/asterisk/vector.h?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/include/asterisk/vector.h (original)
+++ team/file/media_formats-impl/include/asterisk/vector.h Fri Feb 7 07:44:46 2014
@@ -124,12 +124,18 @@
*
* \return 0 on success.
* \return Non-zero on failure.
+ *
+ * \warning This macro will overwrite anything already present at the position provided.
+ *
+ * \warning Use of this macro with the expectation that the element will remain at the provided
+ * index means you can not use the UNORDERED assortment of macros. These macros alter the ordering
+ * of the vector itself.
*/
#define AST_VECTOR_INSERT(vec, idx, elem) ({ \
int res = 0; \
do { \
- if ((idx + 1) > (vec)->max) { \
- size_t new_max = (idx + 1) * 2; \
+ if (((idx) + 1) > (vec)->max) { \
+ size_t new_max = ((idx) + 1) * 2; \
typeof((vec)->elems) new_elems = ast_calloc(1, \
new_max * sizeof(*new_elems)); \
if (new_elems) { \
@@ -144,7 +150,7 @@
} \
} \
(vec)->elems[(idx)] = (elem); \
- if ((idx + 1) > (vec)->current) { \
+ if (((idx) + 1) > (vec)->current) { \
(vec)->current = (idx) + 1; \
} \
} while(0); \
@@ -177,16 +183,16 @@
* \param idx Index of the element to remove.
* \return The element that was removed.
*/
-#define AST_VECTOR_REMOVE_ORDERED(vec, idx) ({ \
- typeof((vec)->elems[0]) res; \
- size_t __idx = (idx); \
+#define AST_VECTOR_REMOVE_ORDERED(vec, idx) ({ \
+ typeof((vec)->elems[0]) res; \
+ size_t __idx = (idx); \
size_t __move; \
- ast_assert(__idx < (vec)->current); \
- res = (vec)->elems[__idx]; \
+ ast_assert(__idx < (vec)->current); \
+ res = (vec)->elems[__idx]; \
__move = ((vec)->current - (__idx) - 1) * sizeof(typeof((vec)->elems[0])); \
memmove(&(vec)->elems[__idx], &(vec)->elems[__idx + 1], __move); \
- (vec)->current--; \
- res; \
+ (vec)->current--; \
+ res; \
})
Modified: team/file/media_formats-impl/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/main/asterisk.c?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/main/asterisk.c (original)
+++ team/file/media_formats-impl/main/asterisk.c Fri Feb 7 07:44:46 2014
@@ -4328,7 +4328,7 @@
if (ast_format_cache_init()) {
printf("%s", term_quit());
- exit(1);
+ exit(1);
}
if (ast_codec_builtin_init()) {
Modified: team/file/media_formats-impl/main/codec.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/main/codec.c?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/main/codec.c (original)
+++ team/file/media_formats-impl/main/codec.c Fri Feb 7 07:44:46 2014
@@ -131,7 +131,7 @@
ast_cli(a->fd, "-----------------------------------------------------------------------------------\n");
ao2_rdlock(codecs);
- i = ao2_iterator_init(codecs, 0);
+ i = ao2_iterator_init(codecs, AO2_ITERATOR_DONTLOCK);
for (; (codec = ao2_iterator_next(&i)); ao2_ref(codec, -1)) {
if (a->argc == 4) {
@@ -226,6 +226,7 @@
{
ast_cli_unregister_multiple(codec_cli, ARRAY_LEN(codec_cli));
ao2_cleanup(codecs);
+ codecs = NULL;
}
int ast_codec_init(void)
Modified: team/file/media_formats-impl/main/codec_builtin.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/main/codec_builtin.c?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/main/codec_builtin.c (original)
+++ team/file/media_formats-impl/main/codec_builtin.c Fri Feb 7 07:44:46 2014
@@ -96,9 +96,8 @@
.sample_rate = 8000,
.minimum_ms = 30,
.maximum_ms = 300,
- .increment_ms = 30,
.default_ms = 30,
- .get_samples = g723_samples,
+ .samples_count = g723_samples,
.get_length = g723_length,
};
@@ -120,9 +119,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = ulaw_samples,
+ .default_ms = 20,
+ .samples_count = ulaw_samples,
.get_length = ulaw_length,
};
@@ -134,9 +132,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = ulaw_samples,
+ .default_ms = 20,
+ .samples_count = ulaw_samples,
.get_length = ulaw_length,
};
@@ -158,9 +155,8 @@
.sample_rate = 8000,
.minimum_ms = 20,
.maximum_ms = 300,
- .increment_ms = 20,
- .default_ms = 20,
- .get_samples = gsm_samples,
+ .default_ms = 20,
+ .samples_count = gsm_samples,
.get_length = gsm_length,
};
@@ -182,9 +178,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 300,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = g726_samples,
+ .default_ms = 20,
+ .samples_count = g726_samples,
.get_length = g726_length,
};
@@ -196,9 +191,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 300,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = g726_samples,
+ .default_ms = 20,
+ .samples_count = g726_samples,
.get_length = g726_length,
};
@@ -210,9 +204,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 300,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = g726_samples,
+ .default_ms = 20,
+ .samples_count = g726_samples,
.get_length = g726_length,
};
@@ -234,9 +227,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -247,9 +239,8 @@
.sample_rate = 12000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -261,9 +252,8 @@
.sample_rate = 16000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -274,9 +264,8 @@
.sample_rate = 24000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -287,9 +276,8 @@
.sample_rate = 32000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -300,9 +288,8 @@
.sample_rate = 44000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -313,9 +300,8 @@
.sample_rate = 48000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -326,9 +312,8 @@
.sample_rate = 96000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -339,9 +324,8 @@
.sample_rate = 192000,
.minimum_ms = 10,
.maximum_ms = 70,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = slin_samples,
+ .default_ms = 20,
+ .samples_count = slin_samples,
.get_length = slin_length,
};
@@ -363,9 +347,8 @@
.sample_rate = 8000,
.minimum_ms = 20,
.maximum_ms = 20,
- .increment_ms = 20,
- .default_ms = 20,
- .get_samples = lpc10_samples,
+ .default_ms = 20,
+ .samples_count = lpc10_samples,
};
static int g729_samples(struct ast_frame *frame)
@@ -386,9 +369,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 230,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = g729_samples,
+ .default_ms = 20,
+ .samples_count = g729_samples,
.get_length = g729_length,
};
@@ -514,9 +496,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 60,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = speex8_samples,
+ .default_ms = 20,
+ .samples_count = speex8_samples,
};
static int speex16_samples(struct ast_frame *frame)
@@ -532,9 +513,8 @@
.sample_rate = 16000,
.minimum_ms = 10,
.maximum_ms = 60,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = speex16_samples,
+ .default_ms = 20,
+ .samples_count = speex16_samples,
};
static int speex32_samples(struct ast_frame *frame)
@@ -549,9 +529,8 @@
.sample_rate = 32000,
.minimum_ms = 10,
.maximum_ms = 60,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = speex32_samples,
+ .default_ms = 20,
+ .samples_count = speex32_samples,
};
static int ilbc_samples(struct ast_frame *frame)
@@ -567,9 +546,8 @@
.sample_rate = 8000,
.minimum_ms = 30,
.maximum_ms = 30,
- .increment_ms = 30,
.default_ms = 30,
- .get_samples = ilbc_samples,
+ .samples_count = ilbc_samples,
};
static struct ast_codec g722 = {
@@ -580,9 +558,8 @@
.sample_rate = 16000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = g726_samples,
+ .default_ms = 20,
+ .samples_count = g726_samples,
.get_length = g726_length,
};
@@ -604,9 +581,8 @@
.sample_rate = 16000,
.minimum_ms = 20,
.maximum_ms = 80,
- .increment_ms = 20,
- .default_ms = 20,
- .get_samples = siren7_samples,
+ .default_ms = 20,
+ .samples_count = siren7_samples,
.get_length = siren7_length,
};
@@ -628,9 +604,8 @@
.sample_rate = 32000,
.minimum_ms = 20,
.maximum_ms = 80,
- .increment_ms = 20,
- .default_ms = 20,
- .get_samples = siren14_samples,
+ .default_ms = 20,
+ .samples_count = siren14_samples,
.get_length = siren14_length,
};
@@ -642,9 +617,8 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
- .default_ms = 20,
- .get_samples = ulaw_samples,
+ .default_ms = 20,
+ .samples_count = ulaw_samples,
.get_length = ulaw_length,
};
@@ -666,9 +640,8 @@
.sample_rate = 48000,
.minimum_ms = 20,
.maximum_ms = 80,
- .increment_ms = 20,
- .default_ms = 20,
- .get_samples = g719_samples,
+ .default_ms = 20,
+ .samples_count = g719_samples,
.get_length = g719_length,
};
@@ -680,7 +653,6 @@
.sample_rate = 48000,
.minimum_ms = 20,
.maximum_ms = 60,
- .increment_ms = 20,
.default_ms = 20,
};
Modified: team/file/media_formats-impl/main/format_cache.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/main/format_cache.c?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/main/format_cache.c (original)
+++ team/file/media_formats-impl/main/format_cache.c Fri Feb 7 07:44:46 2014
@@ -102,6 +102,7 @@
static void format_cache_shutdown(void)
{
ao2_cleanup(formats);
+ formats = NULL;
}
int ast_format_cache_init(void)
Modified: team/file/media_formats-impl/main/format_cap_ng.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/main/format_cap_ng.c?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/main/format_cap_ng.c (original)
+++ team/file/media_formats-impl/main/format_cap_ng.c Fri Feb 7 07:44:46 2014
@@ -64,7 +64,7 @@
AST_LIST_HEAD_NOLOCK(format_cap_framed_list, format_cap_framed);
/*! \brief Dummy empty list for when we are inserting a new list */
-static const struct format_cap_framed_list format_cap_framed_list_empty = { NULL, };
+static const struct format_cap_framed_list format_cap_framed_list_empty = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
/*! \brief Destructor for format capabilities structure */
static void format_cap_destroy(void *obj)
@@ -134,7 +134,7 @@
framed->format = ao2_bump(format);
framed->framing = framing;
- if (format->codec->id >= cap->formats.current) {
+ if (format->codec->id >= AST_VECTOR_SIZE(&cap->formats)) {
if (AST_VECTOR_INSERT(&cap->formats, format->codec->id, format_cap_framed_list_empty)) {
ao2_ref(framed, -1);
return -1;
@@ -156,7 +156,7 @@
{
int id;
- for (id = 0; id < ast_codec_get_max(); ++id) {
+ for (id = 1; id < ast_codec_get_max(); ++id) {
struct ast_codec *codec = ast_codec_get_by_id(id);
struct ast_format *format;
int res;
@@ -211,7 +211,7 @@
{
struct format_cap_framed *framed;
- if (position >= cap->preference_order.current) {
+ if (position >= AST_VECTOR_SIZE(&cap->preference_order)) {
return NULL;
}
@@ -227,7 +227,7 @@
struct format_cap_framed_list *list;
struct format_cap_framed *framed, *result = NULL;
- if (format->codec->id >= cap->formats.current) {
+ if (format->codec->id >= AST_VECTOR_SIZE(&cap->formats)) {
return 0;
}
@@ -280,7 +280,7 @@
struct format_cap_framed_list *list;
struct format_cap_framed *framed;
- if (format->codec->id >= cap->formats.current) {
+ if (format->codec->id >= AST_VECTOR_SIZE(&cap->formats)) {
return -1;
}
@@ -310,7 +310,8 @@
struct format_cap_framed *framed;
AST_LIST_TRAVERSE_SAFE_BEGIN(list, framed, entry) {
- if (framed->format->codec->type != type) {
+ if ((type != AST_MEDIA_TYPE_UNKNOWN) &&
+ framed->format->codec->type != type) {
continue;
}
@@ -323,23 +324,13 @@
}
}
-void ast_format_cap_ng_remove_all(struct ast_format_cap *cap)
-{
- format_cap_destroy(cap);
-
- AST_VECTOR_INIT(&cap->formats, 0);
-
- /* TODO: Look at common usage of this and determine a good starting point */
- AST_VECTOR_INIT(&cap->preference_order, 5);
-}
-
struct ast_format *ast_format_cap_ng_get_compatible_format(const struct ast_format_cap *cap, const struct ast_format *format)
{
struct format_cap_framed_list *list;
struct format_cap_framed *framed;
struct ast_format *result = NULL;
- if (format->codec->id >= cap->formats.current) {
+ if (format->codec->id >= AST_VECTOR_SIZE(&cap->formats)) {
return NULL;
}
@@ -373,7 +364,7 @@
struct format_cap_framed_list *list;
struct format_cap_framed *framed;
- if (format->codec->id >= cap->formats.current) {
+ if (format->codec->id >= AST_VECTOR_SIZE(&cap->formats)) {
return AST_FORMAT_CMP_NOT_EQUAL;
}
Modified: team/file/media_formats-impl/tests/test_core_codec.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/tests/test_core_codec.c?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/tests/test_core_codec.c (original)
+++ team/file/media_formats-impl/tests/test_core_codec.c Fri Feb 7 07:44:46 2014
@@ -44,7 +44,6 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
.default_ms = 20,
};
@@ -55,7 +54,6 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
.default_ms = 20,
};
@@ -66,7 +64,6 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
.default_ms = 20,
};
@@ -76,7 +73,6 @@
.type = AST_MEDIA_TYPE_AUDIO,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
.default_ms = 20,
};
@@ -87,7 +83,6 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
.default_ms = 20,
};
@@ -98,7 +93,6 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
.default_ms = 20,
};
@@ -109,7 +103,6 @@
.sample_rate = 8000,
.minimum_ms = 10,
.maximum_ms = 150,
- .increment_ms = 10,
.default_ms = 20,
};
Modified: team/file/media_formats-impl/tests/test_format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/file/media_formats-impl/tests/test_format_cap.c?view=diff&rev=407675&r1=407674&r2=407675
==============================================================================
--- team/file/media_formats-impl/tests/test_format_cap.c (original)
+++ team/file/media_formats-impl/tests/test_format_cap.c Fri Feb 7 07:44:46 2014
@@ -606,7 +606,7 @@
return AST_TEST_FAIL;
}
- ast_format_cap_ng_remove_all(caps);
+ ast_format_cap_ng_remove_bytype(caps, AST_MEDIA_TYPE_UNKNOWN);
if (ast_format_cap_ng_count(caps)) {
ast_test_status_update(test, "Removed all formats from capabilities structure but some remain\n");
More information about the asterisk-commits
mailing list