[commit message]
authorKevin P. Fleming <kpfleming@digium.com>
Fri, 4 Jan 2008 17:21:25 +0000 (17:21 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Fri, 4 Jan 2008 17:21:25 +0000 (17:21 +0000)
(closes issue #10393)
Reported by: tzafrir
Patches:
      chan_alarm_asterisk.diff uploaded by tzafrir (license 46) (modified by me and added configure script support)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@96500 65c4cc65-6c06-0410-ace0-fbb531ad65f3

acinclude.m4
channels/chan_zap.c
configure
configure.ac
include/asterisk/autoconfig.h.in

index f094043..66e1ef7 100644 (file)
@@ -75,6 +75,7 @@ AC_DEFUN([AST_CHECK_MANDATORY],
 
 # The next three functions check for the availability of a given package.
 # AST_C_DEFINE_CHECK looks for the presence of a #define in a header file,
+# AST_C_COMPILE_CHECK can be used for testing for various items in header files,
 # AST_EXT_LIB_CHECK looks for a symbol in a given library, or at least
 #      for the presence of a header file.
 # AST_EXT_TOOL_CHECK looks for a symbol in using $1-config to determine CFLAGS and LIBS
@@ -120,6 +121,35 @@ AC_DEFUN([AST_C_DEFINE_CHECK],
 ])
 
 
+# Check if a given expression will compile using a certain header.
+
+# AST_C_COMPILE_CHECK([package], [expression], [header file], [version])
+AC_DEFUN([AST_C_COMPILE_CHECK],
+[
+    if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
+       AC_MSG_CHECKING([if "$2" compiles using $3])
+       saved_cppflags="${CPPFLAGS}"
+       if test "x${$1_DIR}" != "x"; then
+           $1_INCLUDE="-I${$1_DIR}/include"
+       fi
+       CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
+
+       AC_COMPILE_IFELSE(
+           [ AC_LANG_PROGRAM( [#include <$3>],
+                              [ $2; ]
+                              )],
+           [   AC_MSG_RESULT(yes)
+               PBX_$1=1
+               AC_DEFINE([HAVE_$1], 1, [Define if your system has the $1 headers.])
+               AC_DEFINE([HAVE_$1_VERSION], $4, [Define $1 headers version])
+           ],
+           [       AC_MSG_RESULT(no) ] 
+       )
+       CPPFLAGS="${saved_cppflags}"
+    fi
+])
+
+
 # Check for existence of a given package ($1), either looking up a function
 # in a library, or, if no function is supplied, only check for the
 # existence of the header files.
index 1654301..1ede608 100644 (file)
@@ -4170,18 +4170,35 @@ static int check_for_conference(struct zt_pvt *p)
        return 0;
 }
 
+/*! Checks channel for alarms
+ * \param p a channel to check for alarms.
+ * \returns the alarms on the span to which the channel belongs, or alarms on
+ *          the channel if no span alarms.
+ */
 static int get_alarms(struct zt_pvt *p)
 {
        int res;
        ZT_SPANINFO zi;
+#if defined(HAVE_ZAPTEL_CHANALARMS)
+       struct zt_params params;
+#endif
+
        memset(&zi, 0, sizeof(zi));
        zi.spanno = p->span;
-       res = ioctl(p->subs[SUB_REAL].zfd, ZT_SPANSTAT, &zi);
-       if (res < 0) {
-               ast_log(LOG_WARNING, "Unable to determine alarm on channel %d\n", p->channel);
-               return 0;
+       if ((res = ioctl(p->subs[SUB_REAL].zfd, ZT_SPANSTAT, &zi)) >= 0) {
+               if (zi.alarms != ZT_ALARM_NONE)
+                       return zi.alarms;
        }
-       return zi.alarms;
+
+#if defined(HAVE_ZAPTEL_CHANALARMS)
+       /* No alarms on the span. Check for channel alarms. */
+       if ((res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &params)) >= 0)
+               return params.chan_alarms;
+#endif
+
+       ast_log(LOG_WARNING, "Unable to determine alarm on channel %d\n", p->channel);
+
+       return ZT_ALARM_NONE;
 }
 
 static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_frame **dest)
index 7ce35ee..4eeb1fe 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 95937 .
+# From configure.ac Revision: 96071 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.4.
 #
@@ -932,6 +932,10 @@ ZAPTEL_ECHOCANPARAMS_LIB
 ZAPTEL_ECHOCANPARAMS_INCLUDE
 ZAPTEL_ECHOCANPARAMS_DIR
 PBX_ZAPTEL_ECHOCANPARAMS
+ZAPTEL_CHANALARMS_LIB
+ZAPTEL_CHANALARMS_INCLUDE
+ZAPTEL_CHANALARMS_DIR
+PBX_ZAPTEL_CHANALARMS
 SDL_LIB
 SDL_INCLUDE
 SDL_DIR
@@ -1630,6 +1634,8 @@ Optional Packages:
   --with-zaptel_echocanparams=PATH
                           use Zaptel Echo Canceler Parameter Support files in
                           PATH
+  --with-zaptel_chanalarms=PATH
+                          use Zaptel Channel Alarm Support files in PATH
   --with-sdl=PATH         use Sdl files in PATH
   --with-SDL_image=PATH   use Sdl Image library files in PATH
   --with-avcodec=PATH     use Ffmpeg and avcodec library files in PATH
@@ -9376,6 +9382,34 @@ fi
 
 
 
+    ZAPTEL_CHANALARMS_DESCRIP="Zaptel Channel Alarm Support"
+    ZAPTEL_CHANALARMS_OPTION="zaptel_chanalarms"
+
+# Check whether --with-zaptel_chanalarms was given.
+if test "${with_zaptel_chanalarms+set}" = set; then
+  withval=$with_zaptel_chanalarms;
+       case ${withval} in
+       n|no)
+       USE_ZAPTEL_CHANALARMS=no
+       ;;
+       y|ye|yes)
+       ac_mandatory_list="${ac_mandatory_list} ZAPTEL_CHANALARMS"
+       ;;
+       *)
+       ZAPTEL_CHANALARMS_DIR="${withval}"
+       ac_mandatory_list="${ac_mandatory_list} ZAPTEL_CHANALARMS"
+       ;;
+       esac
+
+fi
+
+    PBX_ZAPTEL_CHANALARMS=0
+
+
+
+
+
+
 
     SDL_DESCRIP="Sdl"
     SDL_OPTION="sdl"
@@ -44995,7 +45029,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     fi
 
 
-# Check for Zaptel hwgain support
+# Check for hwgain support
 
     if test "x${PBX_ZAPTEL_HWGAIN}" != "x1" -a "${USE_ZAPTEL_HWGAIN}" != "no"; then
        { echo "$as_me:$LINENO: checking for ZT_SET_HWGAIN in zaptel/zaptel.h" >&5
@@ -45072,6 +45106,78 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
     fi
 
 
+# Check for channel alarm support
+
+    if test "x${PBX_ZAPTEL_CHANALARMS}" != "x1" -a "${USE_ZAPTEL_CHANALARMS}" != "no"; then
+       { echo "$as_me:$LINENO: checking if \"size_t foo = sizeof(struct zt_params_v1)\" compiles using zaptel/zaptel.h" >&5
+echo $ECHO_N "checking if \"size_t foo = sizeof(struct zt_params_v1)\" compiles using zaptel/zaptel.h... $ECHO_C" >&6; }
+       saved_cppflags="${CPPFLAGS}"
+       if test "x${ZAPTEL_CHANALARMS_DIR}" != "x"; then
+           ZAPTEL_CHANALARMS_INCLUDE="-I${ZAPTEL_CHANALARMS_DIR}/include"
+       fi
+       CPPFLAGS="${CPPFLAGS} ${ZAPTEL_CHANALARMS_INCLUDE}"
+
+       cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <zaptel/zaptel.h>
+int
+main ()
+{
+ size_t foo = sizeof(struct zt_params_v1);
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+     { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+               PBX_ZAPTEL_CHANALARMS=1
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ZAPTEL_CHANALARMS 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ZAPTEL_CHANALARMS_VERSION
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+              { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       CPPFLAGS="${saved_cppflags}"
+    fi
+
+
 # On FreeBSD, try old zaptel (0.80 or so) and pretend we have vldtmf
 case "${host_os}" in
     freebsd*)
@@ -49263,6 +49369,10 @@ ZAPTEL_ECHOCANPARAMS_LIB!$ZAPTEL_ECHOCANPARAMS_LIB$ac_delim
 ZAPTEL_ECHOCANPARAMS_INCLUDE!$ZAPTEL_ECHOCANPARAMS_INCLUDE$ac_delim
 ZAPTEL_ECHOCANPARAMS_DIR!$ZAPTEL_ECHOCANPARAMS_DIR$ac_delim
 PBX_ZAPTEL_ECHOCANPARAMS!$PBX_ZAPTEL_ECHOCANPARAMS$ac_delim
+ZAPTEL_CHANALARMS_LIB!$ZAPTEL_CHANALARMS_LIB$ac_delim
+ZAPTEL_CHANALARMS_INCLUDE!$ZAPTEL_CHANALARMS_INCLUDE$ac_delim
+ZAPTEL_CHANALARMS_DIR!$ZAPTEL_CHANALARMS_DIR$ac_delim
+PBX_ZAPTEL_CHANALARMS!$PBX_ZAPTEL_CHANALARMS$ac_delim
 SDL_LIB!$SDL_LIB$ac_delim
 SDL_INCLUDE!$SDL_INCLUDE$ac_delim
 SDL_DIR!$SDL_DIR$ac_delim
@@ -49308,7 +49418,7 @@ CURL_CONFIG!$CURL_CONFIG$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 64; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 68; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
index 002e6be..a060636 100644 (file)
@@ -254,6 +254,7 @@ AST_EXT_LIB_SETUP([ZAPTEL_TRANSCODE], [Zaptel Transcoder Support], [zaptel_trans
 AST_EXT_LIB_SETUP([ZAPTEL_VLDTMF], [Zaptel VLDTMF Support], [zaptel_vldtmf])
 AST_EXT_LIB_SETUP([ZAPTEL_HWGAIN], [Zaptel Hardware Gain Support], [zaptel_hwgain])
 AST_EXT_LIB_SETUP([ZAPTEL_ECHOCANPARAMS], [Zaptel Echo Canceler Parameter Support], [zaptel_echocanparams])
+AST_EXT_LIB_SETUP([ZAPTEL_CHANALARMS], [Zaptel Channel Alarm Support], [zaptel_chanalarms])
 
 AST_EXT_LIB_SETUP([SDL], [Sdl], [sdl])
 AST_EXT_LIB_SETUP([SDL_IMAGE], [Sdl Image library], [SDL_image])
@@ -1166,9 +1167,12 @@ AST_C_DEFINE_CHECK([ZAPTEL_ECHOCANPARAMS], [ZT_ECHOCANCEL_PARAMS], [zaptel/zapte
 # Check for transcoder support
 AST_C_DEFINE_CHECK([ZAPTEL_TRANSCODE], [ZT_TCOP_ALLOCATE], [zaptel/zaptel.h])
 
-# Check for Zaptel hwgain support
+# Check for hwgain support
 AST_C_DEFINE_CHECK([ZAPTEL_HWGAIN], [ZT_SET_HWGAIN], [zaptel/zaptel.h])
 
+# Check for channel alarm support
+AST_C_COMPILE_CHECK([ZAPTEL_CHANALARMS], [size_t foo = sizeof(struct zt_params_v1)], [zaptel/zaptel.h])
+
 # On FreeBSD, try old zaptel (0.80 or so) and pretend we have vldtmf
 case "${host_os}" in
     freebsd*)
index 080b4ef..efe469f 100644 (file)
 /* Define this to indicate the ${ZAPTEL_DESCRIP} library */
 #undef HAVE_ZAPTEL
 
+/* Define if your system has the ZAPTEL_CHANALARMS headers. */
+#undef HAVE_ZAPTEL_CHANALARMS
+
+/* Define ZAPTEL_CHANALARMS headers version */
+#undef HAVE_ZAPTEL_CHANALARMS_VERSION
+
 /* Define if your system has the ZAPTEL_ECHOCANPARAMS headers. */
 #undef HAVE_ZAPTEL_ECHOCANPARAMS