修复一个关闭GB28181时引发的崩溃问题 (#3118)

fix #3116 #3115
This commit is contained in:
waken 2023-12-13 17:41:57 +08:00 committed by GitHub
parent 2f4cd67162
commit 9933398614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -205,6 +205,9 @@ Frame::Ptr Factory::getFrameFromPtr(CodecId codec, const char *data, size_t byte
Frame::Ptr Factory::getFrameFromBuffer(CodecId codec, Buffer::Ptr data, uint64_t dts, uint64_t pts) { Frame::Ptr Factory::getFrameFromBuffer(CodecId codec, Buffer::Ptr data, uint64_t dts, uint64_t pts) {
auto frame = Factory::getFrameFromPtr(codec, data->data(), data->size(), dts, pts); auto frame = Factory::getFrameFromPtr(codec, data->data(), data->size(), dts, pts);
if(!frame){
return nullptr;
}
return std::make_shared<FrameCacheAble>(frame, false, std::move(data)); return std::make_shared<FrameCacheAble>(frame, false, std::move(data));
} }

View File

@ -110,6 +110,10 @@ void DecoderImp::onDecode(int stream, int codecid, int flags, int64_t pts, int64
if (!ref.first) { if (!ref.first) {
onTrack(stream, Factory::getTrackByCodecId(codec, 8000, 1, 16)); onTrack(stream, Factory::getTrackByCodecId(codec, 8000, 1, 16));
} }
if (!ref.first) {
WarnL << "not support codec :" << getCodecName(codec);
return;
}
auto frame = Factory::getFrameFromPtr(codec, (char *)data, bytes, dts, pts); auto frame = Factory::getFrameFromPtr(codec, (char *)data, bytes, dts, pts);
if (getTrackType(codec) != TrackVideo) { if (getTrackType(codec) != TrackVideo) {
onFrame(stream, frame); onFrame(stream, frame);