Gstreamer with multithread app (Qt)
Matias Hernandez Arellano
msdark at archlinux.cl
Mon Apr 18 08:11:55 PDT 2011
Me again, but i can't figure out why this can't work...
I have this into the run method of a thread:
for(;;){
Mat frame = this->ImageBuffer->getFrame(); //Get a OpenCV Frame from Circular Buffer
if(!this->m_src.element().isNull() && !frame.empty()){
QGst::BufferPtr buffer = QGst::Buffer::create(640*480*3);
quint8 *data = buffer->data();
memcpy(data,(quint8*)frame.data,640*480*3);
if(!buffer.isNull()){
QGst::FlowReturn ret = this->m_src.pushBuffer(buffer);
if(ret!=QGst::FlowOk)
qDebug()<<"Error";
}
buffer.clear();
}
}
But if i try to see the result (using a receive pipeline into a terminal) the pipeline don't go to PLAYING state so i though i don' copy the data into the buffer the right way.. so i try to see what is in the buffer (what it push into appsrc).. using this qDebug()<<buffer->data();
qDebug()<<buffer->size();
So the buffer->size() show me the exact size i put (640*480*3) .. and the buffer->data() always show me the same value 0x137847000, so the memory direction never change????? .. so i think i push wrong data into the appsrc and obviously i can't see anything in the "client" ...
How can i accomplish this..????
Any help???
Thanks in advance...
El 13-04-2011, a las 15:30, George Kiagiadakis escribió:
> On Wed, Apr 13, 2011 at 1:59 AM, Matias Hernandez Arellano
> <msdark at archlinux.cl> wrote:
>> Mat frame = this->ImageBuffer->getFrame();
>>
>> data = (quint8*)frame.data;
>>
>> I hope you realize that this statement is void, it copies no actual
>> data. You need to copy the data with memcpy() instead.
>>
>> QGst::FlowReturn ret = this->m_src.pushBuffer(buffer);
>>
>>
>> I do this cause i asking in other thread about the use of QGst::Buffer and i
>> get this:
>> The QGst::Buffer class has a data() method which gives you a pointer
>> to the allocated buffer. You can use this pointer to write on the
>> buffer.
>>
>> Btw, the above line of code looks terribly wrong to me... Here is how
>> you should use it:
>>
>> QGst::BufferPtr b = QGst::Buffer::create(size);
>> quint8 *data = b->data();
>> //use the data pointer to write.
>
> Yes, I meant to write on the location where data is pointing at, using
> some function like memcpy() or something similar. This is basic C/C++.
>
>> But i don't know if this is right.. so i try with memcpy. When i testing
>> with C interface of Gstreamer i do this:
>> memcpy(GST_BUFFER_DATA(buffer),img_data,data_size);
>> even i use this GST_BUFFER_DATA(buffer) = img_data; GST_BUFFER_SIZE(buffer)
>> = 640*480*3*sizeof(uchar*);
>> but now i don't know how copy the data into QGst::Buffer... this don't work
>> ...
>>
>> memcpy(data,frame.data,640*480*3*sizeof(uchar*))
>
> What do you mean it doesn't work? Does it crash? Are you sure about
> that sizeof(uchar*) there?
>
> Try:
> memcpy(data, frame.data, 640*480*3);
>
>
> Regards,
> George
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl
More information about the gstreamer-devel
mailing list