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

Method Open

framework/data_source/curl/curl_data_source2.cpp:156–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected