[asterisk-dev] how to send ast_frames?

Alessandro Carminati alessandro.carminati at gmail.com
Fri Jan 3 16:11:57 CST 2014


Hello everybody,

I'm trying writing an app for transmit an FSK message over the line.
I'm having troubles basically because I have no idea of how a voice frame
should be sent using asterisk's api.

If I use this piece of code toward a phone, I can indeed hear the FSK tone.
But if I send it to the receive function I already built, asterisk
complains "Dropping incompatible voice frame on SIP/pbx-0000002e of format
slin since our native format has changed to (ulaw)" several times and after
dies.

can someone please review my code?

ast_frame_t *fr;

res = ast_waitfor(chan, 1000); //wait for a frame:
fr = ast_read(chan);           //I found noway to have an ast_frame but use
this function.
if (!fr) {
          ast_log(LOG_WARNING, "Null frame == hangup() detected\n");
          res = -1;
          break;
         }
samples = fsk_tx(caller_tx, caller_amp, BLOCK_LEN);           //here I
build the fsk message using spandsp functions
fr->frametype = AST_FRAME_VOICE;                              //compiling
new frame
ast_format_set(&fr->subclass.format, AST_FORMAT_SLINEAR, 0);  //compiling
new frame
fr->datalen = samples;                                        //compiling
new frame
fr->samples = samples / 2;                                    //compiling
new frame
fr->offset = AST_FRIENDLY_OFFSET;                             //compiling
new frame
fr->src = __PRETTY_FUNCTION__;                                //compiling
new frame
fr->data.ptr = &caller_amp;                                   //compiling
new frame
if (ast_write(chan, fr) < 0) {                                //send frame
                              res = -1;
                              ast_frfree(fr);
                              break;
                             }

Alessandro Carminati
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140103/2475e40d/attachment.html>


More information about the asterisk-dev mailing list