summaryrefslogtreecommitdiffstats
path: root/gst/rtsp/rtspdefs.c
diff options
context:
space:
mode:
authorPeter Kjellerstedt <pkj@axis.com>2007-01-10 15:19:48 +0000
committerWim Taymans <wim.taymans@gmail.com>2007-01-10 15:19:48 +0000
commit12ab127d12bf2d5f15860e736bb1792918f532ef (patch)
tree85750eca3bb6457a12183b3d98d23f2de5301eba /gst/rtsp/rtspdefs.c
parent8f7c1775d9bc42cdaa84cd305718b09b80c27e95 (diff)
gst/rtsp/: Allow url to be NULL to be able to use it for server connections.
Original commit message from CVS: Patch by: Peter Kjellerstedt <pkj at axis com> * gst/rtsp/COPYING.MIT: * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_create_stream), (gst_rtspsrc_stream_free), (gst_rtspsrc_cleanup), (gst_rtspsrc_alloc_udp_ports), (pad_unblocked), (pad_blocked), (gst_rtspsrc_stream_configure_transport), (gst_rtspsrc_activate_streams), (gst_rtspsrc_loop_interleaved), (gst_rtspsrc_loop_udp), (gst_rtspsrc_send), (gst_rtspsrc_parse_methods), (gst_rtspsrc_create_transports_string), (gst_rtspsrc_prepare_transports), (gst_rtspsrc_setup_streams), (gst_rtspsrc_open), (gst_rtspsrc_close): * gst/rtsp/gstrtspsrc.h: * gst/rtsp/rtspconnection.c: (rtsp_connection_create), (rtsp_connection_connect), (rtsp_connection_send), (read_line), (parse_request_line), (parse_line), (rtsp_connection_read), (rtsp_connection_close): * gst/rtsp/rtspdefs.c: (rtsp_init_status), (rtsp_strresult), (rtsp_method_as_text), (rtsp_header_as_text), (rtsp_status_as_text), (rtsp_find_header_field), (rtsp_find_method): * gst/rtsp/rtspdefs.h: * gst/rtsp/rtspextwms.c: (rtsp_ext_wms_after_send), (rtsp_ext_wms_configure_stream): * gst/rtsp/rtspmessage.c: (rtsp_message_new), (rtsp_message_init), (rtsp_message_new_request), (rtsp_message_init_request), (rtsp_message_new_response), (rtsp_message_init_response), (rtsp_message_init_data), (rtsp_message_unset), (rtsp_message_free), (rtsp_message_add_header), (rtsp_message_get_header), (rtsp_message_set_body), (rtsp_message_get_body), (dump_mem), (rtsp_message_dump): * gst/rtsp/rtspmessage.h: * gst/rtsp/sdpmessage.c: (sdp_message_get_attribute_val_n), (sdp_media_get_attribute_val_n), (read_string), (read_string_del), (sdp_parse_line), (sdp_message_parse_buffer), (print_media), (sdp_message_dump): Allow url to be NULL to be able to use it for server connections. Can now send responses as well as requests. No longer hangs in an endless loop if EOF is received. Can now convert a status code to a text string. Return RTSP_HDR_INVALID for unknown headers. Return RTSP_INVALID for unknown methods. Copy CSeq and Session headers from the request. Only free memory corresponding to the currently set message type. Added const to function arguments as appropriate. Avoid a compiler warning when initializing nmedia. Use guint rather than gint to avoid compiler warnings. Fix crasher in wms extension. Factor out stream setup from open_connection. Delay activation of streams when actual data is received from the server, this prepares us to do proper protocol switching. Added new license. Fixes #380895.
Diffstat (limited to 'gst/rtsp/rtspdefs.c')
-rw-r--r--gst/rtsp/rtspdefs.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/gst/rtsp/rtspdefs.c b/gst/rtsp/rtspdefs.c
index 63b68a3f..6c96e1f4 100644
--- a/gst/rtsp/rtspdefs.c
+++ b/gst/rtsp/rtspdefs.c
@@ -57,7 +57,7 @@ static const gchar *rtsp_results[] = {
"Out of memory",
"Cannot resolve host",
"Function not implemented",
- "System error: '%s'",
+ "System error: %s",
"Parse error",
"Error on WSAStartup",
"Windows sockets are not version 0x202",
@@ -142,11 +142,14 @@ static const gchar *rtsp_headers[] = {
NULL
};
-#define DEF_STATUS(c,t)
+#define DEF_STATUS(c, t) \
+ g_hash_table_insert (statuses, GUINT_TO_POINTER(c), t)
-void
+GHashTable *
rtsp_init_status (void)
{
+ GHashTable *statuses = g_hash_table_new (NULL, NULL);
+
DEF_STATUS (RTSP_STS_CONTINUE, "Continue");
DEF_STATUS (RTSP_STS_OK, "OK");
DEF_STATUS (RTSP_STS_CREATED, "Created");
@@ -196,6 +199,8 @@ rtsp_init_status (void)
DEF_STATUS (RTSP_STS_RTSP_VERSION_NOT_SUPPORTED,
"RTSP Version not supported");
DEF_STATUS (RTSP_STS_OPTION_NOT_SUPPORTED, "Option not supported");
+
+ return statuses;
}
gchar *
@@ -229,7 +234,7 @@ rtsp_method_as_text (RTSPMethod method)
{
gint i;
- if (method == 0)
+ if (method == RTSP_INVALID)
return NULL;
i = 0;
@@ -243,19 +248,21 @@ rtsp_method_as_text (RTSPMethod method)
const gchar *
rtsp_header_as_text (RTSPHeaderField field)
{
- return rtsp_headers[field];
+ if (field == RTSP_HDR_INVALID)
+ return NULL;
+ else
+ return rtsp_headers[field - 1];
}
const gchar *
rtsp_status_as_text (RTSPStatusCode code)
{
- return NULL;
-}
+ static GHashTable *statuses;
-const gchar *
-rtsp_status_to_string (RTSPStatusCode code)
-{
- return NULL;
+ if (G_UNLIKELY (statuses == NULL))
+ statuses = rtsp_init_status ();
+
+ return g_hash_table_lookup (statuses, GUINT_TO_POINTER (code));
}
RTSPHeaderField
@@ -265,10 +272,10 @@ rtsp_find_header_field (gchar * header)
for (idx = 0; rtsp_headers[idx]; idx++) {
if (g_ascii_strcasecmp (rtsp_headers[idx], header) == 0) {
- return idx;
+ return idx + 1;
}
}
- return -1;
+ return RTSP_HDR_INVALID;
}
RTSPMethod
@@ -281,5 +288,5 @@ rtsp_find_method (gchar * method)
return (1 << idx);
}
}
- return -1;
+ return RTSP_INVALID;
}