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

Method write_callback

framework/data_source/curl/CURLConnection2.cpp:179–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179size_t Cicada::CURLConnection2::write_callback(char *buffer, size_t size, size_t nitems, void *userp)
180{
181 if (!userp) {
182 return CURL_WRITEFUNC_PAUSE;
183 }
184 auto *pHandle = (CURLConnection2 *) userp;
185 assert(!pHandle->mPaused);
186 auto amount = (uint32_t) (size * nitems);
187 std::lock_guard<std::mutex> lock(pHandle->mCurlCbMutex);
188 // AF_LOGD("RingBuffergetMaxWriteSize(pHandle->pRbuf) is %u\n",RingBuffergetMaxWriteSize(pHandle->pRbuf));
189 if (RingBuffergetMaxWriteSize(pHandle->pRbuf) < amount) {
190 pHandle->mPaused = true;
191 AF_LOGD("write_callback %p paused\n", pHandle);
192 return CURL_WRITEFUNC_PAUSE;
193 }
194 if (RingBufferWriteData(pHandle->pRbuf, buffer, amount) != amount) {
195 AF_LOGE("write ring buffer error %u %u\n", amount, RingBuffergetMaxWriteSize(pHandle->pRbuf));
196 assert(0);
197 }
198
199 if (pHandle->mPConfig && pHandle->mPConfig->listener) {
200 // TODO: get file type form content type
201 pHandle->mPConfig->listener->onNetWorkInPut(amount, IDataSource::Listener::bitStreamTypeMedia);
202 }
203 return amount;
204}
205
206void Cicada::CURLConnection2::debugHeader(bool in, char *data, size_t size)
207{

Callers

nothing calls this directly

Calls 4

assertClass · 0.85
RingBufferWriteDataFunction · 0.85
onNetWorkInPutMethod · 0.45

Tested by

no test coverage detected