Reputation: 2955
I am trying to create a pipeline and then add on a videosink after I've created it. I need to do this so I can set the video overlay window id of the videosink before I commit it to the pipeline.
so I have this code
pipeline = gst_parse_launch( "filesrc location=file.svg ! rsvgdec ! imagefreeze", &err );
sink = gst_element_factory_make( "glimagesink" );
gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY( sink ), this->winId() );
gst_bin_add_many( GST_BIN( pipeline ), sink, nullptr );
if ( !gst_element_link_many( pipeline, sink, nullptr ) )
{
qCritical() << "Unable to link elements";
}
When I run it it fails to link the elements.
Any idea why this is happening. I'm assuming it's because I'm trying to link an element to a "bin" rather than another element. However, I can't see any examples of where someone adds an element to a pipeline which was created through gst_parse_launch.
Upvotes: 2
Views: 2369
Reputation: 7373
You can't connect it to a bin. You need to specify a pad - or an element from where it tries to pick a pad. So you would need iterate through the bin and pick the imagefreeze
element from the list.
Alternative approach - add the sink and get it from the pipeline:
pipeline = gst_parse_launch( "filesrc location=file.svg ! rsvgdec ! imagefreeze ! glimagesink name=mysink", &err );
GstElement *sink = gst_bin_get_by_name( GST_BIN( pipeline ), "mysink" );
gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY( sink ), this->winId() );
gst_object_unref( sink );
You may have issues here as well tough as you may require a videoconvert
to satisfy the sink's format requirements.
filesrc location=file.svg ! rsvgdec ! imagefreeze ! videoconvert ! glimagesink
or maybe
filesrc location=file.svg ! rsvgdec ! imagefreeze ! glupload ! glcolorconvert ! glimagesink
Upvotes: 2