Hi

I've studied the source code for ooh323c and its asterisk channel and
I've found why putting "allow=all" in ooh323.conf gives the error "local
endpoint does not have any audio capabilities" and hangs up the call
immediately.

In src/ooh323cDriver.c, both ooh323c_set_capability() and
ooh323c_set_capability_for_call() treat the prefs parameter, which is a
struct ast_codec_pref, as the list of codecs to use. This is wrong:
prefs is merely a list of preferences for the codecs given in the int
capability parameter. When you have "allow=gsm" for example, then the
function ast_parse_allow_disallow() called from src/chan_h323.c will add
both a bitfield to capability and a preference to prefs. But when you
have "allow=all", the bitfields are added to capability, but prefs is
left alone - it stays empty (because you have no preferences) - so when
ooh323c_set_capability[_for_call] is called, the for loop over the prefs
never executes, and no codecs are set for ooh323c.

I've made a patch (which is attached) to set the codecs that are in
capability but not in prefs, but it doesn't seem to fully work. With the
patch it doesn't complain about audio capabilities when you have
"allow=all" and doesn't hang up the call any more, but I either get no
audio, or just noise. Maybe you could have a look at it and help me out?

Thank you
Damjan

--- a/asterisk-ooh323c/src/ooh323cDriver.c	2006-09-20 23:16:37.000000000 +0200
+++ b/asterisk-ooh323c/src/ooh323cDriver.c	2007-02-25 22:27:23.000000000 +0200
@@ -62,7 +62,7 @@
 int ooh323c_set_capability
    (struct ast_codec_pref *prefs, int capability, int dtmf)
 {
-   int ret, x, format=0;
+   int ret=0, x, format=0, setCapabilities=0;
    if(gH323Debug)
      ast_verbose("\tAdding capabilities to H323 endpoint\n");
    
@@ -72,6 +72,7 @@
       {
          if(gH323Debug)
             ast_verbose("\tAdding g711 ulaw capability to H323 endpoint\n");
+         setCapabilities |= AST_FORMAT_ULAW;
          ret= ooH323EpAddG711Capability(OO_G711ULAW64K, gtxframes, grxframes, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
@@ -82,6 +83,7 @@
       {
          if(gH323Debug)
             ast_verbose("\tAdding g711 alaw capability to H323 endpoint\n");
+         setCapabilities |= AST_FORMAT_ALAW;
          ret= ooH323EpAddG711Capability(OO_G711ALAW64K, gtxframes, grxframes, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
@@ -93,6 +95,7 @@
       {
          if(gH323Debug)
             ast_verbose("\tAdding g729A capability to H323 endpoint\n");
+         setCapabilities |= AST_FORMAT_G729A;
          ret = ooH323EpAddG729Capability(OO_G729A, 2, 24, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
@@ -112,6 +115,7 @@
       {
          if(gH323Debug)
             ast_verbose("\tAdding g7231 capability to H323 endpoint\n");
+         setCapabilities |= AST_FORMAT_G723_1;
          ret = ooH323EpAddG7231Capability(OO_G7231, 4, 7, FALSE, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
@@ -124,6 +128,7 @@
       {
          if(gH323Debug)
             ast_verbose("\tAdding gsm capability to H323 endpoint\n");
+         setCapabilities |= AST_FORMAT_GSM;
          ret = ooH323EpAddGSMCapability(OO_GSMFULLRATE, 4, FALSE, FALSE, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
@@ -133,7 +138,46 @@
       }
       
    }
-   
+
+   /* Now add capabilities that weren't in the preferences */
+   if((capability & AST_FORMAT_ULAW) && !(setCapabilities & AST_FORMAT_ULAW))
+      ret |= ooH323EpAddG711Capability(OO_G711ULAW64K, gtxframes, grxframes,
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+   if((capability & AST_FORMAT_ALAW) && !(setCapabilities & AST_FORMAT_ALAW))
+      ret |= ooH323EpAddG711Capability(OO_G711ALAW64K, gtxframes, grxframes,
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+   if((capability & AST_FORMAT_GSM) && !(setCapabilities & AST_FORMAT_GSM))
+      ret |= ooH323EpAddGSMCapability(OO_GSMFULLRATE, 4, FALSE, FALSE, 
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+   if((capability & AST_FORMAT_G729A) && !(setCapabilities & AST_FORMAT_G729A))
+   {
+      ret |= ooH323EpAddG729Capability(OO_G729A, 2, 24, 
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+      ret |= ooH323EpAddG729Capability(OO_G729, 2, 24, 
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+   }
+   if((capability & AST_FORMAT_G723_1) && !(setCapabilities & AST_FORMAT_G723_1))
+      ret |= ooH323EpAddG7231Capability(OO_G7231, 4, 7, FALSE, 
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+
    if(dtmf & H323_DTMF_RFC2833)
       ret |= ooH323EpEnableDTMFRFC2833(0);
    else if(dtmf & H323_DTMF_H245ALPHANUMERIC)
@@ -144,11 +188,27 @@
    return ret;
 }
 
+static int default_frames(int codec)
+{
+   struct ast_format_list *format_list;
+   size_t len;
+   int i;
+
+   format_list = ast_get_format_list(&len);
+   for(i=0; i<len; i++)
+   {
+      if(format_list[i].bits == codec)
+         return format_list[i].def_ms;
+   }
+   return 20;
+}
+
 int ooh323c_set_capability_for_call
    (ooCallData *call, struct ast_codec_pref *prefs, int capability, int dtmf)
 {
-   int ret, x, txframes, rxframes;
+   int ret=0, x, txframes, rxframes;
    int format=0;
+   int setCapabilities=0;
    if(gH323Debug)
      ast_verbose("\tAdding capabilities to call(%s, %s)\n", call->callType, 
                                                             call->callToken);
@@ -167,6 +227,7 @@
          if(gH323Debug)
             ast_verbose("\tAdding g711 ulaw capability to call(%s, %s)\n", 
                                               call->callType, call->callToken);
+         setCapabilities |= AST_FORMAT_ULAW;
 	 txframes = prefs->framing[x];
          ret= ooCallAddG711Capability(call, OO_G711ULAW64K, txframes, 
                                       grxframes, OORXANDTX, 
@@ -180,6 +241,7 @@
          if(gH323Debug)
             ast_verbose("\tAdding g711 alaw capability to call(%s, %s)\n",
                                             call->callType, call->callToken);
+         setCapabilities |= AST_FORMAT_ALAW;
          txframes = prefs->framing[x];
          ret= ooCallAddG711Capability(call, OO_G711ALAW64K, txframes, 
                                      grxframes, OORXANDTX, 
@@ -194,6 +256,7 @@
          if(gH323Debug)
             ast_verbose("\tAdding g729A capability to call(%s, %s)\n",
                                             call->callType, call->callToken);
+         setCapabilities |= AST_FORMAT_G729A;
          txframes = (prefs->framing[x])/10;
          ret= ooCallAddG729Capability(call, OO_G729A, txframes, 24, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
@@ -216,6 +279,7 @@
          if(gH323Debug)
             ast_verbose("\tAdding g7231 capability to call (%s, %s)\n",
                                            call->callType, call->callToken);
+         setCapabilities |= AST_FORMAT_G723_1;
          ret = ooCallAddG7231Capability(call, OO_G7231, 4, 7, FALSE, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
@@ -229,6 +293,7 @@
          if(gH323Debug)
             ast_verbose("\tAdding gsm capability to call(%s, %s)\n", 
                                              call->callType, call->callToken);
+         setCapabilities |= AST_FORMAT_GSM;
          ret = ooCallAddGSMCapability(call, OO_GSMFULLRATE, 4, FALSE, FALSE, 
                                      OORXANDTX, &ooh323c_start_receive_channel,
                                      &ooh323c_start_transmit_channel,
@@ -236,6 +301,47 @@
                                      &ooh323c_stop_transmit_channel);
       }
    }
+
+   /* Now add capabilities that weren't in the preferences */
+   if((capability & AST_FORMAT_ULAW) && !(setCapabilities & AST_FORMAT_ULAW))
+      ret |= ooCallAddG711Capability(call, OO_G711ULAW64K, default_frames(AST_FORMAT_ULAW),
+                                     grxframes, OORXANDTX, 
+                                     &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+   if((capability & AST_FORMAT_ALAW) && !(setCapabilities & AST_FORMAT_ALAW))
+      ret |= ooCallAddG711Capability(call, OO_G711ALAW64K, default_frames(AST_FORMAT_ALAW),
+                                     grxframes, OORXANDTX, 
+                                     &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+   if((capability & AST_FORMAT_GSM) && !(setCapabilities & AST_FORMAT_GSM))
+      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((capability & AST_FORMAT_G729A) && !(setCapabilities & AST_FORMAT_G729A))
+   {
+      ret |= ooCallAddG729Capability(call, OO_G729A, default_frames(AST_FORMAT_G729A)/10, 24, 
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+      ret |= ooCallAddG729Capability(call, OO_G729, default_frames(AST_FORMAT_G729A)/10, 24, 
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
+   }
+   if((capability & AST_FORMAT_G723_1) && !(setCapabilities & AST_FORMAT_G723_1))
+      ret |= ooCallAddG7231Capability(call, OO_G7231, 4, 7, FALSE, 
+                                     OORXANDTX, &ooh323c_start_receive_channel,
+                                     &ooh323c_start_transmit_channel,
+                                     &ooh323c_stop_receive_channel, 
+                                     &ooh323c_stop_transmit_channel);
 }
 
 int ooh323c_set_aliases(ooAliases * aliases)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
ooh323c-devel mailing list
ooh323c-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ooh323c-devel

Reply via email to