aboutsummaryrefslogtreecommitdiffstats
path: root/addons/ooh323cDriver.c
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 16:22:10 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2011-02-03 16:22:10 +0000
commit4aca3187a3db25ff4d2208f116f618b363dec7d5 (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /addons/ooh323cDriver.c
parent8170aae0a0882a93ca1ef80736cb95c2d6126865 (diff)
Asterisk media architecture conversion - no more format bitfields
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@306010 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'addons/ooh323cDriver.c')
-rw-r--r--addons/ooh323cDriver.c105
1 files changed, 53 insertions, 52 deletions
diff --git a/addons/ooh323cDriver.c b/addons/ooh323cDriver.c
index dd07bb4b0..604336c21 100644
--- a/addons/ooh323cDriver.c
+++ b/addons/ooh323cDriver.c
@@ -226,15 +226,16 @@ int ooh323c_stop_stack_thread(void)
}
int ooh323c_set_capability
- (struct ast_codec_pref *prefs, int capability, int dtmf, int dtmfcodec)
+ (struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec)
{
- int ret = 0, x, format=0;
+ int ret = 0, x;
+ struct ast_format tmpfmt;
if(gH323Debug)
ast_verbose("\tAdding capabilities to H323 endpoint\n");
- for(x=0; 0 != (format=ast_codec_pref_index(prefs, x)); x++)
+ for(x=0; ast_codec_pref_index(prefs, x, &tmpfmt); x++)
{
- if(format & AST_FORMAT_ULAW)
+ if(tmpfmt.id == AST_FORMAT_ULAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 ulaw capability to H323 endpoint\n");
@@ -244,7 +245,7 @@ int ooh323c_set_capability
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
- if(format & AST_FORMAT_ALAW)
+ if(tmpfmt.id == AST_FORMAT_ALAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 alaw capability to H323 endpoint\n");
@@ -255,7 +256,7 @@ int ooh323c_set_capability
&ooh323c_stop_transmit_channel);
}
- if(format & AST_FORMAT_G729A)
+ if(tmpfmt.id == AST_FORMAT_G729A)
{
if(gH323Debug)
ast_verbose("\tAdding g729A capability to H323 endpoint\n");
@@ -281,7 +282,7 @@ int ooh323c_set_capability
&ooh323c_stop_transmit_channel);
}
- if(format & AST_FORMAT_G723_1)
+ if(tmpfmt.id == AST_FORMAT_G723_1)
{
if(gH323Debug)
ast_verbose("\tAdding g7231 capability to H323 endpoint\n");
@@ -293,7 +294,7 @@ int ooh323c_set_capability
}
- if(format & AST_FORMAT_G726)
+ if(tmpfmt.id == AST_FORMAT_G726)
{
if(gH323Debug)
ast_verbose("\tAdding g726 capability to H323 endpoint\n");
@@ -305,7 +306,7 @@ int ooh323c_set_capability
}
- if(format & AST_FORMAT_G726_AAL2)
+ if(tmpfmt.id == AST_FORMAT_G726_AAL2)
{
if(gH323Debug)
ast_verbose("\tAdding g726aal2 capability to H323 endpoint\n");
@@ -317,7 +318,7 @@ int ooh323c_set_capability
}
- if(format & AST_FORMAT_H263)
+ if(tmpfmt.id == AST_FORMAT_H263)
{
if(gH323Debug)
ast_verbose("\tAdding h263 capability to H323 endpoint\n");
@@ -329,7 +330,7 @@ int ooh323c_set_capability
}
- if(format & AST_FORMAT_GSM)
+ if(tmpfmt.id == AST_FORMAT_GSM)
{
if(gH323Debug)
ast_verbose("\tAdding gsm capability to H323 endpoint\n");
@@ -342,7 +343,7 @@ int ooh323c_set_capability
}
#ifdef AST_FORMAT_AMRNB
- if(format & AST_FORMAT_AMRNB)
+ if(tmpfmt.id == AST_FORMAT_AMRNB)
{
if(gH323Debug)
ast_verbose("\tAdding amr nb capability to H323 endpoint\n");
@@ -356,7 +357,7 @@ int ooh323c_set_capability
#endif
#ifdef AST_FORMAT_SPEEX
- if(format & AST_FORMAT_SPEEX)
+ if(tmpfmt.id == AST_FORMAT_SPEEX)
{
if(gH323Debug)
ast_verbose("\tAdding speex capability to H323 endpoint\n");
@@ -384,11 +385,11 @@ int ooh323c_set_capability
}
int ooh323c_set_capability_for_call
- (ooCallData *call, struct ast_codec_pref *prefs, int capability, int dtmf, int dtmfcodec,
+ (ooCallData *call, struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec,
int t38support)
{
int ret = 0, x, txframes;
- int format=0;
+ struct ast_format tmpfmt;
if(gH323Debug)
ast_verbose("\tAdding capabilities to call(%s, %s)\n", call->callType,
call->callToken);
@@ -409,9 +410,9 @@ int ooh323c_set_capability_for_call
&ooh323c_stop_transmit_datachannel,
0);
- for(x=0; 0 !=(format=ast_codec_pref_index(prefs, x)); x++)
+ for(x=0; ast_codec_pref_index(prefs, x, &tmpfmt); x++)
{
- if(format & AST_FORMAT_ULAW)
+ if(tmpfmt.id == AST_FORMAT_ULAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 ulaw capability to call(%s, %s)\n",
@@ -424,7 +425,7 @@ int ooh323c_set_capability_for_call
&ooh323c_stop_receive_channel,
&ooh323c_stop_transmit_channel);
}
- if(format & AST_FORMAT_ALAW)
+ if(tmpfmt.id == AST_FORMAT_ALAW)
{
if(gH323Debug)
ast_verbose("\tAdding g711 alaw capability to call(%s, %s)\n",
@@ -438,7 +439,7 @@ int ooh323c_set_capability_for_call
&ooh323c_stop_transmit_channel);
}
- if(format & AST_FORMAT_G726)
+ if(tmpfmt.id == AST_FORMAT_G726)
{
if(gH323Debug)
ast_verbose("\tAdding g726 capability to call (%s, %s)\n",
@@ -452,7 +453,7 @@ int ooh323c_set_capability_for_call
}
- if(format & AST_FORMAT_G726_AAL2)
+ if(tmpfmt.id == AST_FORMAT_G726_AAL2)
{
if(gH323Debug)
ast_verbose("\tAdding g726aal2 capability to call (%s, %s)\n",
@@ -466,7 +467,7 @@ int ooh323c_set_capability_for_call
}
- if(format & AST_FORMAT_G729A)
+ if(tmpfmt.id == AST_FORMAT_G729A)
{
txframes = (prefs->framing[x])/10;
@@ -497,7 +498,7 @@ int ooh323c_set_capability_for_call
}
- if(format & AST_FORMAT_G723_1)
+ if(tmpfmt.id == AST_FORMAT_G723_1)
{
if(gH323Debug)
ast_verbose("\tAdding g7231 capability to call (%s, %s)\n",
@@ -510,7 +511,7 @@ int ooh323c_set_capability_for_call
}
- if(format & AST_FORMAT_H263)
+ if(tmpfmt.id == AST_FORMAT_H263)
{
if(gH323Debug)
ast_verbose("\tAdding h263 capability to call (%s, %s)\n",
@@ -523,7 +524,7 @@ int ooh323c_set_capability_for_call
}
- if(format & AST_FORMAT_GSM)
+ if(tmpfmt.id == AST_FORMAT_GSM)
{
if(gH323Debug)
ast_verbose("\tAdding gsm capability to call(%s, %s)\n",
@@ -536,7 +537,7 @@ int ooh323c_set_capability_for_call
}
#ifdef AST_FORMAT_AMRNB
- if(format & AST_FORMAT_AMRNB)
+ if(tmpfmt.id == AST_FORMAT_AMRNB)
{
if(gH323Debug)
ast_verbose("\tAdding AMR capability to call(%s, %s)\n",
@@ -549,7 +550,7 @@ int ooh323c_set_capability_for_call
}
#endif
#ifdef AST_FORMAT_SPEEX
- if(format & AST_FORMAT_SPEEX)
+ if(tmpfmt.id == AST_FORMAT_SPEEX)
{
if(gH323Debug)
ast_verbose("\tAdding Speex capability to call(%s, %s)\n",
@@ -594,9 +595,9 @@ int ooh323c_set_aliases(ooAliases * aliases)
int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
- format_t fmt=-1;
- fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
- if(fmt>0) {
+ struct ast_format tmpfmt;
+ convertH323CapToAsteriskCap(pChannel->chanCap->cap, &tmpfmt);
+ if(tmpfmt.id) {
/* ooh323_set_read_format(call, fmt); */
}else{
ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
@@ -608,19 +609,19 @@ int ooh323c_start_receive_channel(ooCallData *call, ooLogicalChannel *pChannel)
int ooh323c_start_transmit_channel(ooCallData *call, ooLogicalChannel *pChannel)
{
- format_t fmt;
- fmt = convertH323CapToAsteriskCap(pChannel->chanCap->cap);
- if(fmt>0) {
- switch (fmt) {
+ struct ast_format tmpfmt;
+ convertH323CapToAsteriskCap(pChannel->chanCap->cap, &tmpfmt);
+ if(tmpfmt.id) {
+ switch (tmpfmt.id) {
case AST_FORMAT_ALAW:
case AST_FORMAT_ULAW:
- ooh323_set_write_format(call, fmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes);
+ ooh323_set_write_format(call, &tmpfmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes);
break;
case AST_FORMAT_G729A:
- ooh323_set_write_format(call, fmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes*10);
+ ooh323_set_write_format(call, &tmpfmt, ((OOCapParams *)(pChannel->chanCap->params))->txframes*10);
break;
default:
- ooh323_set_write_format(call, fmt, 0);
+ ooh323_set_write_format(call, &tmpfmt, 0);
}
}else{
ast_log(LOG_ERROR, "Invalid capability type for receive channel %s\n",
@@ -665,47 +666,47 @@ int ooh323c_stop_transmit_datachannel(ooCallData *call, ooLogicalChannel *pChann
return 1;
}
-format_t convertH323CapToAsteriskCap(int cap)
+struct ast_format *convertH323CapToAsteriskCap(int cap, struct ast_format *result)
{
-
+ ast_format_clear(result);
switch(cap)
{
case OO_G711ULAW64K:
- return AST_FORMAT_ULAW;
+ return ast_format_set(result, AST_FORMAT_ULAW, 0);
case OO_G711ALAW64K:
- return AST_FORMAT_ALAW;
+ return ast_format_set(result, AST_FORMAT_ALAW, 0);
case OO_GSMFULLRATE:
- return AST_FORMAT_GSM;
+ return ast_format_set(result, AST_FORMAT_GSM, 0);
#ifdef AST_FORMAT_AMRNB
case OO_AMRNB:
- return AST_FORMAT_AMRNB;
+ return ast_format_set(result, AST_FORMAT_AMRNB, 0);
#endif
#ifdef AST_FORMAT_SPEEX
case OO_SPEEX:
- return AST_FORMAT_SPEEX;
+ return ast_format_set(result, AST_FORMAT_SPEEX, 0);
#endif
case OO_G729:
- return AST_FORMAT_G729A;
+ return ast_format_set(result, AST_FORMAT_G729A, 0);
case OO_G729A:
- return AST_FORMAT_G729A;
+ return ast_format_set(result, AST_FORMAT_G729A, 0);
case OO_G729B:
- return AST_FORMAT_G729A;
+ return ast_format_set(result, AST_FORMAT_G729A, 0);
case OO_G7231:
- return AST_FORMAT_G723_1;
+ return ast_format_set(result, AST_FORMAT_G723_1, 0);
case OO_G726:
- return AST_FORMAT_G726;
+ return ast_format_set(result, AST_FORMAT_G726, 0);
case OO_G726AAL2:
- return AST_FORMAT_G726_AAL2;
+ return ast_format_set(result, AST_FORMAT_G726_AAL2, 0);
case OO_H263VIDEO:
- return AST_FORMAT_H263;
+ return ast_format_set(result, AST_FORMAT_H263, 0);
default:
ast_debug(1, "Cap %d is not supported by driver yet\n", cap);
- return -1;
+ return NULL;
}
- return -1;
+ return NULL;
}