diff --git a/frameworks/native/capi/avsource/native_avsource.cpp b/frameworks/native/capi/avsource/native_avsource.cpp index 007bc4020a3c3190e1ead759a2b292ee886759e9..dd5e9e336a465c95d81d718e5c79088793d10f90 100644 --- a/frameworks/native/capi/avsource/native_avsource.cpp +++ b/frameworks/native/capi/avsource/native_avsource.cpp @@ -141,6 +141,7 @@ OH_AVFormat *OH_AVSource_GetSourceFormat(OH_AVSource *source) CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, nullptr, "source_ GetSourceFormat failed!"); OH_AVFormat *avFormat = OH_AVFormat_Create(); + CHECK_AND_RETURN_RET_LOG(avFormat != nullptr, nullptr, "Get source format failed, format is nullptr!"); avFormat->format_ = format; return avFormat; @@ -160,6 +161,7 @@ OH_AVFormat *OH_AVSource_GetTrackFormat(OH_AVSource *source, uint32_t trackIndex CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, nullptr, "Source GetTrackFormat failed!"); OH_AVFormat *avFormat = OH_AVFormat_Create(); + CHECK_AND_RETURN_RET_LOG(avFormat != nullptr, nullptr, "Get format failed, format is nullptr!"); avFormat->format_ = format; return avFormat; diff --git a/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp b/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp index ef7b1a1e6e3d3f814b5f9040944707ecf311d7db..5c9be52c68b85d9aa5d1a001ce7c769b73f57d06 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp @@ -162,7 +162,9 @@ std::shared_ptr BlockQueuePool::Pop(uint32_t trackIndex) } MEDIA_LOG_D("block queue " PUBLIC_LOG_S " Pop finish, trackIndex: " PUBLIC_LOG_U32 ".", name_.c_str(), trackIndex); - sizeMap_[trackIndex] -= 1; + if (sizeMap_[trackIndex] > 0) { + sizeMap_[trackIndex] -= 1; + } return block; } } @@ -203,10 +205,12 @@ std::shared_ptr BlockQueuePool::Back(uint32_t trackIndex) return nullptr; } auto queVector = queMap_[trackIndex]; - auto lastQueIndex = queVector[queVector.size() - 1]; - if (quePool_[lastQueIndex].blockQue != nullptr && quePool_[lastQueIndex].blockQue->Size() > 0) { - auto block = quePool_[lastQueIndex].blockQue->Back(); - return block; + if (queVector.size() > 0) { + auto lastQueIndex = queVector[queVector.size() - 1]; + if (quePool_[lastQueIndex].blockQue != nullptr && quePool_[lastQueIndex].blockQue->Size() > 0) { + auto block = quePool_[lastQueIndex].blockQue->Back(); + return block; + } } MEDIA_LOG_E("trackIndex: " PUBLIC_LOG_U32 " has not cache data", trackIndex); return nullptr; diff --git a/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp b/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp index 6d0cd1102263f928f953772c665a9f496f5d7dfd..dc46f7db817b9b9d433cdb815b5cf42071203387 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp @@ -407,7 +407,7 @@ void FFmpegDemuxerPlugin::ConvertHevcToAnnexb(AVPacket& pkt, std::shared_ptr(cencInfoSize), false); if (NeedCombineFrame(samplePacket->pkts[0]->stream_index) && streamParser_->IsSyncFrame(pkt.data, pkt.size)) { - pkt.flags |= static_cast(AV_PKT_FLAG_KEY); + pkt.flags = static_cast(static_cast(pkt.flags) | static_cast(AV_PKT_FLAG_KEY)); } }