[svn-commits] mjordan: branch group/media_formats-reviewed-trunk r417165 - in /team/group/m...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jun 23 17:29:11 CDT 2014
Author: mjordan
Date: Mon Jun 23 17:29:00 2014
New Revision: 417165
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417165
Log:
------------------------------------------------------------------------
r417164 | mjordan | 2014-06-23 17:09:47 -0500 (Mon, 23 Jun 2014) | 28 lines
Update more of the core
This patch includes all of Corey's fine work on r3625, more that he did in
channel/rtp_engine/dsp, and enough work in format_cache/elsewhere to get
Asterisk's core to compile, along with some improvements in translate.
Major changes made in this patch:
* Removed ast_best_codec, as it was a farce. All channel drivers will now
use the first codec listed in their configured set of codecs as their
preferred codec.
* Formats now store their name, as it can differ from the codec. This now
has the accessor ast_format_get_name; codecs get the new
ast_format_get_codec_name. Similarly, formats can now be constructed
either entirely from the codec, or from a codec + name.
* Updated the format_cache with the expected short-hand pointers to the
cached formats.
* channel.c was updated. That's large. Note that this was done mostly by
Corey Farrell
* Codecs can do an explicit name match without their sample rate. This is
done to make it a bit easier for CLI commands to query codecs with
singular but odd sample rates (looking at you Opus)
* CLI commands in translate.c should now mostly work. translate.c will
now correctly register translation paths - previously, it used the
passed in codecs, which did not contain the codec->id field.
Review: https://reviewboard.asterisk.org/r/3665/
------------------------------------------------------------------------
Modified:
team/group/media_formats-reviewed-trunk/ (props changed)
team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c
team/group/media_formats-reviewed-trunk/channels/chan_gtalk.c
team/group/media_formats-reviewed-trunk/channels/chan_h323.c
team/group/media_formats-reviewed-trunk/channels/chan_iax2.c
team/group/media_formats-reviewed-trunk/channels/chan_jingle.c
team/group/media_formats-reviewed-trunk/channels/chan_mgcp.c
team/group/media_formats-reviewed-trunk/channels/chan_misdn.c
team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c
team/group/media_formats-reviewed-trunk/channels/chan_phone.c
team/group/media_formats-reviewed-trunk/channels/chan_sip.c
team/group/media_formats-reviewed-trunk/channels/chan_skinny.c
team/group/media_formats-reviewed-trunk/channels/chan_unistim.c
team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h
team/group/media_formats-reviewed-trunk/include/asterisk/_private.h
team/group/media_formats-reviewed-trunk/include/asterisk/channel.h
team/group/media_formats-reviewed-trunk/include/asterisk/format.h
team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h
team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h
team/group/media_formats-reviewed-trunk/main/asterisk.c
team/group/media_formats-reviewed-trunk/main/channel.c
team/group/media_formats-reviewed-trunk/main/codec.c
team/group/media_formats-reviewed-trunk/main/codec_builtin.c
team/group/media_formats-reviewed-trunk/main/core_unreal.c
team/group/media_formats-reviewed-trunk/main/dsp.c
team/group/media_formats-reviewed-trunk/main/format.c
team/group/media_formats-reviewed-trunk/main/format_cache.c
team/group/media_formats-reviewed-trunk/main/format_cap.c
team/group/media_formats-reviewed-trunk/main/frame.c
team/group/media_formats-reviewed-trunk/main/rtp_engine.c
team/group/media_formats-reviewed-trunk/main/slinfactory.c
team/group/media_formats-reviewed-trunk/main/translate.c
team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c
team/group/media_formats-reviewed-trunk/tests/test_format_cache.c
Propchange: team/group/media_formats-reviewed-trunk/
------------------------------------------------------------------------------
svn:mergeinfo = /team/group/media_formats-reviewed:417164
Modified: team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c (original)
+++ team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c Mon Jun 23 17:29:00 2014
@@ -385,10 +385,12 @@
if (ch && caps) {
ast_channel_tech_set(ch, &ooh323_tech);
- if (cap)
- ast_best_codec(cap, &tmpfmt);
- if (!tmpfmt)
+ if (cap) {
+ tmpfmt = ast_format_cap_get_format(cap, 0);
+ }
+ if (!tmpfmt) {
tmpfmt = ast_format_cap_get_format(i->cap, 0);
+ }
ast_format_cap_add(caps, tmpfmt, 0);
ast_channel_nativeformats_set(ch, caps);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_gtalk.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_gtalk.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_gtalk.c Mon Jun 23 17:29:00 2014
@@ -1157,11 +1157,12 @@
}
/* Set Frame packetization */
+// BUGBUG
// if (i->rtp) {
// ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(i->rtp), i->rtp, &i->prefs);
// }
- ast_best_codec(what, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(what, 0);
ast_format_cap_add(caps, tmpfmt, 0);
ast_format_cap_append_by_type(caps, i->jointcap, AST_MEDIA_TYPE_VIDEO);
ast_channel_nativeformats_set(tmp, caps);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_h323.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_h323.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_h323.c Mon Jun 23 17:29:00 2014
@@ -1103,7 +1103,7 @@
ast_format_compatibility_bitfield2cap(fmt, nativeformats);
ast_channel_nativeformats_set(ch, nativeformats);
- ast_best_codec(nativeformats, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(nativeformats, 0);
ast_format_cap_remove_bytype(nativeformats, AST_MEDIA_TYPE_UNKNOWN);
ast_format_cap_add(nativeformats, tmpfmt, 0);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_iax2.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_iax2.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_iax2.c Mon Jun 23 17:29:00 2014
@@ -1819,7 +1819,7 @@
if ((cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
ast_format_compatibility_bitfield2cap(formats, cap);
- ast_best_codec(cap, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(cap, 0);
format = ast_format_compatibility_format2bitfield(tmpfmt);
ao2_ref(tmpfmt, -1);
ao2_ref(cap, -1);
@@ -1839,7 +1839,7 @@
}
ast_format_compatibility_bitfield2cap(formats, cap);
- ast_best_codec(cap, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(cap, 0);
format = ast_format_compatibility_format2bitfield(tmpfmt);
ao2_ref(tmpfmt, -1);
ao2_ref(cap, -1);
@@ -5847,13 +5847,14 @@
/* We can support any format by default, until we get restricted */
ast_format_compatibility_bitfield2cap(capability, native);
ast_channel_nativeformats_set(tmp, native);
- ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(ast_channel_nativeformats(tmp), 0);
ast_channel_set_readformat(tmp, tmpfmt);
ast_channel_set_rawreadformat(tmp, tmpfmt);
ast_channel_set_writeformat(tmp, tmpfmt);
ast_channel_set_rawwriteformat(tmp, tmpfmt);
+ ao2_ref(tmpfmt, -1);
ao2_ref(native, -1);
ast_channel_tech_pvt_set(tmp, CALLNO_TO_PTR(i->callno));
@@ -12448,7 +12449,7 @@
ao2_ref(best_fmt_native, -1);
}
ast_channel_nativeformats_set(c, joint);
- ast_best_codec(ast_channel_nativeformats(c), &format);
+ format = ast_format_cap_get_format(ast_channel_nativeformats(c), 0);
ast_channel_set_readformat(c, format);
ast_channel_set_writeformat(c, format);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_jingle.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_jingle.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_jingle.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_jingle.c Mon Jun 23 17:29:00 2014
@@ -877,10 +877,11 @@
what = global_capability;
/* Set Frame packetization */
+// BUGBUG
// if (i->rtp)
// ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(i->rtp), i->rtp, &i->prefs);
- ast_best_codec(what, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(what, 0);
ast_format_cap_add(caps, tmpfmt, 0);
ast_format_cap_append_by_type(caps, i->jointcap, AST_MEDIA_TYPE_VIDEO);
ast_channel_nativeformats_set(tmp, caps);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_mgcp.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_mgcp.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_mgcp.c Mon Jun 23 17:29:00 2014
@@ -1540,9 +1540,11 @@
} else {
i->dsp = NULL;
}
- if (state == AST_STATE_RING)
+ if (state == AST_STATE_RING) {
ast_channel_rings_set(tmp, 1);
- ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
+ }
+
+ tmpfmt = ast_format_cap_get_format(ast_channel_nativeformats(tmp), 0);
ast_channel_set_writeformat(tmp, tmpfmt);
ast_channel_set_rawwriteformat(tmp, tmpfmt);
ast_channel_set_readformat(tmp, tmpfmt);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_misdn.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_misdn.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_misdn.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_misdn.c Mon Jun 23 17:29:00 2014
@@ -8204,7 +8204,7 @@
if (tmp) {
chan_misdn_log(2, port, " --> * NEW CHANNEL dialed:%s caller:%s\n", exten, callerid);
- ast_best_codec(cap, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(cap, 0);
ast_format_cap_add(native, ast_format_alaw, 0);
ast_channel_nativeformats_set(tmp, native);
ast_channel_set_writeformat(tmp, tmpfmt);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c Mon Jun 23 17:29:00 2014
@@ -120,7 +120,7 @@
struct ast_format_cap *caps = NULL;
struct ast_format *fmt = NULL;
- ast_best_codec(cap, &fmt);
+ fmt = ast_format_cap_get_format(cap, 0);
ast_sockaddr_setnull(&control_address);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_phone.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_phone.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_phone.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_phone.c Mon Jun 23 17:29:00 2014
@@ -893,7 +893,7 @@
} else {
ast_format_cap_append_by_type(caps, prefcap, AST_MEDIA_TYPE_UNKNOWN);
}
- ast_best_codec(caps, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(caps, 0);
ast_channel_nativeformats_set(tmp, caps);
ao2_ref(caps, -1);
ast_channel_set_rawreadformat(tmp, tmpfmt);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_sip.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_sip.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_sip.c Mon Jun 23 17:29:00 2014
@@ -11321,6 +11321,7 @@
}
}
}
+ ao2_ref(format, -1);
}
}
@@ -11367,6 +11368,7 @@
} else {
ast_rtp_codecs_payloads_unset(newvideortp, NULL, codec);
}
+ ao2_ref(format, -1);
}
}
Modified: team/group/media_formats-reviewed-trunk/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_skinny.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_skinny.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_skinny.c Mon Jun 23 17:29:00 2014
@@ -2652,7 +2652,7 @@
if (!(req = req_alloc(sizeof(struct open_receive_channel_message), OPEN_RECEIVE_CHANNEL_MESSAGE)))
return;
- ast_best_codec(l->cap, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(l->cap, 0);
framing = ast_format_cap_get_framing(l->cap, tmpfmt);
req->data.openreceivechannel.conferenceId = htolel(sub->callid);
@@ -3666,7 +3666,7 @@
SKINNY_DEBUG(DEBUG_AUDIO, 4, "Peerip = %s:%d\n", ast_inet_ntoa(them.sin_addr), ntohs(them.sin_port));
- ast_best_codec(l->cap, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(l->cap, 0);
framing = ast_format_cap_get_framing(l->cap, tmpfmt);
SKINNY_DEBUG(DEBUG_AUDIO, 4, "Setting payloadType to '%s' (%d ms)\n", ast_format_get_name(tmpfmt), framing);
@@ -5440,7 +5440,7 @@
}
ast_channel_nativeformats_set(tmp, caps);
ao2_ref(caps, -1);
- ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(ast_channel_nativeformats(tmp), 0);
SKINNY_DEBUG(DEBUG_SUB, 3, "skinny_new: tmp->nativeformats=%s fmt=%s\n",
ast_getformatname_multiple(dbgsub_buf, sizeof(dbgsub_buf), ast_channel_nativeformats(tmp)),
ast_format_get_name(tmpfmt));
@@ -6921,7 +6921,7 @@
SKINNY_DEBUG(DEBUG_PACKET, 4, "device ipaddr = %s:%d\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
SKINNY_DEBUG(DEBUG_PACKET, 4, "asterisk ipaddr = %s:%d\n", ast_inet_ntoa(us.sin_addr), ntohs(us.sin_port));
- ast_best_codec(l->cap, &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(l->cap, 0);
framing = ast_format_cap_get_framing(l->cap, tmpfmt);
SKINNY_DEBUG(DEBUG_PACKET, 4, "Setting payloadType to '%s' (%d ms)\n", ast_format_get_name(tmpfmt), framing);
Modified: team/group/media_formats-reviewed-trunk/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/channels/chan_unistim.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/channels/chan_unistim.c (original)
+++ team/group/media_formats-reviewed-trunk/channels/chan_unistim.c Mon Jun 23 17:29:00 2014
@@ -2887,7 +2887,7 @@
if (!ast_format_cap_iscompatible_format(ast_channel_nativeformats(sub->owner), ast_channel_readformat(sub->owner))) {
struct ast_format *tmpfmt;
char tmp[256];
- ast_best_codec(ast_channel_nativeformats(sub->owner), &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(ast_channel_nativeformats(sub->owner), 0);
ast_log(LOG_WARNING,
"Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
ast_format_get_name(ast_channel_readformat(sub->owner)),
@@ -5711,7 +5711,7 @@
ast_channel_nativeformats_set(tmp, caps);
ao2_ref(caps, -1);
- ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
+ tmpfmt = ast_format_cap_get_format(ast_channel_nativeformats(tmp), 0);
if (unistimdebug) {
char tmp1[256], tmp2[256], tmp3[256];
Modified: team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h (original)
+++ team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h Mon Jun 23 17:29:00 2014
@@ -31,6 +31,6 @@
.src = __PRETTY_FUNCTION__,
.data.ptr = ex_alaw,
};
- f.subclass.format = ast_format_copy(ast_format_ulaw);
+ f.subclass.format = ast_format_copy(ast_format_alaw);
return &f;
}
Modified: team/group/media_formats-reviewed-trunk/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/include/asterisk/_private.h?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/include/asterisk/_private.h (original)
+++ team/group/media_formats-reviewed-trunk/include/asterisk/_private.h Mon Jun 23 17:29:00 2014
@@ -121,16 +121,6 @@
*/
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);
Modified: team/group/media_formats-reviewed-trunk/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/include/asterisk/channel.h?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/include/asterisk/channel.h (original)
+++ team/group/media_formats-reviewed-trunk/include/asterisk/channel.h Mon Jun 23 17:29:00 2014
@@ -2085,17 +2085,6 @@
* \return 0 on success and -1 on failure
*/
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);
-
-/*!
- * \brief Pick the best codec
- *
- * \param cap capabilities to pick best codec out of
- * \param result stucture to store the best codec in.
- * \retval on success, pointer to result structure
- * \retval on failure, NULL
- */
-struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format **result);
-
/*!
* \brief Checks the value of an option
Modified: team/group/media_formats-reviewed-trunk/include/asterisk/format.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/include/asterisk/format.h?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/include/asterisk/format.h (original)
+++ team/group/media_formats-reviewed-trunk/include/asterisk/format.h Mon Jun 23 17:29:00 2014
@@ -122,13 +122,31 @@
*
* \param codec The codec to use
*
- * \param non-NULL success
- * \param NULL failure
+ * \retval non-NULL success
+ * \retval NULL failure
*
* \note The format is returned with reference count incremented. It must be released using
* ao2_ref or ao2_cleanup.
*/
struct ast_format *ast_format_create(struct ast_codec *codec);
+
+/*!
+ * \brief Create a new media format with a specific name
+ *
+ * \param format_name The name to use for the format
+ * \param codec The codec to use
+ *
+ * \note This creation function should be used when the name of the \c codec
+ * cannot be explicitly used for the name of the format. This is the case for
+ * codecs with multiple sample rates
+ *
+ * \note The format is returned with reference count incremented. It must be released using
+ * ao2_ref or ao2_cleanup.
+ *
+ * \retval non-NULL success
+ * \retval NULL failure
+ */
+struct ast_format *ast_format_create_named(const char *format_name, struct ast_codec *codec);
/*!
* \brief Compare two formats
@@ -213,6 +231,15 @@
#define ast_format_interface_register(codec, interface) __ast_format_interface_register(codec, interface, ast_module_info->self)
/*!
+ * \brief Get the name associated with a format
+ *
+ * \param format The media format
+ *
+ * \return The name of the format
+ */
+const char *ast_format_get_name(const struct ast_format *format);
+
+/*!
* \brief Get the codec identifier associated with a format
*
* \param format The media format
@@ -226,9 +253,9 @@
*
* \param format The media format
*
- * \return codec name
- */
-const char *ast_format_get_name(const struct ast_format *format);
+ * \return The codec name
+ */
+const char *ast_format_get_codec_name(const struct ast_format *format);
/*!
* \brief Get the media type of a format
Modified: team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h (original)
+++ team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h Mon Jun 23 17:29:00 2014
@@ -114,11 +114,6 @@
extern struct ast_format *ast_format_g726_aal2;
/*!
- * \brief Built-in cached g726-aal2 format.
- */
-extern struct ast_format *ast_format_g726_aal2;
-
-/*!
* \brief Built-in cached ilbc format.
*/
extern struct ast_format *ast_format_ilbc;
@@ -237,7 +232,7 @@
int ast_format_cache_init(void);
/*!
- * \brief Add a named format cache entry.
+ * \brief Set a named format cache entry.
*
* \param name Name of the cached format
* \param format A pointer to the format to cache
@@ -245,7 +240,7 @@
* \retval 0 success
* \retval -1 failure
*/
-int ast_format_cache_add(const char *name, struct ast_format *format);
+int ast_format_cache_set(const char *name, struct ast_format *format);
/*!
* \brief Retrieve a named format from the cache.
@@ -272,4 +267,14 @@
*/
struct ast_format *ast_format_cache_get_slin_by_rate(unsigned int rate);
+/*!
+ * \brief Determines if a format is one of the cached slin formats
+ *
+ * \param format The format to check
+ *
+ * \retval 0 if the format is not an SLIN format
+ * \retval 1 if the format is an SLIN format
+ */
+int ast_format_cache_is_slinear(struct ast_format *format);
+
#endif /* _AST_FORMAT_CACHE_H */
Modified: team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h (original)
+++ team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h Mon Jun 23 17:29:00 2014
@@ -600,6 +600,18 @@
AST_RWLIST_ENTRY(ast_rtp_glue) entry;
};
+/*!
+ * \brief Allocation routine for \ref ast_rtp_payload_type
+ *
+ * \retval NULL on error
+ * \retval An ao2 ref counted \c ast_rtp_payload_type on success.
+ *
+ * \note The \c ast_rtp_payload_type returned by this function is an
+ * ao2 ref counted object.
+ *
+ */
+struct ast_rtp_payload_type *ast_rtp_engine_alloc_payload_type(void);
+
#define ast_rtp_engine_register(engine) ast_rtp_engine_register2(engine, ast_module_info->self)
/*!
@@ -1251,6 +1263,9 @@
* \retval pointer to format structure on success
* \retval NULL on failure
*
+ * \note The format returned by this function has its reference count increased.
+ * Callers are responsible for decrementing the reference count.
+ *
* \since 10.0
*/
struct ast_format *ast_rtp_codecs_get_payload_format(struct ast_rtp_codecs *codecs, int payload);
Modified: team/group/media_formats-reviewed-trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/asterisk.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/asterisk.c (original)
+++ team/group/media_formats-reviewed-trunk/main/asterisk.c Mon Jun 23 17:29:00 2014
@@ -4337,6 +4337,11 @@
exit(1);
}
+ if (ast_format_init()) {
+ printf("%s", term_quit());
+ exit(1);
+ }
+
if (ast_format_cache_init()) {
printf("%s", term_quit());
exit(1);
@@ -4401,8 +4406,6 @@
threadstorage_init();
- ast_format_attr_init();
- ast_format_list_init();
if (ast_rtp_engine_init()) {
printf("%s", term_quit());
exit(1);
Modified: team/group/media_formats-reviewed-trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/main/channel.c?view=diff&rev=417165&r1=417164&r2=417165
==============================================================================
--- team/group/media_formats-reviewed-trunk/main/channel.c (original)
+++ team/group/media_formats-reviewed-trunk/main/channel.c Mon Jun 23 17:29:00 2014
@@ -764,78 +764,6 @@
}
}
-/*! \brief Pick the best audio codec */
-struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format *result)
-{
- /* This just our opinion, expressed in code. We are asked to choose
- the best codec to use, given no information */
- static const enum ast_format_id prefs[] =
- {
- /*! Okay, ulaw is used by all telephony equipment, so start with it */
- AST_FORMAT_ULAW,
- /*! Unless of course, you're a silly European, so then prefer ALAW */
- AST_FORMAT_ALAW,
- AST_FORMAT_G719,
- AST_FORMAT_SIREN14,
- AST_FORMAT_SIREN7,
- AST_FORMAT_TESTLAW,
- /*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */
- AST_FORMAT_G722,
- /*! Okay, well, signed linear is easy to translate into other stuff */
- AST_FORMAT_SLINEAR192,
- AST_FORMAT_SLINEAR96,
- AST_FORMAT_SLINEAR48,
- AST_FORMAT_SLINEAR44,
- AST_FORMAT_SLINEAR32,
- AST_FORMAT_SLINEAR24,
- AST_FORMAT_SLINEAR16,
- AST_FORMAT_SLINEAR12,
- AST_FORMAT_SLINEAR,
- /*! G.726 is standard ADPCM, in RFC3551 packing order */
- AST_FORMAT_G726,
- /*! G.726 is standard ADPCM, in AAL2 packing order */
- AST_FORMAT_G726_AAL2,
- /*! ADPCM has great sound quality and is still pretty easy to translate */
- AST_FORMAT_ADPCM,
- /*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to
- translate and sounds pretty good */
- AST_FORMAT_GSM,
- /*! iLBC is not too bad */
- AST_FORMAT_ILBC,
- /*! Speex is free, but computationally more expensive than GSM */
- AST_FORMAT_SPEEX32,
- AST_FORMAT_SPEEX16,
- AST_FORMAT_SPEEX,
- /*! Opus */
- AST_FORMAT_OPUS,
- /*! SILK is pretty awesome. */
- AST_FORMAT_SILK,
- /*! CELT supports crazy high sample rates */
- AST_FORMAT_CELT,
- /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough
- to use it */
- AST_FORMAT_LPC10,
- /*! G.729a is faster than 723 and slightly less expensive */
- AST_FORMAT_G729A,
- /*! Down to G.723.1 which is proprietary but at least designed for voice */
- AST_FORMAT_G723_1,
- };
- char buf[512];
- int x;
-
- /* Find the first preferred codec in the format given */
- for (x = 0; x < ARRAY_LEN(prefs); x++) {
- if (ast_format_cap_best_byid(cap, prefs[x], result)) {
- return result;
- }
- }
-
- ast_format_clear(result);
- ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), cap));
-
- return NULL;
-}
-
/*! \brief Channel technology used to extract a channel from a running application. The
* channel created with this technology will be immediately hung up - most external
* applications won't ever want to see this.
@@ -883,7 +811,7 @@
ast_channel_stage_snapshot(tmp);
- if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_CACHE_STRINGS))) {
+ if (!(nativeformats = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
/* format capabilities structure allocation failure */
return ast_channel_unref(tmp);
}
@@ -2629,14 +2557,15 @@
ast_translator_free_path(ast_channel_readtrans(clonechan));
ast_channel_writetrans_set(clonechan, NULL);
ast_channel_readtrans_set(clonechan, NULL);
- if (ast_format_cap_is_empty(ast_channel_nativeformats(clonechan))) {
- ast_format_clear(ast_channel_rawwriteformat(clonechan));
- ast_format_clear(ast_channel_rawreadformat(clonechan));
+ if (!ast_format_cap_count(ast_channel_nativeformats(clonechan))) {
+ ast_channel_set_rawwriteformat(clonechan, NULL);
+ ast_channel_set_rawreadformat(clonechan, NULL);
} else {
- struct ast_format tmpfmt;
- ast_best_codec(ast_channel_nativeformats(clonechan), &tmpfmt);
- ast_format_copy(ast_channel_rawwriteformat(clonechan), &tmpfmt);
- ast_format_copy(ast_channel_rawreadformat(clonechan), &tmpfmt);
+ struct ast_format *tmpfmt;
+ tmpfmt = ast_format_cap_get_format(ast_channel_nativeformats(clonechan), 0);
+ ast_channel_set_rawwriteformat(clonechan, tmpfmt);
+ ast_channel_set_rawreadformat(clonechan, tmpfmt);
+ ao2_cleanup(tmpfmt);
}
}
@@ -3001,7 +2930,7 @@
if (!tmp || !generate)
return 0;
- res = generate(chan, tmp, 0, ast_format_rate(ast_channel_writeformat(chan)) / 50);
+ res = generate(chan, tmp, 0, ast_format_get_sample_rate(ast_channel_writeformat(chan)) / 50);
ast_channel_lock(chan);
if (ast_channel_generator(chan) && generate == ast_channel_generator(chan)->generate) {
@@ -3677,11 +3606,9 @@
* We must generate frames in phase locked mode since
* we have no internal timer available.
*/
-
if (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(chan)) == AST_FORMAT_CMP_NOT_EQUAL) {
float factor;
-
- factor = ((float) ast_format_rate(ast_channel_writeformat(chan))) / ((float) ast_format_rate(&f->subclass.format));
+ factor = ((float) ast_format_get_sample_rate(ast_channel_writeformat(chan))) / ((float) ast_format_get_sample_rate(&f->subclass.format));
samples = (int) (((float) f->samples) * factor);
} else {
samples = f->samples;
@@ -4186,11 +4113,11 @@
ast_frfree(f);
f = &ast_null_frame;
}
- } else if ((f->frametype == AST_FRAME_VOICE) && !ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &f->subclass.format)) {
+ } else if ((f->frametype == AST_FRAME_VOICE) && !ast_format_cap_iscompatible_format(ast_channel_nativeformats(chan), f->subclass.format)) {
/* This frame is not one of the current native formats -- drop it on the floor */
char to[200];
ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n",
- ast_channel_name(chan), ast_getformatname(&f->subclass.format), ast_getformatname_multiple(to, sizeof(to), ast_channel_nativeformats(chan)));
+ ast_channel_name(chan), ast_format_get_name(f->subclass.format), ast_getformatname_multiple(to, sizeof(to), ast_channel_nativeformats(chan)));
ast_frfree(f);
f = &ast_null_frame;
} else if ((f->frametype == AST_FRAME_VOICE)) {
@@ -4206,7 +4133,9 @@
#ifndef MONITOR_CONSTANT_DELAY
int jump = ast_channel_outsmpl(chan) - ast_channel_insmpl(chan) - 4 * f->samples;
if (jump >= 0) {
- jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->read_stream->fmt->format));
+ jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)),
+ ast_format_get_sample_rate(f->subclass.format),
+ ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
if (ast_seekstream(ast_channel_monitor(chan)->read_stream, jump, SEEK_FORCECUR) == -1) {
ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
}
@@ -4215,7 +4144,9 @@
ast_channel_insmpl_set(chan, ast_channel_insmpl(chan) + f->samples);
}
#else
- int jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
+ int jump = calc_monitor_jump((ast_channel_outsmpl(chan) - ast_channel_insmpl(chan)),
+ ast_format_get_sample_rate(f->subclass.codec),
+ ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
if (jump - MONITOR_DELAY >= 0) {
if (ast_seekstream(ast_channel_monitor(chan)->read_stream, jump - f->samples, SEEK_FORCECUR) == -1)
ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n");
@@ -4748,7 +4679,7 @@
}
CHECK_BLOCKING(chan);
- if (ast_channel_tech(chan)->write_text && (ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_FORMAT_TYPE_TEXT))) {
+ if (ast_channel_tech(chan)->write_text && (ast_format_cap_has_type(ast_channel_nativeformats(chan), AST_MEDIA_TYPE_TEXT))) {
struct ast_frame f;
f.frametype = AST_FRAME_TEXT;
@@ -4759,7 +4690,7 @@
f.offset = 0;
f.seqno = 0;
- ast_format_set(&f.subclass.format, AST_FORMAT_T140, 0);
+ f.subclass.format = ast_format_t140;
res = ast_channel_tech(chan)->write_text(chan, &f);
} else if (ast_channel_tech(chan)->send_text) {
res = ast_channel_tech(chan)->send_text(chan, text);
@@ -4856,7 +4787,7 @@
/* Send an empty audio frame to get things moving */
if (ast_channel_state(chan) != AST_STATE_UP) {
ast_debug(1, "Prodding channel '%s'\n", ast_channel_name(chan));
- ast_format_copy(&a.subclass.format, ast_channel_rawwriteformat(chan));
+ a.subclass.format = ast_channel_rawwriteformat(chan);
a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod"; /* this better match check in ast_write */
if (ast_write(chan, &a))
@@ -5068,7 +4999,7 @@
CHECK_BLOCKING(chan);
break;
case AST_FRAME_TEXT:
- if (fr->subclass.integer == AST_FORMAT_T140) {
+ if (ast_format_cmp(fr->subclass.format, ast_format_t140) == AST_FORMAT_CMP_EQUAL) {
res = (ast_channel_tech(chan)->write_text == NULL) ? 0 :
ast_channel_tech(chan)->write_text(chan, fr);
} else {
@@ -5093,16 +5024,16 @@
if (ast_channel_tech(chan)->write == NULL)
break; /*! \todo XXX should return 0 maybe ? */
- if (ast_opt_generic_plc && fr->subclass.format.id == AST_FORMAT_SLINEAR) {
+ if (ast_opt_generic_plc && ast_format_cmp(fr->subclass.format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
apply_plc(chan, fr);
}
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
- if (ast_format_cmp(&fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_NOT_EQUAL) {
+ if (ast_format_cmp(fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_NOT_EQUAL) {
f = fr;
} else {
- if ((!ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &fr->subclass.format)) &&
- (ast_format_cmp(ast_channel_writeformat(chan), &fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
+ if ((!ast_format_cap_iscompatible_format(ast_channel_nativeformats(chan), fr->subclass.format)) &&
+ (ast_format_cmp(ast_channel_writeformat(chan), fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
char nf[512];
/*
@@ -5115,9 +5046,9 @@
* areas.
*/
ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
- ast_channel_name(chan), ast_getformatname(&fr->subclass.format), ast_getformatname(ast_channel_writeformat(chan)),
+ ast_channel_name(chan), ast_format_get_name(fr->subclass.format), ast_format_get_name(ast_channel_writeformat(chan)),
ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(chan)));
- ast_set_write_format_by_id(chan, fr->subclass.format.id);
+ ast_set_write_format(chan, fr->subclass.format);
}
f = (ast_channel_writetrans(chan)) ? ast_translate(ast_channel_writetrans(chan), fr, 0) : fr;
@@ -5185,7 +5116,9 @@
#ifndef MONITOR_CONSTANT_DELAY
int jump = ast_channel_insmpl(chan) - ast_channel_outsmpl(chan) - 4 * cur->samples;
if (jump >= 0) {
- jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(&f->subclass.format), ast_format_rate(&ast_channel_monitor(chan)->read_stream->fmt->format));
+ jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)),
+ ast_format_get_sample_rate(f->subclass.format),
+ ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump, SEEK_FORCECUR) == -1) {
ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
}
@@ -5194,7 +5127,9 @@
ast_channel_outsmpl_set(chan, ast_channel_outsmpl(chan) + cur->samples);
}
#else
- int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)), ast_format_rate(f->subclass.codec), ast_format_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
+ int jump = calc_monitor_jump((ast_channel_insmpl(chan) - ast_channel_outsmpl(chan)),
+ ast_format_get_sample_rate(f->subclass.codec),
+ ast_format_get_sample_rate(ast_channel_monitor(chan)->read_stream->fmt->format));
if (jump - MONITOR_DELAY >= 0) {
if (ast_seekstream(ast_channel_monitor(chan)->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) {
ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n");
@@ -5300,21 +5235,20 @@
{
struct ast_trans_pvt *trans_pvt;
struct ast_format_cap *cap_native;
- struct ast_format best_set_fmt;
- struct ast_format best_native_fmt;
+ RAII_VAR(struct ast_format *, best_set_fmt, ast_format_cap_get_format(cap_set, 0), ao2_cleanup);
+ struct ast_format *best_native_fmt;
int res;
-
- ast_best_codec(cap_set, &best_set_fmt);
/* See if the underlying channel driver is capable of performing transcoding for us */
if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &best_set_fmt, sizeof(best_set_fmt), 0)) {
ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", ast_channel_name(chan),
- direction ? "write" : "read", ast_getformatname(&best_set_fmt));
+ direction ? "write" : "read", ast_format_get_name(best_set_fmt));
ast_channel_lock(chan);
- ast_format_copy(format, &best_set_fmt);
- ast_format_copy(rawformat, &best_set_fmt);
[... 2509 lines stripped ...]
More information about the svn-commits
mailing list