Gstreamer with multithread app (Qt)
Matias Hernandez Arellano
msdark at archlinux.cl
Thu Apr 14 13:15:26 PDT 2011
I continue with this... finally i don't get crash problems now...
this is the StreamThread :
Constructor:
QString pipe_str = QString("appsrc name=\"appsrc\" caps=\"video/x-raw-rgb,width=320,height=240\" ! videoparse format=14 width=%1 height=%1 ! videorate "
" ! videoscale ! video/x-raw-rgb,width=320,height=240 "
" ! ffmpegcolorspace ! jpegenc "
" ! tcpserversink port=5000 ").arg(WIDTH,HEIGHT);
this->pipeline = QGst::Parse::launch(pipe_str).dynamicCast<QGst::Pipeline>();
this->m_src.setElement(this->pipeline->getElementByName("appsrc"));
this->pipeline->setState(QGst::StatePlaying);
this->m_src.setLive(true); //with this the application don't crash
The Loop of the Thread
for(;;){
Mat frame = this->ImageBuffer->getFrame();
if(!this->m_src.element().isNull() && !frame.empty()){
this->pipeline->setState(QGst::StatePlaying);
QGst::BufferPtr buffer = QGst::Buffer::create(WIDTH*HEIGHT*3*sizeof(quint8*));
quint8 *data = buffer->data();
memcpy(data,frame.data,frame.elemSize());
if(!buffer.isNull()){
QGst::FlowReturn ret = this->m_src.pushBuffer(buffer);
if(ret!=QGst::FlowOk)
qDebug()<<"Error";
}
}
}
The applicaiton don't crash but if i try in other machine (or even the same) with this pipeline
gst-launch tcpclientsrc host=127.0.0.1 port=5000 ! jpegdec ! queue ! video/x-raw-rgb,width=320,height=240 ! ffmpegcolorspace ! queue ! glimagesink sync=false
I can't get something.. the pipeline never goes
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