mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
add srt config for lantency multiplier
This commit is contained in:
parent
9f357c24b8
commit
83d75c9a72
@ -291,6 +291,9 @@ timeoutSec=5
|
|||||||
#该端口是多线程的,同时支持客户端网络切换导致的连接迁移
|
#该端口是多线程的,同时支持客户端网络切换导致的连接迁移
|
||||||
port=9000
|
port=9000
|
||||||
|
|
||||||
|
#srt 协议中延迟缓存的估算参数,在握手阶段估算rtt ,然后lantencyMul*rtt 为最大缓存时长,此参数越大,表示等待重传的时长就越大
|
||||||
|
lantencyMul=4
|
||||||
|
|
||||||
|
|
||||||
[rtsp]
|
[rtsp]
|
||||||
#rtsp专有鉴权方式是采用base64还是md5方式
|
#rtsp专有鉴权方式是采用base64还是md5方式
|
||||||
|
@ -11,6 +11,8 @@ const std::string kTimeOutSec = SRT_FIELD"timeoutSec";
|
|||||||
//srt 单端口udp服务器
|
//srt 单端口udp服务器
|
||||||
const std::string kPort = SRT_FIELD"port";
|
const std::string kPort = SRT_FIELD"port";
|
||||||
|
|
||||||
|
const std::string kLantencyMul = SRT_FIELD"lantencyMul";
|
||||||
|
|
||||||
static std::atomic<uint32_t> s_srt_socket_id_generate{125};
|
static std::atomic<uint32_t> s_srt_socket_id_generate{125};
|
||||||
//////////// SrtTransport //////////////////////////
|
//////////// SrtTransport //////////////////////////
|
||||||
SrtTransport::SrtTransport(const EventPoller::Ptr &poller)
|
SrtTransport::SrtTransport(const EventPoller::Ptr &poller)
|
||||||
@ -155,7 +157,7 @@ void SrtTransport::handleHandshakeConclusion(HandshakePacket &pkt, struct sockad
|
|||||||
HSExtMessage::Ptr req;
|
HSExtMessage::Ptr req;
|
||||||
HSExtStreamID::Ptr sid;
|
HSExtStreamID::Ptr sid;
|
||||||
uint32_t srt_flag = 0xbf;
|
uint32_t srt_flag = 0xbf;
|
||||||
uint16_t delay = DurationCountMicroseconds(_now - _induction_ts)*4/1000;
|
uint16_t delay = DurationCountMicroseconds(_now - _induction_ts)*getLantencyMul()/1000;
|
||||||
|
|
||||||
for (auto ext : pkt.ext_list) {
|
for (auto ext : pkt.ext_list) {
|
||||||
//TraceL << getIdentifier() << " ext " << ext->dump();
|
//TraceL << getIdentifier() << " ext " << ext->dump();
|
||||||
@ -210,8 +212,6 @@ void SrtTransport::handleHandshakeConclusion(HandshakePacket &pkt, struct sockad
|
|||||||
}
|
}
|
||||||
_last_ack_pkt_seq_num = _init_seq_number;
|
_last_ack_pkt_seq_num = _init_seq_number;
|
||||||
}
|
}
|
||||||
void SrtTransport::bufCheckInterval(){
|
|
||||||
}
|
|
||||||
void SrtTransport::handleHandshake(uint8_t *buf, int len, struct sockaddr_storage *addr){
|
void SrtTransport::handleHandshake(uint8_t *buf, int len, struct sockaddr_storage *addr){
|
||||||
HandshakePacket pkt;
|
HandshakePacket pkt;
|
||||||
assert(pkt.loadFromData(buf,len));
|
assert(pkt.loadFromData(buf,len));
|
||||||
|
@ -21,6 +21,7 @@ using namespace toolkit;
|
|||||||
|
|
||||||
extern const std::string kPort;
|
extern const std::string kPort;
|
||||||
extern const std::string kTimeOutSec;
|
extern const std::string kTimeOutSec;
|
||||||
|
extern const std::string kLantencyMul;
|
||||||
|
|
||||||
class SrtTransport : public std::enable_shared_from_this<SrtTransport> {
|
class SrtTransport : public std::enable_shared_from_this<SrtTransport> {
|
||||||
public:
|
public:
|
||||||
@ -81,13 +82,14 @@ private:
|
|||||||
void sendShutDown();
|
void sendShutDown();
|
||||||
void sendMsgDropReq(uint32_t first ,uint32_t last);
|
void sendMsgDropReq(uint32_t first ,uint32_t last);
|
||||||
|
|
||||||
void bufCheckInterval();
|
|
||||||
|
|
||||||
size_t getPayloadSize();
|
size_t getPayloadSize();
|
||||||
protected:
|
protected:
|
||||||
void sendDataPacket(DataPacket::Ptr pkt,char* buf,int len,bool flush = false);
|
void sendDataPacket(DataPacket::Ptr pkt,char* buf,int len,bool flush = false);
|
||||||
void sendControlPacket(ControlPacket::Ptr pkt,bool flush = true);
|
void sendControlPacket(ControlPacket::Ptr pkt,bool flush = true);
|
||||||
virtual void sendPacket(Buffer::Ptr pkt,bool flush = true);
|
virtual void sendPacket(Buffer::Ptr pkt,bool flush = true);
|
||||||
|
virtual int getLantencyMul(){
|
||||||
|
return 4;
|
||||||
|
};
|
||||||
private:
|
private:
|
||||||
//当前选中的udp链接
|
//当前选中的udp链接
|
||||||
Session::Ptr _selected_session;
|
Session::Ptr _selected_session;
|
||||||
|
@ -273,5 +273,10 @@ void SrtTransportImp::doCachedFunc() {
|
|||||||
_cached_func.clear();
|
_cached_func.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SrtTransportImp::getLantencyMul(){
|
||||||
|
GET_CONFIG(int, lantencyMul, kLantencyMul);
|
||||||
|
return lantencyMul;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace SRT
|
} // namespace SRT
|
@ -38,6 +38,7 @@ protected:
|
|||||||
void onHandShakeFinished(std::string& streamid,struct sockaddr_storage *addr) override;
|
void onHandShakeFinished(std::string& streamid,struct sockaddr_storage *addr) override;
|
||||||
void onSRTData(DataPacket::Ptr pkt) override;
|
void onSRTData(DataPacket::Ptr pkt) override;
|
||||||
void onShutdown(const SockException &ex) override;
|
void onShutdown(const SockException &ex) override;
|
||||||
|
int getLantencyMul() override;
|
||||||
|
|
||||||
void sendPacket(Buffer::Ptr pkt,bool flush = true) override{
|
void sendPacket(Buffer::Ptr pkt,bool flush = true) override{
|
||||||
_total_bytes += pkt->size();
|
_total_bytes += pkt->size();
|
||||||
|
Loading…
Reference in New Issue
Block a user