summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/asterisk/format.h11
-rw-r--r--main/codec.c5
-rw-r--r--main/format.c5
3 files changed, 17 insertions, 4 deletions
diff --git a/include/asterisk/format.h b/include/asterisk/format.h
index 32f9f2b40..3da2d8236 100644
--- a/include/asterisk/format.h
+++ b/include/asterisk/format.h
@@ -276,6 +276,17 @@ void ast_format_set_attribute_data(struct ast_format *format, void *attribute_da
const char *ast_format_get_name(const struct ast_format *format);
/*!
+ * \brief Get the codec associated with a format
+ *
+ * \param format The media format
+ *
+ * \return The codec
+ *
+ * \note The reference count of the returned codec is increased by 1 and must be decremented
+ */
+struct ast_codec *ast_format_get_codec(const struct ast_format *format);
+
+/*!
* \brief Get the codec identifier associated with a format
*
* \param format The media format
diff --git a/main/codec.c b/main/codec.c
index e060efe3e..19e78fa67 100644
--- a/main/codec.c
+++ b/main/codec.c
@@ -355,10 +355,7 @@ unsigned int ast_codec_samples_count(struct ast_frame *frame)
return 0;
}
- /* BUGBUG - why not just get the codec pointer off the format?
- This is a bit roundabout
- */
- codec = ast_codec_get_by_id(ast_format_get_codec_id(frame->subclass.format));
+ codec = ast_format_get_codec(frame->subclass.format);
if (codec->samples_count) {
samples = codec->samples_count(frame);
diff --git a/main/format.c b/main/format.c
index e54fca01b..09d7ef0c5 100644
--- a/main/format.c
+++ b/main/format.c
@@ -323,6 +323,11 @@ void ast_format_generate_sdp_fmtp(const struct ast_format *format, unsigned int
format->interface->format_generate_sdp_fmtp(format, payload, str);
}
+struct ast_codec *ast_format_get_codec(const struct ast_format *format)
+{
+ return ao2_bump(format->codec);
+}
+
unsigned int ast_format_get_codec_id(const struct ast_format *format)
{
return format->codec->id;