mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 18:50:20 +08:00
Performance: 使用循环池优化webrtc分发性能
This commit is contained in:
parent
97f7255f0a
commit
dd30ab22cf
@ -313,6 +313,7 @@ void WebRtcTransportImp::onCreate(){
|
||||
|
||||
WebRtcTransportImp::WebRtcTransportImp(const EventPoller::Ptr &poller) : WebRtcTransport(poller) {
|
||||
InfoL << getIdentifier();
|
||||
_packet_pool.setSize(64);
|
||||
}
|
||||
|
||||
WebRtcTransportImp::~WebRtcTransportImp() {
|
||||
@ -329,7 +330,7 @@ void WebRtcTransportImp::onSendSockData(const char *buf, size_t len, struct sock
|
||||
WarnL << "send data failed:" << len;
|
||||
return;
|
||||
}
|
||||
auto ptr = BufferRaw::create();
|
||||
auto ptr = _packet_pool.obtain();
|
||||
ptr->assign(buf, len);
|
||||
//一次性发送一帧的rtp数据,提高网络io性能
|
||||
_session->setSendFlushFlag(flush);
|
||||
|
@ -214,8 +214,6 @@ struct WrappedRtpTrack : public WrappedMediaTrack {
|
||||
void inputRtp(const char *buf, size_t len, uint64_t stamp_ms, RtpHeader *rtp) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class WebRtcTransportImp : public WebRtcTransport {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<WebRtcTransportImp>;
|
||||
@ -281,6 +279,8 @@ private:
|
||||
unordered_map<uint32_t/*ssrc*/, MediaTrack::Ptr> _ssrc_to_track;
|
||||
//根据接收rtp的pt获取相关信息
|
||||
unordered_map<uint8_t/*pt*/, std::unique_ptr<WrappedMediaTrack>> _pt_to_track;
|
||||
//循环池
|
||||
ResourcePool<BufferRaw> _packet_pool;
|
||||
};
|
||||
|
||||
class WebRtcTransportManager {
|
||||
|
Loading…
Reference in New Issue
Block a user