[Freeswitch-dev] Howto keep control over read and write frames in my own module after initiating a new call

Achim Stamm stamm at lyth.de
Mon Jul 26 03:08:03 PDT 2010


I have following problem:
My current session is connected to my own module which uses the
freeswitch API doing Read and write frames in the while loop.
I want bridge my current session to make an outbound call within my while loop.
The calling of method bridge runs in a thread using modificated bgapi.
The outbounded phone rings and after picking it up the reading and
writing of frames is done only by freeswitch core and not any more in my while
loop. But after bridging I want to keep control over reading and writing

How can i gain control back or keep it over reading and writing
frames after bridging ?

A solution may be to run an extension instead of making the call in while loop.
How can i execute an extension with switch_core_session_execute_exten ?

Here is a snippet of my Dialplan:

<extension name="Caller">
      <condition field="destination_number" expression="^1000$">
	     <action application="answer"/>
		 <action application="info"/>
		 <action application="set" data="hangup_after_bridge=false"/>
		 <action application="set" data="ignore_early_media=true"/>
		 <action application="myapplication" data="DoingReadAndWriteFrames"/> 
Here is a snippet of my DoingReadAndWriteFrames from myapplication:

static switch_status_t DoingBridge(switch_core_session_t *session, switch_input_args_t *args)
	switch_codec_t codec = { 0 };
	switch_status_t status;
	switch_frame_t *read_frame;
	switch_channel_t *channel = switch_core_session_get_channel(session);
	switch_stream_handle_t dstream = { 0 };
	// Bridge to phone in a thread:		
	mybg_bridge("user/1012 at" ,60, session, &dstream);
	while (switch_channel_ready(channel)) 
		// Read Frame :
		status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
		// Write Frame :
		vucOutAudio = CControlThirdPartyApplication::getInstance().getAudio(session);
		switch_status_t tstatus_caller = switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0);
		// Make Outbound Call:
		string dialNumber = CControlThirdPartyApplication::getInstance().getDialNumber(session);
		if (!dialNumber.empty())
			// @ ToDo Dial outbound:
			// execute another extension ("Test"), that is doing our outbound call ??:
			// or Bridge to dialNumber in a thread:	
			dialNumber = "user/" + dialNumber;
			dialNumber = dialNumber + "@";
			mybg(dialNumber.c_str(), 60, session, &dstream);
			// if dialNumber pickup, than freeswitch core read and write frames ?? I want control over read and write frame


Achim Stamm

Achim Stamm, Dipl.-Inform. (FH)

Lyncker & Theis GmbH
Wilhelmstr. 16
65185 Wiesbaden

Fon +49 611/9006951
Fax +49 611/9406125

Handelsregister: HRB 23156 Amtsgericht Wiesbaden
Steuernummer: 04323897052
USt-IdNr.: DE255806399

Filip Lyncker,
Armin Theis 

More information about the FreeSWITCH-dev mailing list