[Asterisk-video] [patch] libh324m / app_h324m reversing bits

Emmanuel BUU emmanuel.buu at ives.fr
Fri Aug 21 05:36:24 CDT 2009


Hello,

Here is a set of patches that enable reversing bits of the H.245 
bitstream per configuration. This enable the seamless installation of 
the h324m stack on both misdn and zaptel driver without digging and 
recompiling the code.

in /etc/asterisk/h324m.conf, there is a new parameter

[h245]
reversebits=0|1


by default it is set to 1.


Enjoy.

--- for libh324m


Index: include/h324m.h
===================================================================
--- include/h324m.h    (révision 269)
+++ include/h324m.h    (copie de travail)
@@ -18,7 +18,7 @@
 {
 #endif
 void     TIFFReverseBits(unsigned char* buffer,int length);
-
+void    H324MSetReverseBits(int reverse);
 void     H324MLoggerSetLevel(int level);
 
 void*    H324MSessionCreate(void);
Index: h324m.cpp
===================================================================
--- h324m.cpp    (révision 269)
+++ h324m.cpp    (copie de travail)
@@ -5,6 +5,8 @@
 
 #include "src/H324MSession.h"
 
+static bool _reverseBits = true;
+
 extern "C"
 {
 
@@ -13,6 +15,11 @@
     Logger::SetLevel(level);   
 }
 
+void H324MSetReverseBits(int reverse)
+{
+    _reverseBits = (bool) reverse;
+}
+
 void H324MLoggerSetCallback(int (*callback)  (const char *, va_list))
 {
     Logger::SetCallback(callback);
@@ -45,14 +52,14 @@
 
 int  H324MSessionRead(void * id,unsigned char *buffer,int len)
 {
-    TIFFReverseBits(buffer,len);
+    if (_reverseBits) TIFFReverseBits(buffer,len);
     return ((H324MSession*)id)->Read(buffer,len);
 }
 
 int  H324MSessionWrite(void * id,unsigned char *buffer,int len)
 {    
     int ret = ((H324MSession*)id)->Write(buffer,len);
-    TIFFReverseBits(buffer,len);
+    if (_reverseBits) TIFFReverseBits(buffer,len);
     return ret;
 }
 

--- for app_h324m

Index: app_h324m.c
===================================================================
--- app_h324m.c    (révision 690)
+++ app_h324m.c    (copie de travail)
@@ -129,7 +129,7 @@
   struct ast_config *cfg;
   struct ast_variable *var;
   char *tmp;
-  int level;
+  int level, reverse;
 
   cfg = (void *)ast_config_load(config);
   if (!cfg)
@@ -170,6 +170,7 @@
     level = 1;
   }
 
+
   tmp = (void *)ast_variable_retrieve(cfg, "general", "boardcodec");
   if ((tmp) && (strlen(tmp) < 9))
   {
@@ -194,12 +195,27 @@
     strcpy(boardcodec, DEFAULT_BOARDCODEC);
   }
 
-  ast_config_destroy(cfg);
 
+   tmp = (void *)ast_variable_retrieve(cfg, "h245", "reversebits");
+   if (tmp)
+   {
+      if (sscanf(tmp, "%d", &reverse) >=1 )
+      {
+          ast_verbose(VERBOSE_PREFIX_3 "H245 reverse bits : %s\n",
+            (reverse == 0)?"no":"yes");
+      H324MReverseBit(reverse);
+      }
+      else
+      {
+      ast_log(LOG_WARNING, "Invalid reverse bit flag %s. Bits will be 
reversed.\n", tmp);
+      }
+   }
+   ast_config_destroy(cfg);
+
   if (level > 0)
   {
-    ast_verbose(VERBOSE_PREFIX_3 "Debug level  : %d\n", level);
-    ast_verbose(VERBOSE_PREFIX_3 "Board codec  : %s\n", boardcodec);
+      ast_verbose(VERBOSE_PREFIX_3 "Debug level  : %d\n", level);
+      ast_verbose(VERBOSE_PREFIX_3 "Board codec  : %s\n", boardcodec);
   }
  






More information about the asterisk-video mailing list