<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
ok,&nbsp; which is the best mechanism to controll the amount of data. Can you recommend a timer? I use PCMA codec with 20 msec intervall.<br><br><br><hr id="stopSpelling">Date: Fri, 26 Mar 2010 11:31:43 -0500<br>From: anthony.minessale@gmail.com<br>To: freeswitch-dev@lists.freeswitch.org<br>Subject: Re: [Freeswitch-dev] hooked functions are not called while using        one single session<br><br>you can only write back the exact number of bytes you negotiated per interval.<br><br><br><div class="ecxgmail_quote">On Fri, Mar 26, 2010 at 7:27 AM, Francisco Scaramanga <span dir="ltr">&lt;<a href="mailto:scaram@hotmail.de">scaram@hotmail.de</a>&gt;</span> wrote:<br>
<blockquote class="ecxgmail_quote" style="padding-left: 1ex;">



<div>
Now I call switch_core_session_read_frame and switch_core_session_write_frame in the same foreground loop. Then I write audio into a file and as a result I see that there are many audio gaps. <br><br>There seems to be a cross effect by using switch_core_session_write_frame and switch_core_session_read_frame together.<br>
If I only use switch_core_session_read_frame in the loop, there are no gaps and everything sounds perfect!<br><br>What could be the problem? <br><br><br><br>while (1)<br>{<br>&nbsp;&nbsp;&nbsp; // READ<br>&nbsp;&nbsp;&nbsp; tstatus = switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0);<br>
&nbsp;&nbsp;&nbsp; if (tstatus==SWITCH_STATUS_SUCCESS)<br>&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // write audio in a testfile<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fwrite((short *)(read_frame)-&gt;data, 2, ((read_frame)-&gt;datalen)/2 ,tmp);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; switch_size_t ts_rf=read_frame-&gt;timestamp;<br>
&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; // WRITE<br>&nbsp;&nbsp;&nbsp; vector&lt;unsigned char&gt; vucIn;<br>&nbsp;&nbsp;&nbsp; if (getAudio(&amp;vucAudio)) // get next audio and send it back<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; memcpy( write_frame.data, &amp;vucIn[0], vucIn.size());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; write_frame.datalen=vucIn.size();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; tstatus = switch_core_session_write_frame(session, &amp;write_frame, SWITCH_IO_FLAG_NONE, 0);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; //Sleep(1);//?<br>}<br><br><hr>Date: Mon, 22 Mar 2010 18:34:46 -0500<div><div></div><div class="h5"><br>
From: <a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a><br>To: <a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a><br>Subject: Re: [Freeswitch-dev] hooked functions are not called while using        one single session<br>
<br>you don't use the hook functions you use a frame pointer <br><br>switch_frame_t *read_frame;<br><br>switch_core_session_read_frame(session, &amp;read_frame, SWITCH_IO_FLAG_NONE, 0);<br><br>when i said to look at the stream file example i meant in the function itself to see how <br>

to read and write audio from a channel in a foreground loop.<br><br><br><br><div>On Mon, Mar 22, 2010 at 6:23 PM, Francisco Scaramanga <span dir="ltr">&lt;<a href="mailto:scaram@hotmail.de">scaram@hotmail.de</a>&gt;</span> wrote:<br>

<blockquote style="padding-left: 1ex;">



<div>
I have an selfmade software which is controlled by a telephone call (ISDN/CAPI). The user calls with his phone, gets <br>connected and can speak commands which are detected by an internal speech recognizer. Furthermore the user can accept <br>

or hangup incoming calls just by his voice command. It is also possible to dial out. <br><br>Now I am adding VOIP functionality to my system and decided to use FreeSwitch. Therefore I wrote a FreeSwitch module which should be the VOIP interface for my software. The module must be able to:<br>

<br>1. recognize an incoming call which is the users control session (single session)<br>&nbsp;&nbsp; I do this in statehandler function channel_on_init.<br>2. pick up another incoming call and intercept with my users control session. <br>

3. Get the audio data from voip session (user control session) and send it to my application (by own tcp-socket)<br>&nbsp; &nbsp; My idea is to use channel_write_frame to receive audio.<br>3. Send audio data from my application to voip user control session so the user can hear audio.<br>

&nbsp;&nbsp;&nbsp; My idea is to use channel_read_frame.<br><br>explanation for using hooks:<br>----------------------------<br>The endpoint interface callback functions where never called in my module, even I tried to adapt the way it is done <br>

in mod_portaudio. So my workaround was to set hook functions channel_read_frame/channel_write_frame to handle audio. <br><br>My problems:<br>------------<br>The hook functions are working fine if I have 2 sessions (put together by switch_ivr_intercept_session), but if I only have the single user control session no hooked function is called. In this case the only way to achieve that hooks are called, is to play audio with switch_ivr_play_file. But then, audio samples got lost sometimes.<br>

<br>Maybe there is a better way to solve my requirements? <br><br><br><br><br><hr>Date: Mon, 22 Mar 2010 11:55:42 -0500<div><div></div><div><br>From: <a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a><br>

To: <a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a><br>Subject: Re: [Freeswitch-dev] hooked functions are not called while using        one single session<br><br>Why do you even need the hooks?<br>

What exactly are you trying to do?<br>Maybe you should explain it.<br><br><br><div>On Mon, Mar 22, 2010 at 5:33 AM, Francisco Scaramanga <span dir="ltr">&lt;<a href="mailto:scaram@hotmail.de">scaram@hotmail.de</a>&gt;</span> wrote:<br>


<blockquote style="padding-left: 1ex;">



<div>
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.<br><br>SWITCH_STANDARD_APP(mod_my_function)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp; /* play audio file */<br>


&nbsp;&nbsp;&nbsp; switch_ivr_play_file(session, NULL, "C:\\freeswitch1.0.4\\debug\\sounds\\music\\8000\\danza-espanola-op-37-h-142-xii-arabesca.wav", NULL);<br>}<br><br>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. <br>


<div><br>static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)<br>{<br></div>&nbsp; // Audio from danza-espanola-op-37-h-142-xii-arabesca.wav is written into a file<br>


&nbsp; fwrite((short *)frame-&gt;data, 2, frame-&gt;datalen/2 ,tmp);<div><br>}<br>static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)<br>
{<br></div>&nbsp;&nbsp;&nbsp; // Spoken audio samples from my microphone are written, but sometimes samples are missing<br>&nbsp;&nbsp;&nbsp; fwrite((short *)frame-&gt;data, 2, frame-&gt;datalen/2 ,tmp);<br>}<br><br>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?<br>


<br><br><br><br><br><br><hr>Date: Tue, 16 Mar 2010 13:59:28 -0500<div><div></div><div><br>From: <a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a><br>To: <a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a><br>


Subject: Re: [Freeswitch-dev] hooked functions are not called while using        one single session<br><br>you probably want to use the application interface and a while loop while reading a frame.<br><br>see most of the functions in switch_ivr_play_say<br>


<br><br><div>On Tue, Mar 16, 2010 at 8:51 AM, Francisco Scaramanga <span dir="ltr">&lt;<a href="mailto:scaram@hotmail.de">scaram@hotmail.de</a>&gt;</span> wrote:<br>
<blockquote style="padding-left: 1ex;">



<div>
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. <br>



<br>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? <br><br><br><hr>Date: Tue, 16 Mar 2010 08:34:18 -0500<br>



From: <a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a><br>To: <a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a><br>Subject: Re: [Freeswitch-dev] hooked functions are not called while using        one single session<div>



<div></div><div><br><br>What exactly is your goal?<br><br>those hooks will probably only be called if you send the channel to do something that <br>requires reading and writing audio.<br><br><br><div>On Tue, Mar 16, 2010 at 6:47 AM, Francisco Scaramanga <span dir="ltr">&lt;<a href="mailto:scaram@hotmail.de">scaram@hotmail.de</a>&gt;</span> wrote:<br>




<blockquote style="padding-left: 1ex;">



<div>
Hello,<br>I am writing my own freeswitch module and have implemented 2 hooks for reading and writing audio (I did not implement the endpoint interface).<br>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. <br>




<br>How can I achieve this? <br>scaram<br><br>/* on channel init I answer the session and set hooks */<br>static switch_status_t channel_on_init(switch_core_session_t *session)<br>{<br>&nbsp;&nbsp; &nbsp;switch_channel_t *channel = switch_core_session_get_channel(session);<br>




&nbsp;&nbsp; &nbsp;switch_channel_answer(channel);<br><br>&nbsp;&nbsp; &nbsp;switch_channel_set_state(channel, CS_EXCHANGE_MEDIA);<br>&nbsp;&nbsp; &nbsp;switch_set_flag(tech_pvt, TFLAG_IO);<br><br>&nbsp;&nbsp; &nbsp;switch_core_event_hook_add_write_frame(session, &amp;channel_write_frame);<br>




&nbsp;&nbsp; &nbsp;switch_core_event_hook_add_read_frame(session, &amp;channel_read_frame);<br>}<br><br>static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)<br>




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




}<br><div><br><br>                                               <br><hr>Ein Postfach für Alles – &nbsp; <a href="http://redirect.gimas.net/?n=M1003HM5Adressen">bei Hotmail 5 E-Mail-Adressen online verwalten!</a></div></div>
<br>_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>




Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN:anthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>



GTALK/JABBER/<a href="mailto:PAYPAL:anthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip:888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br>



<a href="http://conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk:conf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:+19193869900<br>                                               <br></div></div><div><hr>Alles in einem Postfach  –   <a href="http://redirect.gimas.net/?n=M1003Hotmail">Ich will Hotmail!</a></div>



</div>
<br>_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>



Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN:anthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>


GTALK/JABBER/<a href="mailto:PAYPAL:anthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip:888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br>


<a href="http://conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk:conf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:+19193869900<br>                                               <br></div></div><hr>Treffe Freunde  <a href="http://redirect.gimas.net/?n=M1003IMVideochat">im Messenger Videochat!</a></div>



<br>_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>


Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN:anthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>

GTALK/JABBER/<a href="mailto:PAYPAL:anthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip:888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br>

<a href="http://conference.freeswitch.org/888">iax:guest@conference.freeswitch.org/888</a><br>
<a href="mailto:googletalk:conf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>pstn:+19193869900<br>                                               <br><hr>Alles in einem Postfach  –   <a href="http://redirect.gimas.net/?n=M1003Hotmail">Ich will Hotmail!</a></div>

</div></div>
<br>_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>

Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN:anthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>
GTALK/JABBER/<a href="mailto:PAYPAL:anthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip:888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br>
<a href="mailto:googletalk:conf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:+19193869900<br>                                               <br><hr>Treffe Freunde  <a href="http://redirect.gimas.net/?n=M1003IMVideochat">im Messenger Videochat!</a></div></div></div>
<br>_______________________________________________<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Anthony Minessale II<br><br>FreeSWITCH <a href="http://www.freeswitch.org/">http://www.freeswitch.org/</a><br>ClueCon <a href="http://www.cluecon.com/">http://www.cluecon.com/</a><br>
Twitter: <a href="http://twitter.com/FreeSWITCH_wire">http://twitter.com/FreeSWITCH_wire</a><br><br>AIM: anthm<br><a href="mailto:MSN:anthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>GTALK/JABBER/<a href="mailto:PAYPAL:anthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net">irc.freenode.net</a> #freeswitch<br><br>FreeSWITCH Developer Conference<br><a href="mailto:sip:888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br><a href="mailto:googletalk:conf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:+19193869900<br>                                               <br /><hr />Alles in einem Postfach  –   <a href='http://redirect.gimas.net/?n=M1003Hotmail' target='_new'>Ich will Hotmail!</a></body>
</html>