rtspsrc: Use GST_ELEMENT_ERROR_WITH_DETAILS

Allows the application to know the exact status code that was returned
by the server in a programmatic fashion.

https://bugzilla.gnome.org/show_bug.cgi?id=781304
This commit is contained in:
Edward Hervey 2017-04-14 10:56:41 +02:00 committed by Edward Hervey
parent 3b9ea4b85f
commit 474819cc3d

View file

@ -288,6 +288,14 @@ gst_rtsp_nat_method_get_type (void)
return rtsp_nat_method_type; return rtsp_nat_method_type;
} }
#define RTSP_SRC_RESPONSE_ERROR(src, response_msg, err_cat, err_code, error_message) \
do { \
GST_ELEMENT_ERROR_WITH_DETAILS((src), err_cat, err_code, ("%s", error_message), \
("%s (%d)", (response_msg)->type_data.response.reason, (response_msg)->type_data.response.code), \
("rtsp-status-code", G_TYPE_UINT, (response_msg)->type_data.response.code, \
"rtsp-status-reason", G_TYPE_STRING, GST_STR_NULL((response_msg)->type_data.response.reason), NULL)); \
} while (0)
static void gst_rtspsrc_finalize (GObject * object); static void gst_rtspsrc_finalize (GObject * object);
static void gst_rtspsrc_set_property (GObject * object, guint prop_id, static void gst_rtspsrc_set_property (GObject * object, guint prop_id,
@ -1585,7 +1593,7 @@ no_proto:
} }
unknown_proto: unknown_proto:
{ {
GST_ERROR_OBJECT (src, "unknown proto in media %s", proto); GST_ERROR_OBJECT (src, "unknown proto in media: '%s'", proto);
return; return;
} }
} }
@ -5548,12 +5556,12 @@ error_response:
switch (response->type_data.response.code) { switch (response->type_data.response.code) {
case GST_RTSP_STS_NOT_FOUND: case GST_RTSP_STS_NOT_FOUND:
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), ("%s", RTSP_SRC_RESPONSE_ERROR (src, response, RESOURCE, NOT_FOUND,
response->type_data.response.reason)); "Not found");
break; break;
case GST_RTSP_STS_UNAUTHORIZED: case GST_RTSP_STS_UNAUTHORIZED:
GST_ELEMENT_ERROR (src, RESOURCE, NOT_AUTHORIZED, (NULL), ("%s", RTSP_SRC_RESPONSE_ERROR (src, response, RESOURCE, NOT_AUTHORIZED,
response->type_data.response.reason)); "Unauthorized");
break; break;
case GST_RTSP_STS_MOVED_PERMANENTLY: case GST_RTSP_STS_MOVED_PERMANENTLY:
case GST_RTSP_STS_MOVE_TEMPORARILY: case GST_RTSP_STS_MOVE_TEMPORARILY:
@ -5597,9 +5605,8 @@ error_response:
res = GST_RTSP_OK; res = GST_RTSP_OK;
break; break;
default: default:
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), RTSP_SRC_RESPONSE_ERROR (src, response, RESOURCE, READ,
("Got error response: %d (%s).", response->type_data.response.code, "Unhandled error");
response->type_data.response.reason));
break; break;
} }
/* if we return ERROR we should unset the response ourselves */ /* if we return ERROR we should unset the response ourselves */