[asterisk-commits] coreyfarrell: branch group/media_formats-reviewed-trunk r417058 - in /team/gr...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jun 22 21:33:56 CDT 2014
Author: coreyfarrell
Date: Sun Jun 22 21:33:47 2014
New Revision: 417058
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417058
Log:
Merge /team/group/media_formats-reviewed at 416997
main/format.c:
This file was copied directly from media_formats-reviewed.
Any changes made to trunk may need to be added back if they still apply.
main/translate.c:
ast_translator_best_choice was copied from media_formats-reviewed.
This will need to be looked at again
Added:
team/group/media_formats-reviewed-trunk/include/asterisk/codec.h (with props)
team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h (with props)
team/group/media_formats-reviewed-trunk/include/asterisk/format_compatibility.h (with props)
team/group/media_formats-reviewed-trunk/include/asterisk/smoother.h (with props)
team/group/media_formats-reviewed-trunk/main/codec.c (with props)
team/group/media_formats-reviewed-trunk/main/codec_builtin.c (with props)
team/group/media_formats-reviewed-trunk/main/format_cache.c (with props)
team/group/media_formats-reviewed-trunk/main/format_compatibility.c (with props)
team/group/media_formats-reviewed-trunk/main/smoother.c (with props)
team/group/media_formats-reviewed-trunk/tests/test_core_codec.c (with props)
team/group/media_formats-reviewed-trunk/tests/test_core_format.c (with props)
team/group/media_formats-reviewed-trunk/tests/test_format_cache.c (with props)
team/group/media_formats-reviewed-trunk/tests/test_format_cap.c (with props)
Removed:
team/group/media_formats-reviewed-trunk/include/asterisk/format_pref.h
team/group/media_formats-reviewed-trunk/main/format_pref.c
Modified:
team/group/media_formats-reviewed-trunk/addons/chan_mobile.c
team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c
team/group/media_formats-reviewed-trunk/addons/chan_ooh323.h
team/group/media_formats-reviewed-trunk/addons/format_mp3.c
team/group/media_formats-reviewed-trunk/addons/ooh323cDriver.c
team/group/media_formats-reviewed-trunk/addons/ooh323cDriver.h
team/group/media_formats-reviewed-trunk/apps/app_agent_pool.c
team/group/media_formats-reviewed-trunk/apps/app_alarmreceiver.c
team/group/media_formats-reviewed-trunk/apps/app_amd.c
team/group/media_formats-reviewed-trunk/apps/app_chanspy.c
team/group/media_formats-reviewed-trunk/apps/app_confbridge.c
team/group/media_formats-reviewed-trunk/apps/app_dahdibarge.c
team/group/media_formats-reviewed-trunk/apps/app_dictate.c
team/group/media_formats-reviewed-trunk/apps/app_dumpchan.c
team/group/media_formats-reviewed-trunk/apps/app_echo.c
team/group/media_formats-reviewed-trunk/apps/app_fax.c
team/group/media_formats-reviewed-trunk/apps/app_festival.c
team/group/media_formats-reviewed-trunk/apps/app_ices.c
team/group/media_formats-reviewed-trunk/apps/app_jack.c
team/group/media_formats-reviewed-trunk/apps/app_meetme.c
team/group/media_formats-reviewed-trunk/apps/app_milliwatt.c
team/group/media_formats-reviewed-trunk/apps/app_mixmonitor.c
team/group/media_formats-reviewed-trunk/apps/app_mp3.c
team/group/media_formats-reviewed-trunk/apps/app_nbscat.c
team/group/media_formats-reviewed-trunk/apps/app_originate.c
team/group/media_formats-reviewed-trunk/apps/app_record.c
team/group/media_formats-reviewed-trunk/apps/app_sms.c
team/group/media_formats-reviewed-trunk/apps/app_speech_utils.c
team/group/media_formats-reviewed-trunk/apps/app_talkdetect.c
team/group/media_formats-reviewed-trunk/apps/app_test.c
team/group/media_formats-reviewed-trunk/apps/app_voicemail.c
team/group/media_formats-reviewed-trunk/apps/app_waitforsilence.c
team/group/media_formats-reviewed-trunk/apps/confbridge/conf_chan_record.c
team/group/media_formats-reviewed-trunk/bridges/bridge_holding.c
team/group/media_formats-reviewed-trunk/bridges/bridge_native_rtp.c
team/group/media_formats-reviewed-trunk/bridges/bridge_simple.c
team/group/media_formats-reviewed-trunk/bridges/bridge_softmix.c
team/group/media_formats-reviewed-trunk/channels/chan_alsa.c
team/group/media_formats-reviewed-trunk/channels/chan_bridge_media.c
team/group/media_formats-reviewed-trunk/channels/chan_console.c
team/group/media_formats-reviewed-trunk/channels/chan_dahdi.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_motif.c
team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c
team/group/media_formats-reviewed-trunk/channels/chan_nbs.c
team/group/media_formats-reviewed-trunk/channels/chan_oss.c
team/group/media_formats-reviewed-trunk/channels/chan_phone.c
team/group/media_formats-reviewed-trunk/channels/chan_pjsip.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/channels/chan_vpb.cc
team/group/media_formats-reviewed-trunk/channels/dahdi/bridge_native_dahdi.c
team/group/media_formats-reviewed-trunk/channels/h323/ast_h323.cxx
team/group/media_formats-reviewed-trunk/channels/h323/chan_h323.h
team/group/media_formats-reviewed-trunk/channels/iax2/parser.c
team/group/media_formats-reviewed-trunk/channels/iax2/provision.c
team/group/media_formats-reviewed-trunk/channels/pjsip/dialplan_functions.c
team/group/media_formats-reviewed-trunk/channels/sip/include/sip.h
team/group/media_formats-reviewed-trunk/codecs/codec_a_mu.c
team/group/media_formats-reviewed-trunk/codecs/codec_adpcm.c
team/group/media_formats-reviewed-trunk/codecs/codec_alaw.c
team/group/media_formats-reviewed-trunk/codecs/codec_dahdi.c
team/group/media_formats-reviewed-trunk/codecs/codec_g722.c
team/group/media_formats-reviewed-trunk/codecs/codec_g726.c
team/group/media_formats-reviewed-trunk/codecs/codec_gsm.c
team/group/media_formats-reviewed-trunk/codecs/codec_ilbc.c
team/group/media_formats-reviewed-trunk/codecs/codec_lpc10.c
team/group/media_formats-reviewed-trunk/codecs/codec_resample.c
team/group/media_formats-reviewed-trunk/codecs/codec_speex.c
team/group/media_formats-reviewed-trunk/codecs/codec_ulaw.c
team/group/media_formats-reviewed-trunk/codecs/ex_adpcm.h
team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h
team/group/media_formats-reviewed-trunk/codecs/ex_g722.h
team/group/media_formats-reviewed-trunk/codecs/ex_g726.h
team/group/media_formats-reviewed-trunk/codecs/ex_gsm.h
team/group/media_formats-reviewed-trunk/codecs/ex_ilbc.h
team/group/media_formats-reviewed-trunk/codecs/ex_lpc10.h
team/group/media_formats-reviewed-trunk/codecs/ex_speex.h
team/group/media_formats-reviewed-trunk/codecs/ex_ulaw.h
team/group/media_formats-reviewed-trunk/formats/format_g719.c
team/group/media_formats-reviewed-trunk/formats/format_g723.c
team/group/media_formats-reviewed-trunk/formats/format_g726.c
team/group/media_formats-reviewed-trunk/formats/format_g729.c
team/group/media_formats-reviewed-trunk/formats/format_gsm.c
team/group/media_formats-reviewed-trunk/formats/format_h263.c
team/group/media_formats-reviewed-trunk/formats/format_h264.c
team/group/media_formats-reviewed-trunk/formats/format_ilbc.c
team/group/media_formats-reviewed-trunk/formats/format_jpeg.c
team/group/media_formats-reviewed-trunk/formats/format_ogg_vorbis.c
team/group/media_formats-reviewed-trunk/formats/format_pcm.c
team/group/media_formats-reviewed-trunk/formats/format_siren14.c
team/group/media_formats-reviewed-trunk/formats/format_siren7.c
team/group/media_formats-reviewed-trunk/formats/format_sln.c
team/group/media_formats-reviewed-trunk/formats/format_vox.c
team/group/media_formats-reviewed-trunk/formats/format_wav.c
team/group/media_formats-reviewed-trunk/formats/format_wav_gsm.c
team/group/media_formats-reviewed-trunk/funcs/func_channel.c
team/group/media_formats-reviewed-trunk/funcs/func_frame_trace.c
team/group/media_formats-reviewed-trunk/funcs/func_pitchshift.c
team/group/media_formats-reviewed-trunk/funcs/func_speex.c
team/group/media_formats-reviewed-trunk/include/asterisk/abstract_jb.h
team/group/media_formats-reviewed-trunk/include/asterisk/audiohook.h
team/group/media_formats-reviewed-trunk/include/asterisk/bridge_channel.h
team/group/media_formats-reviewed-trunk/include/asterisk/callerid.h
team/group/media_formats-reviewed-trunk/include/asterisk/channel.h
team/group/media_formats-reviewed-trunk/include/asterisk/config_options.h
team/group/media_formats-reviewed-trunk/include/asterisk/data.h
team/group/media_formats-reviewed-trunk/include/asterisk/file.h
team/group/media_formats-reviewed-trunk/include/asterisk/format.h
team/group/media_formats-reviewed-trunk/include/asterisk/format_cap.h
team/group/media_formats-reviewed-trunk/include/asterisk/frame.h
team/group/media_formats-reviewed-trunk/include/asterisk/image.h
team/group/media_formats-reviewed-trunk/include/asterisk/mod_format.h
team/group/media_formats-reviewed-trunk/include/asterisk/res_pjsip.h
team/group/media_formats-reviewed-trunk/include/asterisk/res_pjsip_session.h
team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h
team/group/media_formats-reviewed-trunk/include/asterisk/slin.h
team/group/media_formats-reviewed-trunk/include/asterisk/slinfactory.h
team/group/media_formats-reviewed-trunk/include/asterisk/speech.h
team/group/media_formats-reviewed-trunk/include/asterisk/translate.h
team/group/media_formats-reviewed-trunk/include/asterisk/vector.h
team/group/media_formats-reviewed-trunk/main/abstract_jb.c
team/group/media_formats-reviewed-trunk/main/app.c
team/group/media_formats-reviewed-trunk/main/asterisk.c
team/group/media_formats-reviewed-trunk/main/audiohook.c
team/group/media_formats-reviewed-trunk/main/bridge.c
team/group/media_formats-reviewed-trunk/main/bridge_basic.c
team/group/media_formats-reviewed-trunk/main/bridge_channel.c
team/group/media_formats-reviewed-trunk/main/callerid.c
team/group/media_formats-reviewed-trunk/main/ccss.c
team/group/media_formats-reviewed-trunk/main/channel_internal_api.c
team/group/media_formats-reviewed-trunk/main/config_options.c
team/group/media_formats-reviewed-trunk/main/core_local.c
team/group/media_formats-reviewed-trunk/main/core_unreal.c
team/group/media_formats-reviewed-trunk/main/data.c
team/group/media_formats-reviewed-trunk/main/dial.c
team/group/media_formats-reviewed-trunk/main/file.c
team/group/media_formats-reviewed-trunk/main/format.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/image.c
team/group/media_formats-reviewed-trunk/main/indications.c
team/group/media_formats-reviewed-trunk/main/manager.c
team/group/media_formats-reviewed-trunk/main/media_index.c
team/group/media_formats-reviewed-trunk/main/slinfactory.c
team/group/media_formats-reviewed-trunk/main/sorcery.c
team/group/media_formats-reviewed-trunk/main/sounds_index.c
team/group/media_formats-reviewed-trunk/main/translate.c
team/group/media_formats-reviewed-trunk/pbx/pbx_spool.c
team/group/media_formats-reviewed-trunk/res/ari/resource_bridges.c
team/group/media_formats-reviewed-trunk/res/ari/resource_channels.c
team/group/media_formats-reviewed-trunk/res/ari/resource_sounds.c
team/group/media_formats-reviewed-trunk/res/parking/parking_applications.c
team/group/media_formats-reviewed-trunk/res/res_adsi.c
team/group/media_formats-reviewed-trunk/res/res_agi.c
team/group/media_formats-reviewed-trunk/res/res_calendar.c
team/group/media_formats-reviewed-trunk/res/res_clioriginate.c
team/group/media_formats-reviewed-trunk/res/res_fax.c
team/group/media_formats-reviewed-trunk/res/res_fax_spandsp.c
team/group/media_formats-reviewed-trunk/res/res_musiconhold.c
team/group/media_formats-reviewed-trunk/res/res_pjsip/pjsip_configuration.c
team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c
team/group/media_formats-reviewed-trunk/res/res_pjsip_session.c
team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c
team/group/media_formats-reviewed-trunk/res/res_speech.c
team/group/media_formats-reviewed-trunk/res/res_stasis.c
team/group/media_formats-reviewed-trunk/res/res_stasis_snoop.c
team/group/media_formats-reviewed-trunk/tests/test_config.c
Modified: team/group/media_formats-reviewed-trunk/addons/chan_mobile.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats-reviewed-trunk/addons/chan_mobile.c?view=diff&rev=417058&r1=417057&r2=417058
==============================================================================
--- team/group/media_formats-reviewed-trunk/addons/chan_mobile.c (original)
+++ team/group/media_formats-reviewed-trunk/addons/chan_mobile.c Sun Jun 22 21:33:47 2014
@@ -73,15 +73,15 @@
#include "asterisk/app.h"
#include "asterisk/manager.h"
#include "asterisk/io.h"
+#include "asterisk/smoother.h"
+#include "asterisk/format_cache.h"
#define MBL_CONFIG "chan_mobile.conf"
#define MBL_CONFIG_OLD "mobile.conf"
#define DEVICE_FRAME_SIZE 48
-#define DEVICE_FRAME_FORMAT AST_FORMAT_SLINEAR
+#define DEVICE_FRAME_FORMAT ast_format_slin
#define CHANNEL_FRAME_SIZE 320
-
-static struct ast_format prefformat;
static int discovery_interval = 60; /* The device discovery interval, default 60 seconds. */
static pthread_t discovery_thread = AST_PTHREADT_NULL; /* The discovery thread */
@@ -840,7 +840,6 @@
static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num,
const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
{
-
struct ast_channel *chn;
pvt->answered = 0;
@@ -862,11 +861,11 @@
}
ast_channel_tech_set(chn, &mbl_tech);
- ast_format_cap_add(ast_channel_nativeformats(chn), &prefformat);
- ast_format_copy(ast_channel_rawreadformat(chn), &prefformat);
- ast_format_copy(ast_channel_rawwriteformat(chn), &prefformat);
- ast_format_copy(ast_channel_writeformat(chn), &prefformat);
- ast_format_copy(ast_channel_readformat(chn), &prefformat);
+ ast_channel_nativeformats_set(chn, mbl_tech.capabilities);
+ ast_channel_set_rawreadformat(chn, DEVICE_FRAME_FORMAT);
+ ast_channel_set_rawwriteformat(chn, DEVICE_FRAME_FORMAT);
+ ast_channel_set_writeformat(chn, DEVICE_FRAME_FORMAT);
+ ast_channel_set_readformat(chn, DEVICE_FRAME_FORMAT);
ast_channel_tech_pvt_set(chn, pvt);
if (state == AST_STATE_RING)
@@ -902,7 +901,7 @@
return NULL;
}
- if (!(ast_format_cap_iscompatible(cap, &prefformat))) {
+ if (!(ast_format_cap_iscompatible_format(cap, DEVICE_FRAME_FORMAT))) {
char tmp[256];
ast_log(LOG_WARNING, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
*cause = AST_CAUSE_FACILITY_NOT_IMPLEMENTED;
@@ -1116,7 +1115,7 @@
memset(&pvt->fr, 0x00, sizeof(struct ast_frame));
pvt->fr.frametype = AST_FRAME_VOICE;
- ast_format_set(&pvt->fr.subclass.format, DEVICE_FRAME_FORMAT, 0);
+ pvt->fr.subclass.format = ast_format_copy(DEVICE_FRAME_FORMAT);
pvt->fr.src = "Mobile";
pvt->fr.offset = AST_FRIENDLY_OFFSET;
pvt->fr.mallocd = 0;
@@ -1131,6 +1130,7 @@
pvt->sco_socket = -1;
ast_channel_set_fd(ast, 0, -1);
}
+ ao2_ref(pvt->fr.subclass.format, -1);
goto e_return;
}
@@ -4697,7 +4697,8 @@
if (sdp_session)
sdp_close(sdp_session);
- mbl_tech.capabilities = ast_format_cap_destroy(mbl_tech.capabilities);
+ ao2_ref(mbl_tech.capabilities, -1);
+ mbl_tech.capabilities = NULL;
return 0;
}
@@ -4706,11 +4707,11 @@
int dev_id, s;
- if (!(mbl_tech.capabilities = ast_format_cap_alloc(0))) {
+ if (!(mbl_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
return AST_MODULE_LOAD_DECLINE;
}
- ast_format_set(&prefformat, DEVICE_FRAME_FORMAT, 0);
- ast_format_cap_add(mbl_tech.capabilities, &prefformat);
+
+ ast_format_cap_add(mbl_tech.capabilities, DEVICE_FRAME_FORMAT, 0);
/* Check if we have Bluetooth, no point loading otherwise... */
dev_id = hci_get_route(NULL);
s = hci_open_dev(dev_id);
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=417058&r1=417057&r2=417058
==============================================================================
--- team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c (original)
+++ team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c Sun Jun 22 21:33:47 2014
@@ -91,8 +91,6 @@
struct ast_rtp_instance *vrtp, struct ast_rtp_instance *trtp, const struct ast_format_cap *codecs, int nat_active);
static void ooh323_get_codec(struct ast_channel *chan, struct ast_format_cap *result);
void setup_rtp_remote(ooCallData *call, const char *remoteIp, int remotePort);
-
-static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
struct ooh323_peer *find_friend(const char *name, int port);
@@ -174,10 +172,9 @@
char callee_url[AST_MAX_EXTENSION];
int port;
- struct ast_format readformat; /* negotiated read format */
- struct ast_format writeformat; /* negotiated write format */
+ struct ast_format *readformat; /* negotiated read format */
+ struct ast_format *writeformat; /* negotiated write format */
struct ast_format_cap *cap;
- struct ast_codec_pref prefs;
int dtmfmode;
int dtmfcodec;
char exten[AST_MAX_EXTENSION]; /* Requested extension */
@@ -212,7 +209,6 @@
char accountcode[20];
int amaflags;
struct ast_format_cap *cap;
- struct ast_codec_pref prefs;
int dtmfmode;
int dtmfcodec;
int faxdetect;
@@ -239,7 +235,6 @@
unsigned outgoinglimit;
unsigned outUse;
struct ast_format_cap *cap;
- struct ast_codec_pref prefs;
char accountcode[20];
int amaflags;
int dtmfmode;
@@ -307,7 +302,6 @@
static char gCallerID[AST_MAX_EXTENSION] = "";
static struct ooAliases *gAliasList;
static struct ast_format_cap *gCap;
-static struct ast_codec_pref gPrefs;
static int gDTMFMode = H323_DTMF_RFC2833;
static int gDTMFCodec = 101;
static int gFAXdetect = FAXDETECT_CNG;
@@ -366,15 +360,17 @@
const char *host, struct ast_format_cap *cap,
const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
{
+ struct ast_format_cap *caps = NULL;
struct ast_channel *ch = NULL;
- struct ast_format tmpfmt;
+ struct ast_format *tmpfmt = NULL;
int features = 0;
if (gH323Debug) {
ast_verb(0, "--- ooh323_new - %s\n", host);
}
- ast_format_clear(&tmpfmt);
+ caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+
/* Don't hold a h323 pvt lock while we allocate a channel */
ast_mutex_unlock(&i->lock);
ast_mutex_lock(&ooh323c_cn_lock);
@@ -386,17 +382,23 @@
ast_mutex_lock(&i->lock);
- if (ch) {
+ if (ch && caps) {
ast_channel_tech_set(ch, &ooh323_tech);
if (cap)
ast_best_codec(cap, &tmpfmt);
- if (!tmpfmt.id)
- ast_codec_pref_index(&i->prefs, 0, &tmpfmt);
-
- ast_format_cap_add(ast_channel_nativeformats(ch), &tmpfmt);
- ast_format_copy(ast_channel_rawwriteformat(ch), &tmpfmt);
- ast_format_copy(ast_channel_rawreadformat(ch), &tmpfmt);
+ if (!tmpfmt)
+ tmpfmt = ast_format_cap_get_format(i->cap, 0);
+
+ ast_format_cap_add(caps, tmpfmt, 0);
+ ast_channel_nativeformats_set(ch, caps);
+ ao2_ref(caps, -1);
+
+ ast_channel_set_rawwriteformat(ch, tmpfmt);
+ ast_channel_set_rawreadformat(ch, tmpfmt);
+ ast_set_write_format(ch, tmpfmt);
+ ast_set_read_format(ch, tmpfmt);
+ ao2_ref(tmpfmt, -1);
ast_jb_configure(ch, &global_jbconf);
@@ -404,8 +406,6 @@
ast_channel_rings_set(ch, 1);
ast_channel_adsicpe_set(ch, AST_ADSI_UNAVAILABLE);
- ast_set_write_format(ch, &tmpfmt);
- ast_set_read_format(ch, &tmpfmt);
ast_channel_tech_pvt_set(ch, i);
i->owner = ch;
ast_module_ref(myself);
@@ -485,8 +485,10 @@
ast_publish_channel_state(ch);
}
- } else
+ } else {
+ ao2_cleanup(caps);
ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
+ }
if(ch) ast_channel_unlock(ch);
@@ -512,7 +514,7 @@
ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
return NULL;
}
- if (!(pvt->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_NOLOCK))) {
+ if (!(pvt->cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
ast_free(pvt);
ast_log(LOG_ERROR, "Couldn't allocate private ooh323 structure\n");
return NULL;
@@ -546,8 +548,7 @@
ast_copy_string(pvt->accountcode, gAccountcode, sizeof(pvt->accountcode));
pvt->amaflags = gAMAFLAGS;
- ast_format_cap_copy(pvt->cap, gCap);
- memcpy(&pvt->prefs, &gPrefs, sizeof(pvt->prefs));
+ ast_format_cap_append_by_type(pvt->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
pvt->aniasdni = gANIasDNI;
@@ -586,7 +587,7 @@
ast_verb(0, "--- ooh323_request - data %s format %s\n", data,
ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,cap));
- if (!(ast_format_cap_has_type(cap, AST_FORMAT_TYPE_AUDIO))) {
+ if (!(ast_format_cap_has_type(cap, AST_MEDIA_TYPE_AUDIO))) {
ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,cap));
return NULL;
}
@@ -651,8 +652,7 @@
if (ext)
ast_copy_string(p->exten, ext, sizeof(p->exten));
- ast_format_cap_copy(p->cap, peer->cap);
- memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref));
+ ast_format_cap_append_by_type(p->cap, peer->cap, AST_MEDIA_TYPE_UNKNOWN);
p->g729onlyA = peer->g729onlyA;
p->dtmfmode |= peer->dtmfmode;
p->dtmfcodec = peer->dtmfcodec;
@@ -697,7 +697,7 @@
p->t38support = gT38Support;
p->rtptimeout = gRTPTimeout;
p->nat = gNat;
- ast_format_cap_copy(p->cap, gCap);
+ ast_format_cap_append_by_type(p->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
p->rtdrinterval = gRTDRInterval;
p->rtdrcount = gRTDRCount;
p->faststart = gFastStart;
@@ -705,7 +705,6 @@
p->directrtp = gDirectRTP;
p->earlydirect = gEarlyDirect;
- memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref));
p->username = strdup(dest);
p->host = strdup(dest);
@@ -1190,16 +1189,16 @@
}
- if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
- if (!(ast_format_cap_is_empty(ast_channel_nativeformats(ast)))) {
+ if (!(ast_format_cap_iscompatible_format(ast_channel_nativeformats(ast), f->subclass.format))) {
+ if (ast_format_cap_count(ast_channel_nativeformats(ast))) {
ast_log(LOG_WARNING,
"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
- ast_getformatname(&f->subclass.format),
+ ast_format_get_name(f->subclass.format),
ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
- ast_getformatname(ast_channel_readformat(ast)),
- ast_getformatname(ast_channel_writeformat(ast)));
-
- ast_set_write_format(ast, &f->subclass.format);
+ ast_format_get_name(ast_channel_readformat(ast)),
+ ast_format_get_name(ast_channel_writeformat(ast)));
+
+ ast_set_write_format(ast, f->subclass.format);
} else {
/* ast_set_write_format(ast, f->subclass);
ast->nativeformats = f->subclass; */
@@ -1512,7 +1511,7 @@
if (gH323Debug)
ast_verb(0, "--- ooh323_update_writeformat %s/%d\n",
- ast_getformatname(fmt), txframes);
+ ast_format_get_name(fmt), txframes);
p = find_call(call);
if (!p) {
@@ -1522,9 +1521,18 @@
ast_mutex_lock(&p->lock);
- ast_format_copy(&(p->writeformat), fmt);
+ ao2_cleanup(p->writeformat);
+ p->writeformat = ast_format_copy(fmt);
if (p->owner) {
+ struct ast_format_cap *caps;
+
+ caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (!caps) {
+ ast_log(LOG_ERROR, "Could not allocate capabilities structure\n");
+ return;
+ }
+
while (p->owner && ast_channel_trylock(p->owner)) {
ast_debug(1,"Failed to grab lock, trying again\n");
DEADLOCK_AVOIDANCE(&p->lock);
@@ -1532,15 +1540,19 @@
if (!p->owner) {
ast_mutex_unlock(&p->lock);
ast_log(LOG_ERROR, "Channel has no owner\n");
+ ao2_ref(caps, -1);
return;
}
if (gH323Debug)
ast_verb(0, "Writeformat before update %s/%s\n",
- ast_getformatname(ast_channel_writeformat(p->owner)),
+ ast_format_get_name(ast_channel_writeformat(p->owner)),
ast_getformatname_multiple(formats, sizeof(formats), ast_channel_nativeformats(p->owner)));
+ /* BUGBUG: RTP - Needs to be updated if API changes */
+#if 0
if (txframes)
ast_codec_pref_setsize(&p->prefs, fmt, txframes);
ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(p->rtp), p->rtp, &p->prefs);
+#endif
if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
ast_rtp_codecs_payloads_set_rtpmap_type(ast_rtp_instance_get_codecs(p->rtp),
p->rtp, p->dtmfcodec, "audio", "telephone-event", 0);
@@ -1550,7 +1562,9 @@
p->rtp, p->dtmfcodec, "audio", "cisco-telephone-event", 0);
}
- ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
+ ast_format_cap_add(caps, fmt, 0);
+ ast_channel_nativeformats_set(p->owner, caps);
+ ao2_ref(caps, -1);
ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
ast_channel_unlock(p->owner);
@@ -1570,7 +1584,7 @@
if (gH323Debug)
ast_verb(0, "--- ooh323_update_readformat %s\n",
- ast_getformatname(fmt));
+ ast_format_get_name(fmt));
p = find_call(call);
if (!p) {
@@ -1580,9 +1594,18 @@
ast_mutex_lock(&p->lock);
- ast_format_copy(&(p->readformat), fmt);
+ ao2_cleanup(p->readformat);
+ p->readformat = ast_format_copy(fmt);
if (p->owner) {
+ struct ast_format_cap *caps;
+
+ caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (!caps) {
+ ast_log(LOG_ERROR, "Could not allocate capabilities structure\n");
+ return;
+ }
+
while (p->owner && ast_channel_trylock(p->owner)) {
ast_debug(1,"Failed to grab lock, trying again\n");
DEADLOCK_AVOIDANCE(&p->lock);
@@ -1590,13 +1613,16 @@
if (!p->owner) {
ast_mutex_unlock(&p->lock);
ast_log(LOG_ERROR, "Channel has no owner\n");
+ ao2_ref(caps, -1);
return;
}
if (gH323Debug)
ast_verb(0, "Readformat before update %s\n",
- ast_getformatname(ast_channel_readformat(p->owner)));
- ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
+ ast_format_get_name(ast_channel_readformat(p->owner)));
+ ast_format_cap_add(caps, fmt, 0);
+ ast_channel_nativeformats_set(p->owner, caps);
+ ao2_ref(caps, -1);
ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
ast_channel_unlock(p->owner);
} else
@@ -1854,9 +1880,8 @@
ast_copy_string(p->context, user->context, sizeof(p->context));
ast_copy_string(p->accountcode, user->accountcode, sizeof(p->accountcode));
p->amaflags = user->amaflags;
- ast_format_cap_copy(p->cap, user->cap);
+ ast_format_cap_append_by_type(p->cap, user->cap, AST_MEDIA_TYPE_UNKNOWN);
p->g729onlyA = user->g729onlyA;
- memcpy(&p->prefs, &user->prefs, sizeof(struct ast_codec_pref));
p->dtmfmode |= user->dtmfmode;
p->dtmfcodec = user->dtmfcodec;
p->faxdetect = user->faxdetect;
@@ -1914,7 +1939,7 @@
}
}
- ooh323c_set_capability_for_call(call, &p->prefs, p->cap, p->dtmfmode, p->dtmfcodec,
+ ooh323c_set_capability_for_call(call, p->cap, p->dtmfmode, p->dtmfcodec,
p->t38support, p->g729onlyA);
/* Incoming call */
c = ooh323_new(p, AST_STATE_RING, p->username, 0, NULL, NULL);
@@ -2088,13 +2113,14 @@
}
if (gH323Debug) {
- char prefsBuf[256];
- ast_codec_pref_string(&p->prefs, prefsBuf, sizeof(prefsBuf));
+ char formats[FORMAT_STRING_SIZE];
+
ast_verb(0, " Outgoing call %s(%s) - Codec prefs - %s\n",
- p->username?p->username:"NULL", call->callToken, prefsBuf);
- }
-
- ooh323c_set_capability_for_call(call, &p->prefs, p->cap,
+ p->username?p->username:"NULL", call->callToken,
+ ast_getformatname_multiple(formats,FORMAT_STRING_SIZE,p->cap));
+ }
+
+ ooh323c_set_capability_for_call(call, p->cap,
p->dtmfmode, p->dtmfcodec, p->t38support, p->g729onlyA);
configure_local_rtp(p, call);
@@ -2284,7 +2310,7 @@
if(peer->url) free(peer->url);
if(peer->e164) free(peer->e164);
- peer->cap = ast_format_cap_destroy(peer->cap);
+ ao2_cleanup(peer->cap);
free(peer);
}
@@ -2311,8 +2337,7 @@
}
ast_mutex_init(&user->lock);
ast_copy_string(user->name, name, sizeof(user->name));
- ast_format_cap_copy(user->cap, gCap);
- memcpy(&user->prefs, &gPrefs, sizeof(user->prefs));
+ ast_format_cap_append_by_type(user->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
user->rtptimeout = gRTPTimeout;
user->nat = gNat;
user->dtmfmode = gDTMFMode;
@@ -2367,15 +2392,13 @@
sizeof(user->rtpmaskstr));
} else user->rtpmask = NULL;
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&user->prefs,
- user->cap, v->value, 0);
+ ast_parse_allow_disallow(user->cap, v->value, 0);
} else if (!strcasecmp(v->name, "allow")) {
const char* tcodecs = v->value;
if (!strcasecmp(v->value, "all")) {
tcodecs = "ulaw,alaw,g729,g723,gsm";
}
- ast_parse_allow_disallow(&user->prefs,
- user->cap, tcodecs, 1);
+ ast_parse_allow_disallow(user->cap, tcodecs, 1);
} else if (!strcasecmp(v->name, "amaflags")) {
user->amaflags = ast_channel_string2amaflag(v->value);
} else if (!strcasecmp(v->name, "ip") || !strcasecmp(v->name, "host")) {
@@ -2461,8 +2484,7 @@
}
ast_mutex_init(&peer->lock);
ast_copy_string(peer->name, name, sizeof(peer->name));
- ast_format_cap_copy(peer->cap, gCap);
- memcpy(&peer->prefs, &gPrefs, sizeof(peer->prefs));
+ ast_format_cap_append_by_type(peer->cap, gCap, AST_MEDIA_TYPE_UNKNOWN);
peer->rtptimeout = gRTPTimeout;
peer->nat = gNat;
ast_copy_string(peer->accountcode, gAccountcode, sizeof(peer->accountcode));
@@ -2565,15 +2587,13 @@
sizeof(peer->rtpmaskstr));
} else peer->rtpmask = NULL;
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&peer->prefs, peer->cap,
- v->value, 0);
+ ast_parse_allow_disallow(peer->cap, v->value, 0);
} else if (!strcasecmp(v->name, "allow")) {
const char* tcodecs = v->value;
if (!strcasecmp(v->value, "all")) {
tcodecs = "ulaw,alaw,g729,g723,gsm";
}
- ast_parse_allow_disallow(&peer->prefs, peer->cap,
- tcodecs, 1);
+ ast_parse_allow_disallow(peer->cap, tcodecs, 1);
} else if (!strcasecmp(v->name, "amaflags")) {
peer->amaflags = ast_channel_string2amaflag(v->value);
} else if (!strcasecmp(v->name, "roundtrip")) {
@@ -2754,7 +2774,6 @@
struct ooh323_peer *peer = NULL;
char *cat;
const char *utype;
- struct ast_format tmpfmt;
if (gH323Debug)
ast_verb(0, "--- reload_config\n");
@@ -2790,8 +2809,8 @@
gPort = 1720;
gIP[0] = '\0';
strcpy(gCallerID, DEFAULT_H323ID);
- ast_format_cap_set(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ALAW, 0));
- memset(&gPrefs, 0, sizeof(struct ast_codec_pref));
+ ast_format_cap_remove_bytype(gCap, AST_MEDIA_TYPE_UNKNOWN);
+ ast_format_cap_add(gCap, ast_format_ulaw, 0);
gDTMFMode = H323_DTMF_RFC2833;
gDTMFCodec = 101;
gFAXdetect = FAXDETECT_CNG;
@@ -2992,13 +3011,13 @@
} else if (!strcasecmp(v->name, "accountcode")) {
ast_copy_string(gAccountcode, v->value, sizeof(gAccountcode));
} else if (!strcasecmp(v->name, "disallow")) {
- ast_parse_allow_disallow(&gPrefs, gCap, v->value, 0);
+ ast_parse_allow_disallow(gCap, v->value, 0);
} else if (!strcasecmp(v->name, "allow")) {
const char* tcodecs = v->value;
if (!strcasecmp(v->value, "all")) {
tcodecs = "ulaw,alaw,g729,g723,gsm";
}
- ast_parse_allow_disallow(&gPrefs, gCap, tcodecs, 1);
+ ast_parse_allow_disallow(gCap, tcodecs, 1);
} else if (!strcasecmp(v->name, "dtmfmode")) {
if (!strcasecmp(v->value, "inband"))
gDTMFMode = H323_DTMF_INBAND;
@@ -3150,9 +3169,6 @@
peer->h245tunneling?"yes":"no");
ast_cli(a->fd, "%-15s%s\n", "DirectRTP", peer->directrtp ? "yes" : "no");
ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", peer->earlydirect ? "yes" : "no");
- ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "(");
- print_codec_to_cli(a->fd, &peer->prefs);
- ast_cli(a->fd, ")\n");
ast_cli(a->fd, "%-15.15s", "DTMF Mode: ");
if (peer->dtmfmode & H323_DTMF_CISCO) {
ast_cli(a->fd, "%s\n", "cisco");
@@ -3253,24 +3269,6 @@
return CLI_SUCCESS;
}
-/*! \brief Print codec list from preference to CLI/manager */
-static void print_codec_to_cli(int fd, struct ast_codec_pref *pref)
-{
- int x;
- struct ast_format tmpfmt;
- for (x = 0; x < 32; x++) {
- ast_codec_pref_index(pref, x, &tmpfmt);
- if (!tmpfmt.id)
- break;
- ast_cli(fd, "%s", ast_getformatname(&tmpfmt));
- ast_cli(fd, ":%d", pref->framing[x]);
- if (x < 31 && ast_codec_pref_index(pref, x + 1, &tmpfmt))
- ast_cli(fd, ",");
- }
- if (!x)
- ast_cli(fd, "none");
-}
-
static char *handle_cli_ooh323_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct ooh323_user *prev = NULL, *user = NULL;
@@ -3309,9 +3307,6 @@
user->h245tunneling?"yes":"no");
ast_cli(a->fd, "%-15s%s\n", "DirectRTP", user->directrtp ? "yes" : "no");
ast_cli(a->fd, "%-15s%s\n", "EarlyDirectRTP", user->earlydirect ? "yes" : "no");
- ast_cli(a->fd, "%-15.15s%s", "Format Prefs: ", "(");
- print_codec_to_cli(a->fd, &user->prefs);
- ast_cli(a->fd, ")\n");
ast_cli(a->fd, "%-15.15s", "DTMF Mode: ");
if (user->dtmfmode & H323_DTMF_CISCO) {
ast_cli(a->fd, "%s\n", "cisco");
@@ -3737,7 +3732,6 @@
{
struct ooAliases * pNewAlias = NULL;
struct ooh323_peer *peer = NULL;
- struct ast_format tmpfmt;
OOH225MsgCallbacks h225Callbacks = {0, 0, 0, 0};
OOH323CALLBACKS h323Callbacks = {
@@ -3753,14 +3747,16 @@
.onModeChanged = onModeChanged,
.onMediaChanged = (cb_OnMediaChanged) setup_rtp_remote,
};
- if (!(gCap = ast_format_cap_alloc(0))) {
+ if (!(gCap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
return AST_MODULE_LOAD_FAILURE;
}
- if (!(ooh323_tech.capabilities = ast_format_cap_alloc(0))) {
+ if (!(ooh323_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
+ ao2_ref(gCap, -1);
+ gCap = NULL;
return AST_MODULE_LOAD_FAILURE;
}
- ast_format_cap_add(gCap, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0));
- ast_format_cap_add_all(ooh323_tech.capabilities);
+ ast_format_cap_add(gCap, ast_format_ulaw, 0);
+ ast_format_cap_add_all_by_type(ooh323_tech.capabilities, AST_MEDIA_TYPE_UNKNOWN);
myself = ast_module_info->self;
@@ -3789,12 +3785,20 @@
if (OO_OK != ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, gLogFile)) {
ast_log(LOG_ERROR, "Failed to initialize OOH323 endpoint-"
"OOH323 Disabled\n");
+ ao2_ref(gCap, -1);
+ gCap = NULL;
+ ao2_ref(ooh323_tech.capabilities, -1);
+ ooh323_tech.capabilities = NULL;
return AST_MODULE_LOAD_FAILURE;
}
/* Make sure we can register our OOH323 channel type */
if (ast_channel_register(&ooh323_tech)) {
ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
+ ao2_ref(gCap, -1);
+ gCap = NULL;
+ ao2_ref(ooh323_tech.capabilities, -1);
+ ooh323_tech.capabilities = NULL;
return AST_MODULE_LOAD_FAILURE;
}
ast_rtp_glue_register(&ooh323_rtp);
@@ -3876,8 +3880,12 @@
ooH323EpSetH323Callbacks(h323Callbacks);
/* Add endpoint capabilities */
- if (ooh323c_set_capability(&gPrefs, gCap, gDTMFMode, gDTMFCodec) < 0) {
+ if (ooh323c_set_capability(gCap, gDTMFMode, gDTMFCodec) < 0) {
ast_log(LOG_ERROR, "Capabilities failure for OOH323. OOH323 Disabled.\n");
+ ao2_ref(gCap, -1);
+ gCap = NULL;
+ ao2_ref(ooh323_tech.capabilities, -1);
+ ooh323_tech.capabilities = NULL;
return 1;
}
@@ -3887,6 +3895,10 @@
"OOH323 DISABLED\n");
ooH323EpDestroy();
+ ao2_ref(gCap, -1);
+ gCap = NULL;
+ ao2_ref(ooh323_tech.capabilities, -1);
+ ooh323_tech.capabilities = NULL;
return 1;
}
@@ -3894,6 +3906,10 @@
ast_log(LOG_ERROR, "Failed to start OOH323 stack thread. "
"OOH323 DISABLED\n");
ooH323EpDestroy();
+ ao2_ref(gCap, -1);
+ gCap = NULL;
+ ao2_ref(ooh323_tech.capabilities, -1);
+ ooh323_tech.capabilities = NULL;
return 1;
}
/* And start the monitor for the first time */
@@ -4142,7 +4158,9 @@
ast_mutex_unlock(&cur->lock);
ast_mutex_destroy(&cur->lock);
- cur->cap = ast_format_cap_destroy(cur->cap);
+ ao2_cleanup(cur->writeformat);
+ ao2_cleanup(cur->readformat);
+ ao2_cleanup(cur->cap);
ast_free(cur);
}
@@ -4207,7 +4225,7 @@
free(prev->rtpmask);
}
}
- prev->cap = ast_format_cap_destroy(prev->cap);
+ ao2_cleanup(prev->cap);
free(prev);
if (cur == userl.users) {
break;
@@ -4335,8 +4353,10 @@
ast_verb(0, "+++ ooh323 unload_module \n");
}
- gCap = ast_format_cap_destroy(gCap);
- ooh323_tech.capabilities = ast_format_cap_destroy(ooh323_tech.capabilities);
+ ao2_ref(gCap, -1);
+ gCap = NULL;
+ ao2_ref(ooh323_tech.capabilities, -1);
+ ooh323_tech.capabilities = NULL;
return 0;
}
@@ -4348,8 +4368,11 @@
}
if (p) {
- ast_format_cap_append(result, ast_format_cap_is_empty(ast_channel_nativeformats(chan)) ?
- (ast_format_cap_is_empty(p->cap) ? NULL : p->cap) : ast_channel_nativeformats(chan));
+ if (ast_format_cap_count(ast_channel_nativeformats(chan))) {
+ ast_format_cap_append_by_type(result, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_UNKNOWN);
+ } else if (ast_format_cap_count(p->cap)) {
+ ast_format_cap_append_by_type(result, p->cap, AST_MEDIA_TYPE_UNKNOWN);
+ }
}
if (gH323Debug) {
@@ -4423,56 +4446,28 @@
return res;
}
-
-int ooh323_update_capPrefsOrderForCall
- (ooCallData *call, struct ast_codec_pref *prefs)
-{
- int i = 0;
- struct ast_format tmpfmt;
-
- ast_codec_pref_index(prefs, i, &tmpfmt);
-
- ooResetCapPrefs(call);
- while (tmpfmt.id) {
- ooAppendCapToCapPrefs(call, ooh323_convertAsteriskCapToH323Cap(&tmpfmt));
- ast_codec_pref_index(prefs, ++i, &tmpfmt);
- }
-
- return 0;
-}
-
-
int ooh323_convertAsteriskCapToH323Cap(struct ast_format *format)
{
- switch (format->id) {
- case AST_FORMAT_ULAW:
+ if (ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
return OO_G711ULAW64K;
- case AST_FORMAT_ALAW:
+ } else if (ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
return OO_G711ALAW64K;
- case AST_FORMAT_GSM:
+ } else if (ast_format_cmp(format, ast_format_gsm) == AST_FORMAT_CMP_EQUAL) {
return OO_GSMFULLRATE;
-
-#ifdef AST_FORMAT_AMRNB
- case AST_FORMAT_AMRNB:
- return OO_AMRNB;
-#endif
-#ifdef AST_FORMAT_SPEEX
- case AST_FORMAT_SPEEX:
+ } else if (ast_format_cmp(format, ast_format_speex) == AST_FORMAT_CMP_EQUAL) {
return OO_SPEEX;
-#endif
-
- case AST_FORMAT_G729A:
[... 28757 lines stripped ...]
More information about the asterisk-commits
mailing list