Merge branch 'develop' of gitee.com:zjskpajs/av_codec into dev_lzm

This commit is contained in:
linziming 2023-04-06 09:23:20 +08:00
commit 4c611c53c4
23 changed files with 281 additions and 217 deletions

View File

@ -57,7 +57,7 @@ int32_t AVCodecImpl::Init(AVCodecType type, bool isMimeType, const std::string &
AVCodecImpl::AVCodecImpl()
{
MEDIA_LOGD("AVCodecImpl:0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
AVCODEC_LOGD("AVCodecImpl:0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
}
AVCodecImpl::~AVCodecImpl()
@ -66,7 +66,7 @@ AVCodecImpl::~AVCodecImpl()
(void)MediaServiceFactory::GetInstance().DestroyAVCodecService(codecService_);
codecService_ = nullptr;
}
MEDIA_LOGD("AVCodecImpl:0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
AVCODEC_LOGD("AVCodecImpl:0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
}
int32_t AVCodecImpl::Configure(const Format &format)

View File

@ -45,7 +45,7 @@ int32_t AVDemuxerImpl::Init(Source *source)
AVDemuxerImpl::AVDemuxerImpl()
{
MEDIA_LOGD("AVDemuxerImpl:0x%{public}06" PRIXPTR " Instances create". FAKE_POINTER(this));
AVCODEC_LOGD("AVDemuxerImpl:0x%{public}06" PRIXPTR " Instances create". FAKE_POINTER(this));
}
AVDemuxerImpl::~AVDemuxerImpl()
@ -54,7 +54,7 @@ AVDemuxerImpl::~AVDemuxerImpl()
(void)MediaServiceFactory::GetInstance().DestroyAVDemuxerService(demuxerService_);
demuxerService_ = nullptr;
}
MEDIA_LOGD("AVDemuxerImpl:0x%{public}06" PRIXPTR " Instances destroy". FAKE_POINTER(this));
AVCODEC_LOGD("AVDemuxerImpl:0x%{public}06" PRIXPTR " Instances destroy". FAKE_POINTER(this));
}
int32_t AVDemuxerImpl::AddSourceTrackByID(uint32_t index)

View File

@ -39,12 +39,12 @@ std::shared_ptr<AVMuxer> AVMuxerFactory::CreateAVMuxer(int32_t fd, OutputFormat
AVMuxerImpl::AVMuxerImpl(int32_t fd, OutputFormat format) : fd_(fd), format_(format)
{
MEDIA_LOGD("AVMuxerImpl:0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
AVCODEC_LOGD("AVMuxerImpl:0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
}
AVMuxerImpl::~AVMuxerImpl()
{
MEDIA_LOGD("AVMuxerImpl:0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
AVCODEC_LOGD("AVMuxerImpl:0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
}
int32_t AVMuxerImpl::Init()

View File

@ -77,7 +77,7 @@ public:
CHECK_AND_RETURN_LOG(codecObj->codec_ != nullptr, "codec_ is nullptr!");
if (codecObj->isFlushing_.load() || codecObj->isStop_.load() || codecObj->isEOS_.load()) {
MEDIA_LOGD("At flush, eos or stop, no buffer available");
AVCODEC_LOGD("At flush, eos or stop, no buffer available");
return;
}
OH_AVBufferElement *data = GetInputData(codec_, index);
@ -95,7 +95,7 @@ public:
CHECK_AND_RETURN_LOG(codecObj->codec_ != nullptr, "codec_ is nullptr!");
if (codecObj->isFlushing_.load() || codecObj->isStop_.load()) {
MEDIA_LOGD("At flush or stop, ignore");
AVCODEC_LOGD("At flush or stop, ignore");
return;
}
struct OH_AVCodecBufferAttr bufferAttr;
@ -206,7 +206,7 @@ struct OH_AVCodec *OH_AVCodec_CreateByName(const char *name)
return object;
}
OH_AVErrCode OH_AVCodec_Destroy(struct OH_AVCodec *codec)
OH_AVCodecErrCode OH_AVCodec_Destroy(struct OH_AVCodec *codec)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
@ -218,19 +218,19 @@ OH_AVErrCode OH_AVCodec_Destroy(struct OH_AVCodec *codec)
codecObj->isStop_.store(false);
int32_t ret = codecObj->codec_->Release();
if (ret != MSERR_OK) {
MEDIA_LOGE("codec Release failed!");
AVCODEC_LOGE("codec Release failed!");
delete codec;
return AV_ERR_OPERATE_NOT_PERMIT;
}
} else {
MEDIA_LOGD("codec_ is nullptr!");
AVCODEC_LOGD("codec_ is nullptr!");
}
delete codec;
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_Configure(struct OH_AVCodec *codec, struct OH_AVFormat *format)
OH_AVCodecErrCode OH_AVCodec_Configure(struct OH_AVCodec *codec, struct OH_AVFormat *format)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
CHECK_AND_RETURN_RET_LOG(format != nullptr, AV_ERR_INVALID_VAL, "input format is nullptr!");
@ -241,10 +241,10 @@ OH_AVErrCode OH_AVCodec_Configure(struct OH_AVCodec *codec, struct OH_AVFormat *
int32_t ret = codecObj->codec_->Configure(format->format_);
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_OPERATE_NOT_PERMIT, "codec Configure failed!");
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_Start(struct OH_AVCodec *codec)
OH_AVCodecErrCode OH_AVCodec_Start(struct OH_AVCodec *codec)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
@ -255,10 +255,10 @@ OH_AVErrCode OH_AVCodec_Start(struct OH_AVCodec *codec)
int32_t ret = codecObj->codec_->Start();
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_OPERATE_NOT_PERMIT, "codec Start failed!");
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_Stop(struct OH_AVCodec *codec)
OH_AVCodecErrCode OH_AVCodec_Stop(struct OH_AVCodec *codec)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
@ -266,20 +266,20 @@ OH_AVErrCode OH_AVCodec_Stop(struct OH_AVCodec *codec)
CHECK_AND_RETURN_RET_LOG(codecObj->codec_ != nullptr, AV_ERR_INVALID_VAL, "codec_ is nullptr!");
codecObj->isStop_.store(true);
MEDIA_LOGD("Set stop status to true");
AVCODEC_LOGD("Set stop status to true");
int32_t ret = codecObj->codec_->Stop();
if (ret != MSERR_OK) {
codecObj->isStop_.store(false);
MEDIA_LOGE("codec Stop failed! Set stop status to false");
AVCODEC_LOGE("codec Stop failed! Set stop status to false");
return AV_ERR_OPERATE_NOT_PERMIT;
}
codecObj->memoryObjList_.clear();
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_Flush(struct OH_AVCodec *codec)
OH_AVCodecErrCode OH_AVCodec_Flush(struct OH_AVCodec *codec)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
@ -287,41 +287,41 @@ OH_AVErrCode OH_AVCodec_Flush(struct OH_AVCodec *codec)
CHECK_AND_RETURN_RET_LOG(codecObj->codec_ != nullptr, AV_ERR_INVALID_VAL, "codec_ is nullptr!");
codecObj->isFlushing_.store(true);
MEDIA_LOGD("Set flush status to true");
AVCODEC_LOGD("Set flush status to true");
int32_t ret = codecObj->codec_->Flush();
if (ret != MSERR_OK) {
codecObj->isFlushing_.store(false);
MEDIA_LOGD("codec Flush failed! Set flush status to false");
AVCODEC_LOGD("codec Flush failed! Set flush status to false");
return AV_ERR_OPERATE_NOT_PERMIT;
}
codecObj->memoryObjList_.clear();
codecObj->isFlushing_.store(false);
MEDIA_LOGD("Set flush status to false");
return AV_ERR_OK;
AVCODEC_LOGD("Set flush status to false");
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_Reset(struct OH_AVCodec *codec)
OH_AVCodecErrCode OH_AVCodec_Reset(struct OH_AVCodec *codec)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
struct CodecObject *codecObj = reinterpret_cast<CodecObject *>(codec);
CHECK_AND_RETURN_RET_LOG(codecObj->codec_ != nullptr, AV_ERR_INVALID_VAL, "codec_ is nullptr!");
codecObj->isStop_.store(false);
MEDIA_LOGD("Set stop status to true");
AVCODEC_LOGD("Set stop status to true");
int32_t ret = codecObj->codec_->Reset();
if (ret != MSERR_OK) {
codecObj->isStop_.store(false);
MEDIA_LOGE("codec Reset failed! Set stop status to false");
AVCODEC_LOGE("codec Reset failed! Set stop status to false");
return AV_ERR_OPERATE_NOT_PERMIT;
}
codecObj->memoryObjList_.clear();
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_VideoDecoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window)
OH_AVCodecErrCode OH_AVCodec_VideoDecoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
CHECK_AND_RETURN_RET_LOG(window != nullptr, AV_ERR_INVALID_VAL, "input window is nullptr!");
@ -333,12 +333,12 @@ OH_AVErrCode OH_AVCodec_VideoDecoderSetSurface(OH_AVCodec *codec, OHNativeWindow
int32_t ret = codecObj->codec_->SetOutputSurface(window->surface);
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_OPERATE_NOT_PERMIT, "codec SetOutputSurface failed!");
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_QueueInputBuffer(struct OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr)
OH_AVCodecErrCode OH_AVCodec_QueueInputBuffer(struct OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr)
{
MEDIA_LOGD("In OH_AVCodec_QueueInputBuffer");
AVCODEC_LOGD("In OH_AVCodec_QueueInputBuffer");
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
struct CodecObject *codecObj = reinterpret_cast<CodecObject *>(codec);
@ -356,7 +356,7 @@ OH_AVErrCode OH_AVCodec_QueueInputBuffer(struct OH_AVCodec *codec, uint32_t inde
codecObj->isEOS_.store(true);
}
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVFormat *OH_AVCodec_GetOutputFormat(struct OH_AVCodec *codec)
@ -376,9 +376,9 @@ OH_AVFormat *OH_AVCodec_GetOutputFormat(struct OH_AVCodec *codec)
return avFormat;
}
OH_AVErrCode OH_AVCodec_VideoDecoderRenderFrame(struct OH_AVCodec *codec, uint32_t index)
OH_AVCodecErrCode OH_AVCodec_VideoDecoderRenderFrame(struct OH_AVCodec *codec, uint32_t index)
{
MEDIA_LOGD("In OH_AVCodec_VideoDecoderRenderFrame");
AVCODEC_LOGD("In OH_AVCodec_VideoDecoderRenderFrame");
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
struct CodecObject *codecObj = reinterpret_cast<CodecObject *>(codec);
@ -387,12 +387,12 @@ OH_AVErrCode OH_AVCodec_VideoDecoderRenderFrame(struct OH_AVCodec *codec, uint32
int32_t ret = codecObj->codec_->ReleaseOutputBuffer(index, true);
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_OPERATE_NOT_PERMIT, "codec ReleaseOutputBuffer failed!");
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_ReleaseOutputData(struct OH_AVCodec *codec, uint32_t index)
OH_AVCodecErrCode OH_AVCodec_ReleaseOutputData(struct OH_AVCodec *codec, uint32_t index)
{
MEDIA_LOGD("In OH_AVCodec_ReleaseOutputData");
AVCODEC_LOGD("In OH_AVCodec_ReleaseOutputData");
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
struct CodecObject *codecObj = reinterpret_cast<CodecObject *>(codec);
@ -401,10 +401,10 @@ OH_AVErrCode OH_AVCodec_ReleaseOutputData(struct OH_AVCodec *codec, uint32_t ind
int32_t ret = codecObj->codec_->ReleaseOutputBuffer(index, false);
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_OPERATE_NOT_PERMIT, "codec ReleaseOutputBuffer failed!");
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_SetParameter(struct OH_AVCodec *codec, struct OH_AVFormat *format)
OH_AVCodecErrCode OH_AVCodec_SetParameter(struct OH_AVCodec *codec, struct OH_AVFormat *format)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
CHECK_AND_RETURN_RET_LOG(format != nullptr, AV_ERR_INVALID_VAL, "input format is nullptr!");
@ -415,10 +415,10 @@ OH_AVErrCode OH_AVCodec_SetParameter(struct OH_AVCodec *codec, struct OH_AVForma
int32_t ret = codecObj->codec_->SetParameter(format->format_);
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_OPERATE_NOT_PERMIT, "codec SetParameter failed!");
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVErrCode OH_AVCodec_SetCallback(
OH_AVCodecErrCode OH_AVCodec_SetCallback(
struct OH_AVCodec *codec, struct OH_AVCodecCallback callback, void *userData)
{
CHECK_AND_RETURN_RET_LOG(codec != nullptr, AV_ERR_INVALID_VAL, "input codec is nullptr!");
@ -432,7 +432,7 @@ OH_AVErrCode OH_AVCodec_SetCallback(
int32_t ret = codecObj->codec_->SetCallback(codecObj->callback_);
CHECK_AND_RETURN_RET_LOG(ret == MSERR_OK, AV_ERR_OPERATE_NOT_PERMIT, "codec SetCallback failed!");
return AV_ERR_OK;
return AVCODEC_ERR_OK;
}
OH_AVBufferElement* OH_AVCodec_GetInputBuffer(OH_AVCodec *codec, size_t index)
@ -461,32 +461,37 @@ OH_AVBufferElement* OH_AVCodec_GetOutputBuffer(OH_AVCodec *codec, size_t index)
return bufferElement;
}
int32_t OH_AVCodec_DequeueInputBuffer(OH_AVCodec *codec, int64_t timeoutUs)
OH_AVCodecErrCode OH_AVCodec_DequeueInputBuffer(OH_AVCodec *codec, uint32_t index, int64_t timeoutUs)
{
return 0;
return AVCODEC_ERR_UNSUPPORT;
}
int32_t OH_AVCodec_DequeueOutputBuffer(OH_AVCodec *codec, int64_t timeoutUs)
OH_AVCodecErrCode OH_AVCodec_DequeueOutputBuffer(OH_AVCodec *codec, uint32_t index, int64_t timeoutUs)
{
return 0;
return AVCODEC_ERR_UNSUPPORT;
}
OH_AVErrCode OH_AVCodec_VideoEncoderGetSurface(OH_AVCodec *codec, OHNativeWindow **window)
OH_AVCodecErrCode OH_AVCodec_VideoEncoderGetSurface(OH_AVCodec *codec, OHNativeWindow **window)
{
return AV_ERR_OK;
return AVCODEC_ERR_UNSUPPORT;
}
OH_AVErrCode OH_AVCodec_VideoEncoderGetPersistentSurface(OHNativeWindow **window)
OH_AVCodecErrCode OH_AVCodec_VideoEncoderGetPersistentSurface(OHNativeWindow **window)
{
return AV_ERR_OK;
return AVCODEC_ERR_UNSUPPORT;
}
OH_AVErrCode OH_AVCodec_VideoEncoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window)
OH_AVCodecErrCode OH_AVCodec_VideoEncoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window)
{
return AV_ERR_OK;
return AVCODEC_ERR_UNSUPPORT;
}
OH_AVErrCode OH_AVCodec_VideoEncoderNotifyEndOfStream(OH_AVCodec *codec)
OH_AVCodecErrCode OH_AVCodec_VideoEncoderNotifyEndOfStream(OH_AVCodec *codec)
{
return AV_ERR_OK;
return AVCODEC_ERR_UNSUPPORT;
}
bool OH_AVCodec_IsValid(OH_AVCodec *codec)
{
return true;
}

View File

@ -56,12 +56,12 @@ OH_AVErrCode OH_AVDemuxer_Destroy(OH_AVDemuxer *demuxer)
if (demuxerObj != nullptr && demuxerObj->demuxer_ != nullptr) {
int32_t ret = demuxerObj->demuxer_->Destroy();
if (ret != MSERR_OK) {
MEDIA_LOGE("demuxer Destroy failed!");
AVCODEC_LOGE("demuxer Destroy failed!");
delete demuxer;
return AV_ERR_OPERATE_NOT_PERMIT;
}
} else {
MEDIA_LOGE("demuxer_ is nullptr!");
AVCODEC_LOGE("demuxer_ is nullptr!");
}
delete demuxer;

View File

@ -26,7 +26,7 @@ using namespace OHOS::Media;
struct AVMuxerObject : public OH_AVMuxer {
explicit AVMuxerObject(const std::shared_ptr<AVMuxer> &muxer)
: OH_AVMuxer(AVMagic::MEDIA_MAGIC_AVMUXER), muxer_(muxer) {}
: OH_AVMuxer(AVMagic::AVCODEC_MAGIC_AVMUXER), muxer_(muxer) {}
~AVMuxerObject() = default;
const std::shared_ptr<AVMuxer> muxer_;
@ -42,7 +42,7 @@ struct OH_AVMuxer *OH_AVMuxer_Create(int32_t fd, OH_AVOutputFormat format) {
OH_AVErrCode OH_AVMuxer_SetLocation(OH_AVMuxer *muxer, float latitude, float longitude) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
struct AVMuxerObject *object = reinterpret_cast<AVMuxerObject *>(muxer);
CHECK_AND_RETURN_RET_LOG(object->muxer_ != nullptr, AV_ERR_INVALID_VAL, "muxer_ is nullptr!");
@ -55,7 +55,7 @@ OH_AVErrCode OH_AVMuxer_SetLocation(OH_AVMuxer *muxer, float latitude, float lon
OH_AVErrCode OH_AVMuxer_SetRotation(OH_AVMuxer *muxer, int32_t rotation) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
struct AVMuxerObject *object = reinterpret_cast<AVMuxerObject *>(muxer);
CHECK_AND_RETURN_RET_LOG(object->muxer_ != nullptr, AV_ERR_INVALID_VAL, "muxer_ is nullptr!");
@ -73,9 +73,9 @@ OH_AVErrCode OH_AVMuxer_SetRotation(OH_AVMuxer *muxer, int32_t rotation) {
OH_AVErrCode OH_AVMuxer_SetParameter(OH_AVMuxer *muxer, OH_AVFormat *generalFormat) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(generalFormat != nullptr, AV_ERR_INVALID_VAL, "input general format is nullptr!");
CHECK_AND_RETURN_RET_LOG(generalFormat->magic_ == AVMagic::MEDIA_MAGIC_FORMAT, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(generalFormat->magic_ == AVMagic::AVCODEC_MAGIC_FORMAT, AV_ERR_INVALID_VAL, "magic error!");
struct AVMuxerObject *object = reinterpret_cast<AVMuxerObject *>(muxer);
CHECK_AND_RETURN_RET_LOG(object->muxer_ != nullptr, AV_ERR_INVALID_VAL, "muxer_ is nullptr!");
@ -88,9 +88,9 @@ OH_AVErrCode OH_AVMuxer_SetParameter(OH_AVMuxer *muxer, OH_AVFormat *generalForm
int32_t OH_AVMuxer_AddTrack(OH_AVMuxer *muxer, OH_AVFormat *trackFormat) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(trackFormat != nullptr, AV_ERR_INVALID_VAL, "input track format is nullptr!");
CHECK_AND_RETURN_RET_LOG(trackFormat->magic_ == AVMagic::MEDIA_MAGIC_FORMAT, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(trackFormat->magic_ == AVMagic::AVCODEC_MAGIC_FORMAT, AV_ERR_INVALID_VAL, "magic error!");
struct AVMuxerObject *object = reinterpret_cast<AVMuxerObject *>(muxer);
CHECK_AND_RETURN_RET_LOG(object->muxer_ != nullptr, AV_ERR_INVALID_VAL, "muxer_ is nullptr!");
@ -103,7 +103,7 @@ int32_t OH_AVMuxer_AddTrack(OH_AVMuxer *muxer, OH_AVFormat *trackFormat) {
OH_AVErrCode OH_AVMuxer_Start(OH_AVMuxer *muxer) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
struct AVMuxerObject *object = reinterpret_cast<AVMuxerObject *>(muxer);
CHECK_AND_RETURN_RET_LOG(object->muxer_ != nullptr, AV_ERR_INVALID_VAL, "muxer_ is nullptr!");
@ -116,7 +116,7 @@ OH_AVErrCode OH_AVMuxer_Start(OH_AVMuxer *muxer) {
OH_AVErrCode OH_AVMuxer_WriteSampleBuffer(OH_AVMuxer *muxer, uint32_t trackIndex, uint8_t *sampleBuffer, OH_AVCodecBufferInfo info) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
struct AVMuxerObject *object = reinterpret_cast<AVMuxerObject *>(muxer);
CHECK_AND_RETURN_RET_LOG(object->muxer_ != nullptr, AV_ERR_INVALID_VAL, "muxer_ is nullptr!");
@ -129,7 +129,7 @@ OH_AVErrCode OH_AVMuxer_WriteSampleBuffer(OH_AVMuxer *muxer, uint32_t trackIndex
OH_AVErrCode OH_AVMuxer_Stop(OH_AVMuxer *muxer) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
struct AVMuxerObject *object = reinterpret_cast<AVMuxerObject *>(muxer);
CHECK_AND_RETURN_RET_LOG(object->muxer_ != nullptr, AV_ERR_INVALID_VAL, "muxer_ is nullptr!");
@ -142,7 +142,7 @@ OH_AVErrCode OH_AVMuxer_Stop(OH_AVMuxer *muxer) {
OH_AVErrCode OH_AVMuxer_Destroy(OH_AVMuxer *muxer) {
CHECK_AND_RETURN_RET_LOG(muxer != nullptr, AV_ERR_INVALID_VAL, "input muxer is nullptr!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::MEDIA_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
CHECK_AND_RETURN_RET_LOG(muxer->magic_ == AVMagic::AVCODEC_MAGIC_AVMUXER, AV_ERR_INVALID_VAL, "magic error!");
delete muxer;

View File

@ -176,7 +176,7 @@ bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, con
CHECK_AND_RETURN_RET_LOG(format->outString_ != nullptr, false, "malloc out string nullptr!");
if (strcpy_s(format->outString_, bufLength + 1, str.c_str()) != EOK) {
MEDIA_LOGE("Failed to strcpy_s");
AVCODEC_LOGE("Failed to strcpy_s");
free(format->outString_);
format->outString_ = nullptr;
return false;
@ -211,7 +211,7 @@ const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format)
format->dumpInfo_ = static_cast<char *>(malloc((bufLength + 1) * sizeof(char)));
CHECK_AND_RETURN_RET_LOG(format->dumpInfo_ != nullptr, nullptr, "malloc dump info nullptr!");
if (strcpy_s(format->dumpInfo_, bufLength + 1, info.c_str()) != EOK) {
MEDIA_LOGE("Failed to strcpy_s");
AVCODEC_LOGE("Failed to strcpy_s");
free(format->dumpInfo_);
format->dumpInfo_ = nullptr;
}

View File

@ -24,8 +24,8 @@
#define AV_MAGIC(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + ((d) << 0))
enum AVMagic {
MEDIA_MAGIC_AVMUXER = AV_MAGIC('M', 'U', 'X', 'R'),
MEDIA_MAGIC_FORMAT = AV_MAGIC('F', 'R', 'M', 'T'),
AVCODEC_MAGIC_AVMUXER = AV_MAGIC('M', 'U', 'X', 'R'),
AVCODEC_MAGIC_FORMAT = AV_MAGIC('F', 'R', 'M', 'T'),
};
struct AVObjectMagic : public OHOS::RefBase {

View File

@ -73,12 +73,12 @@ OH_AVErrCode OH_AVSource_Destroy(OH_AVSource *source)
if (sourceObj != nullptr && sourceObj->source_ != nullptr) {
int32_t ret = sourceObj->source_->Destroy();
if (ret != MSERR_OK) {
MEDIA_LOGE("source Destroy failed!");
AVCODEC_LOGE("source Destroy failed!");
delete source;
return AV_ERR_OPERATE_NOT_PERMIT;
}
} else {
MEDIA_LOGE("source_ is nullptr!");
AVCODEC_LOGE("source_ is nullptr!");
}
delete source;

29
hisysevent.yaml Normal file
View File

@ -0,0 +1,29 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
domain: AVCODEC
AVCODEC_ERR:
__BASE: {type: FAULT, level: CRITICAL, desc: AVCodec error}
PID: {type: INT32, desc: The pid of the AVCODEC_ERR event}
UID: {type: INT32, desc: The uid of the AVCODEC_ERR event}
MODULE: {type: STRING, desc: module name}
ERRORCODE: {type: INT32, desc: error code}
MSG: {type: STRING, desc: error description}
AVCODEC_STATE:
__BASE: {type: BEHAVIOR, level: MINOR, desc: state change}
PID: {type: INT32, desc: The pid of the AVCODEC_STATE event}
UID: {type: INT32, desc: The uid of the AVCODEC_STATE event}
MODULE: {type: STRING, desc: module name}
STATE: {type: STRING, desc: current state}

View File

@ -91,21 +91,6 @@ typedef enum AVCodecServiceExtErrCode : ErrCode {
AVCS_ERR_EXT_EXTEND_START = 100, // extend err start.
} AVCodecServiceExtErrCode;
// avcodec northbound interface error code
typedef enum OH_AVCodecErrCode {
AVC_ERR_OK = 0,
AVC_ERR_NO_MEMORY = 1, // no memory.
AVC_ERR_OPERATE_NOT_PERMIT = 2, // opertation not be permitted.
AVC_ERR_INVALID_VAL = 3, // invalid argument.
AVC_ERR_IO = 4, // IO error.
AVC_ERR_TIMEOUT = 5, // network timeout.
AVC_ERR_UNKNOWN = 6, // unknown error.
AVC_ERR_SERVICE_DIED = 7, // avcodec service died.
AVC_ERR_INVALID_STATE = 8, // the state is not support this operation.
AVC_ERR_UNSUPPORT = 9, // unsupport interface.
AVC_ERR_EXTEND_START = 100, // extend err start.
} OH_AVCodecErrCode;
__attribute__((visibility("default"))) std::string AVCSErrorToString(AVCodecServiceErrCode code);
__attribute__((visibility("default"))) std::string AVCSExtErrorToString(AVCodecServiceExtErrCode code);
__attribute__((visibility("default"))) std::string AVCSErrorToExtErrorString(AVCodecServiceErrCode code);

View File

@ -224,9 +224,9 @@ extern const char *OH_MD_KEY_ROTATION;
*/
typedef enum OH_MediaType {
/* track is audio. */
MEDIA_TYPE_AUD = 0,
AVCODEC_TYPE_AUD = 0,
/* track is video. */
MEDIA_TYPE_VID = 1,
AVCODEC_TYPE_VID = 1,
} OH_MediaType;
/**

View File

@ -60,12 +60,12 @@ OH_AVCodec *OH_AVCodec_CreateByName(const char *name);
* @brief destroy the codec and free its resources.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_Destroy(OH_AVCodec *codec);
OH_AVCodecErrCode OH_AVCodec_Destroy(OH_AVCodec *codec);
/**
* @brief Set the asynchronous callback function so that your application can respond to the events
@ -74,12 +74,12 @@ OH_AVErrCode OH_AVCodec_Destroy(OH_AVCodec *codec);
* @param codec Pointer to an OH_AVCodec instance
* @param callback A collection of all callback functions, see {@link OH_AVCodecCallback}
* @param userData User specific data
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_SetCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData);
OH_AVCodecErrCode OH_AVCodec_SetCallback(OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData);
/**
* @brief To configure the codec, typically, you would get the fotmat from an extractor for decoding.
@ -87,36 +87,36 @@ OH_AVErrCode OH_AVCodec_SetCallback(OH_AVCodec *codec, OH_AVCodecCallback callba
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param format A pointer to an OH_AVFormat to give the description of the video track to be decoded
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_Configure(OH_AVCodec *codec, OH_AVFormat *format);
OH_AVCodecErrCode OH_AVCodec_Configure(OH_AVCodec *codec, OH_AVFormat *format);
/**
* @brief Start the codec, this interface must be called after the OH_AVCodec_Configure is successful.
* After being successfully started, the codec will start reporting InputDataReady events.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_Start(OH_AVCodec *codec);
OH_AVCodecErrCode OH_AVCodec_Start(OH_AVCodec *codec);
/**
* @brief Stop the codec. After stopping, you can re-enter the Started state through Start,
* but it should be noted that if Codec-Specific-Data has been input to the decoder before, it needs to be input again.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_Stop(OH_AVCodec *codec);
OH_AVCodecErrCode OH_AVCodec_Stop(OH_AVCodec *codec);
/**
* @brief Clear the input and output data buffered in the codec. After this interface is called, all the Buffer
@ -124,24 +124,24 @@ OH_AVErrCode OH_AVCodec_Stop(OH_AVCodec *codec);
* the Buffers corresponding to these indexes.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_Flush(OH_AVCodec *codec);
OH_AVCodecErrCode OH_AVCodec_Flush(OH_AVCodec *codec);
/**
* @brief Reset the codec. To continue decoding, you need to call the Configure interface again
* to configure the codec instance.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_Reset(OH_AVCodec *codec);
OH_AVCodecErrCode OH_AVCodec_Reset(OH_AVCodec *codec);
/**
* @brief Get the format information of the output data of the codec, refer to {@link OH_AVFormat}
@ -161,24 +161,25 @@ OH_AVFormat *OH_AVCodec_GetOutputFormat(OH_AVCodec *codec);
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param format pointer to an OH_AVFormat instance
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_SetParameter(OH_AVCodec *codec, OH_AVFormat *format);
OH_AVCodecErrCode OH_AVCodec_SetParameter(OH_AVCodec *codec, OH_AVFormat *format);
/**
* @brief Get the index of the next ready input buffer.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param index Pointer to an uint32_t instance
* @param timeoutUs timeoutUs
* @return Returns non-negtive value of the buffer index,
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns negtive value for invalid buffer index
* @since 10
* @version 4.0
*/
int32_t OH_AVCodec_DequeueInputBuffer(OH_AVCodec *codec, int64_t timeoutUs);
OH_AVCodecErrCode OH_AVCodec_DequeueInputBuffer(OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs);
/**
* @brief Get an input buffer.
@ -190,7 +191,7 @@ int32_t OH_AVCodec_DequeueInputBuffer(OH_AVCodec *codec, int64_t timeoutUs);
* @since 10
* @version 4.0
*/
OH_AVBufferElement* OH_AVCodec_GetInputBuffer(OH_AVCodec *codec, size_t index);
OH_AVBufferElement* OH_AVCodec_GetInputBuffer(OH_AVCodec *codec, uint32_t index);
/**
* @brief Submit the input buffer filled with data to the codec. The {@link OH_AVCodecOnInputDataReady} callback
@ -203,24 +204,25 @@ OH_AVBufferElement* OH_AVCodec_GetInputBuffer(OH_AVCodec *codec, size_t index);
* @param codec Pointer to an OH_AVCodec instance
* @param index Enter the index value corresponding to the Buffer
* @param attr Information describing the data contained in the Buffer
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_QueueInputBuffer(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr);
OH_AVCodecErrCode OH_AVCodec_QueueInputBuffer(OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr);
/**
* @brief Get the index of the next ready output buffer of processed data.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param index Pointer to an uint32_t instance
* @param timeoutUs timeoutUs
* @return Returns non-negtive value of the buffer index,
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns negtive value for invalid buffer index
* @since 10
* @version 4.0
*/
int32_t OH_AVCodec_DequeueOutputBuffer(OH_AVCodec *codec, int64_t timeoutUs);
OH_AVCodecErrCode OH_AVCodec_DequeueOutputBuffer(OH_AVCodec *codec, uint32_t *index, int64_t timeoutUs);
/**
* @brief Get an output buffer.
@ -232,31 +234,31 @@ int32_t OH_AVCodec_DequeueOutputBuffer(OH_AVCodec *codec, int64_t timeoutUs);
* @since 10
* @version 4.0
*/
OH_AVBufferElement* OH_AVCodec_GetOutputBuffer(OH_AVCodec *codec, size_t index);
OH_AVBufferElement* OH_AVCodec_GetOutputBuffer(OH_AVCodec *codec, uint32_t index);
/**
* @brief Return the processed output Buffer to the codec.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param index The index value corresponding to the output Buffer
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_ReleaseOutputData(OH_AVCodec *codec, uint32_t index);
OH_AVCodecErrCode OH_AVCodec_ReleaseOutputData(OH_AVCodec *codec, uint32_t index);
/**
* @brief Get the input Surface from the video encoder, this interface must be called before Configure is called.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow}
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_VideoEncoderGetSurface(OH_AVCodec *codec, OHNativeWindow **window);
OH_AVCodecErrCode OH_AVCodec_VideoEncoderGetSurface(OH_AVCodec *codec, OHNativeWindow **window);
/**
* @brief Create a persistent surface that can be used as the input to encoder.
@ -264,12 +266,12 @@ OH_AVErrCode OH_AVCodec_VideoEncoderGetSurface(OH_AVCodec *codec, OHNativeWindow
* A persistent surface can be connected to at most one instance of AVCodec.
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow}
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_VideoEncoderGetPersistentSurface(OHNativeWindow **window);
OH_AVCodecErrCode OH_AVCodec_VideoEncoderGetPersistentSurface(OHNativeWindow **window);
/**
* @brief Set a persistent surface that can be used as the input to encoder, inplaces of input buffers.
@ -278,12 +280,12 @@ OH_AVErrCode OH_AVCodec_VideoEncoderGetPersistentSurface(OHNativeWindow **window
* @param codec Pointer to an OH_AVCodec instance
* @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow},
* which must be a presistent surface created by OH_AVCodec_VideoEncoderGetPersistentSurface()
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_VideoEncoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window);
OH_AVCodecErrCode OH_AVCodec_VideoEncoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window);
/**
* @brief Specify the output Surface to provide video decoding output,
@ -291,12 +293,12 @@ OH_AVErrCode OH_AVCodec_VideoEncoderSetSurface(OH_AVCodec *codec, OHNativeWindow
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param window A pointer to a OHNativeWindow instance, see {@link OHNativeWindow}
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_VideoDecoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window);
OH_AVCodecErrCode OH_AVCodec_VideoDecoderSetSurface(OH_AVCodec *codec, OHNativeWindow *window);
/**
* @brief Return the processed output Buffer to the decoder, and notify the decoder to finish rendering the
@ -305,24 +307,36 @@ OH_AVErrCode OH_AVCodec_VideoDecoderSetSurface(OH_AVCodec *codec, OHNativeWindow
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @param index The index value corresponding to the output Buffer
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_VideoDecoderRenderFrame(OH_AVCodec *codec, uint32_t index);
OH_AVCodecErrCode OH_AVCodec_VideoDecoderRenderFrame(OH_AVCodec *codec, uint32_t index);
/**
* @brief Notifies the video encoder that the input stream has ended. It is recommended to use this interface to notify
* the encoder of the end of the stream in surface mode
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @return Returns AV_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVErrCode}
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
OH_AVErrCode OH_AVCodec_VideoEncoderNotifyEndOfStream(OH_AVCodec *codec);
OH_AVCodecErrCode OH_AVCodec_VideoEncoderNotifyEndOfStream(OH_AVCodec *codec);
/**
* @brief Is used to check whether the current codec instance is valid. It can be used fault recovery or app
* switchback from the background
* @syscap SystemCapability.Multimedia.AVCodec.Codec
* @param codec Pointer to an OH_AVCodec instance
* @return Returns AVCODEC_ERR_OK if the execution is successful,
* otherwise returns a specific error code, refer to {@link OH_AVCodecErrCode}
* @since 10
* @version 4.0
*/
bool OH_AVCodec_IsValid(OH_AVCodec *codec);
#ifdef __cplusplus
}

View File

@ -25,51 +25,51 @@ extern "C" {
* @since 10
* @version 4.0
*/
typedef enum OH_AVErrCode {
typedef enum OH_AVCodecErrCode {
/**
* the operation completed successfully.
*/
AV_ERR_OK = 0,
AVCODEC_ERR_OK = 0,
/**
* no memory.
*/
AV_ERR_NO_MEMORY = -1,
AVCODEC_ERR_NO_MEMORY = 1,
/**
* opertation not be permitted.
*/
AV_ERR_OPERATE_NOT_PERMIT = -2,
AVCODEC_ERR_OPERATE_NOT_PERMIT = 2,
/**
* invalid argument.
*/
AV_ERR_INVALID_VAL = -3,
AVCODEC_ERR_INVALID_VAL = 3,
/**
* IO error.
*/
AV_ERR_IO = -4,
AVCODEC_ERR_IO = 4,
/**
* network timeout.
* avcodec service timeout.
*/
AV_ERR_TIMEOUT = -5,
AVCODEC_ERR_TIMEOUT = 5,
/**
* unknown error.
*/
AV_ERR_UNKNOWN = -6,
AVCODEC_ERR_UNKNOWN = 6,
/**
* media service died.
* avcodec service died.
*/
AV_ERR_SERVICE_DIED = -7,
AVCODEC_ERR_SERVICE_DIED = 7,
/**
* the state is not support this operation.
*/
AV_ERR_INVALID_STATE = -8,
AVCODEC_ERR_INVALID_STATE = 8,
/**
* unsupport interface.
*/
AV_ERR_UNSUPPORT = -9,
AVCODEC_ERR_UNSUPPORT = 9,
/**
* extend err start.
*/
AV_ERR_EXTEND_START = -100,
AVCODEC_ERR_EXTEND_START = 100,
} OH_AVErrCode;
#ifdef __cplusplus

View File

@ -44,7 +44,7 @@ bool AVCodecEvent::CreateMsg(const char *format, ...)
return true;
}
void AVCodecEvent::EventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
void AVCodecEvent::StatisticEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
std::string module)
{
int32_t pid = getpid();
@ -56,21 +56,46 @@ void AVCodecEvent::EventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent
"MSG", msg_);
}
void AVCodecEvent::BehaviorEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
std::string module)
{
int32_t pid = getpid();
uint32_t uid = getuid();
HiSysEventWrite(HISYSEVENT_DOMAIN_AVCODEC, eventName, type,
"PID", pid,
"UID", uid,
"MODULE", module,
"STATE", msg_);
}
void AVCodecEvent::FaultEventWrite(std::string eventName, int32_t errorCode, OHOS::HiviewDFX::HiSysEvent::EventType type,
std::string module)
{
int32_t pid = getpid();
uint32_t uid = getuid();
HiSysEventWrite(HISYSEVENT_DOMAIN_AVCODEC, eventName, type,
"PID", pid,
"UID", uid,
"MODULE", module,
"ERRORCODE", errorCode,
"MSG", msg_);
}
void BehaviorEventWrite(std::string status, std::string moudle)
{
AVCodecEvent event;
if (event.CreateMsg("%s, current state is: %s", "state change", status.c_str())) {
event.EventWrite("AVCODEC_STATE", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, moudle);
event.BehaviorEventWrite("AVCODEC_STATE", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, moudle);
} else {
AVCODEC_LOGW("Failed to call CreateMsg");
}
}
void FaultEventWrite(std::string msg, std::string moudle)
void FaultEventWrite(int32_t errorCode, std::string msg, std::string moudle)
{
AVCodecEvent event;
if (event.CreateMsg("%s", msg.c_str())) {
event.EventWrite("AVCODEC_ERR", OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, moudle);
event.FaultEventWrite("AVCODEC_ERR", errorCode, OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, moudle);
} else {
AVCODEC_LOGW("Failed to call CreateMsg");
}
@ -80,7 +105,7 @@ void StatisticEventWrite(std::string msg, std::string moudle)
{
AVCodecEvent event;
if (event.CreateMsg("%s", msg.c_str())) {
event.EventWrite("AVCODEC_STATISTIC", OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, moudle);
event.StatisticEventWrite("AVCODEC_STATISTIC", OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, moudle);
} else {
AVCODEC_LOGW("Failed to call CreateMsg");
}

View File

@ -29,14 +29,18 @@ public:
AVCodecEvent() = default;
~AVCodecEvent() = default;
bool CreateMsg(const char *format, ...) __attribute__((__format__(printf, 2, 3)));
void EventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
void StatisticEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
std::string module);
void BehaviorEventWrite(std::string eventName, OHOS::HiviewDFX::HiSysEvent::EventType type,
std::string module);
void FaultEventWrite(std::string eventName, int32_t errorCode, OHOS::HiviewDFX::HiSysEvent::EventType type,
std::string module);
private:
std::string msg_;
};
__attribute__((visibility("default"))) void BehaviorEventWrite(std::string status, std::string moudle);
__attribute__((visibility("default"))) void FaultEventWrite(std::string msg, std::string moudle);
__attribute__((visibility("default"))) void FaultEventWrite(int32_t errorCode, std::string msg, std::string moudle);
__attribute__((visibility("default"))) void StatisticEventWrite(std::string msg, std::string moudle);
class __attribute__((visibility("default"))) AVCodecTrace : public NoCopyable {

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
#ifndef I_MEDIA_SERVICE_H
#define I_MEDIA_SERVICE_H
#ifndef I_AVCODEC_SERVICE_H
#define I_AVCODEC_SERVICE_H
#include <memory>
@ -121,4 +121,4 @@ private:
};
} // namespace AVCodec
} // namespace OHOS
#endif // I_MEDIA_SERVICE_H
#endif // I_AVCODEC_SERVICE_H

View File

@ -12,8 +12,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef AVCODECBASE_H
#define AVCODECBASE_H
#ifndef CODECBASE_H
#define CODECBASE_H
#include <string>
#include "avcodec_common.h"
@ -21,9 +21,10 @@
namespace OHOS {
namespace AVCodec {
class AVCodecBase {
static std::shared_ptr<AVCodecBase> Create(const std::string& name);
static std::shared_ptr<AVCodecBase> Create(bool isEncoder,const std::string& mime);
class CodecBase {
virtual ~CodecBase() = default;
static std::shared_ptr<CodecBase> Create(const std::string& name);
static std::shared_ptr<CodecBase> Create(bool isEncoder,const std::string& mime);
virtual int32_t SetCallback(const std::shared_ptr<AVCodecCallBack>& callback) = 0;
virtual int32_t Configure(const Format& format) = 0;
virtual int32_t Start() = 0;
@ -48,4 +49,4 @@ class AVCodecBase {
};
} // namespace AVCodec
} // namespace OHOS
#endif // AVCODECBASE_H
#endif // CODECBASE_H

View File

@ -20,9 +20,10 @@
namespace OHOS {
namespace AVCodec {
class AVCodecListBase {
class CodecListBase {
virtual ~CodecListBase() = default;
virtual int32_t GetCapabilityList(std::vector<CapabilityData>& caps) = 0;
};
} // namespace AVCodec
} // namespace OHOS
#endif // AVCODECLISTBASE_H
#endif // CODECLISTBASE_H

View File

@ -35,7 +35,7 @@ std::shared_ptr<AVSharedMemory> AVDataSrcMemory::CreateFromLocal(
std::shared_ptr<AVDataSrcMemory> memory = std::make_shared<AVDataSrcMemory>(size, flags, name);
int32_t ret = memory->Init();
if (ret != MSERR_OK) {
MEDIA_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
AVCODEC_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
return nullptr;
}
@ -48,7 +48,7 @@ std::shared_ptr<AVSharedMemory> AVDataSrcMemory::CreateFromRemote(
std::shared_ptr<AVDataSrcMemory> memory = std::make_shared<AVSharedMemoryBaseImpl>(fd, size, flags, name);
int32_t ret = memory->Init();
if (ret != MSERR_OK) {
MEDIA_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
AVCODEC_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
return nullptr;
}
@ -58,7 +58,7 @@ std::shared_ptr<AVSharedMemory> AVDataSrcMemory::CreateFromRemote(
AVDataSrcMemory::AVDataSrcMemory(int32_t size, uint32_t flags, const std::string &name)
: AVSharedMemoryBase(size, flags, name)
{
MEDIA_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
AVCODEC_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
FAKE_POINTER(this), name.c_str());
offset_ = 0;
}
@ -66,14 +66,14 @@ AVDataSrcMemory::AVDataSrcMemory(int32_t size, uint32_t flags, const std::string
AVDataSrcMemory::AVDataSrcMemory(int32_t fd, int32_t size, uint32_t flags, const std::string &name)
: AVSharedMemoryBase(fd, size, flags, name)
{
MEDIA_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
AVCODEC_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
FAKE_POINTER(this), name.c_str());
offset_ = 0;
}
AVDataSrcMemory::~AVDataSrcMemory()
{
MEDIA_LOGD("enter dtor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
AVCODEC_LOGD("enter dtor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
FAKE_POINTER(this), GetName().c_str());
}
} // namespace AVCodec

View File

@ -39,7 +39,7 @@ std::shared_ptr<AVSharedMemory> AVSharedMemoryBase::CreateFromLocal(
std::shared_ptr<AVSharedMemoryBase> memory = std::make_shared<AVSharedMemoryBase>(size, flags, name);
int32_t ret = memory->Init();
if (ret != MSERR_OK) {
MEDIA_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
AVCODEC_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
return nullptr;
}
@ -52,7 +52,7 @@ std::shared_ptr<AVSharedMemory> AVSharedMemoryBase::CreateFromRemote(
std::shared_ptr<AVSharedMemoryBase> memory = std::make_shared<AVSharedMemoryBaseImpl>(fd, size, flags, name);
int32_t ret = memory->Init();
if (ret != MSERR_OK) {
MEDIA_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
AVCODEC_LOGE("Create avsharedmemory failed, ret = %{public}d", ret);
return nullptr;
}
@ -62,20 +62,20 @@ std::shared_ptr<AVSharedMemory> AVSharedMemoryBase::CreateFromRemote(
AVSharedMemoryBase::AVSharedMemoryBase(int32_t size, uint32_t flags, const std::string &name)
: base_(nullptr), size_(size), flags_(flags), name_(name), fd_(-1)
{
MEDIA_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
AVCODEC_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
FAKE_POINTER(this), name_.c_str());
}
AVSharedMemoryBase::AVSharedMemoryBase(int32_t fd, int32_t size, uint32_t flags, const std::string &name)
: base_(nullptr), size_(size), flags_(flags), name_(name), fd_(dup(fd))
{
MEDIA_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
AVCODEC_LOGD("enter ctor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
FAKE_POINTER(this), name_.c_str());
}
AVSharedMemoryBase::~AVSharedMemoryBase()
{
MEDIA_LOGD("enter dtor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
AVCODEC_LOGD("enter dtor, instance: 0x%{public}06" PRIXPTR ", name = %{public}s",
FAKE_POINTER(this), name_.c_str());
Close();
}
@ -83,7 +83,7 @@ AVSharedMemoryBase::~AVSharedMemoryBase()
int32_t AVSharedMemoryBase::Init()
{
ON_SCOPE_EXIT(0) {
MEDIA_LOGE("create avsharedmemory failed, name = %{public}s, size = %{public}d, "
AVCODEC_LOGE("create avsharedmemory failed, name = %{public}s, size = %{public}d, "
"flags = 0x%{public}x, fd = %{public}d",
name_.c_str(), size_, flags_, fd_);
Close();

View File

@ -27,12 +27,12 @@ namespace OHOS {
namespace AVCodec {
AVSharedMemoryPool::AVSharedMemoryPool(const std::string &name) : name_(name)
{
MEDIA_LOGD("enter ctor, 0x%{public}06" PRIXPTR ", name: %{public}s", FAKE_POINTER(this), name_.c_str());
AVCODEC_LOGD("enter ctor, 0x%{public}06" PRIXPTR ", name: %{public}s", FAKE_POINTER(this), name_.c_str());
}
AVSharedMemoryPool::~AVSharedMemoryPool()
{
MEDIA_LOGD("enter dtor, 0x%{public}06" PRIXPTR ", name: %{public}s", FAKE_POINTER(this), name_.c_str());
AVCODEC_LOGD("enter dtor, 0x%{public}06" PRIXPTR ", name: %{public}s", FAKE_POINTER(this), name_.c_str());
Reset();
}
@ -49,7 +49,7 @@ int32_t AVSharedMemoryPool::Init(const InitializeOption &option)
option_.preAllocMemCnt = option.maxMemCnt;
}
MEDIA_LOGI("name: %{public}s, init option: preAllocMemCnt = %{public}u, memSize = %{public}d, "
AVCODEC_LOGI("name: %{public}s, init option: preAllocMemCnt = %{public}u, memSize = %{public}d, "
"maxMemCnt = %{public}u, enableFixedSize = %{public}d",
name_.c_str(), option_.preAllocMemCnt, option_.memSize, option_.maxMemCnt,
option_.enableFixedSize);
@ -57,7 +57,7 @@ int32_t AVSharedMemoryPool::Init(const InitializeOption &option)
for (uint32_t i = 0; i < option_.preAllocMemCnt; ++i) {
auto memory = AllocMemory(option_.memSize);
if (memory == nullptr) {
MEDIA_LOGE("alloc memory failed");
AVCODEC_LOGE("alloc memory failed");
ret = false;
break;
}
@ -85,7 +85,7 @@ AVSharedMemory *AVSharedMemoryPool::AllocMemory(int32_t size)
if (memory->Init() != MSERR_OK) {
delete memory;
memory = nullptr;
MEDIA_LOGE("init avsharedmemorybase failed");
AVCODEC_LOGE("init avsharedmemorybase failed");
}
return memory;
@ -104,7 +104,7 @@ void AVSharedMemoryPool::ReleaseMemory(AVSharedMemory *memory)
busyList_.erase(iter);
idleList_.push_back(memory);
cond_.notify_all();
MEDIA_LOGD("0x%{public}06" PRIXPTR " released back to pool %{public}s",
AVCODEC_LOGD("0x%{public}06" PRIXPTR " released back to pool %{public}s",
FAKE_POINTER(memory), name_.c_str());
lock.unlock();
@ -114,13 +114,13 @@ void AVSharedMemoryPool::ReleaseMemory(AVSharedMemory *memory)
return;
}
MEDIA_LOGE("0x%{public}06" PRIXPTR " is no longer managed by this pool", FAKE_POINTER(memory));
AVCODEC_LOGE("0x%{public}06" PRIXPTR " is no longer managed by this pool", FAKE_POINTER(memory));
delete memory;
}
bool AVSharedMemoryPool::DoAcquireMemory(int32_t size, AVSharedMemory **outMemory)
{
MEDIA_LOGD("busylist size %{public}zu, idlelist size %{public}zu", busyList_.size(), idleList_.size());
AVCODEC_LOGD("busylist size %{public}zu, idlelist size %{public}zu", busyList_.size(), idleList_.size());
AVSharedMemory *result = nullptr;
std::list<AVSharedMemory *>::iterator minSizeIdleMem = idleList_.end();
@ -184,12 +184,12 @@ bool AVSharedMemoryPool::CheckSize(int32_t size)
std::shared_ptr<AVSharedMemory> AVSharedMemoryPool::AcquireMemory(int32_t size, bool blocking)
{
MEDIA_LOGD("acquire memory for size: %{public}d from pool %{public}s, blocking: %{public}d",
AVCODEC_LOGD("acquire memory for size: %{public}d from pool %{public}s, blocking: %{public}d",
size, name_.c_str(), blocking);
std::unique_lock<std::mutex> lock(mutex_);
if (!CheckSize(size)) {
MEDIA_LOGE("invalid size: %{public}d", size);
AVCODEC_LOGE("invalid size: %{public}d", size);
return nullptr;
}
@ -211,7 +211,7 @@ std::shared_ptr<AVSharedMemory> AVSharedMemoryPool::AcquireMemory(int32_t size,
} while (inited_ && !forceNonBlocking_);
if (memory == nullptr) {
MEDIA_LOGD("acquire memory failed for size: %{public}d", size);
AVCODEC_LOGD("acquire memory failed for size: %{public}d", size);
return nullptr;
}
@ -222,19 +222,19 @@ std::shared_ptr<AVSharedMemory> AVSharedMemoryPool::AcquireMemory(int32_t size,
if (pool != nullptr) {
pool->ReleaseMemory(memory);
} else {
MEDIA_LOGI("release memory 0x%{public}06" PRIXPTR ", but the pool is destroyed", FAKE_POINTER(memory));
AVCODEC_LOGI("release memory 0x%{public}06" PRIXPTR ", but the pool is destroyed", FAKE_POINTER(memory));
delete memory;
}
});
MEDIA_LOGD("0x%{public}06" PRIXPTR " acquired from pool", FAKE_POINTER(memory));
AVCODEC_LOGD("0x%{public}06" PRIXPTR " acquired from pool", FAKE_POINTER(memory));
return result;
}
void AVSharedMemoryPool::SetNonBlocking(bool enable)
{
std::unique_lock<std::mutex> lock(mutex_);
MEDIA_LOGD("SetNonBlocking: %{public}d", enable);
AVCODEC_LOGD("SetNonBlocking: %{public}d", enable);
forceNonBlocking_ = enable;
if (forceNonBlocking_) {
cond_.notify_all();
@ -243,7 +243,7 @@ void AVSharedMemoryPool::SetNonBlocking(bool enable)
void AVSharedMemoryPool::Reset()
{
MEDIA_LOGD("Reset");
AVCODEC_LOGD("Reset");
std::unique_lock<std::mutex> lock(mutex_);
for (auto &memory : idleList_) {

View File

@ -43,7 +43,7 @@ void CopyFormatDataMap(const Format::FormatDataMap &from, Format::FormatDataMap
it->second.addr = reinterpret_cast<uint8_t *>(malloc(it->second.size));
if (it->second.addr == nullptr) {
MEDIA_LOGE("malloc addr failed. Key: %{public}s", it->first.c_str());
AVCODEC_LOGE("malloc addr failed. Key: %{public}s", it->first.c_str());
it = to.erase(it);
continue;
}
@ -51,7 +51,7 @@ void CopyFormatDataMap(const Format::FormatDataMap &from, Format::FormatDataMap
errno_t err = memcpy_s(reinterpret_cast<void *>(it->second.addr),
it->second.size, reinterpret_cast<const void *>(from.at(it->first).addr), it->second.size);
if (err != EOK) {
MEDIA_LOGE("memcpy addr failed. Key: %{public}s", it->first.c_str());
AVCODEC_LOGE("memcpy addr failed. Key: %{public}s", it->first.c_str());
free(it->second.addr);
it->second.addr = nullptr;
it = to.erase(it);
@ -159,7 +159,7 @@ bool Format::GetStringValue(const std::string_view &key, std::string &value) con
{
auto iter = formatMap_.find(key);
if (iter == formatMap_.end() || iter->second.type != FORMAT_TYPE_STRING) {
MEDIA_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
AVCODEC_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
return false;
}
value = iter->second.stringVal;
@ -170,7 +170,7 @@ bool Format::GetIntValue(const std::string_view &key, int32_t &value) const
{
auto iter = formatMap_.find(key);
if (iter == formatMap_.end() || iter->second.type != FORMAT_TYPE_INT32) {
MEDIA_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
AVCODEC_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
return false;
}
value = iter->second.val.int32Val;
@ -181,7 +181,7 @@ bool Format::GetLongValue(const std::string_view &key, int64_t &value) const
{
auto iter = formatMap_.find(key);
if (iter == formatMap_.end() || iter->second.type != FORMAT_TYPE_INT64) {
MEDIA_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
AVCODEC_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
return false;
}
value = iter->second.val.int64Val;
@ -192,7 +192,7 @@ bool Format::GetFloatValue(const std::string_view &key, float &value) const
{
auto iter = formatMap_.find(key);
if (iter == formatMap_.end() || iter->second.type != FORMAT_TYPE_FLOAT) {
MEDIA_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
AVCODEC_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
return false;
}
value = iter->second.val.floatVal;
@ -203,7 +203,7 @@ bool Format::GetDoubleValue(const std::string_view &key, double &value) const
{
auto iter = formatMap_.find(key);
if (iter == formatMap_.end() || iter->second.type != FORMAT_TYPE_DOUBLE) {
MEDIA_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
AVCODEC_LOGE("Format::GetFormat failed. Key: %{public}s", key.data());
return false;
}
value = iter->second.val.doubleVal;
@ -213,13 +213,13 @@ bool Format::GetDoubleValue(const std::string_view &key, double &value) const
bool Format::PutBuffer(const std::string_view &key, const uint8_t *addr, size_t size)
{
if (addr == nullptr) {
MEDIA_LOGE("put buffer error, addr is nullptr");
AVCODEC_LOGE("put buffer error, addr is nullptr");
return false;
}
constexpr size_t sizeMax = 1 * 1024 * 1024;
if (size > sizeMax) {
MEDIA_LOGE("PutBuffer input size failed. Key: %{public}s", key.data());
AVCODEC_LOGE("PutBuffer input size failed. Key: %{public}s", key.data());
return false;
}
@ -227,13 +227,13 @@ bool Format::PutBuffer(const std::string_view &key, const uint8_t *addr, size_t
data.type = FORMAT_TYPE_ADDR;
data.addr = reinterpret_cast<uint8_t *>(malloc(size));
if (data.addr == nullptr) {
MEDIA_LOGE("malloc addr failed. Key: %{public}s", key.data());
AVCODEC_LOGE("malloc addr failed. Key: %{public}s", key.data());
return false;
}
errno_t err = memcpy_s(reinterpret_cast<void *>(data.addr), size, reinterpret_cast<const void *>(addr), size);
if (err != EOK) {
MEDIA_LOGE("PutBuffer memcpy addr failed. Key: %{public}s", key.data());
AVCODEC_LOGE("PutBuffer memcpy addr failed. Key: %{public}s", key.data());
free(data.addr);
return false;
}
@ -249,7 +249,7 @@ bool Format::GetBuffer(const std::string_view &key, uint8_t **addr, size_t &size
{
auto iter = formatMap_.find(key);
if (iter == formatMap_.end() || iter->second.type != FORMAT_TYPE_ADDR) {
MEDIA_LOGE("Format::GetBuffer failed. Key: %{public}s", key.data());
AVCODEC_LOGE("Format::GetBuffer failed. Key: %{public}s", key.data());
return false;
}
*addr = iter->second.addr;
@ -317,7 +317,7 @@ std::string Format::Stringify() const
case FORMAT_TYPE_ADDR:
break;
default:
MEDIA_LOGE("Format::Stringify failed. Key: %{public}s", iter->first.c_str());
AVCODEC_LOGE("Format::Stringify failed. Key: %{public}s", iter->first.c_str());
}
}
return outString;