rtsp: Further clean up of gst_rtsp_strresult()

Since we no longer use an array of error messages, there is no reason
to clamp the error code, which allows us to simplify the code some more
and also to actually report the correct error code for unknown errors.
This commit is contained in:
Peter Kjellerstedt 2010-03-17 16:39:13 +01:00
parent 5f10a8a9b5
commit f21e123bcc

View file

@ -259,21 +259,16 @@ rtsp_init_status (void)
gchar *
gst_rtsp_strresult (GstRTSPResult result)
{
gint idx;
idx = ABS (result);
idx = CLAMP (idx, 0, -GST_RTSP_ELAST);
switch (idx) {
switch (result) {
case GST_RTSP_OK:
return g_strdup ("OK");
#ifdef G_OS_WIN32
case -GST_RTSP_ESYS:
case -GST_RTSP_ENET:
case GST_RTSP_ESYS:
case GST_RTSP_ENET:
{
gchar *res, *msg;
msg = g_win32_error_message (WSAGetLastError ());
if (idx == -GST_RTSP_ESYS)
if (result == GST_RTSP_ESYS)
res = g_strdup_printf ("System error: %s", msg);
else
res = g_strdup_printf ("Network error: %s", msg);
@ -281,40 +276,40 @@ gst_rtsp_strresult (GstRTSPResult result)
return res;
}
#else
case -GST_RTSP_ESYS:
case GST_RTSP_ESYS:
return g_strdup_printf ("System error: %s", g_strerror (errno));
case -GST_RTSP_ENET:
case GST_RTSP_ENET:
return g_strdup_printf ("Network error: %s", hstrerror (h_errno));
#endif
case -GST_RTSP_ERROR:
case GST_RTSP_ERROR:
return g_strdup ("Generic error");
case -GST_RTSP_EINVAL:
case GST_RTSP_EINVAL:
return g_strdup ("Invalid parameter specified");
case -GST_RTSP_EINTR:
case GST_RTSP_EINTR:
return g_strdup ("Operation interrupted");
case -GST_RTSP_ENOMEM:
case GST_RTSP_ENOMEM:
return g_strdup ("Out of memory");
case -GST_RTSP_ERESOLV:
case GST_RTSP_ERESOLV:
return g_strdup ("Cannot resolve host");
case -GST_RTSP_ENOTIMPL:
case GST_RTSP_ENOTIMPL:
return g_strdup ("Function not implemented");
case -GST_RTSP_EPARSE:
case GST_RTSP_EPARSE:
return g_strdup ("Parse error");
case -GST_RTSP_EWSASTART:
case GST_RTSP_EWSASTART:
return g_strdup ("Error on WSAStartup");
case -GST_RTSP_EWSAVERSION:
case GST_RTSP_EWSAVERSION:
return g_strdup ("Windows sockets are not version 0x202");
case -GST_RTSP_EEOF:
case GST_RTSP_EEOF:
return g_strdup ("Received end-of-file");
case -GST_RTSP_ENOTIP:
case GST_RTSP_ENOTIP:
return g_strdup ("Host is not a valid IP address");
case -GST_RTSP_ETIMEOUT:
case GST_RTSP_ETIMEOUT:
return g_strdup ("Timeout while waiting for server response");
case -GST_RTSP_ETGET:
case GST_RTSP_ETGET:
return g_strdup ("Tunnel GET request received");
case -GST_RTSP_ETPOST:
case GST_RTSP_ETPOST:
return g_strdup ("Tunnel POST request received");
case -GST_RTSP_ELAST:
case GST_RTSP_ELAST:
default:
return g_strdup_printf ("Unknown error (%d)", result);
}