diff options
-rw-r--r-- | gst/rtsp/gstrtspsrc.c | 85 | ||||
-rw-r--r-- | gst/rtsp/gstrtspsrc.h | 4 |
2 files changed, 89 insertions, 0 deletions
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 64b501cb9..667211a33 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -150,2 +150,3 @@ enum #define DEFAULT_DO_RTCP TRUE +#define DEFAULT_PROXY NULL @@ -164,2 +165,3 @@ enum PROP_DO_RTCP, + PROP_PROXY, PROP_LAST @@ -354,2 +356,15 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass) + /** + * GstRTSPSrc::proxy + * + * Set the proxy parameters. This has to be a string of the format + * [user:passwd@]host[:port]. + * + * Since: 0.10.15 + */ + g_object_class_install_property (gobject_class, PROP_PROXY, + g_param_spec_string ("proxy", "Proxy", + "Proxy settings for HTTP tunneling. Format: [user:passwd@]host[:port]", + DEFAULT_PROXY, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + gstelement_class->change_state = gst_rtspsrc_change_state; @@ -425,2 +440,49 @@ gst_rtspsrc_finalize (GObject * object) +/* a proxy string of the format [user:passwd@]host[:port] */ +static gboolean +gst_rtspsrc_set_proxy (GstRTSPSrc * rtsp, const gchar * proxy) +{ + gchar *p, *at, *col; + + g_free (rtsp->proxy_user); + rtsp->proxy_user = NULL; + g_free (rtsp->proxy_passwd); + rtsp->proxy_passwd = NULL; + g_free (rtsp->proxy_host); + rtsp->proxy_host = NULL; + rtsp->proxy_port = 0; + + p = (gchar *) proxy; + + if (p == NULL) + return TRUE; + + at = strchr (p, '@'); + if (at) { + /* look for user:passwd */ + col = strchr (proxy, ':'); + if (col == NULL || col > at) + return FALSE; + + rtsp->proxy_user = g_strndup (p, col - p); + col++; + rtsp->proxy_passwd = g_strndup (col, at - col); + + /* move to host */ + p = at + 1; + } + col = strchr (p, ':'); + + if (col) { + /* everything before the colon is the hostname */ + rtsp->proxy_host = g_strndup (p, col - p); + p = col + 1; + rtsp->proxy_port = strtoul (p, (char **) &p, 10); + } else { + rtsp->proxy_host = g_strdup (p); + rtsp->proxy_port = 8080; + } + return TRUE; +} + static void @@ -475,2 +537,5 @@ gst_rtspsrc_set_property (GObject * object, guint prop_id, const GValue * value, break; + case PROP_PROXY: + gst_rtspsrc_set_proxy (rtspsrc, g_value_get_string (value)); + break; default: @@ -526,2 +591,15 @@ gst_rtspsrc_get_property (GObject * object, guint prop_id, GValue * value, break; + case PROP_PROXY: + { + gchar *str; + + if (rtspsrc->proxy_host) { + str = + g_strdup_printf ("%s:%d", rtspsrc->proxy_host, rtspsrc->proxy_port); + } else { + str = NULL; + } + g_value_take_string (value, str); + break; + } default: @@ -4323,2 +4401,9 @@ restart: + if (src->proxy_host) { + GST_DEBUG_OBJECT (src, "setting proxy %s:%d", src->proxy_host, + src->proxy_port); + gst_rtsp_connection_set_proxy (src->connection, src->proxy_host, + src->proxy_port); + } + /* connect */ diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h index c90e671ae..2e41c2749 100644 --- a/gst/rtsp/gstrtspsrc.h +++ b/gst/rtsp/gstrtspsrc.h @@ -190,2 +190,6 @@ struct _GstRTSPSrc { gboolean do_rtcp; + gchar *proxy_host; + guint proxy_port; + gchar *proxy_user; + gchar *proxy_passwd; |