Gstreamer: Live streaming pause with flicker observed when using appsink in gstreamer pipeline over Wifi network

Manish manish434k at yahoo.com
Wed Nov 18 04:07:55 PST 2015


We are trying to live stream video from udpsrc in our qt application using
gstreamer 

We tried following pipeline directly from command line:
- gst-launch-1.0 udpsrc port=5000 caps =\"application/x-rtp,
media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264\" !
rtph264depay ! avdec_h264 !  autovideosink sync=false  async=false
enable-last-buffer=true

and it is working fine(no pause or flicker is observed)


We have used same pipeline in our code with little difference (appsink in
place of autovideosink).
Due to some image processing requirement we needed to hook the stream buffer
and then display (after image processing), "appsink" is used for hooking the
data buffer.

- gstreamer pipeline: "udpsrc port=5000 caps =\"application/x-rtp,
media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264\" !
rtph264depay ! avdec_h264 ! videoconvert ! video/x-raw,format=RGB16 !
appsink name=sink sync=false  async=false"

this case pause is ovserved 



please find below code for reference:



void CAVCaptureWifi::startGStreamerPipe()
{
   GError *error = NULL;

   /* create a new pipeline */
   
   gchar *descr = (gchar*) "udpsrc port=5000 caps =\"application/x-rtp,
media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264\" !
rtph264depay ! avdec_h264 ! videoconvert ! video/x-raw,format=RGB16 !
appsink name=sink sync=false  async=false";
   pipeline = gst_parse_launch (descr, &error);

   if (error != NULL) {
     g_print ("could not construct pipeline: %s\n", error->message);
     g_error_free (error);
     exit (-1);
   }

   /* get sink */
   sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");

   
   gst_app_sink_set_drop(GST_APP_SINK(sink), true);
   gst_app_sink_set_max_buffers(GST_APP_SINK(sink), 100);

   gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);

   this->start(); // thread started for pulling buffer

}

// buffer pulling  in separate thread
void CAVCaptureWifi::run()
{
    while(1)
    {
        new_sample(GST_APP_SINK(sink),this);
        msleep(20);
    }
}


static GstFlowReturn new_sample(GstAppSink *appsink, gpointer data1)
{

  CAVCaptureWifi *data =NULL;
  data = (CAVCaptureWifi*)data1;

  gboolean res;

  GstSample *sample = NULL;
  sample = gst_app_sink_pull_sample(appsink);
  if(NULL == sample)
  {
    g_print ("could not get gst sample \n");
    return GST_FLOW_OK;
  }
  GstCaps *caps = NULL;
  /* get the snapshot buffer format now. We set the caps on the appsink so
   * that it can only be an rgb buffer. The only thing we have not specified
   * on the caps is the height, which is dependant on the pixel-aspect-ratio
   * of the source material */
  caps = gst_sample_get_caps (sample);
  if (!caps) {
    g_print ("could not get snapshot format\n");
    //exit (-1);
    return GST_FLOW_OK;
  }
  GstStructure *s;
   s = gst_caps_get_structure (caps, 0);
   /* we need to get the final caps on the buffer to get the size */
   res = gst_structure_get_int (s, "width", &data->m_width);
   res |= gst_structure_get_int (s, "height", &data->m_height);
   if (!res) {
     g_print ("could not get snapshot dimension\n");
     //exit (-1);
     return GST_FLOW_OK;
   }

  GstBuffer *buffer = NULL;

  buffer = gst_sample_get_buffer(sample);
  if(NULL==buffer)
  {
      return GST_FLOW_OK;
  }

  //const GstStructure *info = gst_sample_get_info(sample);

  // ---- Read frame and emit frame ready signal---------------
  //GstMapInfo map;
  gst_buffer_map (buffer, &data->m_map, GST_MAP_READ);

  QImage image(data->m_map.data,data->m_width, data->m_height,
QImage::Format_RGB16);

  emit data->frameReady(image);

  gst_buffer_unmap(buffer, &data->m_map);

  gst_sample_unref (sample);
  return GST_FLOW_OK;
}





--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Gstreamer-Live-streaming-pause-with-flicker-observed-when-using-appsink-in-gstreamer-pipeline-over-Wk-tp4674553.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list