|
Hi all,
i am implementing an rtsp server, which listens for UDP stream.
One concern is that if client is already connected rtsp server, which transmits active udp stream and after the udp stream is stopped (e.g. device streaming udp is disconnected) there is no way do disconnect the client from the server to indicate that the stream is not available.
The pipeline which i use to provide a stream:
> udpsrc port=4000 caps="application/x-rtp" ! rtph264depay ! rtph264pay name=pay0
There is a timeout property that for udpsrc element that should indicate that the stream is not available by sending GstUDPSrcTimeout message to the bus, but how can i connect to a bus of the pipeline, where udpsrc is resided.
I tried to catch a signals from GstRTSPMediaFactor up on media creation and apply next callback:
static void media_constructed_cb(GstRTSPMediaFactory * self,
GstRTSPMedia * object,
gpointer user_data)
{
GST_ERROR("Media constructed");
GstElement* element = gst_rtsp_media_get_element(object);
GstBus* bus = gst_element_get_bus(element);
gst_bus_add_signal_watch(bus);
g_signal_connect(G_OBJECT(bus), "message::element", G_CALLBACK(stream_to_cb), object);
gst_object_unref(bus);
gst_object_unref(element);
}
static void stream_to_cb(GstBus* bus, GstMessage* msg, GstRTSPMedia* media)
{
const GstStructure* st = gst_message_get_structure(msg);
GST_ERROR("Received message on the bus");
if(GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ELEMENT && gst_structure_has_name(st, "GstUDPSrcTimeout"))
GST_ERROR("RTP stream timeout");
}
But using this code i am not able to connect to create a watch for this bus receiving next messages:
(rtp-to-rtsp-server:16903): GStreamer-CRITICAL **: 19:56:53.161: gst_bus_create_watch: assertion 'bus->priv->poll != NULL' failed
(rtp-to-rtsp-server:16903): GStreamer-CRITICAL **: 19:56:53.161: Creating bus watch failed
(rtp-to-rtsp-server:16903): GStreamer-CRITICAL **: 19:56:53.161: Could not add signal watch to bus bus13
Am i doing something wrong or should i pick another approach to detect stream timeout?
|