gst/rtsp/: Improve error reporting.

Original commit message from CVS:
* 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.
This commit is contained in:
Wim Taymans 2006-09-23 15:31:56 +00:00
parent af6e4da92e
commit 23ec2eb189
5 changed files with 100 additions and 23 deletions

View file

@ -1,3 +1,14 @@
2006-09-23 Wim Taymans <wim@fluendo.com>
* 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 <wim@fluendo.com>
* gst/rtp/gstasteriskh263.c: (gst_asteriskh263_plugin_init):

View file

@ -1000,17 +1000,11 @@ unknown_stream:
}
receive_error:
{
switch (res) {
case RTSP_ESYS:
gchar *str = rtsp_strresult (res);
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;
}
("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:

View file

@ -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;
}
}

View file

@ -40,9 +40,34 @@
* SOFTWARE.
*/
#include <errno.h>
extern int h_errno;
#include <netdb.h>
#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)
{

View file

@ -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);