diff --git a/ChangeLog b/ChangeLog index 3cd1232db3..2dd57d3596 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-09-23 Wim Taymans + + * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_loop), (gst_rtspsrc_send), + (gst_rtspsrc_open): + * gst/rtsp/rtspconnection.c: (rtsp_connection_create), + (rtsp_connection_connect), (rtsp_connection_read), (read_body), + (rtsp_connection_receive): + * gst/rtsp/rtspdefs.c: (rtsp_strresult): + * gst/rtsp/rtspdefs.h: + Improve error reporting. + 2006-09-23 Wim Taymans * gst/rtp/gstasteriskh263.c: (gst_asteriskh263_plugin_init): diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 11279c38ae..0c8f5bf84f 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -1000,17 +1000,11 @@ unknown_stream: } receive_error: { - switch (res) { - case RTSP_ESYS: - GST_ELEMENT_ERROR (src, RESOURCE, READ, - ("Could not receive message. (%d: %s)", res, strerror (errno)), - GST_ERROR_SYSTEM); - break; - default: - GST_ELEMENT_ERROR (src, RESOURCE, READ, - ("Could not receive message. (%d)", res), (NULL)); - break; - } + gchar *str = rtsp_strresult (res); + + GST_ELEMENT_ERROR (src, RESOURCE, READ, + ("Could not receive message. (%s)", str), (NULL)); + g_free (str); if (src->debug) rtsp_message_dump (&response); rtsp_message_unset (&response); @@ -1103,14 +1097,20 @@ gst_rtspsrc_send (GstRTSPSrc * src, RTSPMessage * request, /* ERRORS */ send_error: { + gchar *str = rtsp_strresult (res); + GST_ELEMENT_ERROR (src, RESOURCE, WRITE, - ("Could not send message."), (NULL)); + ("Could not send message. (%s)", res), (NULL)); + g_free (str); return FALSE; } receive_error: { + gchar *str = rtsp_strresult (res); + GST_ELEMENT_ERROR (src, RESOURCE, READ, - ("Could not receive message."), (NULL)); + ("Could not receive message. (%s)", str), (NULL)); + g_free (str); return FALSE; } error_response: @@ -1467,26 +1467,38 @@ no_url: } could_not_create: { + gchar *str = rtsp_strresult (res); + GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, - ("Could not create connection."), (NULL)); + ("Could not create connection. (%s)", str), (NULL)); + g_free (str); goto cleanup_error; } could_not_connect: { + gchar *str = rtsp_strresult (res); + GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, - ("Could not connect to server."), (NULL)); + ("Could not connect to server. (%s)", str), (NULL)); + g_free (str); goto cleanup_error; } create_request_failed: { + gchar *str = rtsp_strresult (res); + GST_ELEMENT_ERROR (src, LIBRARY, INIT, - ("Could not create request."), (NULL)); + ("Could not create request. (%s)", str), (NULL)); + g_free (str); goto cleanup_error; } send_error: { + gchar *str = rtsp_strresult (res); + GST_ELEMENT_ERROR (src, RESOURCE, WRITE, - ("Could not send message."), (NULL)); + ("Could not send message. (%s)", str), (NULL)); + g_free (str); goto cleanup_error; } methods_error: diff --git a/gst/rtsp/rtspconnection.c b/gst/rtsp/rtspconnection.c index 41a374fe84..019fdfeb40 100644 --- a/gst/rtsp/rtspconnection.c +++ b/gst/rtsp/rtspconnection.c @@ -206,13 +206,11 @@ sys_error: } not_resolved: { - g_warning ("could not resolve host \"%s\"\n", url->host); - return RTSP_ESYS; + return RTSP_ENET; } not_ip: { - g_warning ("host \"%s\" is not IP\n", url->host); - return RTSP_ESYS; + return RTSP_ENOTIP; } } diff --git a/gst/rtsp/rtspdefs.c b/gst/rtsp/rtspdefs.c index 414abbe774..0e760940ea 100644 --- a/gst/rtsp/rtspdefs.c +++ b/gst/rtsp/rtspdefs.c @@ -40,9 +40,34 @@ * SOFTWARE. */ +#include + +extern int h_errno; + +#include + #include "rtspdefs.h" -const gchar *rtsp_methods[] = { +static const gchar *rtsp_results[] = { + "OK", + /* errors */ + "Invalid parameter specified", + "Operation interrupted", + "Out of memory", + "Cannot resolve host", + "Function not implemented", + "System error: '%s'", + "Parse error", + "Error on WSAStartup", + "Windows sockets are not version 0x202", + "Received end-of-file", + "Network error: %s", + "Host is not a valid IP address", + "Unknown error (%d)", + NULL +}; + +static const gchar *rtsp_methods[] = { "DESCRIBE", "ANNOUNCE", "GET_PARAMETER", @@ -57,7 +82,7 @@ const gchar *rtsp_methods[] = { NULL }; -const gchar *rtsp_headers[] = { +static const gchar *rtsp_headers[] = { "Accept", /* Accept R opt. entity */ "Accept-Encoding", /* Accept-Encoding R opt. entity */ "Accept-Language", /* Accept-Language R opt. all */ @@ -156,6 +181,32 @@ rtsp_init_status (void) DEF_STATUS (RTSP_STS_OPTION_NOT_SUPPORTED, "Option not supported"); } +gchar * +rtsp_strresult (RTSPResult result) +{ + gint idx; + gchar *res; + + idx = ABS (result); + idx = CLAMP (idx, 0, -RTSP_ELAST); + + switch (idx) { + case -RTSP_ESYS: + res = g_strdup_printf (rtsp_results[idx], g_strerror (errno)); + break; + case -RTSP_ENET: + res = g_strdup_printf (rtsp_results[idx], hstrerror (h_errno)); + break; + case -RTSP_ELAST: + res = g_strdup_printf (rtsp_results[idx], result); + break; + default: + res = g_strdup (rtsp_results[idx]); + break; + } + return res; +} + const gchar * rtsp_method_as_text (RTSPMethod method) { diff --git a/gst/rtsp/rtspdefs.h b/gst/rtsp/rtspdefs.h index fb303eaafd..4a0d6f49d7 100644 --- a/gst/rtsp/rtspdefs.h +++ b/gst/rtsp/rtspdefs.h @@ -63,7 +63,10 @@ typedef enum { RTSP_EWSASTART = -8, RTSP_EWSAVERSION = -9, RTSP_EEOF = -10, + RTSP_ENET = -11, + RTSP_ENOTIP = -12, + RTSP_ELAST = -13, } RTSPResult; typedef enum { @@ -197,6 +200,8 @@ typedef enum { RTSP_STS_OPTION_NOT_SUPPORTED = 551, } RTSPStatusCode; +gchar* rtsp_strresult (RTSPResult result); + const gchar* rtsp_method_as_text (RTSPMethod method); const gchar* rtsp_header_as_text (RTSPHeaderField field); const gchar* rtsp_status_as_text (RTSPStatusCode code);