mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 08:39:34 +08:00
完善Rtsp复用器
This commit is contained in:
parent
d1348f3846
commit
413b18521d
@ -33,15 +33,22 @@ void RtspMuxer::addTrack(const Track::Ptr &track, uint32_t ssrc, int mtu) {
|
||||
//记录该Track
|
||||
auto codec_id = track->getCodecId();
|
||||
_track_map[codec_id] = track;
|
||||
|
||||
auto lam = [this,ssrc,mtu,track](){
|
||||
//异步生成rtp编码器
|
||||
//根据track生产sdp
|
||||
Sdp::Ptr sdp = Factory::getSdpByTrack(track);
|
||||
if (!sdp) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据sdp生成rtp编码器
|
||||
auto encoder = sdp->createRtpEncoder(ssrc ? ssrc : ((uint64_t) sdp.get()) & 0xFFFFFFFF, mtu);
|
||||
if (!encoder) {
|
||||
return;
|
||||
}
|
||||
//添加其sdp
|
||||
_sdp.append(sdp->getSdp());
|
||||
//设置Track的代理,这样输入frame至Track时,最终数据将输出到RtpEncoder中
|
||||
track->setDelegate(encoder);
|
||||
//rtp编码器共用同一个环形缓存
|
||||
@ -59,12 +66,7 @@ string RtspMuxer::getSdp() {
|
||||
//尚未就绪
|
||||
return "";
|
||||
}
|
||||
|
||||
// _StrPrinter printer;
|
||||
// for (auto &pr : _sdp_map) {
|
||||
// printer << pr.second->getSdp();
|
||||
// }
|
||||
// return printer;
|
||||
return _sdp;
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +82,7 @@ void RtspMuxer::inputFrame(const Frame::Ptr &frame) {
|
||||
it->second->inputFrame(frame);
|
||||
|
||||
if(!ready && it->second->ready()){
|
||||
//Track又未就绪状态装换成就绪状态,我们就生成sdp以及rtp编码器
|
||||
//Track由未就绪状态装换成就绪状态,我们就生成sdp以及rtp编码器
|
||||
auto it_callback = _trackReadyCallback.find(codec_id);
|
||||
if(it_callback != _trackReadyCallback.end()){
|
||||
it_callback->second();
|
||||
|
@ -38,7 +38,8 @@ public:
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
RtspMuxer(){
|
||||
RtspMuxer(const TitleSdp::Ptr &title = std::make_shared<TitleSdp>()){
|
||||
_sdp = title->getSdp();
|
||||
_rtpRing = std::make_shared<RtpRingInterface::RingType>();
|
||||
}
|
||||
virtual ~RtspMuxer(){}
|
||||
@ -79,6 +80,7 @@ private:
|
||||
map<int,Track::Ptr> _track_map;
|
||||
map<int,function<void()> > _trackReadyCallback;
|
||||
RtpRingInterface::RingType::Ptr _rtpRing;
|
||||
string _sdp;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user