[Freeswitch-dev] VAD Events stop Firing after Bridgine

Rony Beck rony at botl.au.com
Mon May 20 10:54:01 MSD 2013


Hi All,

I have a problem with Voice Activity Detection.  I am writing a module 
which will bridge a call to a conference when it detects voice activity 
on the line.  When voice activity isn't detected for a period, the call 
is parked until voice activity is detected again.  It seems that before 
the call is bridged to the conference, Voice Activity Detection works 
fine and events with the "Action" of "start-talking" or "stop-talking" 
are fired.  Once the call is bridged, these events are no longer fired.  
Even If I manually park the call from fs_cli using "uuid_park", the 
events with "start-talking"/"stop-talking" are never fired again.  I 
have been scouring the net looking for a means of getting these events 
to fire again.  The sip profiles involved all have VAD enabled in both 
directions.

In code, I start the conference call like so:

sprintf(szCommand,"{TALK, 
NOTALK}sofia/externalx/confuser@%s:5080",szConfAddress);
switch_ivr_originate( NULL,&pPersistentSession,cause,szCommand, 
iTimeout, NULL,NULL,NULL,NULL,NULL, SOF_FORKED_DIAL,NULL ) != 
SWITCH_STATUS_SUCCESS;
pMainSessionUUID = switch_core_session_get_uuid( pPersistentSession );
pPersistentChannel = switch_core_session_get_channel( pPersistentSession );
pAppName = switch_core_session_strdup( pPersistentSession, "conference" );
sprintf(szCommand,"%s at default",pExtension);
pAppOpt  = switch_core_session_strdup( pPersistentSession, szCommand);
pPersistentCallExtension = 
switch_caller_extension_new(pPersistentSession, pAppName, pAppOpt);
switch_caller_extension_add_application( pPersistentSession, 
pPersistentCallExtension, pAppName, pAppOpt );
switch_channel_set_caller_extension( pPersistentChannel, 
pPersistentCallExtension );
switch_channel_set_state( pPersistentChannel, CS_EXECUTE );

This is just calling another freeswitch box which answers the call and 
keeps the conference open.

I then make a second call to the user's sip phone in much the same way.

sprintf(szCommand,"{TALK, NOTALK}user/1001");
switch_ivr_originate( NULL, &pUserSession,&cause, szCommand, 
iTimeout,NULL,NULL,NULL,NULL,NULL, SOF_FORKED_DIAL,NULL );
pUserSessionUUID = switch_core_session_get_uuid( pUserSession );
pUserChannel = switch_core_session_get_channel( pUserSession );
pUserAppName = switch_core_session_strdup( pUserSession, "conference" );
sprintf(szCommand,"%s at default",USER_EXTENSION);
pUserAppOpt  = switch_core_session_strdup( pUserSession, szCommand);
pUserCallerExtension = switch_caller_extension_new(pUserSession, 
pUserAppName, pUserAppOpt);
switch_caller_extension_add_application( pUserSession, 
pUserCallerExtension, pUserAppName, pUserAppOpt );
switch_channel_set_caller_extension( pUserChannel, pUserCallerExtension );
switch_channel_set_state( pUserChannel, CS_EXECUTE );

At this point the events are firing fine and my event handler is 
reacting to them.  On the first "start-talking" event I get from the 
user, I bridge the calls like so:

switch_ivr_uuid_bridge (pMainSessionUUID,pUserSessionUUID);

At this point, the events for "start-talking" or "stop-talking" are no 
longer fired and are never fired again even if I break the bridging.  I 
tried commenting out the bridging line just to be sure that the events 
are fired without the briding and it looks fine.  I get all the events 
continuously.   So it seems to break as soon as I bridge.

To capture the events, I had expected that I should bind to the events 
like this:

switch_event_bind("START_TALK_EVENT", SWITCH_EVENT_TALK, 
SWITCH_EVENT_SUBCLASS_ANY, detect_talk , NULL);
switch_event_bind("END_TALK_EVENT", SWITCH_EVENT_NOTALK, 
SWITCH_EVENT_SUBCLASS_ANY, detect_talk , NULL);

This never worked.   What did work was this:

switch_event_bind("TALK_EVENT", SWITCH_EVENT_CUSTOM, 
"conference::maintenance", detect_talk , NULL);

My event handler would just look for an event where the "Action" was set 
to "start-talking" or "stop-talking".

Is there something I am missing here?  I don't find enough information 
on the wiki to help me work out exactly how VAD events should be 
listened for and handled, so it is entirely likely I am doing it wrong.  
Can someone help me here or event paste a working code sample?

Many thanks for your time,

Ronnie





Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-dev mailing list