[asterisk-dev] OT: C problems with access to "struct ast_frame.data" member

Moises Silva moises.silva at gmail.com
Sun May 24 15:58:54 CDT 2009


> Before the update I used something like that:
>
> struct ast_frame *f=NULL;
> f=ast_read(chan);
> if(f->frametype==AST_FRAME_TEXT) {
>        ast_log(AST_CONF_DEBUG,"Text: %s\n",f->data);
> }
>

You need to read this: http://www.crasseux.com/books/ctutorial/union.html

And use the ptr member of the union.

struct ast_frame *f=NULL;
f=ast_read(chan);
if(f->frametype==AST_FRAME_TEXT) {
        ast_log(AST_CONF_DEBUG,"Text: %s\n",f->data.ptr);
}

In the future you may want to take a look at how other code makes use
of frames, is not that hard.

Moy



More information about the asterisk-dev mailing list