After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796351 - Pipeline with single named bin inside is incorrectly created
Pipeline with single named bin inside is incorrectly created
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.14.0
Other Windows
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-05-23 08:38 UTC by Daniel F
Modified: 2018-11-03 12:46 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Daniel F 2018-05-23 08:38:03 UTC
I tried to create pipeline which contained rtpbin with assigned name. Pipeline was created successfully, but I was not able to get bin from pipeline - gst_bin_get_by_name() returned NULL.

Example code:

#include <gst/gst.h>

int main(int argc, char* argv[])
{
  GOptionContext* context = g_option_context_new("");
  g_option_context_add_group(context, gst_init_get_option_group());
  g_option_context_parse(context, &argc, &argv, NULL);
  GMainLoop* loop = g_main_loop_new(NULL, FALSE);
  const char* p = "rtpbin name=bin";
  //GstElement* pipe = gst_parse_launch(p, NULL);
  GstElement* pipe = gst_parse_launch_full(p, NULL, GST_PARSE_FLAG_NONE, NULL);
  GstElement* bin = gst_bin_get_by_name(GST_BIN(pipe), "bin");
  g_assert_nonnull(bin);
  //gst_element_set_state(GST_ELEMENT(pipe), GST_STATE_PLAYING);
  g_main_loop_run(loop);
  return 0;
}

Logs:

# GST_DEBUG="*:4" ./test2
0:00:00.000197464 27515      0x1586800 INFO                GST_INIT gst.c:586:init_pre: Initializing GStreamer Core Library version 1.14.0
0:00:00.000448052 27515      0x1586800 INFO                GST_INIT gst.c:587:init_pre: Using library installed in /home/daniel/cerbero/build/dist/linux_x86_64/lib
0:00:00.000480487 27515      0x1586800 INFO                GST_INIT gst.c:607:init_pre: Linux daniel.localdomain 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64
0:00:00.001184472 27515      0x1586800 INFO                GST_INIT gstmessage.c:127:_priv_gst_message_initialize: init messages
0:00:00.002469879 27515      0x1586800 INFO                GST_INIT gstcontext.c:84:_priv_gst_context_initialize: init contexts
0:00:00.002989245 27515      0x1586800 INFO      GST_PLUGIN_LOADING gstplugin.c:317:_priv_gst_plugin_initialize: registering 0 static plugins
0:00:00.003220841 27515      0x1586800 INFO      GST_PLUGIN_LOADING gstplugin.c:225:gst_plugin_register_static: registered static plugin "staticelements"
0:00:00.003287932 27515      0x1586800 INFO      GST_PLUGIN_LOADING gstplugin.c:227:gst_plugin_register_static: added static plugin "staticelements", result: 1
0:00:00.003405086 27515      0x1586800 INFO            GST_REGISTRY gstregistry.c:1727:ensure_current_registry: reading registry cache: /root/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.045722933 27515      0x1586800 INFO            GST_REGISTRY gstregistrybinary.c:621:priv_gst_registry_binary_read_cache: loaded /root/.cache/gstreamer-1.0/registry.x86_64.bin in 0.042258 seconds
0:00:00.045827509 27515      0x1586800 INFO            GST_REGISTRY gstregistry.c:1583:scan_and_update_registry: Validating plugins from registry cache: /root/.cache/gstreamer-1.0/registry.x86_64.bin
0:00:00.048939530 27515      0x1586800 INFO            GST_REGISTRY gstregistry.c:1685:scan_and_update_registry: Registry cache has not changed
0:00:00.048952699 27515      0x1586800 INFO            GST_REGISTRY gstregistry.c:1762:ensure_current_registry: registry reading and updating done, result = 1
0:00:00.048964067 27515      0x1586800 INFO                GST_INIT gst.c:807:init_post: GLib runtime version: 2.54.3
0:00:00.048973419 27515      0x1586800 INFO                GST_INIT gst.c:809:init_post: GLib headers version: 2.54.3
0:00:00.048984738 27515      0x1586800 INFO                GST_INIT gst.c:810:init_post: initialized GStreamer successfully
0:00:00.049035232 27515      0x1586800 INFO            GST_PIPELINE gstparse.c:337:gst_parse_launch_full: parsing pipeline description 'rtpbin name=bin'
0:00:00.050520790 27515      0x1586800 INFO      GST_PLUGIN_LOADING gstplugin.c:901:_priv_gst_plugin_load_file_for_registry: plugin "/home/daniel/cerbero/build/dist/linux_x86_64/lib/gstreamer-1.0/libgstrtpmanager.so" loaded
0:00:00.050544098 27515      0x1586800 INFO     GST_ELEMENT_FACTORY gstelementfactory.c:361:gst_element_factory_create: creating element "rtpbin"
0:00:00.050944770 27515      0x1586800 INFO           GST_PARENTAGE gstbin.c:4466:gst_bin_get_by_name: [bin]: looking up child element bin
**
ERROR:test2.c:13:main: 'bin' should not be NULL
Aborted (core dumped)
Comment 1 Sebastian Dröge (slomo) 2018-05-24 06:32:13 UTC
This is expected. If there is only a single element, then only a single element is created instead of placing it in a bin.

Is this the problem here?
Comment 2 Daniel F 2018-05-24 08:39:38 UTC
My app handles RTP connections, non-WebRTC and WebRTC ones. I have function which creates audio source/encoding bin (using gst_parse_bin_from_description) and adds it to existing pipeline, which is used for both types of connections. For non-WebRTC my initial pipeline consists of rtpbin and two udpsrc elements, so it worked properly for me. However for WebRTC this initial pipeline has webrtcbin only, and this was not working for me as I expected. I had to modify my code to create both webrtcbin and my source/encoding bin at the same time, fortunately pipeline syntax is flexible enough.

I also wonder if functionality of GstPipeline is properly added to existing bin (or other kind of element) in such case.
Comment 3 Daniel F 2018-05-24 08:59:19 UTC
One more thing: documentation specifies that this kind of behavior is enabled by using GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS flag. There is no flag to force single-element bin (or pipeline), so I assumed that GstPipeline always will be created.
Comment 4 Tim-Philipp Müller 2018-05-24 09:13:36 UTC
FWIW I think you can do  ".bin ( rtpbin name=foo )".
Comment 5 GStreamer system administrator 2018-11-03 12:46:38 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/295.