1 /* 2 * GstCurlHttpSrc 3 * Copyright 2017 British Broadcasting Corporation - Research and Development 4 * 5 * Author: Sam Hurst <samuelh@rd.bbc.co.uk> 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in 15 * all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 * DEALINGS IN THE SOFTWARE. 24 * 25 * Alternatively, the contents of this file may be used under the 26 * GNU Lesser General Public License Version 2.1 (the "LGPL"), in 27 * which case the following provisions apply instead of the ones 28 * mentioned above: 29 * 30 * This library is free software; you can redistribute it and/or 31 * modify it under the terms of the GNU Library General Public 32 * License as published by the Free Software Foundation; either 33 * version 2 of the License, or (at your option) any later version. 34 * 35 * This library is distributed in the hope that it will be useful, 36 * but WITHOUT ANY WARRANTY; without even the implied warranty of 37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 38 * Library General Public License for more details. 39 * 40 * You should have received a copy of the GNU Library General Public 41 * License along with this library; if not, write to the 42 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 43 * Boston, MA 02111-1307, USA. 44 */ 45 46 #ifndef GSTCURLDEFAULTS_H_ 47 #define GSTCURLDEFAULTS_H_ 48 49 /* 50 * This file contains a list of all the default values used. These are used to 51 * initialise an object in its init call. 52 * 53 * Must all conform to GSTCURL_HANDLE_DEFAULT_##type for macro sillyness in 54 * curltask.h, where "type" is the CURLOPT_<something> string. 55 */ 56 /* Defaults from http://curl.haxx.se/libcurl/c/curl_easy_setopt.html */ 57 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_URL ((void *)0) 58 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_USERNAME ((void *)0) 59 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_PASSWORD ((void *)0) 60 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_PROXY ((void *)0) 61 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_PROXYUSERNAME ((void *)0) 62 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_PROXYPASSWORD ((void *)0) 63 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_USERAGENT "GStreamer curlhttpsrc libcurl" 64 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_ACCEPT_ENCODING FALSE 65 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_FOLLOWLOCATION 1L 66 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_MAXREDIRS -1 67 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_TCP_KEEPALIVE 1L 68 #ifdef OHOS_EXT_FUNC 69 // ohos.ext.func.0033 70 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_TIMEOUT 3 71 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_RECONNECTION_TIMEOUT 3000000 // 3s 72 #else 73 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_TIMEOUT 0 74 #endif 75 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_SSL_VERIFYPEER 1 76 #define GSTCURL_HANDLE_DEFAULT_CURLOPT_CAINFO ((void *)0) 77 78 79 /* Defaults from http://curl.haxx.se/libcurl/c/curl_multi_setopt.html */ 80 #define GSTCURL_HANDLE_DEFAULT_CURLMOPT_PIPELINING 1L 81 #define GSTCURL_HANDLE_DEFAULT_CURLMOPT_MAXCONNECTS 255L 82 #define GSTCURL_HANDLE_DEFAULT_CURLMOPT_MAX_HOST_CONNECTIONS 0L 83 #define GSTCURL_HANDLE_DEFAULT_CURLMOPT_MAX_PIPELINE_LENGTH 5L 84 #define GSTCURL_HANDLE_DEFAULT_CURLMOPT_MAX_TOTAL_CONNECTIONS 255L 85 86 /* Not a CURLOPT, is something I've implemented which curl doesn't */ 87 #define GSTCURL_HANDLE_DEFAULT_RETRIES -1 88 89 /* 90 * Now set acceptable ranges. Defaults can lie outside the range, in which case 91 * it is expected that the programmer will use the gst_curl_setopt and not the 92 * gst_curl_setopt_default macro, as if the value supplied lies outside of the 93 * default range, it won't bother to set it. If the _default macro is used, 94 * then the offending value is replaced by the default type above. 95 */ 96 #define GSTCURL_HANDLE_MIN_CURLOPT_FOLLOWLOCATION 0L 97 #define GSTCURL_HANDLE_MAX_CURLOPT_FOLLOWLOCATION 1L 98 #define GSTCURL_HANDLE_MIN_CURLOPT_MAXREDIRS -1 99 #define GSTCURL_HANDLE_MAX_CURLOPT_MAXREDIRS 255 100 #define GSTCURL_HANDLE_MIN_CURLOPT_TCP_KEEPALIVE 0L 101 #define GSTCURL_HANDLE_MAX_CURLOPT_TCP_KEEPALIVE 1L 102 #define GSTCURL_HANDLE_MIN_CURLOPT_TIMEOUT 0 103 #define GSTCURL_HANDLE_MAX_CURLOPT_TIMEOUT 3600 104 #ifdef OHOS_EXT_FUNC 105 // ohos.ext.func.0033 106 #define GSTCURL_HANDLE_MIN_CURLOPT_RECONNECTION_TIMEOUT 0 107 #define GSTCURL_HANDLE_MAX_CURLOPT_RECONNECTION_TIMEOUT 3600000000 // 3600s 108 #endif 109 #define GSTCURL_HANDLE_MIN_CURLOPT_SSL_VERIFYPEER 0 110 #define GSTCURL_HANDLE_MAX_CURLOPT_SSL_VERIFYPEER 1 111 #define GSTCURL_HANDLE_MIN_CURLOPT_HTTP_VERSION CURL_HTTP_VERSION_1_0 112 #ifdef CURL_VERSION_HTTP2 113 #define GSTCURL_HANDLE_MAX_CURLOPT_HTTP_VERSION CURL_HTTP_VERSION_2_0 114 #else 115 #define GSTCURL_HANDLE_MAX_CURLOPT_HTTP_VERSION CURL_HTTP_VERSION_1_1 116 #endif 117 118 #define GSTCURL_HANDLE_MIN_CURLMOPT_PIPELINING 0L 119 #define GSTCURL_HANDLE_MAX_CURLMOPT_PIPELINING 1L 120 #define GSTCURL_HANDLE_MIN_CURLMOPT_MAXCONNECTS 32L 121 #define GSTCURL_HANDLE_MAX_CURLMOPT_MAXCONNECTS 255L 122 #define GSTCURL_HANDLE_MIN_CURLMOPT_MAX_HOST_CONNECTIONS 1L 123 #define GSTCURL_HANDLE_MAX_CURLMOPT_MAX_HOST_CONNECTIONS 127L 124 #define GSTCURL_HANDLE_MIN_CURLMOPT_MAX_PIPELINE_LENGTH 1L 125 #define GSTCURL_HANDLE_MAX_CURLMOPT_MAX_PIPELINE_LENGTH 200L 126 #define GSTCURL_HANDLE_MIN_CURLMOPT_MAX_TOTAL_CONNECTIONS 32L 127 #define GSTCURL_HANDLE_MAX_CURLMOPT_MAX_TOTAL_CONNECTIONS 255L 128 129 #define GSTCURL_HANDLE_MIN_RETRIES -1 130 #define GSTCURL_HANDLE_MAX_RETRIES 9999 131 132 /* Because g_param_spec_int requires min/max bounding... */ 133 #define GSTCURL_MIN_REDIRECTIONS -1 134 #define GSTCURL_MAX_REDIRECTIONS 255 135 #define GSTCURL_MIN_CONNECTION_TIME 2 136 #define GSTCURL_MAX_CONNECTION_TIME 60 137 #define GSTCURL_MIN_CONNECTIONS_SERVER 1 138 #define GSTCURL_MAX_CONNECTIONS_SERVER 60 139 #define GSTCURL_MIN_CONNECTIONS_PROXY 1 140 #define GSTCURL_MAX_CONNECTIONS_PROXY 60 141 #define GSTCURL_MIN_CONNECTIONS_GLOBAL 1 142 #define GSTCURL_MAX_CONNECTIONS_GLOBAL 255 143 #define GSTCURL_DEFAULT_CONNECTION_TIME 30 144 #define GSTCURL_DEFAULT_CONNECTIONS_SERVER 5 145 #define GSTCURL_DEFAULT_CONNECTIONS_PROXY 30 146 #define GSTCURL_DEFAULT_CONNECTIONS_GLOBAL 255 147 #define GSTCURL_INFO_RESPONSE(x) ((x >= 100) && (x <= 199)) 148 #define GSTCURL_SUCCESS_RESPONSE(x) ((x >= 200) && (x <=299)) 149 #define GSTCURL_REDIRECT_RESPONSE(x) ((x >= 300) && (x <= 399)) 150 #define GSTCURL_CLIENT_ERR_RESPONSE(x) ((x >= 400) && (x <= 499)) 151 #define GSTCURL_SERVER_ERR_RESPONSE(x) ((x >= 500) && (x <= 599)) 152 #define GSTCURL_FUNCTIONTRACE 0 153 154 #endif /* GSTCURLDEFAULTS_H_ */ 155