adaptivedemux: tests: use macro to define names of request and response structs

Following the Don't Repeat Yourself principle, define macros
for the structures that contain the request and response headers,
so that the name is not repeated in multiple places in multiple files.

https://bugzilla.gnome.org/show_bug.cgi?id=762144
This commit is contained in:
Florin Apostol 2016-02-16 14:26:55 +00:00 committed by Thiago Santos
parent 3224cfd0b5
commit 00a74e98b3
2 changed files with 22 additions and 6 deletions

View file

@ -314,7 +314,8 @@ gst_test_http_src_start (GstBaseSrc * basesrc)
http_headers = gst_structure_new_empty ("http-headers");
gst_structure_set (http_headers, "uri", G_TYPE_STRING, src->uri, NULL);
if (!src->input.request_headers) {
src->input.request_headers = gst_structure_new_empty ("request-headers");
src->input.request_headers =
gst_structure_new_empty (TEST_HTTP_SRC_REQUEST_HEADERS_NAME);
}
if (!gst_structure_has_field_typed (src->input.request_headers,
"User-Agent", G_TYPE_STRING)) {
@ -334,10 +335,11 @@ gst_test_http_src_start (GstBaseSrc * basesrc)
gst_structure_set (src->input.request_headers, "Accept-Encoding",
G_TYPE_STRING, "compress, gzip", NULL);
}
gst_structure_set (http_headers, "request-headers", GST_TYPE_STRUCTURE,
src->input.request_headers, NULL);
gst_structure_set (http_headers, TEST_HTTP_SRC_REQUEST_HEADERS_NAME,
GST_TYPE_STRUCTURE, src->input.request_headers, NULL);
if (!src->input.response_headers) {
src->input.response_headers = gst_structure_new_empty ("response-headers");
src->input.response_headers =
gst_structure_new_empty (TEST_HTTP_SRC_RESPONSE_HEADERS_NAME);
}
if (!gst_structure_has_field_typed (src->input.response_headers,
"Connection", G_TYPE_STRING)) {
@ -359,8 +361,8 @@ gst_test_http_src_start (GstBaseSrc * basesrc)
g_free (date_str);
g_date_time_unref (now);
}
gst_structure_set (http_headers, "response-headers", GST_TYPE_STRUCTURE,
src->input.response_headers, NULL);
gst_structure_set (http_headers, TEST_HTTP_SRC_RESPONSE_HEADERS_NAME,
GST_TYPE_STRUCTURE, src->input.response_headers, NULL);
if (src->http_headers_event) {
gst_event_unref (src->http_headers_event);
}

View file

@ -27,6 +27,20 @@ G_BEGIN_DECLS
#define GST_TYPE_TEST_HTTP_SRC (gst_test_http_src_get_type ())
/**
* TEST_HTTP_SRC_REQUEST_HEADERS_NAME:
* The name of the #GstStructure that will contain all the HTTP request
* headers
*/
#define TEST_HTTP_SRC_REQUEST_HEADERS_NAME "request-headers"
/**
* TEST_HTTP_SRC_RESPONSE_HEADERS_NAME:
* The name of the #GstStructure that will contain all the HTTP response
* headers
*/
#define TEST_HTTP_SRC_RESPONSE_HEADERS_NAME "response-headers"
/* structure used by src_start function to configure the
* GstTestHTTPSrc plugin.
* It specifies information about a given URI.