write GstBuffer data to a file in decoder's chain method

classic Classic list List threaded Threaded
1 message Options
lyc
Reply | Threaded
Open this post in threaded view
|

write GstBuffer data to a file in decoder's chain method

lyc
hi,

I want to write the GstBuffer data to a file in decoder's method,but it can't.I define a method to save data,the fllow is my detail:
static void save0(guchar *data,int len)
{
           int fd;
           int written;
           if((fd = open("/home/sns/data.text",O_RDWR|O_CREAT|O_APPEND,0755)) < 0)
           {
                   printf("open fail\n");
                 return ;
           }
           written =write(fd, data , len);
           close(fd);
}

in decoder chain method,i invoke save0 method to save data via   save0(GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
but it can't write data to file,why?how can i do?