gst/rtsp/: Reuse already existing enum for lower transport.

Original commit message from CVS:
* gst/rtsp/gstrtspsrc.c: (gst_rtsp_lower_trans_get_type),
(gst_rtspsrc_class_init), (gst_rtspsrc_loop_interleaved),
(gst_rtspsrc_loop_udp), (gst_rtspsrc_open),
(gst_rtspsrc_uri_get_protocols), (gst_rtspsrc_uri_set_uri):
* gst/rtsp/rtspconnection.c: (rtsp_connection_create):
* gst/rtsp/rtspdefs.h:
* gst/rtsp/rtspurl.c: (rtsp_url_parse):
* gst/rtsp/rtspurl.h:
Reuse already existing enum for lower transport.
Add rtspt and rtspu protocols.
Send redirect to rtspt when udp times out.
This commit is contained in:
Wim Taymans 2006-10-18 16:18:55 +00:00
parent 02ae90eaf4
commit b14738fb20
6 changed files with 70 additions and 34 deletions

View file

@ -1,3 +1,17 @@
2006-10-18 Wim Taymans <wim@fluendo.com>
* gst/rtsp/gstrtspsrc.c: (gst_rtsp_lower_trans_get_type),
(gst_rtspsrc_class_init), (gst_rtspsrc_loop_interleaved),
(gst_rtspsrc_loop_udp), (gst_rtspsrc_open),
(gst_rtspsrc_uri_get_protocols), (gst_rtspsrc_uri_set_uri):
* gst/rtsp/rtspconnection.c: (rtsp_connection_create):
* gst/rtsp/rtspdefs.h:
* gst/rtsp/rtspurl.c: (rtsp_url_parse):
* gst/rtsp/rtspurl.h:
Reuse already existing enum for lower transport.
Add rtspt and rtspu protocols.
Send redirect to rtspt when udp times out.
2006-10-18 Wim Taymans <wim@fluendo.com> 2006-10-18 Wim Taymans <wim@fluendo.com>
* gst/wavparse/gstwavparse.c: (gst_wavparse_perform_seek), * gst/wavparse/gstwavparse.c: (gst_wavparse_perform_seek),

View file

@ -143,22 +143,23 @@ enum
PROP_TIMEOUT, PROP_TIMEOUT,
}; };
#define GST_TYPE_RTSP_PROTO (gst_rtsp_proto_get_type()) #define GST_TYPE_RTSP_LOWER_TRANS (gst_rtsp_lower_trans_get_type())
static GType static GType
gst_rtsp_proto_get_type (void) gst_rtsp_lower_trans_get_type (void)
{ {
static GType rtsp_proto_type = 0; static GType rtsp_lower_trans_type = 0;
static const GFlagsValue rtsp_proto[] = { static const GFlagsValue rtsp_lower_trans[] = {
{RTSP_LOWER_TRANS_UDP, "UDP Unicast Mode", "udp-unicast"}, {RTSP_LOWER_TRANS_UDP, "UDP Unicast Mode", "udp-unicast"},
{RTSP_LOWER_TRANS_UDP_MCAST, "UDP Multicast Mode", "udp-multicast"}, {RTSP_LOWER_TRANS_UDP_MCAST, "UDP Multicast Mode", "udp-multicast"},
{RTSP_LOWER_TRANS_TCP, "TCP interleaved mode", "tcp"}, {RTSP_LOWER_TRANS_TCP, "TCP interleaved mode", "tcp"},
{0, NULL, NULL}, {0, NULL, NULL},
}; };
if (!rtsp_proto_type) { if (!rtsp_lower_trans_type) {
rtsp_proto_type = g_flags_register_static ("GstRTSPProto", rtsp_proto); rtsp_lower_trans_type =
g_flags_register_static ("GstRTSPLowerTrans", rtsp_lower_trans);
} }
return rtsp_proto_type; return rtsp_lower_trans_type;
} }
static void gst_rtspsrc_base_init (gpointer g_class); static void gst_rtspsrc_base_init (gpointer g_class);
@ -245,7 +246,7 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
g_object_class_install_property (gobject_class, PROP_PROTOCOLS, g_object_class_install_property (gobject_class, PROP_PROTOCOLS,
g_param_spec_flags ("protocols", "Protocols", g_param_spec_flags ("protocols", "Protocols",
"Allowed lower transport protocols", GST_TYPE_RTSP_PROTO, "Allowed lower transport protocols", GST_TYPE_RTSP_LOWER_TRANS,
DEFAULT_PROTOCOLS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); DEFAULT_PROTOCOLS, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (gobject_class, PROP_DEBUG, g_object_class_install_property (gobject_class, PROP_DEBUG,
@ -1170,8 +1171,10 @@ receive_error:
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Could not receive message. (%s)", str)); ("Could not receive message. (%s)", str));
g_free (str); g_free (str);
if (src->debug) if (src->debug)
rtsp_message_dump (&response); rtsp_message_dump (&response);
rtsp_message_unset (&response); rtsp_message_unset (&response);
ret = GST_FLOW_UNEXPECTED; ret = GST_FLOW_UNEXPECTED;
goto need_pause; goto need_pause;
@ -1250,6 +1253,8 @@ gst_rtspsrc_loop_udp (GstRTSPSrc * src)
/* see if we have TCP left to try */ /* see if we have TCP left to try */
if (src->cur_protocols & RTSP_LOWER_TRANS_TCP) { if (src->cur_protocols & RTSP_LOWER_TRANS_TCP) {
gchar *url, *pos;
/* We post a warning message now to inform the user /* We post a warning message now to inform the user
* that nothing happened. It's most likely a firewall thing. */ * that nothing happened. It's most likely a firewall thing. */
GST_ELEMENT_WARNING (src, RESOURCE, READ, (NULL), GST_ELEMENT_WARNING (src, RESOURCE, READ, (NULL),
@ -1258,14 +1263,23 @@ gst_rtspsrc_loop_udp (GstRTSPSrc * src)
(gdouble) src->timeout / 1000000)); (gdouble) src->timeout / 1000000));
/* we can try only TCP now */ /* we can try only TCP now */
src->cur_protocols = RTSP_LOWER_TRANS_TCP; src->cur_protocols = RTSP_LOWER_TRANS_TCP;
gst_rtspsrc_open (src);
gst_rtspsrc_play (src); pos = strstr (src->location, "://");
if (!pos)
goto weird_url;
url = g_strdup_printf ("rtspt://%s", pos + 3);
gst_element_post_message (GST_ELEMENT_CAST (src),
gst_message_new_element (GST_OBJECT_CAST (src),
gst_structure_new ("redirect",
"new-location", G_TYPE_STRING, url, NULL)));
g_free (url);
} else { } else {
src->cur_protocols = 0; src->cur_protocols = 0;
/* no transport possible, post an error */ /* no transport possible, post an error and stop */
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Could not receive any UDP packets for %.4f seconds, maybe your " ("Could not connect to server, no protocols left"));
"firewall is blocking it.", (gdouble) src->timeout / 1000000));
} }
} }
return; return;
@ -1278,6 +1292,12 @@ stopping:
gst_task_pause (src->task); gst_task_pause (src->task);
return; return;
} }
weird_url:
{
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Could not redirect, location %s is invalid", src->location));
return;
}
} }
static void static void
@ -1738,9 +1758,9 @@ gst_rtspsrc_open (GstRTSPSrc * src)
if (src->extension && src->extension->parse_sdp) if (src->extension && src->extension->parse_sdp)
src->extension->parse_sdp (src->extension, &sdp); src->extension->parse_sdp (src->extension, &sdp);
/* we initially allow all configured lower transports. based on the /* we initially allow all configured lower transports. based on the URL
* replies from the server we narrow them down. */ * transports and the replies from the server we narrow them down. */
protocols = src->cur_protocols; protocols = src->url->transports & src->cur_protocols;
/* setup streams */ /* setup streams */
n_streams = sdp_message_medias_len (&sdp); n_streams = sdp_message_medias_len (&sdp);
@ -2230,7 +2250,7 @@ gst_rtspsrc_uri_get_type (void)
static gchar ** static gchar **
gst_rtspsrc_uri_get_protocols (void) gst_rtspsrc_uri_get_protocols (void)
{ {
static gchar *protocols[] = { "rtsp", NULL }; static gchar *protocols[] = { "rtsp", "rtspu", "rtspt", NULL };
return protocols; return protocols;
} }
@ -2267,6 +2287,8 @@ gst_rtspsrc_uri_set_uri (GstURIHandler * handler, const gchar * uri)
src->url = newurl; src->url = newurl;
g_free (src->location); g_free (src->location);
src->location = g_strdup (uri); src->location = g_strdup (uri);
if (!g_str_has_prefix (src->location, "rtsp://"))
memmove (src->location + 4, src->location + 5, strlen (src->location) - 4);
GST_DEBUG_OBJECT (src, "set uri: %s", GST_STR_NULL (uri)); GST_DEBUG_OBJECT (src, "set uri: %s", GST_STR_NULL (uri));

View file

@ -120,9 +120,6 @@ rtsp_connection_create (RTSPUrl * url, RTSPConnection ** conn)
g_return_val_if_fail (url != NULL, RTSP_EINVAL); g_return_val_if_fail (url != NULL, RTSP_EINVAL);
g_return_val_if_fail (conn != NULL, RTSP_EINVAL); g_return_val_if_fail (conn != NULL, RTSP_EINVAL);
if (url->protocol != RTSP_PROTO_TCP)
return RTSP_ENOTIMPL;
newconn = g_new (RTSPConnection, 1); newconn = g_new (RTSPConnection, 1);
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32

View file

@ -70,11 +70,6 @@ typedef enum {
RTSP_ELAST = -14, RTSP_ELAST = -14,
} RTSPResult; } RTSPResult;
typedef enum {
RTSP_PROTO_TCP,
RTSP_PROTO_UDP,
} RTSPProto;
typedef enum { typedef enum {
RTSP_FAM_NONE, RTSP_FAM_NONE,
RTSP_FAM_INET, RTSP_FAM_INET,

View file

@ -49,6 +49,8 @@
#define RTSP_PROTO_LEN 7 #define RTSP_PROTO_LEN 7
#define RTSPU_PROTO "rtspu://" #define RTSPU_PROTO "rtspu://"
#define RTSPU_PROTO_LEN 8 #define RTSPU_PROTO_LEN 8
#define RTSPT_PROTO "rtspt://"
#define RTSPT_PROTO_LEN 8
/* format is rtsp[u]://[user:passwd@]host[:port]/abspath */ /* format is rtsp[u]://[user:passwd@]host[:port]/abspath */
@ -65,11 +67,16 @@ rtsp_url_parse (const gchar * urlstr, RTSPUrl ** url)
p = (gchar *) urlstr; p = (gchar *) urlstr;
if (g_str_has_prefix (p, RTSP_PROTO)) { if (g_str_has_prefix (p, RTSP_PROTO)) {
res->protocol = RTSP_PROTO_TCP; res->transports =
RTSP_LOWER_TRANS_TCP | RTSP_LOWER_TRANS_UDP |
RTSP_LOWER_TRANS_UDP_MCAST;
p += RTSP_PROTO_LEN; p += RTSP_PROTO_LEN;
} else if (g_str_has_prefix (p, RTSPU_PROTO)) { } else if (g_str_has_prefix (p, RTSPU_PROTO)) {
res->protocol = RTSP_PROTO_UDP; res->transports = RTSP_LOWER_TRANS_UDP | RTSP_LOWER_TRANS_UDP_MCAST;
p += RTSPU_PROTO_LEN; p += RTSPU_PROTO_LEN;
} else if (g_str_has_prefix (p, RTSPT_PROTO)) {
res->transports = RTSP_LOWER_TRANS_TCP;
p += RTSPT_PROTO_LEN;
} else } else
goto invalid; goto invalid;

View file

@ -46,19 +46,20 @@
#include <glib.h> #include <glib.h>
#include <rtspdefs.h> #include <rtspdefs.h>
#include <rtsptransport.h>
G_BEGIN_DECLS G_BEGIN_DECLS
#define RTSP_DEFAULT_PORT 554 #define RTSP_DEFAULT_PORT 554
typedef struct _RTSPUrl { typedef struct _RTSPUrl {
RTSPProto protocol; RTSPLowerTrans transports;
RTSPFamily family; RTSPFamily family;
gchar *user; gchar *user;
gchar *passwd; gchar *passwd;
gchar *host; gchar *host;
guint16 port; guint16 port;
gchar *abspath; gchar *abspath;
} RTSPUrl; } RTSPUrl;
RTSPResult rtsp_url_parse (const gchar *urlstr, RTSPUrl **url); RTSPResult rtsp_url_parse (const gchar *urlstr, RTSPUrl **url);