Example #1
0
int ooh323c_set_capability_for_call
   (ooCallData *call, struct ast_format_cap *cap, int dtmf, int dtmfcodec,
		 int t38support, int g729onlyA)
{
   int ret = 0, x, txframes;
   if (gH323Debug) {
     ast_verb(0, "\tAdding capabilities to call(%s, %s)\n", call->callType, 
                                                            call->callToken);
   }
   if(dtmf & H323_DTMF_CISCO || 1)
      ret |= ooCallEnableDTMFCISCO(call,dtmfcodec);
   if(dtmf & H323_DTMF_RFC2833 || 1)
      ret |= ooCallEnableDTMFRFC2833(call,dtmfcodec);
   if(dtmf & H323_DTMF_H245ALPHANUMERIC || 1)
      ret |= ooCallEnableDTMFH245Alphanumeric(call);
   if(dtmf & H323_DTMF_H245SIGNAL || 1)
      ret |= ooCallEnableDTMFH245Signal(call);

   if (t38support)
   	ooCapabilityAddT38Capability(call, OO_T38, OORXANDTX, 
					&ooh323c_start_receive_datachannel,
					&ooh323c_start_transmit_datachannel,
					&ooh323c_stop_receive_datachannel,
					&ooh323c_stop_transmit_datachannel,
					0);

   for(x=0; x<ast_format_cap_count(cap); x++)
   {
    struct ast_format *format = ast_format_cap_get_format(cap, x);
      if(ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding g711 ulaw capability to call(%s, %s)\n", 
                                              call->callType, call->callToken);
	 }
	 txframes = ast_format_cap_get_format_framing(cap, format);
         ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes, 
                                      txframes, OORXANDTX, 
                                      &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
                                      &ooh323c_stop_receive_channel, 
                                      &ooh323c_stop_transmit_channel);
      }
      if(ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding g711 alaw capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
	 }
         txframes = ast_format_cap_get_format_framing(cap, format);
         ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes, 
                                     txframes, OORXANDTX, 
                                     &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
      }

      if(ast_format_cmp(format, ast_format_g726) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding g726 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
	 }
	 txframes = ast_format_cap_get_format_framing(cap, format);
         ret = ooCallAddG726Capability(call, OO_G726, txframes, grxframes, FALSE,
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(ast_format_cmp(format, ast_format_g726_aal2) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding g726aal2 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
	 }
	 txframes = ast_format_cap_get_format_framing(cap, format);
         ret = ooCallAddG726Capability(call, OO_G726AAL2, txframes, grxframes, FALSE,
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(ast_format_cmp(format, ast_format_g729) == AST_FORMAT_CMP_EQUAL)
      {
      
         txframes = (ast_format_cap_get_format_framing(cap, format))/10;
         if (gH323Debug) {
            ast_verb(0, "\tAdding g729A capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
	 }
         ret= ooCallAddG729Capability(call, OO_G729A, txframes, txframes, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
	 if (g729onlyA)
		continue;
         if (gH323Debug) {
            ast_verb(0, "\tAdding g729 capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
	 }
         ret|= ooCallAddG729Capability(call, OO_G729, txframes, txframes, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
         if (gH323Debug) {
            ast_verb(0, "\tAdding g729B capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
	 }
         ret|= ooCallAddG729Capability(call, OO_G729B, txframes, txframes, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(ast_format_cmp(format, ast_format_g723) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding g7231 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
	 }
         ret = ooCallAddG7231Capability(call, OO_G7231, 1, 1, FALSE, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(ast_format_cmp(format, ast_format_h263) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding h263 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
	 }
         ret = ooCallAddH263VideoCapability(call, OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(ast_format_cmp(format, ast_format_gsm) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding gsm capability to call(%s, %s)\n", 
                                             call->callType, call->callToken);
	 }
         ret = ooCallAddGSMCapability(call, OO_GSMFULLRATE, 4, FALSE, FALSE, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
      }

      if(ast_format_cmp(format, ast_format_speex) == AST_FORMAT_CMP_EQUAL)
      {
         if (gH323Debug) {
            ast_verb(0, "\tAdding Speex capability to call(%s, %s)\n", 
                                             call->callType, call->callToken);
	 }
         ret = ooCallAddSpeexCapability(call, OO_SPEEX, 4, 4, FALSE, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
      }

      ao2_ref(format, -1);
   }
   return ret;
}
Example #2
0
int ooh323c_set_capability_for_call
   (ooCallData *call, struct ast_codec_pref *prefs, struct ast_format_cap *cap, int dtmf, int dtmfcodec,
		 int t38support, int g729onlyA)
{
   int ret = 0, x, txframes;
   struct ast_format tmpfmt;
   if(gH323Debug)
     ast_verbose("\tAdding capabilities to call(%s, %s)\n", call->callType, 
                                                            call->callToken);
   if(dtmf & H323_DTMF_CISCO || 1)
      ret |= ooCallEnableDTMFCISCO(call,dtmfcodec);
   if(dtmf & H323_DTMF_RFC2833 || 1)
      ret |= ooCallEnableDTMFRFC2833(call,dtmfcodec);
   if(dtmf & H323_DTMF_H245ALPHANUMERIC || 1)
      ret |= ooCallEnableDTMFH245Alphanumeric(call);
   if(dtmf & H323_DTMF_H245SIGNAL || 1)
      ret |= ooCallEnableDTMFH245Signal(call);

   if (t38support)
   	ooCapabilityAddT38Capability(call, OO_T38, OORXANDTX, 
					&ooh323c_start_receive_datachannel,
					&ooh323c_start_transmit_datachannel,
					&ooh323c_stop_receive_datachannel,
					&ooh323c_stop_transmit_datachannel,
					0);

   for(x=0; ast_codec_pref_index(prefs, x, &tmpfmt); x++)
   {
      if(tmpfmt.id == AST_FORMAT_ULAW)
      {
         if(gH323Debug)
            ast_verbose("\tAdding g711 ulaw capability to call(%s, %s)\n", 
                                              call->callType, call->callToken);
	 txframes = prefs->framing[x];
         ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes, 
                                      txframes, OORXANDTX, 
                                      &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
                                      &ooh323c_stop_receive_channel, 
                                      &ooh323c_stop_transmit_channel);
      }
      if(tmpfmt.id == AST_FORMAT_ALAW)
      {
         if(gH323Debug)
            ast_verbose("\tAdding g711 alaw capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
         txframes = prefs->framing[x];
         ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes, 
                                     txframes, OORXANDTX, 
                                     &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
      }

      if(tmpfmt.id == AST_FORMAT_G726)
      {
         if(gH323Debug)
            ast_verbose("\tAdding g726 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
	 txframes = prefs->framing[x];
         ret = ooCallAddG726Capability(call, OO_G726, txframes, grxframes, FALSE,
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(tmpfmt.id == AST_FORMAT_G726_AAL2)
      {
         if(gH323Debug)
            ast_verbose("\tAdding g726aal2 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
	 txframes = prefs->framing[x];
         ret = ooCallAddG726Capability(call, OO_G726AAL2, txframes, grxframes, FALSE,
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(tmpfmt.id == AST_FORMAT_G729A)
      {
      
         txframes = (prefs->framing[x])/10;
         if(gH323Debug)
            ast_verbose("\tAdding g729A capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
         ret= ooCallAddG729Capability(call, OO_G729A, txframes, txframes, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
	 if (g729onlyA)
		continue;
         if(gH323Debug)
            ast_verbose("\tAdding g729 capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
         ret|= ooCallAddG729Capability(call, OO_G729, txframes, txframes, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
         if(gH323Debug)
            ast_verbose("\tAdding g729B capability to call(%s, %s)\n",
                                            call->callType, call->callToken);
         ret|= ooCallAddG729Capability(call, OO_G729B, txframes, txframes, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(tmpfmt.id == AST_FORMAT_G723_1)
      {
         if(gH323Debug)
            ast_verbose("\tAdding g7231 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
         ret = ooCallAddG7231Capability(call, OO_G7231, 1, 1, FALSE, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(tmpfmt.id == AST_FORMAT_H263)
      {
         if(gH323Debug)
            ast_verbose("\tAdding h263 capability to call (%s, %s)\n",
                                           call->callType, call->callToken);
         ret = ooCallAddH263VideoCapability(call, OO_H263VIDEO, 1, 0, 0, 0, 0, 320*1024, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);

      }

      if(tmpfmt.id == AST_FORMAT_GSM)
      {
         if(gH323Debug)
            ast_verbose("\tAdding gsm capability to call(%s, %s)\n", 
                                             call->callType, call->callToken);
         ret = ooCallAddGSMCapability(call, OO_GSMFULLRATE, 4, FALSE, FALSE, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
      }

#ifdef AST_FORMAT_AMRNB
      if(tmpfmt.id == AST_FORMAT_AMRNB)
      {
         if(gH323Debug)
            ast_verbose("\tAdding AMR capability to call(%s, %s)\n", 
                                             call->callType, call->callToken);
         ret = ooCallAddAMRNBCapability(call, OO_AMRNB, 4, 4, FALSE, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
      }
#endif
#ifdef AST_FORMAT_SPEEX
      if(tmpfmt.id == AST_FORMAT_SPEEX)
      {
         if(gH323Debug)
            ast_verbose("\tAdding Speex capability to call(%s, %s)\n", 
                                             call->callType, call->callToken);
         ret = ooCallAddSpeexCapability(call, OO_SPEEX, 4, 4, FALSE, 
                                     OORXANDTX, &ooh323c_start_receive_channel,
                                     &ooh323c_start_transmit_channel,
                                     &ooh323c_stop_receive_channel, 
                                     &ooh323c_stop_transmit_channel);
      }
#endif
   }
   return ret;
}