Prevent access to nullptr when cloning a track

This commit is contained in:
xiongziliang 2024-01-15 20:34:17 +08:00
parent dfda93a4c4
commit 6514be74f1

View File

@ -37,6 +37,7 @@ bool MediaSink::addTrack(const Track::Ptr &track_in) {
} }
// 克隆Track只拷贝其数据不拷贝其数据转发关系 // 克隆Track只拷贝其数据不拷贝其数据转发关系
auto track = track_in->clone(); auto track = track_in->clone();
CHECK(track, "Clone track failed: ", track_in->getCodecName());
auto index = track->getIndex(); auto index = track->getIndex();
if (!_track_map.emplace(index, std::make_pair(track, false)).second) { if (!_track_map.emplace(index, std::make_pair(track, false)).second) {
WarnL << "Already add a same track: " << track->getIndex() << ", codec: " << track->getCodecName(); WarnL << "Already add a same track: " << track->getIndex() << ", codec: " << track->getCodecName();