| 149 | } |
| 150 | |
| 151 | int CurlDataSource::Open(int flags) |
| 152 | { |
| 153 | // TODO: deal with ret |
| 154 | mOpenTimeMS = af_gettime_relative() / 1000; |
| 155 | bool isRTMP = mUri.compare(0, 7, "rtmp://") == 0; |
| 156 | mLocation = (isRTMP ? (mUri + " live=1").c_str() : mUri.c_str()); |
| 157 | pConfig = &mConfig; |
| 158 | |
| 159 | if (headerList) { |
| 160 | curl_slist_free_all(headerList); |
| 161 | headerList = nullptr; |
| 162 | } |
| 163 | |
| 164 | if (getProperty("ro.network.http.globeHeader")) { |
| 165 | headerList = curl_slist_append(headerList, getProperty("ro.network.http.globeHeader")); |
| 166 | } |
| 167 | |
| 168 | std::vector<std::string> &customHeaders = mConfig.customHeaders; |
| 169 | |
| 170 | for (string &item : customHeaders) { |
| 171 | if (!item.empty()) { |
| 172 | headerList = curl_slist_append(headerList, item.c_str()); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | if (pConfig->so_rcv_size >= MIN_SO_RCVBUF_SIZE) { |
| 177 | pConfig->so_rcv_size = pConfig->so_rcv_size >> 12; |
| 178 | pConfig->so_rcv_size = pConfig->so_rcv_size << 12; |
| 179 | AF_LOGI("so_rcv_size is %d\n", pConfig->so_rcv_size); |
| 180 | } else if (pConfig->so_rcv_size > 0) { |
| 181 | AF_LOGI("so_rcv_size too small\n"); |
| 182 | pConfig->so_rcv_size = 0; |
| 183 | } |
| 184 | |
| 185 | { |
| 186 | std::lock_guard<std::mutex> lock(mMutex); |
| 187 | mPConnection = initConnection(); |
| 188 | mPConnection->setInterrupt(&mInterrupt); |
| 189 | } |
| 190 | |
| 191 | int ret = curl_connect(mPConnection, rangeStart != INT64_MIN ? rangeStart : 0); |
| 192 | mOpenTimeMS = af_gettime_relative() / 1000 - mOpenTimeMS; |
| 193 | |
| 194 | if (ret >= 0) { |
| 195 | fillConnectInfo(); |
| 196 | } |
| 197 | |
| 198 | if (nullptr == mConnections) { |
| 199 | mConnections = new std::vector<CURLConnection *>(); |
| 200 | } |
| 201 | |
| 202 | return ret; |
| 203 | } |
| 204 | |
| 205 | int CurlDataSource::Open(const string &url) |
| 206 | { |
nothing calls this directly
no test coverage detected