mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 00:37:39 +08:00
优化纯音频流的延时
This commit is contained in:
parent
a9539eb626
commit
92f69c3915
@ -129,6 +129,10 @@ public:
|
||||
*/
|
||||
void onWrite(const RtmpPacket::Ptr &pkt, bool key = true) override {
|
||||
lock_guard<recursive_mutex> lock(_mtx);
|
||||
if(pkt->typeId == MSG_VIDEO){
|
||||
//有视频,那么启用GOP缓存
|
||||
_have_video = true;
|
||||
}
|
||||
if (pkt->isCfgFrame()) {
|
||||
_config_frame_map[pkt->typeId] = pkt;
|
||||
return;
|
||||
@ -155,7 +159,8 @@ public:
|
||||
}
|
||||
}
|
||||
_track_stamps_map[pkt->typeId] = pkt->timeStamp;
|
||||
_ring->write(pkt, pkt->isVideoKeyFrame());
|
||||
//不存在视频,为了减少缓存延时,那么关闭GOP缓存
|
||||
_ring->write(pkt, _have_video ? pkt->isVideoKeyFrame() : true);
|
||||
checkNoneReader();
|
||||
}
|
||||
|
||||
@ -203,6 +208,7 @@ private:
|
||||
protected:
|
||||
int _ring_size;
|
||||
bool _async_emit_none_reader = false;
|
||||
bool _have_video = false;
|
||||
mutable recursive_mutex _mtx;
|
||||
Ticker _reader_changed_ticker;
|
||||
AMFValue _metadata;
|
||||
|
@ -153,6 +153,7 @@ public:
|
||||
virtual void setSdp(const string &sdp) {
|
||||
_sdp = sdp;
|
||||
_sdp_parser.load(sdp);
|
||||
_have_video = (bool)_sdp_parser.getTrack(TrackVideo);
|
||||
if (_ring) {
|
||||
regist();
|
||||
}
|
||||
@ -188,7 +189,8 @@ public:
|
||||
regist();
|
||||
}
|
||||
}
|
||||
_ring->write(rtp, keyPos);
|
||||
//不存在视频,为了减少缓存延时,那么关闭GOP缓存
|
||||
_ring->write(rtp, _have_video ? keyPos : true);
|
||||
checkNoneReader();
|
||||
}
|
||||
private:
|
||||
@ -220,6 +222,7 @@ private:
|
||||
protected:
|
||||
int _ring_size;
|
||||
bool _async_emit_none_reader = false;
|
||||
bool _have_video = false;
|
||||
Ticker _reader_changed_ticker;
|
||||
SdpParser _sdp_parser;
|
||||
string _sdp;
|
||||
|
Loading…
Reference in New Issue
Block a user