add srt recv and send packet buf size

This commit is contained in:
xiongguangjie 2022-06-11 22:51:11 +08:00
parent f8373302d0
commit 4b9f789c79
5 changed files with 15 additions and 2 deletions

View File

@ -294,6 +294,9 @@ port=9000
#srt 协议中延迟缓存的估算参数在握手阶段估算rtt ,然后latencyMul*rtt 为最大缓存时长,此参数越大,表示等待重传的时长就越大 #srt 协议中延迟缓存的估算参数在握手阶段估算rtt ,然后latencyMul*rtt 为最大缓存时长,此参数越大,表示等待重传的时长就越大
latencyMul=4 latencyMul=4
#包缓存的大小
pktBufSize=8192
[rtsp] [rtsp]
#rtsp专有鉴权方式是采用base64还是md5方式 #rtsp专有鉴权方式是采用base64还是md5方式

View File

@ -12,6 +12,7 @@ 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 kLatencyMul = SRT_FIELD "latencyMul"; const std::string kLatencyMul = SRT_FIELD "latencyMul";
const std::string kPktBufSize = SRT_FIELD "pktBufSize";
static std::atomic<uint32_t> s_srt_socket_id_generate { 125 }; static std::atomic<uint32_t> s_srt_socket_id_generate { 125 };
//////////// SrtTransport ////////////////////////// //////////// SrtTransport //////////////////////////
@ -207,8 +208,8 @@ void SrtTransport::handleHandshakeConclusion(HandshakePacket &pkt, struct sockad
sendControlPacket(res, true); sendControlPacket(res, true);
TraceL << " buf size = " << res->max_flow_window_size << " init seq =" << _init_seq_number TraceL << " buf size = " << res->max_flow_window_size << " init seq =" << _init_seq_number
<< " latency=" << delay; << " latency=" << delay;
_recv_buf = std::make_shared<PacketQueue>(res->max_flow_window_size, _init_seq_number, delay * 1e3); _recv_buf = std::make_shared<PacketQueue>(getPktBufSize(), _init_seq_number, delay * 1e3);
_send_buf = std::make_shared<PacketSendQueue>(res->max_flow_window_size, delay * 1e3); _send_buf = std::make_shared<PacketSendQueue>(getPktBufSize(), delay * 1e3);
_send_packet_seq_number = _init_seq_number; _send_packet_seq_number = _init_seq_number;
_buf_delay = delay; _buf_delay = delay;
onHandShakeFinished(_stream_id, addr); onHandShakeFinished(_stream_id, addr);

View File

@ -23,6 +23,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 kLatencyMul; extern const std::string kLatencyMul;
extern const std::string kPktBufSize;
class SrtTransport : public std::enable_shared_from_this<SrtTransport> { class SrtTransport : public std::enable_shared_from_this<SrtTransport> {
public: public:
@ -55,6 +56,7 @@ protected:
virtual void onHandShakeFinished(std::string &streamid, struct sockaddr_storage *addr) {}; virtual void onHandShakeFinished(std::string &streamid, struct sockaddr_storage *addr) {};
virtual void sendPacket(Buffer::Ptr pkt, bool flush = true); virtual void sendPacket(Buffer::Ptr pkt, bool flush = true);
virtual int getLatencyMul() { return 4; }; virtual int getLatencyMul() { return 4; };
virtual int getPktBufSize() { return 8192; };
private: private:
void registerSelf(); void registerSelf();

View File

@ -326,4 +326,10 @@ int SrtTransportImp::getLatencyMul() {
return latencyMul; return latencyMul;
} }
int SrtTransportImp::getPktBufSize() {
// kPktBufSize
GET_CONFIG(int, pktBufSize, kPktBufSize);
return pktBufSize;
}
} // namespace SRT } // namespace SRT

View File

@ -36,6 +36,7 @@ public:
protected: protected:
///////SrtTransport override/////// ///////SrtTransport override///////
int getLatencyMul() override; int getLatencyMul() override;
int getPktBufSize() 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;
void onHandShakeFinished(std::string &streamid, struct sockaddr_storage *addr) override; void onHandShakeFinished(std::string &streamid, struct sockaddr_storage *addr) override;