mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-30 07:26:53 +08:00
修复可能丢帧的bug
This commit is contained in:
parent
35c324b6b4
commit
a400b39fab
@ -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();
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user