强制flush后更新时间戳
This commit is contained in:
parent
14db56932b
commit
3f6625e75a
|
|
@ -58,7 +58,7 @@ public:
|
||||||
bool inputFrame(const Frame::Ptr &frame) override {
|
bool inputFrame(const Frame::Ptr &frame) override {
|
||||||
if (!_timer) {
|
if (!_timer) {
|
||||||
resetTimer(EventPoller::getCurrentPoller());
|
resetTimer(EventPoller::getCurrentPoller());
|
||||||
_ticker.resetTime();
|
setCurrentStamp(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t dts;
|
int64_t dts;
|
||||||
|
|
@ -71,7 +71,7 @@ private:
|
||||||
void onTick() {
|
void onTick() {
|
||||||
while (!_cache.empty()) {
|
while (!_cache.empty()) {
|
||||||
auto &front = _cache.front();
|
auto &front = _cache.front();
|
||||||
if (_ticker.elapsedTime() < front.first) {
|
if (getCurrentStamp() < front.first) {
|
||||||
// 还没到消费时间
|
// 还没到消费时间
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -81,6 +81,7 @@ private:
|
||||||
_cache.pop_front();
|
_cache.pop_front();
|
||||||
}
|
}
|
||||||
if (_cache.size() > 25 * 5) {
|
if (_cache.size() > 25 * 5) {
|
||||||
|
auto dts = _cache.back().first;
|
||||||
// 强制flush数据
|
// 强制flush数据
|
||||||
WarnL << "Flush frame paced sender cache: " << _cache.size();
|
WarnL << "Flush frame paced sender cache: " << _cache.size();
|
||||||
while (!_cache.empty()) {
|
while (!_cache.empty()) {
|
||||||
|
|
@ -88,11 +89,22 @@ private:
|
||||||
_cb(front.second);
|
_cb(front.second);
|
||||||
_cache.pop_front();
|
_cache.pop_front();
|
||||||
}
|
}
|
||||||
|
setCurrentStamp(dts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t getCurrentStamp () {
|
||||||
|
return _ticker.elapsedTime() + _stamp_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t setCurrentStamp(uint64_t stamp ) {
|
||||||
|
_stamp_offset = stamp;
|
||||||
|
_ticker.resetTime();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t _paced_sender_ms;
|
uint32_t _paced_sender_ms;
|
||||||
|
uint64_t _stamp_offset = 0;
|
||||||
OnFrame _cb;
|
OnFrame _cb;
|
||||||
Stamp _stamp[2];
|
Stamp _stamp[2];
|
||||||
Ticker _ticker;
|
Ticker _ticker;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue