修复Rtmp复用器循环引用的bug

This commit is contained in:
xiongziliang 2018-10-29 10:53:08 +08:00
parent 05b51585cb
commit 3bf1a9fddb
4 changed files with 15 additions and 3 deletions

View File

@ -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;

View File

@ -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: {

View File

@ -55,6 +55,14 @@ public:
*/
RtmpDemuxer(const AMFValue &val);
/**
*
* rtmp track
* @param metedata rtmp的metedata
* @return
*/
static int getTrackCount(const AMFValue &metedata);
virtual ~RtmpDemuxer(){};
/**

View File

@ -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;
}