BadShmSeg when adding textoverlay dynamically

Francisco Velázquez francisco.javier at me.com
Sat Nov 15 07:53:01 PST 2014


Hi Tim

Thank you for your reply.

I have updated the code following your advices from a) and b). The code, however, is still throwing a BadShmSeg error. The code is in this link: http://pastebin.com/tevjhKdp, the debug log is here: http://pastebin.com/FxUGswTE.

Your advice in c) works fine. When using elements in silent mode, do they still introduce an overhead? For example, do they perform some copy operations that can impact performance? does it depend on the implementation of each element, or does the GStreamer framework handle silent elements as they were not instantiated?

Do you know what else can I try to make it work when adding dynamically the textoverlay into the pipeline? I would like to apply similar scenarios for other pipelines. In my scenarios, it is relatively unknown the element that will come in the future. Therefore, I cannot link them before using the “silent” property.

Best regards,

Francisco.

> On 14 Nov 2014, at 22:00, Tim Müller <tim at centricular.com> wrote:
> 
> On Fri, 2014-11-14 at 21:46 +0100, Francisco Velázquez wrote:
> 
> Hi Francisco,
> 
> I have not tried running your code, just some observations:
> 
> a) there's no need to remove the videosink and then to re-add it again
> right after. It shouldn't *hurt* either of course, but it's a bit weird.
> 
> b) you should set the state from sink to source, so try setting the sink
> to playing state first, then the text overlay in your callback.
> 
> c) why not just leave the textoverlay in the pipeline at all times? You
> can just put it into do-nothing passthrough mode with
> 
>  g_object_set (textoverlay, "silent", TRUE, NULL);
> 
> Much easier than adding/removing it while the pipeline is running. Not
> that that shouldn't work as well of course.
> 
> Cheers
>  -Tim
> 
>> Dear GStreamer community,
>> 
>> I'm trying to add a text overlay on-the-fly but I am getting BadShmSeg error. The most simple pipeline to reproduce this error changes from:
>> 
>> videotestsrc ! ximagesink 
>> 
>> to: 
>> 
>> videotestsrc ! textoverlay text="Hello World!" ! imagesink.
>> 
>> The code is:
>> ---------------------------
>> 
>> #include <gst/gst.h>
>> 
>> static GstPad *videosrc_blockpad;
>> static GstElement *videosrc, *videosink, *pipeline, *textoverlay;
>> 
>> static GstPadProbeReturn pad_probe_videosrc_cb(GstPad * videosrc_pad, GstPadProbeInfo * info, gpointer user_data){
>> 
>>    /* unlink videotestsrc from ximagesink */
>>    gst_element_set_state(videosink, GST_STATE_NULL);
>>    gst_bin_remove(GST_BIN(pipeline), videosink);
>> 
>>    /* adding the textoverlay */
>>    textoverlay = gst_element_factory_make("textoverlay", NULL);
>>    g_object_set(G_OBJECT (textoverlay), "text", "Hello World!", NULL);
>>    gst_bin_add_many(GST_BIN(pipeline), textoverlay, videosink, NULL);
>> 
>>    /* inserting the text overlay */
>>    gst_element_link_many(videosrc, textoverlay, videosink, NULL);
>> 
>>    /* I might need to setup a GST_STATE_PLAYING again. */
>>    gst_element_set_state(textoverlay, GST_STATE_PLAYING);
>>    gst_element_set_state(videosink, GST_STATE_PLAYING);
>> 
>>    gst_debug_set_threshold_from_string ("*:5", TRUE);
>> 
>>    return GST_PAD_PROBE_REMOVE;
>> }
>> 
>> static gboolean timeout_cb (gpointer user_data){
>> 
>>    gst_pad_add_probe (videosrc_blockpad, GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM, pad_probe_videosrc_cb, user_data, NULL);
>>    return FALSE;
>> }
>> 
>> int main (int argc, char **argv){
>>    GMainLoop *loop;
>> 
>>    /* init GStreamer */
>>    gst_init (&argc, &argv);
>>    loop = g_main_loop_new (NULL, FALSE);
>> 
>>    videosrc = gst_element_factory_make("videotestsrc", NULL);
>>    videosrc_blockpad = gst_element_get_static_pad(videosrc, "src");
>> 
>>    videosink = gst_element_factory_make("ximagesink", NULL);
>> 
>>    pipeline = gst_pipeline_new("pipeline");
>> 
>>    gst_bin_add_many(GST_BIN(pipeline), videosrc, videosink, NULL);
>> 
>>    gst_element_link_many(videosrc, videosink, NULL);
>> 
>>    gst_element_set_state(pipeline, GST_STATE_PLAYING);
>> 
>>    g_timeout_add_seconds (5, timeout_cb, loop);
>> 
>>    g_main_loop_run (loop);
>> 
>>    gst_element_set_state (pipeline, GST_STATE_NULL);
>> 
>>    gst_object_unref (pipeline);
>> 
>>    return 0;
>> }
>> —————————
>> 
>> The error log:
>> 
>> ….
>> 
>> 0:00:06.233014000 43633    0x1020ea230 DEBUG              videosink gstvideosink.c:117:void gst_video_sink_center_rect(GstVideoRectangle, GstVideoRectangle, GstVideoRectangle *, gboolean): source is 320x240 dest is 320x240, result is 320x240 with x,y 0x0
>> X Error of failed request:  BadShmSeg (invalid shared segment parameter)
>>  Major opcode of failed request:  132 (MIT-SHM)
>>  Minor opcode of failed request:  3 (X_ShmPutImage)
>>  Segment id in failed request:  0x600003
>>  Serial number of failed request:  41
>>  Current serial number in output stream:  42
>> Program ended with exit code: 1
>> ———————————————————————————————————————————
>> 
>> Can somebody help me to find out what I'm doing wrong?
>> 
>> Thank you!
>> 
>> Francisco
>> _______________________________________________
>> gstreamer-devel mailing list
>> gstreamer-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> 
> -- 
> Tim Müller, Centricular Ltd - http://www.centricular.com
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



More information about the gstreamer-devel mailing list