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