[Freeswitch-dev] hooked functions are not called while using one single session

Francisco Scaramanga scaram at hotmail.de
Mon Mar 22 03:33:30 PDT 2010


I am now using the application interface and play a file after answering the call. The call is not connected to a another session, it's just a single session.

SWITCH_STANDARD_APP(mod_my_function)
{
     /* play audio file */
    switch_ivr_play_file(session, NULL, "C:\\freeswitch1.0.4\\debug\\sounds\\music\\8000\\danza-espanola-op-37-h-142-xii-arabesca.wav", NULL);
}

Now the hooks for channel_write_frame and channel_read_frame are called! I write the audio frames into a file for testing if everything is correct. The data written in channel_write_frame seems to be perfect, but audio written in channel_read_frame only seems to be good at first sight. If I record 20 seconds of audio and listen to the audiofile I hear that 2 or 3 times short parts are missing. 

static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
{
  // Audio from danza-espanola-op-37-h-142-xii-arabesca.wav is written into a file
  fwrite((short *)frame->data, 2, frame->datalen/2 ,tmp);
}
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
{
    // Spoken audio samples from my microphone are written, but sometimes samples are missing
    fwrite((short *)frame->data, 2, frame->datalen/2 ,tmp);
}

Is it possible that I don't get all audio samples by hooked functions? why audio recorded in channel_write_frame is brilliant and in channel_read_frame not?






Date: Tue, 16 Mar 2010 13:59:28 -0500
From: anthony.minessale at gmail.com
To: freeswitch-dev at lists.freeswitch.org
Subject: Re: [Freeswitch-dev] hooked functions are not called while using	one single session

you probably want to use the application interface and a while loop while reading a frame.

see most of the functions in switch_ivr_play_say


On Tue, Mar 16, 2010 at 8:51 AM, Francisco Scaramanga <scaram at hotmail.de> wrote:






The module I am writing should be an endpoint VOIP-interface for another program. The module should answer a call and transport incoming audio into a 3rd party application. Furthermore the 3rd party application sends audio data back to the caller. This is why I hooked channel_read_frame and channel_write_frame. 


How can I trigger the channel to do something that requires reading or writing audio? Does it make a difference to use the endpoint interface instead of the hooks? 


Date: Tue, 16 Mar 2010 08:34:18 -0500

From: anthony.minessale at gmail.com
To: freeswitch-dev at lists.freeswitch.org
Subject: Re: [Freeswitch-dev] hooked functions are not called while using	one single session


What exactly is your goal?

those hooks will probably only be called if you send the channel to do something that 
requires reading and writing audio.


On Tue, Mar 16, 2010 at 6:47 AM, Francisco Scaramanga <scaram at hotmail.de> wrote:







Hello,
I am writing my own freeswitch module and have implemented 2 hooks for reading and writing audio (I did not implement the endpoint interface).
My problem is that the channel_write_frame and channel_read_frame callback-functions are only called if I make an intercept with another session (switch_ivr_intercept_session), but my usecase has only one single Session for getting and putting audio data in my module. 



How can I achieve this? 
scaram

/* on channel init I answer the session and set hooks */
static switch_status_t channel_on_init(switch_core_session_t *session)
{
    switch_channel_t *channel = switch_core_session_get_channel(session);


    switch_channel_answer(channel);

    switch_channel_set_state(channel, CS_EXCHANGE_MEDIA);
    switch_set_flag(tech_pvt, TFLAG_IO);

    switch_core_event_hook_add_write_frame(session, &channel_write_frame);


    switch_core_event_hook_add_read_frame(session, &channel_read_frame);
}

static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)


{
    /* is only called when I intercept 2 Sessions */
}
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
{
    /* is only called when I intercept 2 Sessions */


}


 		 	   		  
Ein Postfach für Alles –   bei Hotmail 5 E-Mail-Adressen online verwalten!

_______________________________________________

FreeSWITCH-dev mailing list

FreeSWITCH-dev at lists.freeswitch.org

http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev

UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev

http://www.freeswitch.org




-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/


Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale at hotmail.com

GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com

IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org

iax:guest at conference.freeswitch.org/888

googletalk:conf+888 at conference.freeswitch.org
pstn:+19193869900
 		 	   		  
Alles in einem Postfach  –   Ich will Hotmail!


_______________________________________________

FreeSWITCH-dev mailing list

FreeSWITCH-dev at lists.freeswitch.org

http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev

UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev

http://www.freeswitch.org




-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale at hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com

IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org
iax:guest at conference.freeswitch.org/888

googletalk:conf+888 at conference.freeswitch.org
pstn:+19193869900
 		 	   		  
_________________________________________________________________
http://redirect.gimas.net/?n=M1003xIMVideochat2
Treffe Freunde im Messenger Videochat!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20100322/9b13f689/attachment.html 


More information about the FreeSWITCH-dev mailing list