mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 08:39:34 +08:00
修复Rtmp复用器循环引用的bug
This commit is contained in:
parent
05b51585cb
commit
3bf1a9fddb
@ -80,8 +80,7 @@ public:
|
||||
virtual void onGetMetaData(const AMFValue &metadata) {
|
||||
lock_guard<recursive_mutex> lock(_mtxMap);
|
||||
_metadata = metadata;
|
||||
RtmpDemuxer parser(metadata);
|
||||
_iCfgFrameSize = parser.getTracks().size();
|
||||
_iCfgFrameSize = RtmpDemuxer::getTrackCount(metadata);
|
||||
if(ready()){
|
||||
MediaSource::regist();
|
||||
_bRegisted = true;
|
||||
|
@ -45,6 +45,10 @@ RtmpDemuxer::RtmpDemuxer(const AMFValue &val) {
|
||||
}
|
||||
}
|
||||
|
||||
int RtmpDemuxer::getTrackCount(const AMFValue &metedata) {
|
||||
return (int)(metedata["videocodecid"].type() != AMF_NULL) + (int)(metedata["audiocodecid"].type() != AMF_NULL);
|
||||
}
|
||||
|
||||
bool RtmpDemuxer::inputRtmp(const RtmpPacket::Ptr &pkt) {
|
||||
switch (pkt->typeId) {
|
||||
case MSG_VIDEO: {
|
||||
|
@ -55,6 +55,14 @@ public:
|
||||
*/
|
||||
RtmpDemuxer(const AMFValue &val);
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取rtmp track 数
|
||||
* @param metedata rtmp的metedata
|
||||
* @return
|
||||
*/
|
||||
static int getTrackCount(const AMFValue &metedata);
|
||||
|
||||
virtual ~RtmpDemuxer(){};
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,8 @@ RtmpMuxer::RtmpMuxer(const TitleMete::Ptr &title) {
|
||||
|
||||
void RtmpMuxer::onTrackReady(const Track::Ptr &track) {
|
||||
//生成rtmp编码器
|
||||
auto encoder = Factory::getRtmpCodecByTrack(track);
|
||||
//克隆该Track,防止循环引用
|
||||
auto encoder = Factory::getRtmpCodecByTrack(track->clone());
|
||||
if (!encoder) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user