Test for Asterisk Version info
[asterisk/asterisk.git] / apps / app_waitforring.c
index dfe33db..bd0353b 100644 (file)
  * \ingroup applications
  */
 
+/*** MODULEINFO
+       <support_level>extended</support_level>
+ ***/
+
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -56,6 +60,7 @@ static char *app = "WaitForRing";
 static int waitforring_exec(struct ast_channel *chan, const char *data)
 {
        struct ast_frame *f;
+       struct ast_silence_generator *silgen = NULL;
        int res = 0;
        double s;
        int ms;
@@ -65,6 +70,10 @@ static int waitforring_exec(struct ast_channel *chan, const char *data)
                return 0;
        }
 
+       if (ast_opt_transmit_silence) {
+               silgen = ast_channel_start_silence_generator(chan);
+       }
+
        ms = s * 1000.0;
        while (ms > 0) {
                ms = ast_waitfor(chan, ms);
@@ -78,7 +87,7 @@ static int waitforring_exec(struct ast_channel *chan, const char *data)
                                res = -1;
                                break;
                        }
-                       if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) {
+                       if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) {
                                ast_verb(3, "Got a ring but still waiting for timeout\n");
                        }
                        ast_frfree(f);
@@ -99,7 +108,7 @@ static int waitforring_exec(struct ast_channel *chan, const char *data)
                                        res = -1;
                                        break;
                                }
-                               if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_RING)) {
+                               if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass.integer == AST_CONTROL_RING)) {
                                        ast_verb(3, "Got a ring after the timeout\n");
                                        ast_frfree(f);
                                        break;
@@ -109,6 +118,10 @@ static int waitforring_exec(struct ast_channel *chan, const char *data)
                }
        }
 
+       if (silgen) {
+               ast_channel_stop_silence_generator(chan, silgen);
+       }
+
        return res;
 }