mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
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:
parent
5f10a8a9b5
commit
f21e123bcc
1 changed files with 21 additions and 26 deletions
|
@ -259,21 +259,16 @@ rtsp_init_status (void)
|
||||||
gchar *
|
gchar *
|
||||||
gst_rtsp_strresult (GstRTSPResult result)
|
gst_rtsp_strresult (GstRTSPResult result)
|
||||||
{
|
{
|
||||||
gint idx;
|
switch (result) {
|
||||||
|
|
||||||
idx = ABS (result);
|
|
||||||
idx = CLAMP (idx, 0, -GST_RTSP_ELAST);
|
|
||||||
|
|
||||||
switch (idx) {
|
|
||||||
case GST_RTSP_OK:
|
case GST_RTSP_OK:
|
||||||
return g_strdup ("OK");
|
return g_strdup ("OK");
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
case -GST_RTSP_ESYS:
|
case GST_RTSP_ESYS:
|
||||||
case -GST_RTSP_ENET:
|
case GST_RTSP_ENET:
|
||||||
{
|
{
|
||||||
gchar *res, *msg;
|
gchar *res, *msg;
|
||||||
msg = g_win32_error_message (WSAGetLastError ());
|
msg = g_win32_error_message (WSAGetLastError ());
|
||||||
if (idx == -GST_RTSP_ESYS)
|
if (result == GST_RTSP_ESYS)
|
||||||
res = g_strdup_printf ("System error: %s", msg);
|
res = g_strdup_printf ("System error: %s", msg);
|
||||||
else
|
else
|
||||||
res = g_strdup_printf ("Network error: %s", msg);
|
res = g_strdup_printf ("Network error: %s", msg);
|
||||||
|
@ -281,40 +276,40 @@ gst_rtsp_strresult (GstRTSPResult result)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
case -GST_RTSP_ESYS:
|
case GST_RTSP_ESYS:
|
||||||
return g_strdup_printf ("System error: %s", g_strerror (errno));
|
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));
|
return g_strdup_printf ("Network error: %s", hstrerror (h_errno));
|
||||||
#endif
|
#endif
|
||||||
case -GST_RTSP_ERROR:
|
case GST_RTSP_ERROR:
|
||||||
return g_strdup ("Generic error");
|
return g_strdup ("Generic error");
|
||||||
case -GST_RTSP_EINVAL:
|
case GST_RTSP_EINVAL:
|
||||||
return g_strdup ("Invalid parameter specified");
|
return g_strdup ("Invalid parameter specified");
|
||||||
case -GST_RTSP_EINTR:
|
case GST_RTSP_EINTR:
|
||||||
return g_strdup ("Operation interrupted");
|
return g_strdup ("Operation interrupted");
|
||||||
case -GST_RTSP_ENOMEM:
|
case GST_RTSP_ENOMEM:
|
||||||
return g_strdup ("Out of memory");
|
return g_strdup ("Out of memory");
|
||||||
case -GST_RTSP_ERESOLV:
|
case GST_RTSP_ERESOLV:
|
||||||
return g_strdup ("Cannot resolve host");
|
return g_strdup ("Cannot resolve host");
|
||||||
case -GST_RTSP_ENOTIMPL:
|
case GST_RTSP_ENOTIMPL:
|
||||||
return g_strdup ("Function not implemented");
|
return g_strdup ("Function not implemented");
|
||||||
case -GST_RTSP_EPARSE:
|
case GST_RTSP_EPARSE:
|
||||||
return g_strdup ("Parse error");
|
return g_strdup ("Parse error");
|
||||||
case -GST_RTSP_EWSASTART:
|
case GST_RTSP_EWSASTART:
|
||||||
return g_strdup ("Error on WSAStartup");
|
return g_strdup ("Error on WSAStartup");
|
||||||
case -GST_RTSP_EWSAVERSION:
|
case GST_RTSP_EWSAVERSION:
|
||||||
return g_strdup ("Windows sockets are not version 0x202");
|
return g_strdup ("Windows sockets are not version 0x202");
|
||||||
case -GST_RTSP_EEOF:
|
case GST_RTSP_EEOF:
|
||||||
return g_strdup ("Received end-of-file");
|
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");
|
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");
|
return g_strdup ("Timeout while waiting for server response");
|
||||||
case -GST_RTSP_ETGET:
|
case GST_RTSP_ETGET:
|
||||||
return g_strdup ("Tunnel GET request received");
|
return g_strdup ("Tunnel GET request received");
|
||||||
case -GST_RTSP_ETPOST:
|
case GST_RTSP_ETPOST:
|
||||||
return g_strdup ("Tunnel POST request received");
|
return g_strdup ("Tunnel POST request received");
|
||||||
case -GST_RTSP_ELAST:
|
case GST_RTSP_ELAST:
|
||||||
default:
|
default:
|
||||||
return g_strdup_printf ("Unknown error (%d)", result);
|
return g_strdup_printf ("Unknown error (%d)", result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue