| | |
| | | pthread_mutex_lock(&mtx); |
| | | if (q.empty()) { |
| | | gettimeofday(&now, NULL); |
| | | t.tv_sec = now.tv_sec + 5; |
| | | t.tv_sec = now.tv_sec + 3; |
| | | t.tv_nsec = now.tv_usec * 1000; |
| | | // pthread_cond_wait(&cond, &mtx); |
| | | pthread_cond_timedwait(&cond, &mtx, &t); |
| | |
| | | while (!q.empty()) q.pop_front(); |
| | | pthread_mutex_unlock(&mtx); |
| | | } |
| | | |
| | | void clearAll(std::function<void(T)> fn){ |
| | | pthread_mutex_lock(&mtx); |
| | | while (!q.empty()){ |
| | | T value = q.front(); |
| | | fn(value); |
| | | q.pop_front(); |
| | | } |
| | | pthread_mutex_unlock(&mtx); |
| | | } |
| | | private: |
| | | deque<T> q; |
| | | pthread_mutex_t mtx; |
| | |
| | | |
| | | ~GB28181API(){ |
| | | printf("GB28181API end!\n"); |
| | | m_rtpQueue.clearAll(); |
| | | // m_rtpQueue.clearAll(); |
| | | m_rtpQueue.clearAll([](frameBuffInfo *info){ |
| | | delete[] info->buff; |
| | | delete info; |
| | | }); |
| | | deleteCamera(); |
| | | } |
| | | |