[asterisk-dev] rtp data in an app question
Russell Bryant
russell at digium.com
Wed Aug 12 04:47:10 CDT 2009
Gallmeier, Jonathan wrote:
> I'm still trying to debug my original problem where the phone can't
> decode the data from the sip channel. I'm trying to get the RTP data out
> of the channel by copying it like:
>
> struct ast_frame *f = ast_read(chan); // chan is my SIP channel
>
> ...
> write(outpipe, f->data.ptr, f->datalen); // outpipe is the named pipe
> to my phone's rtp input
>
> ...
>
> I verified that my formats are the same on both ends of the call (ulaw,
> same data rate and packet size).
>
> Is this the correct way to read data from the channel? Should I use the
> offset field or the samplesize field?
This is right, sort of. The big thing to note here is that the data in
the frame is _not_ an RTP frame. It is raw audio data. The only
encapsulation involved at this point is the ast_frame structure itself.
One other note is that a frame is not always audio. Frames may also be
signaling frames, among other things (see ast_frame_type in frame.h).
Make sure that you check to ensure that the frame type is
AST_FRAME_AUDIO before you treat it as such.
By the way, it would be most excellent if you could follow posting
convention on this list and not top-post messages. :-)
--
Russell Bryant
Digium, Inc. | Engineering Manager, Open Source Software
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: www.digium.com & www.asterisk.org
More information about the asterisk-dev
mailing list