228228 provided timeout) before going to the destination provided in the <literal>g</literal>
229229 or <literal>h</literal> option. Default is 1.</para>
230230 </option>
231+ <option name="p">
232+ <para>Match immediately on audible ringback tone, instead of or in addition to
233+ a particular frequency.</para>
234+ </option>
231235 <option name="r">
232236 <para>Apply to received frames only. Default is both directions.</para>
233237 </option>
@@ -297,6 +301,7 @@ enum td_opts {
297301 OPT_SIT = (1 << 9 ),
298302 OPT_BUSY = (1 << 10 ),
299303 OPT_DIALTONE = (1 << 11 ),
304+ OPT_RINGING = (1 << 12 ),
300305};
301306
302307enum {
@@ -316,6 +321,7 @@ AST_APP_OPTIONS(td_opts, {
316321 AST_APP_OPTION_ARG ('g' , OPT_GOTO_RX , OPT_ARG_GOTO_RX ),
317322 AST_APP_OPTION_ARG ('h' , OPT_GOTO_TX , OPT_ARG_GOTO_TX ),
318323 AST_APP_OPTION_ARG ('n' , OPT_HITS_REQ , OPT_ARG_HITS_REQ ),
324+ AST_APP_OPTION ('p' , OPT_RINGING ),
319325 AST_APP_OPTION ('s' , OPT_SQUELCH ),
320326 AST_APP_OPTION ('t' , OPT_TX ),
321327 AST_APP_OPTION ('r' , OPT_RX ),
@@ -403,18 +409,31 @@ static int detect_callback(struct ast_audiohook *audiohook, struct ast_channel *
403409 if (tstate > 0 ) {
404410 ast_debug (3 , "tcount: %d, tstate: %d\n" , tcount , tstate );
405411 switch (tstate ) {
412+ case DSP_TONE_STATE_RINGING :
413+ if (di -> signalfeatures & DSP_PROGRESS_RINGING ) {
414+ ast_debug (1 , "Detected ringing on %s in %s direction\n" , ast_channel_name (chan ),
415+ direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write" );
416+ match = 1 ;
417+ }
418+ break ;
406419 case DSP_TONE_STATE_DIALTONE :
407420 if (di -> signalfeatures & DSP_FEATURE_WAITDIALTONE ) {
421+ ast_debug (1 , "Detected dial tone on %s in %s direction\n" , ast_channel_name (chan ),
422+ direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write" );
408423 match = 1 ;
409424 }
410425 break ;
411426 case DSP_TONE_STATE_BUSY :
412427 if (di -> signalfeatures & DSP_PROGRESS_BUSY ) {
428+ ast_debug (1 , "Detected busy tone on %s in %s direction\n" , ast_channel_name (chan ),
429+ direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write" );
413430 match = 1 ;
414431 }
415432 break ;
416433 case DSP_TONE_STATE_SPECIAL3 :
417434 if (di -> signalfeatures & DSP_PROGRESS_CONGESTION ) {
435+ ast_debug (1 , "Detected SIT on %s in %s direction\n" , ast_channel_name (chan ),
436+ direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write" );
418437 match = 1 ;
419438 }
420439 break ;
@@ -427,7 +446,8 @@ static int detect_callback(struct ast_audiohook *audiohook, struct ast_channel *
427446 } else if (di -> gototx ) {
428447 ast_async_parseable_goto (chan , di -> gototx );
429448 } else {
430- ast_debug (3 , "Detected call progress signal, but don't know where to go\n" );
449+ ast_debug (3 , "Detected call progress signal in %s direction, but don't know where to go\n" ,
450+ direction == AST_AUDIOHOOK_DIRECTION_READ ? "read" : "write" );
431451 }
432452 }
433453 }
@@ -583,6 +603,9 @@ static int parse_signal_features(struct ast_flags *flags)
583603 if (ast_test_flag (flags , OPT_DIALTONE )) {
584604 features |= DSP_FEATURE_WAITDIALTONE ;
585605 }
606+ if (ast_test_flag (flags , OPT_RINGING )) {
607+ features |= DSP_PROGRESS_RINGING ;
608+ }
586609
587610 return features ;
588611}
0 commit comments