MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / Open

Method Open

framework/data_source/curl/curl_data_source.cpp:151–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151int 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
205int CurlDataSource::Open(const string &url)
206{

Callers

nothing calls this directly

Calls 9

af_gettime_relativeFunction · 0.85
getPropertyFunction · 0.85
disconnectMethod · 0.80
compareMethod · 0.45
emptyMethod · 0.45
setInterruptMethod · 0.45
updateSourceMethod · 0.45
updateHeaderListMethod · 0.45
setPostMethod · 0.45

Tested by

no test coverage detected