title: Custom Event Handling in GStreamer 1.0
body: <p>I am having a hard time wrapping my head around GStreamer event sending and handling. I understand the process, but can not achieve my desired outcome. I am developing a series of GStreamer plugins in tandem with a GStreamer main application. I have 3 plugins <code>my_src</code> which inherits from <code>GstPushSrc</code>, <code>my_transform</code> which inherits from <code>GstBaseTransform</code> and <code>my_sink</code> which inherits from <code>GstBaseSink</code>, and a main application <code>my_app</code>.</p>
  
  <p>I am trying to send a custom event from <code>my_app</code> to all elements in the pipeline telling them to reconfigure the processing parameters. This is different from <code>GST_EVENT_RECONFIGURE</code> because it does not involve any renegotiation of caps. I am sending the event from <code>my_app</code> with the following:</p>
  
  <pre><code>// my_app.c
  
  GstStructure *reconfigureStructure = gst_structure_new("reconfigure", NULL);
  GstEvent *reconfigureEvent = gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM, 
                                                    reconfigureStructure);
  gst_element_send_event(pipeline, reconfigureEvent);
  </code></pre>
  
  <p>I have overridden the <code>GstBaseSrc</code> <code>event()</code> method as follows:</p>
  
  <pre><code>// my_src.c
  
  static gboolean my_src_event(GstBaseSrc *bs, GstEvent *event);
  
  static void
  my_src_class_init(MySrcClass *msc)
  {
    GstBaseSrcClass *bsc = GST_BASE_SRC_CLASS(msc);
    bsc-&gt;event = my_src_event;
  }
  
  static gboolean
  my_src_event(GstBaseSrc *bs, GstEvent *event)
  {
    switch (GST_EVENT_TYPE(event)) {
      case GST_EVENT_CUSTOM_DOWNSTREAM: {
        const GstStructure *structure = gst_event_get_structure(event);
  
        if (gst_structure_has_name(structure, "reconfigure")) {
          g_print("MY SRC RECONFIGURE\n");
          // do reconfigure things
        }
  
        break;
      }
    }
  
    return GST_BASE_SRC_CLASS(parent_class)-&gt;event(bs, event);
  }
  </code></pre>
  
  <p>Similarly, I have overridden the <code>GstBaseSink</code> event handler as follows:</p>
  
  <pre><code>// my_sink.c
  
  static gboolean my_sink_event(GstBaseSink *bs, GstEvent *event);
  
  static void
  my_sink_class_init(MySinkClass *msc)
  {
    GstBaseSinkClass *bsc = GST_BASE_SINK_CLASS(msc);
    bsc-&gt;event = my_sink_event;
  }
  
  static gboolean
  my_sink_event(GstBaseSink *bs, GstEvent *event)
  {
    switch (GST_EVENT_TYPE(event)) {
      case GST_EVENT_CUSTOM_DOWNSTREAM: {
        const GstStructure *structure = gst_event_get_structure(event);
  
        if (gst_structure_has_name(structure, "reconfigure")) {
          g_print("MY SINK RECONFIGURE\n");
          // do reconfigure things
        }
  
        break;
      }
    }
  
    return GST_BASE_SINK_CLASS(parent_class)-&gt;event(bs, event);
  }
  </code></pre>
  
  <p>Lastly, I have overridden the <code>GstBaseTransform</code> <code>sink_event()</code> method as follows:</p>
  
  <pre><code>// my_transform.c
  
  static gboolean my_transform_sink_event(GstBaseTransform *bt, GstEvent *event);
  
  static void
  my_transform_class_init(MyTransformClass *mtc)
  {
    GstBaseTransformClass *btc = GST_BASE_TRANDFORM_CLASS(mtc);
    btc-&gt;sink_event = my_transform_sink_event;
  }
  
  static gboolean
  my_transform_sink_event(GstBaseTransfor *bt, GstEvent *event)
  {
    switch (GST_EVENT_TYPE(event)) {
      case GST_EVENT_CUSTOM_DOWNSTREAM: {
        const GstStructure *structure = gst_event_get_structure(event);
  
        if (gst_structure_has_name(structure, "reconfigure")) {
          g_print("MY TRANSFORM RECONFIGURE\n");
          // do reconfigure things
        }
  
        break;
      }
    }
  
    return GST_BASE_TRANSFORM_CLASS(parent_class)-&gt;sink_event(bt, event);
  }
  </code></pre>
  
  <p>When I run <code>my_app</code> I would expect the output to be:</p>
  
  <pre><code>MY SRC RECONFIGURE
  MY TRANSFORM RECONFIGURE
  MY SINK RECONFIGURE
  </code></pre>
  
  <p>However, I am only getting:</p>
  
  <pre><code>MY SINK RECONFIGURE
  </code></pre>
  
  <p>Any ideas what I am doing wrong here?</p>