Hi guys,
I’m new in RTSP server Gstreamer, I want find out source port and destination port of RTP packet when a client connect to RTSP server with UDP transport. actually my RTSP server is behind NAT and I want use UPNP to dynamically port forward.
This is my source code
static void on_ssrc_active (GObject * session, GObject * source, GstRTSPMedia * media) { GstStructure *stats;
GST_INFO ("source %p in session %p is active", source, session);
g_object_get (source, "stats", &stats, NULL);
if (stats) {
gchar *sstr;
sstr = gst_structure_to_string (stats);
g_print ("structure: %s\n", sstr);
g_free (sstr);
gst_structure_free (stats);
}
}
static void
on_sender_ssrc_active (GObject * session, GObject * source,
GstRTSPMedia * media)
{
GstStructure *stats;
GST_INFO ("source %p in session %p is active", source, session);
g_object_get (source, "stats", &stats, NULL);
if (stats) {
gchar *sstr;
sstr = gst_structure_to_string (stats);
g_print ("Sender stats:\nstructure: %s\n", sstr);
g_free (sstr);
gst_structure_free (stats);
}
}
static void
media_prepared_cb (GstRTSPMedia * media)
{
guint i, n_streams;
n_streams = gst_rtsp_media_n_streams (media);
GST_INFO ("media %p is prepared and has %u streams", media, n_streams);
for (i = 0; i < n_streams; i++) {
GstRTSPStream *stream;
GObject *session;
stream = gst_rtsp_media_get_stream (media, i);
if (stream == NULL)
continue;
session = gst_rtsp_stream_get_rtpsession (stream);
GST_INFO ("watching session %p on stream %u", session, i);
gst_rtsp_session_get_header((GstRTSPSession *)session);
g_signal_connect (session, "on-ssrc-active",
(GCallback) on_ssrc_active, media);
g_signal_connect (session, "on-sender-ssrc-active",
(GCallback) on_sender_ssrc_active, media);
}
}
void static media_configure_handler(GstRTSPMediaFactory *factory, GstRTSPMedia *media,
udp *This) {
g_signal_connect (media, "prepared", (GCallback) media_prepared_cb, factory); }
I tried above code but it didn’t work.
Thanks so much.