gst_bin_get_by_name returns NULL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gst_bin_get_by_name returns NULL

Marcin Rosner
Hi all,

I am using gstreamer 1.2.4 and the function gst_bin_get_by_name always returns NULL when I pass a valid and working pipeline to it.
Here a code which I took from a gstreamer tutorial and modified a bit:

gst_init (NULL, NULL);

GstElement* pipeline = gst_parse_launch("videotestsrc ! xvimagesink", NULL);
GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink");
gst_element_set_state (pipeline, GST_STATE_PLAYING);

GMainLoop *loop;
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);

The code works and a test video is shown on a screen, but sink is NULL as also sinkpads and srcpads from the pipeline.
Why is that? How should I do it properly?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst_bin_get_by_name returns NULL

Mikl

Hello, Marcin


How you can see here

https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBin.html#gst-bin-get-by-name

It finding element by name.

But elements in you pipeline have no name.


If you will make elements like this

GstElement* element= gst_element_factory_make(videotestsrc , "videotestsrc");

you can find it latter by name

GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "videotestsrc");


Mikl


From: gstreamer-devel <[hidden email]> on behalf of Marcin Rosner <[hidden email]>
Sent: Thursday, October 27, 2016 2:29:11 PM
To: [hidden email]
Subject: gst_bin_get_by_name returns NULL
 
Hi all,

I am using gstreamer 1.2.4 and the function gst_bin_get_by_name always returns NULL when I pass a valid and working pipeline to it.
Here a code which I took from a gstreamer tutorial and modified a bit:

gst_init (NULL, NULL);

GstElement* pipeline = gst_parse_launch("videotestsrc ! xvimagesink", NULL);
GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink");
gst_element_set_state (pipeline, GST_STATE_PLAYING);

GMainLoop *loop;
loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);

The code works and a test video is shown on a screen, but sink is NULL as also sinkpads and srcpads from the pipeline.
Why is that? How should I do it properly?

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst_bin_get_by_name returns NULL

Tim Müller
In reply to this post by Marcin Rosner
On Thu, 2016-10-27 at 14:29 +0200, Marcin Rosner wrote:

Hi Marcin,

> GstElement* pipeline = gst_parse_launch("videotestsrc ! xvimagesink",
> NULL);
> GstElement* sink = gst_bin_get_by_name(GST_BIN(pipeline), "sink");
> gst_element_set_state (pipeline, GST_STATE_PLAYING);
> ...
>
> The code works and a test video is shown on a screen, but sink is
> NULL as also sinkpads and srcpads from the pipeline.
> Why is that? How should I do it properly?

You're not giving a name to the xvimagesink element, so gstreamer picks
its own default name, which will be "xvimagesink0" most likely.

Try: "videotestsrc ! xvimagesink name=sink"

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel