Assign buffer to sink pad of tsdemux element
Mayank Agarwal
mayank77fromindia at gmail.com
Tue Apr 21 04:38:50 PDT 2015
Hi,
I am downloading tsfile content into fragment and then assigning it to GstBuffer
Now i am creating the pipeline to play ts file using gstreamer element.
1. Is it possible to play ts file exactly the same way if i give ts
path as uri to playbin
2.I want to realize ABR player like that e,g
A thread will be running to gauge the network bandwidth
and according to that i will be downloading the ts file in real time
and give it for playing to
the gstreamer pipeline.Is the above scheme ok to build ABR player
using gstreamer or there
can be alternate approach
3.Instead of above approach if i should write code for building
pipeline as described in following link:
https://coaxion.net/blog/wp-content/uploads/2014/05/hls-av.png
Does souphttpsrc takes care of adaptive bit rate functionality or it
has to be modified by writing own algorithm.
Please guide
Best Regards
Mayank
#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