Assign buffer to sink pad of tsdemux element

Mayank Agarwal mayank77fromindia at gmail.com
Fri Apr 17 06:28:55 PDT 2015


Hi,

I have written the following small code to play ts file .
Instead of giving the ts file path in uri or location i am downloading it
and then converting the fragment to buffer.
I want to give this buffer to tsdemux sink pad  and after that
i am creating pipeline to play using elements.

Please find my code below:



#include <gst/gst.h>

#include "gsturidownloader.h"


int main(int argc,char *argv[])
{



gchar *uri = "http://devimages.apple.com/iphone/samples/bipbop/gear3/fileSequence1.ts"
GstUriDownloader *downloader;
GstBuffer *buffer;
GstFragment *fragment;
GstElement *demuxer,*queue,*mpegvideoparse,*decoder,*autovideosink;

GError **err;


fragment = gst_fragment_new();

downloader = gst_uri_downloader_new ();

fragment = gst_uri_downloader_fetch_uri (downloader, uri, TRUE,
FALSE,FALSE,FALSE,err);
   if (fragment == NULL)
g_print("failed to download");
else
{
g_print("successfully downloaded");

buffer = gst_fragment_get_buffer (fragment);
}

/*  how to assign buffer to sink pad of tsdemux */

  demuxer = gst_element_factory_make("tsdemux","demuxer");
  if(demuxer == NULL)
  g_print("demuxer element cannot be created");
  queue = gst_element_factory_make("queue","queue");
  if(queue == NULL)
  g_print("queue element cannot be created");

  mpegvideoparse = gst_element_factory_make("mpegvideoparse","parse");
  if(queue == NULL)
  g_print("mpegvideoparse element cannot be created");

  decoder = gst_element_factory_make("mpeg2dec","decoder");
  if(queue == NULL)
  g_print("decoder element cannot be created");

  sink = gst_element_factory_make("autovideosink","sink");
  if(queue == NULL)
  g_print("sink element cannot be created");


   pipeline = gst_pipeline_new ("test-pipeline");
   if(pipeline == NULL)
   g_print("pipeline element cannot be created");


    gst_bin_add_many (GST_BIN (pipeline),
tsdemux,queue,mpegvideoparse,mpeg2dec,autovideosink,NULL);
  if (!gst_element_link_many (
tsdemux,queue,mpegvideoparse,mpeg2dec,autovideosink)) {
    g_printerr ("Elements could not be linked.\n");
    gst_object_unref (data.pipeline);
    return -1;
  }


  /* Start playing */
  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
  if (ret == GST_STATE_CHANGE_FAILURE) {
    g_printerr ("Unable to set the pipeline to the playing state.\n");
    gst_object_unref (data.pipeline);
    return -1;
  }



gst_object_unref(uri);
gst_object_unref(fragment);
gst_object_unref(buffer);


}


More information about the gstreamer-devel mailing list