Can't push data from Nvidia API in Appsrc

TJay yalcin.kilic87 at gmail.com
Sat Sep 26 11:05:53 PDT 2015


Hi,

as i mentioned before i am trying to push data which i get from the Nvidia
GRID API into my Gstreamer Buffer.

Here are the important code snippets of my App:


typedef struct _ThreadData ThreadData;

struct _ThreadData {
   GAsyncQueue *bufferQueue;
   deque <gsize> count_of_elements_each_frame;
}: ThreadData threadData;


static void display(){
/* GL context stuff and Nvidia API which give me encoded h264 data for each
frame in the void pointer *data* and the *dataSize* of  *data*. So what i
want, push the data from the api to my gstreamer buffer! */

/* Nvidia API Locks data, where i load the data into my queue */
   g_async_queue_lock(threadData.bufferQueue);	
   g_async_queue_push_unlocked(threadData.bufferQueue,&data);
   threadData.count_of_elements_each_frame.push_back(dataSize);
   g_async_queue_unlock(threadData.bufferQueue);
...
/*as a sample, the data will be written into a file */
  fwrite(data, 1, dataSize, outfile);

}


I have implented the Gstreamer Stuff in another Thread. When I load the
source data from a the outfile on my hdd, everthing works fine(load the File
with GMappedFile and then get the content and push it to appsrc).But as you
already know, this is not effient and quite a bottleneck!

So i tried it with the async bufferqueue and my cb_need_data looks like
this:



static gboolean cb_need_data (App * app){

    static GstClockTime timestamp = 0;
    GstBuffer *buffer, *inputFrameBuffer;
    gpointer enc_frame;
    gsize maxSize;
    GstFlowReturn ret;

    buffer= gst_buffer_new();
    
    g_async_queue_lock(threadData.bufferQueue);

    while(g_async_queue_length_unlocked(threadData.bufferQueue) > 1 ) // one
frame should be buffer
    {
    enc_frame = g_async_queue_pop_unlocked(threadData.bufferQueue);
    length = threadData.count_of_elements_each_frame.front();
    threadData.count_of_elements_each_frame.pop_front();

   inputFrameBuffer = gst_buffer_new_allocate(NULL, length, NULL);

   gst_buffer_fill(inputFrameBuffer, 0, enc_frame, length);

   buffer = gst_buffer_append(buffer, inputFrameBuffer);
   }
   
   g_async_queue_unlock(threadData.bufferQueue);
   
   g_signal_emit_by_name (app->appsrc, "push-buffer", buffer, &ret);
   gst_buffer_unref(buffer);

   return TRUE;
}

static void start_feed (GstElement * pipeline, guint size, App * app){
   if (app->sourceid == 0){
    app->sourceid = g_timeout_add (67, (GSourceFunc) cb_need_data, app);
   }
}

static void stop_feed (GstElement * pipeline, App * app){
  if (app->sourceid != 0) {
    //GST_DEBUG ("stop feeding");
    g_source_remove (app->sourceid);
    app->sourceid = 0;
  }
}


the data should be passed to a client via udp. my gstreamer pipeline looks
like this:
server: appsrc ! h264parse ! rtph264pay ! udpsink 
receiver: udpsrc ! application/x-rtp, encoding-name=H264, payload=86 !
rtph264depay ! h264parse ! avdec_h264 ! autovideosink


But the client does not receive any data from the server. I used the same
pipeline c code with appsrc and the file loaded vie GMappedFile and than
push it to the gstreamer buffer. so the pipeline c code is fine, the
cb_need_data function is the only difference here. 

there is also no failure during app run.

Did i missed something? or where is my failure?

Best Regards




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Can-t-push-data-from-Nvidia-API-in-Appsrc-tp4673848.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list