修复可能丢帧的bug

This commit is contained in:
xiongziliang 2019-08-02 11:09:17 +08:00
parent 35c324b6b4
commit a400b39fab
2 changed files with 4 additions and 2 deletions

View File

@ -41,7 +41,7 @@ void MediaSink::addTrack(const Track::Ptr &track_in) {
if(!strongSelf){ if(!strongSelf){
return; return;
} }
if(strongSelf->_allTrackReady){ if(!strongSelf->_anyTrackUnReady){
strongSelf->onTrackFrame(frame); strongSelf->onTrackFrame(frame);
} }
})); }));
@ -53,6 +53,7 @@ void MediaSink::addTrack(const Track::Ptr &track_in) {
if(track->ready()){ if(track->ready()){
lam(); lam();
}else{ }else{
_anyTrackUnReady = true;
_allTrackReady = false; _allTrackReady = false;
_trackReadyCallback[codec_id] = lam; _trackReadyCallback[codec_id] = lam;
_ticker.resetTime(); _ticker.resetTime();
@ -79,7 +80,7 @@ void MediaSink::inputFrame(const Frame::Ptr &frame) {
if(!_allTrackReady && (_trackReadyCallback.empty() || _ticker.elapsedTime() > MAX_WAIT_MS)){ if(!_allTrackReady && (_trackReadyCallback.empty() || _ticker.elapsedTime() > MAX_WAIT_MS)){
_allTrackReady = true; _allTrackReady = true;
_anyTrackUnReady = false;
if(!_trackReadyCallback.empty()){ if(!_trackReadyCallback.empty()){
//这是超时强制忽略未准备好的Track //这是超时强制忽略未准备好的Track
_trackReadyCallback.clear(); _trackReadyCallback.clear();

View File

@ -99,6 +99,7 @@ private:
map<int,Track::Ptr> _track_map; map<int,Track::Ptr> _track_map;
map<int,function<void()> > _trackReadyCallback; map<int,function<void()> > _trackReadyCallback;
bool _allTrackReady = false; bool _allTrackReady = false;
bool _anyTrackUnReady = false;
Ticker _ticker; Ticker _ticker;
}; };