| 177 | } |
| 178 | |
| 179 | size_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 | |
| 206 | void Cicada::CURLConnection2::debugHeader(bool in, char *data, size_t size) |
| 207 | { |
nothing calls this directly
no test coverage detected