souphttpsrc: Make more usage of error macro
authorEdward Hervey <edward@centricular.com>
Thu, 13 Apr 2017 06:00:30 +0000 (08:00 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Thu, 13 Apr 2017 06:00:30 +0000 (08:00 +0200)
And make sure we actually use the provided soup_msg argument in the macro

ext/soup/gstsouphttpsrc.c

index 3abfc40..2d08e13 100644 (file)
@@ -1248,7 +1248,7 @@ gst_soup_http_src_alloc_buffer (GstSoupHTTPSrc * src)
     GST_ELEMENT_ERROR_WITH_DETAILS ((src), cat, code, ("%s", error_message), \
         ("%s (%d), URL: %s, Redirect to: %s", (soup_msg)->reason_phrase, \
             (soup_msg)->status_code, (src)->location, GST_STR_NULL ((src)->redirection_uri)), \
-            ("http-status-code", G_TYPE_UINT, msg->status_code, \
+            ("http-status-code", G_TYPE_UINT, (soup_msg)->status_code, \
              "http-redirect-uri", G_TYPE_STRING, GST_STR_NULL ((src)->redirection_uri), NULL)); \
   } while(0)
 
@@ -1323,33 +1323,14 @@ gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src)
      * error dialog according to libsoup documentation.
      */
     if (msg->status_code == SOUP_STATUS_NOT_FOUND) {
-      GST_ELEMENT_ERROR_WITH_DETAILS (src, RESOURCE, NOT_FOUND,
-          ("%s", reason_phrase),
-          ("%s (%d), URL: %s, Redirect to: %s", reason_phrase,
-              msg->status_code, src->location,
-              GST_STR_NULL (src->redirection_uri)),
-          ("http-status-code", G_TYPE_UINT, msg->status_code,
-              "http-redirect-uri", G_TYPE_STRING,
-              GST_STR_NULL (src->redirection_uri), NULL));
+      SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND, (reason_phrase));
     } else if (msg->status_code == SOUP_STATUS_UNAUTHORIZED
         || msg->status_code == SOUP_STATUS_PAYMENT_REQUIRED
         || msg->status_code == SOUP_STATUS_FORBIDDEN
         || msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
-      GST_ELEMENT_ERROR_WITH_DETAILS (src, RESOURCE, NOT_AUTHORIZED, ("%s",
-              reason_phrase), ("%s (%d), URL: %s, Redirect to: %s",
-              reason_phrase, msg->status_code, src->location,
-              GST_STR_NULL (src->redirection_uri)), ("http-status-code",
-              G_TYPE_UINT, msg->status_code, "http-redirect-uri", G_TYPE_STRING,
-              GST_STR_NULL (src->redirection_uri), NULL));
+      SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_AUTHORIZED, (reason_phrase));
     } else {
-      GST_ELEMENT_ERROR_WITH_DETAILS (src, RESOURCE, OPEN_READ,
-          ("%s", reason_phrase),
-          ("%s (%d), URL: %s, Redirect to: %s", reason_phrase,
-              msg->status_code, src->location,
-              GST_STR_NULL (src->redirection_uri)),
-          ("http-status-code", G_TYPE_UINT, msg->status_code,
-              "http-redirect-uri", G_TYPE_STRING,
-              GST_STR_NULL (src->redirection_uri), NULL));
+      SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ, (reason_phrase));
     }
     return GST_FLOW_ERROR;
   }