GNOME Bugzilla – Bug 709770
[PATCH] signal for message received by GstRTSPMedia
Last modified: 2018-01-13 14:25:30 UTC
diff -r d196ca9dfc7a gst/rtsp-server/rtsp-media.c --- a/gst/rtsp-server/rtsp-media.c Fri Sep 27 10:38:39 2013 -0600 +++ b/gst/rtsp-server/rtsp-media.c Wed Oct 09 14:13:37 2013 -0600 @@ -56,6 +56,7 @@ SIGNAL_PREPARED, SIGNAL_UNPREPARED, SIGNAL_NEW_STATE, + SIGNAL_BUS_MESSAGE, SIGNAL_LAST }; @@ -137,6 +138,11 @@ G_STRUCT_OFFSET (GstRTSPMediaClass, new_state), NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 0, G_TYPE_INT); + gst_rtsp_media_signals[SIGNAL_BUS_MESSAGE] = + g_signal_new ("bus-message", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstRTSPMediaClass, bus_message), NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_MESSAGE); + klass->context = g_main_context_new (); klass->loop = g_main_loop_new (klass->context, TRUE); @@ -1517,6 +1523,8 @@ { GstMessageType type; + g_signal_emit (media, gst_rtsp_media_signals[SIGNAL_BUS_MESSAGE], 0, message,NULL); + type = GST_MESSAGE_TYPE (message); switch (type) { @@ -1622,6 +1630,7 @@ gst_message_type_get_name (type)); break; } + return TRUE; } diff -r d196ca9dfc7a gst/rtsp-server/rtsp-media.h --- a/gst/rtsp-server/rtsp-media.h Fri Sep 27 10:38:39 2013 -0600 +++ b/gst/rtsp-server/rtsp-media.h Wed Oct 09 14:13:37 2013 -0600 @@ -260,6 +260,7 @@ gboolean (*unprepared) (GstRTSPMedia *media); gboolean (*new_state) (GstRTSPMedia *media, GstState state); + gboolean (*bus_message) (GstRTSPMedia *media, GstMessage *message); }; GType gst_rtsp_media_get_type (void);
We usually use subclassing to get the messages because then you can modify or drop the message or decide to call the parent before or after you custom implementation. You can actually do all that if you hook the vmethod in a signal. I would accept a patch do implement it like that.