QGst ApplicationSource

Matias Hernandez Arellano msdark at archlinux.cl
Mon Apr 18 19:35:59 PDT 2011


(sorry for my english)

I have an application that generate images and i need to stream this images (like a video) to another location through network (udpsink, tcpserversink, etc) .

I wan't to use QGst, my application is write with Qt (but without GUI).

So i use ApplicationSource to accomplish that (push the generated images into the pipeline to stream)..

And i get this: (A Thread class, read the images from a Circular Buffer)

StreamThread::StreamThread(FrameBuffer *b, QObject *parent):QThread(parent){
     this->ImageBuffer = b;
     QGst::init(NULL,NULL);
     qDebug()<<"Iniciando Stream ImageBuffer Size " << this->ImageBuffer->getBufferSize();
     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 ! multipartmux "
                               " ! 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);
}

//The run method
void StreamThread::run(){
    for(;;){
        Mat frame = this->ImageBuffer->getFrame();
        if(!this->m_src.element().isNull() && !frame.empty()){
            QGst::BufferPtr buffer = QGst::Buffer::create(640*480*3);
            quint8 *data = buffer->data();
            memcpy(buffer->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();
        }
    }
}


The Circular Buffer (ImageBuffer) represents a queue containing OpenCV frames, this represent the image like a (uchar*) matrix in frame.data

This run without problem, but if i try to see the stream in for example another terminal in the same machine (or other) with gst-launch tcpclientsrc port=5000 ! multipartdemux ! jpegdec ! ffmpegcolorspace ! glimagesink sync=false
 
This pipeline never go to PLAYING state ...

Any idea why??

i though in the buffer copy part.. i try to check what is in the buffer and i get always the same memory direction of *data .. so i think i never push valid data to appsrc ....


Thanks in advance


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