mirror of
https://gitee.com/openharmony/multimedia_av_codec
synced 2024-10-07 22:23:44 +00:00
!2861 【修改说明】 修改视频后处理onerror报错错误码&修改GetOutputFormat通路
Merge pull request !2861 from 李建超/master
This commit is contained in:
commit
09f80d1e9a
@ -68,7 +68,8 @@ const std::map<AVCodecServiceErrCode, std::string> AVCS_ERRCODE_INFOS = {
|
||||
{AVCS_ERR_CONFIGURE_ERROR, "compression level incorrect in flac encoder"},
|
||||
{AVCS_ERR_DECRYPT_FAILED, "decrypt protected content failed"},
|
||||
{AVCS_ERR_CODEC_PARAM_INCORRECT, "video codec param check failed"},
|
||||
{AVCS_ERR_EXTEND_START, "extend start error code"}};
|
||||
{AVCS_ERR_EXTEND_START, "extend start error code"},
|
||||
{AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION, "video unsupported color space conversion"}};
|
||||
|
||||
const std::map<AVCodecServiceErrCode, OH_AVErrCode> AVCSERRCODE_TO_OHAVCODECERRCODE = {
|
||||
{AVCS_ERR_OK, AV_ERR_OK},
|
||||
@ -119,6 +120,7 @@ const std::map<AVCodecServiceErrCode, OH_AVErrCode> AVCSERRCODE_TO_OHAVCODECERRC
|
||||
{AVCS_ERR_EXTEND_START, AV_ERR_EXTEND_START},
|
||||
{AVCS_ERR_DECRYPT_FAILED, AV_ERR_DRM_DECRYPT_FAILED},
|
||||
{AVCS_ERR_CODEC_PARAM_INCORRECT, AV_ERR_INVALID_VAL},
|
||||
{AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION, AV_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION},
|
||||
};
|
||||
|
||||
const std::map<OH_AVErrCode, std::string> OHAVCODECERRCODE_INFOS = {
|
||||
@ -180,6 +182,21 @@ const std::map<Status, AVCodecServiceErrCode> STATUS_TO_AVCSERRCODE = {
|
||||
{Status::ERROR_IPC_SEND_REQUEST, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
|
||||
{Status::ERROR_DRM_DECRYPT_FAILED, AVCodecServiceErrCode::AVCS_ERR_DECRYPT_FAILED}};
|
||||
|
||||
const std::map<int32_t, AVCodecServiceErrCode> VPEERROR_TO_AVCSERRCODE = {
|
||||
{0, AVCodecServiceErrCode::AVCS_ERR_OK},
|
||||
{63635468, AVCodecServiceErrCode::AVCS_ERR_NO_MEMORY}, // 63635468: no memory
|
||||
{63635494, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION}, // 63635494: opertation not be permitted
|
||||
{63635478, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL}, // 63635478: invalid argument
|
||||
{63635968, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635968: unknow error
|
||||
{63635969, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635969: video processing engine init failed
|
||||
{63635970, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635970: extension not found
|
||||
{63635971, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635971: extension init failed
|
||||
{63635972, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635972: extension process failed
|
||||
{63635973,
|
||||
AVCodecServiceErrCode::AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION}, // 63635973: extension is not implemented
|
||||
{63635974, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION}, // 63635974: not supported operation
|
||||
{63635975, AVCodecServiceErrCode::AVCS_ERR_INVALID_STATE}}; // 63635975: the state is not support this operation
|
||||
|
||||
std::string ErrorMessageOk(const std::string ¶m1, const std::string ¶m2)
|
||||
{
|
||||
(void)param1;
|
||||
@ -296,5 +313,14 @@ AVCodecServiceErrCode StatusToAVCodecServiceErrCode(Status code)
|
||||
|
||||
return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
AVCodecServiceErrCode VPEErrorToAVCSError(int32_t code)
|
||||
{
|
||||
if (VPEERROR_TO_AVCSERRCODE.count(code) != 0) {
|
||||
return VPEERROR_TO_AVCSERRCODE.at(code);
|
||||
}
|
||||
|
||||
return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN;
|
||||
}
|
||||
} // namespace MediaAVCodec
|
||||
} // namespace OHOS
|
||||
|
@ -73,9 +73,9 @@ typedef enum AVCodecServiceErrCode : ErrCode {
|
||||
AVCS_ERR_DATA_SOURCE_ERROR_UNKNOWN, // avcodec data source error unknow.
|
||||
AVCS_ERR_CODEC_PARAM_INCORRECT, // video codec param check failed.
|
||||
|
||||
AVCE_ERR_IPC_UNKNOWN, // avcodec ipc unknown err.
|
||||
AVCE_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, // avcodec ipc err, get sub system ability failed.
|
||||
AVCE_ERR_IPC_SET_DEATH_LISTENER_FAILED, // avcodec ipc err, set death listener failed.
|
||||
AVCS_ERR_IPC_UNKNOWN, // avcodec ipc unknown err.
|
||||
AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, // avcodec ipc err, get sub system ability failed.
|
||||
AVCS_ERR_IPC_SET_DEATH_LISTENER_FAILED, // avcodec ipc err, set death listener failed.
|
||||
AVCS_ERR_CREATE_CODECLIST_STUB_FAILED, // create codeclist sub service failed.
|
||||
AVCS_ERR_CREATE_AVCODEC_STUB_FAILED, // create avcodec sub service failed.
|
||||
|
||||
@ -88,7 +88,8 @@ typedef enum AVCodecServiceErrCode : ErrCode {
|
||||
AVCS_ERR_INVALID_DATA, // Invalid data found when processing input
|
||||
AVCS_ERR_DECRYPT_FAILED, // drm decrypt failed
|
||||
AVCS_ERR_TRY_AGAIN, // try again later
|
||||
AVCS_ERR_EMPTY_INPUT_FAILED, //there is somthing wrong for input buffer
|
||||
AVCS_ERR_EMPTY_INPUT_FAILED, // there is somthing wrong for input buffer
|
||||
AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION, // video unsupport color space conversion
|
||||
|
||||
AVCS_ERR_EXTEND_START = AVCS_ERR_OFFSET + 0xF000, // extend err start.
|
||||
} AVCodecServiceErrCode;
|
||||
@ -98,6 +99,7 @@ __attribute__((visibility("default"))) std::string OHAVErrCodeToString(OH_AVErrC
|
||||
__attribute__((visibility("default"))) std::string AVCSErrorToOHAVErrCodeString(AVCodecServiceErrCode code);
|
||||
__attribute__((visibility("default"))) OH_AVErrCode AVCSErrorToOHAVErrCode(AVCodecServiceErrCode code);
|
||||
__attribute__((visibility("default"))) AVCodecServiceErrCode StatusToAVCodecServiceErrCode(Media::Status code);
|
||||
__attribute__((visibility("default"))) AVCodecServiceErrCode VPEErrorToAVCSError(int32_t code);
|
||||
} // namespace MediaAVCodec
|
||||
} // namespace OHOS
|
||||
#endif // MEDIA_AVCODEC_ERRORS_H
|
||||
|
@ -631,12 +631,10 @@ extern const char *OH_MD_KEY_START_TIME;
|
||||
* The supported value is {@link OH_COLORSPACE_BT709_LIMIT}, see {@link OH_NativeBuffer_ColorSpace}. It is used in
|
||||
* {@link OH_VideoDecoder_Configure}. If the color space conversion capability is supported and this key is configured,
|
||||
* the video decoder will automatically transcode an HDR Vivid video to an SDR video with color space BT709.
|
||||
* If the value of this key is not configured as {@link OH_COLORSPACE_BT709_LIMIT}, {@link OH_VideoDecoder_Configure}
|
||||
* returns @{link AV_ERR_INVALID_VAL}.
|
||||
* If color space conversion capability is not supported, {@link OH_VideoDecoder_Configure} returns
|
||||
* {@link AV_ERR_INVALID_VAL}.
|
||||
* If the input video is not an HDR vivid video, an error {@link AV_ERR_UNSUPPORT} will be reported by callback
|
||||
* function {@link OH_AVCodecOnError}.
|
||||
* {@link AV_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION}.
|
||||
* If the input video is not an HDR vivid video, an error {@link AV_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION} will be
|
||||
* reported by callback function {@link OH_AVCodecOnError}.
|
||||
*
|
||||
* @syscap SystemCapability.Multimedia.Media.CodecBase
|
||||
* @since 12
|
||||
|
@ -135,6 +135,8 @@ OH_AVErrCode OH_VideoDecoder_SetSurface(OH_AVCodec *codec, OHNativeWindow *windo
|
||||
* {@link AV_ERR_UNKNOWN}, unknown error.
|
||||
* {@link AV_ERR_SERVICE_DIED}, avcodec service is died.
|
||||
* {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state, must be called before Prepare.
|
||||
* {@link AV_ERR_UNSUPPORT}, unsupported features.
|
||||
* {@link AV_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION}, video unsupported color space conversion.
|
||||
* @since 9
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -367,15 +367,17 @@ int32_t PostProcessingChecker(CapabilityData &capData, Format &format, CodecScen
|
||||
if (!hasColorSpace) {
|
||||
return AVCS_ERR_OK;
|
||||
}
|
||||
CHECK_AND_RETURN_RET_LOG(
|
||||
scenario == CodecScenario::CODEC_SCENARIO_DEC_NORMAL && capData.mimeType == CodecMimeType::VIDEO_HEVC &&
|
||||
capData.isVendor,
|
||||
AVCS_ERR_INVALID_VAL,
|
||||
"colorspace conversion is not available for the codec.");
|
||||
CHECK_AND_RETURN_RET_LOG((colorSpace >= 0) && // 0: OH_COLORSAPCE_NONE
|
||||
(colorSpace <= 31), // 31: OH_COLORSPACE_DISPLAY_BT2020_PQ
|
||||
AVCS_ERR_INVALID_VAL, "The output color space %{public}d is invaild", colorSpace);
|
||||
CHECK_AND_RETURN_RET_LOG(scenario == CodecScenario::CODEC_SCENARIO_DEC_NORMAL &&
|
||||
capData.mimeType == CodecMimeType::VIDEO_HEVC && capData.isVendor,
|
||||
AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION,
|
||||
"colorspace conversion is not available for the codec.");
|
||||
|
||||
constexpr int32_t colorSpaceBt709Limited = 8; // see OH_COLORSPACE_BT709_LIMITED in native_buffer.h;
|
||||
CHECK_AND_RETURN_RET_LOG(colorSpace == colorSpaceBt709Limited, AVCS_ERR_INVALID_VAL,
|
||||
"The output color space %{public}d is not supported", colorSpace);
|
||||
CHECK_AND_RETURN_RET_LOG(colorSpace == colorSpaceBt709Limited, AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION,
|
||||
"The output color space %{public}d is not supported", colorSpace);
|
||||
PrintParam(true, MediaDescriptionKey::MD_KEY_VIDEO_DECODER_OUTPUT_COLOR_SPACE, colorSpace);
|
||||
|
||||
return AVCS_ERR_OK;
|
||||
|
@ -582,6 +582,8 @@ int32_t CodecServer::GetOutputFormat(Format &format)
|
||||
GetStatusDescription(status_).data());
|
||||
CHECK_AND_RETURN_RET_LOG(codecBase_ != nullptr, AVCS_ERR_NO_MEMORY, "Codecbase is nullptr");
|
||||
if (postProcessing_) {
|
||||
int32_t ret = codecBase_->GetOutputFormat(format);
|
||||
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, ret, "GetOutputFormat failed");
|
||||
return GetPostProcessingOutputFormat(format);
|
||||
} else {
|
||||
return codecBase_->GetOutputFormat(format);
|
||||
@ -846,6 +848,9 @@ void CodecServer::OnError(int32_t errorType, int32_t errorCode)
|
||||
void CodecServer::OnOutputFormatChanged(const Format &format)
|
||||
{
|
||||
std::lock_guard<std::shared_mutex> lock(cbMutex_);
|
||||
if (postProcessing_) {
|
||||
return;
|
||||
}
|
||||
if (videoCb_ != nullptr) {
|
||||
videoCb_->OnOutputFormatChanged(format);
|
||||
}
|
||||
@ -1335,7 +1340,9 @@ void CodecServer::PostProcessingOnError(int32_t errorCode)
|
||||
if (!videoCb_) {
|
||||
AVCODEC_LOGD("Missing video callback");
|
||||
}
|
||||
videoCb_->OnError(AVCodecErrorType::AVCODEC_ERROR_INTERNAL, errorCode);
|
||||
int32_t ret = VPEErrorToAVCSError(errorCode);
|
||||
AVCODEC_LOGD("PostProcessingOnError, errorCodec:%{public}d -> %{public}d", errorCode, ret);
|
||||
videoCb_->OnError(AVCodecErrorType::AVCODEC_ERROR_INTERNAL, ret);
|
||||
}
|
||||
|
||||
void CodecServer::PostProcessingOnOutputBufferAvailable(uint32_t index, [[maybe_unused]] int32_t flag)
|
||||
|
@ -106,6 +106,11 @@ public:
|
||||
return This()->FlushImpl();
|
||||
}
|
||||
|
||||
int32_t GetOutputFormat(Media::Format& format)
|
||||
{
|
||||
return This()->GetOutputFormatImpl(format);
|
||||
}
|
||||
|
||||
int32_t Reset()
|
||||
{
|
||||
return This()->ResetImpl();
|
||||
@ -215,6 +220,12 @@ private:
|
||||
return AVCS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
int32_t GetOutputFormatImpl([[maybe_unused]] Media::Format &format)
|
||||
{
|
||||
AVCODEC_LOGE("Not implemented.");
|
||||
return AVCS_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
int32_t ResetImpl()
|
||||
{
|
||||
AVCODEC_LOGE("Not implemented.");
|
||||
|
@ -144,7 +144,16 @@ int32_t DynamicController::StopImpl()
|
||||
int32_t DynamicController::FlushImpl()
|
||||
{
|
||||
auto ret = interface_.Invoke<DynamicInterfaceName::FLUSH>(instance_);
|
||||
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION, "Stop video processing failed.");
|
||||
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION, "Flush video processing failed.");
|
||||
return AVCS_ERR_OK;
|
||||
}
|
||||
|
||||
int32_t DynamicController::GetOutputFormatImpl(Media::Format &format)
|
||||
{
|
||||
void *formatPtr = static_cast<void *>(&format);
|
||||
auto ret = interface_.Invoke<DynamicInterfaceName::GET_OUTPUT_FORMAT>(instance_, formatPtr);
|
||||
CHECK_AND_RETURN_RET_LOG(ret == AVCS_ERR_OK, AVCS_ERR_INVALID_OPERATION,
|
||||
"GetOutputFormat video processing failed.");
|
||||
return AVCS_ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
int32_t StartImpl();
|
||||
int32_t StopImpl();
|
||||
int32_t FlushImpl();
|
||||
int32_t GetOutputFormatImpl(Media::Format& format);
|
||||
int32_t ResetImpl();
|
||||
int32_t ReleaseImpl();
|
||||
int32_t ReleaseOutputBufferImpl(uint32_t index, bool render);
|
||||
|
@ -42,6 +42,7 @@ using DynamicFlushFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
|
||||
using DynamicResetFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
|
||||
using DynamicReleaseFunc = int32_t(*)(DynamicColorSpaceConverterHandle*);
|
||||
using DynamicReleaseOutputBufferFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, uint32_t, bool);
|
||||
using DynamicGetOutputFormatFunc = int32_t(*)(DynamicColorSpaceConverterHandle*, void*);
|
||||
|
||||
// function pointer types array
|
||||
using DynamicInterfaceFuncTypes = TypeArray<
|
||||
@ -60,7 +61,8 @@ using DynamicInterfaceFuncTypes = TypeArray<
|
||||
DynamicFlushFunc,
|
||||
DynamicResetFunc,
|
||||
DynamicReleaseFunc,
|
||||
DynamicReleaseOutputBufferFunc
|
||||
DynamicReleaseOutputBufferFunc,
|
||||
DynamicGetOutputFormatFunc
|
||||
>;
|
||||
|
||||
// function symbols
|
||||
@ -80,7 +82,8 @@ constexpr const char* DYNAMIC_INTERFACE_SYMBOLS[]{
|
||||
"ColorSpaceConvertVideoFlush",
|
||||
"ColorSpaceConvertVideoReset",
|
||||
"ColorSpaceConvertVideoRelease",
|
||||
"ColorSpaceConvertVideoReleaseOutputBuffer"
|
||||
"ColorSpaceConvertVideoReleaseOutputBuffer",
|
||||
"ColorSpaceConvertVideoGetOutputFormat"
|
||||
};
|
||||
|
||||
// function name enumeration
|
||||
@ -100,7 +103,8 @@ enum class DynamicInterfaceName : size_t {
|
||||
FLUSH,
|
||||
RESET,
|
||||
RELEASE,
|
||||
RELEASE_OUPUT_BUFFER
|
||||
RELEASE_OUPUT_BUFFER,
|
||||
GET_OUTPUT_FORMAT,
|
||||
};
|
||||
|
||||
// dynamic interface helper types
|
||||
|
@ -203,14 +203,19 @@ public:
|
||||
|
||||
void GetOutputFormat(Format& format)
|
||||
{
|
||||
format = format_;
|
||||
CHECK_AND_RETURN_LOG(controller_, "Post processing controller is null");
|
||||
AVCODEC_SYNC_TRACE;
|
||||
int32_t ret = controller_->GetOutputFormat(format);
|
||||
CHECK_AND_RETURN_LOG(ret == AVCS_ERR_OK, "GetOutputFormat failed");
|
||||
return;
|
||||
}
|
||||
private:
|
||||
int32_t Init(const Format& format)
|
||||
{
|
||||
controller_ = std::make_unique<T>();
|
||||
CHECK_AND_RETURN_RET_LOG(controller_, AVCS_ERR_NO_MEMORY, "Create post processing controller failed");
|
||||
CHECK_AND_RETURN_RET_LOG(controller_->LoadInterfaces(), AVCS_ERR_UNSUPPORT, "Initialize interfaces failed.");
|
||||
CHECK_AND_RETURN_RET_LOG(controller_->LoadInterfaces(), AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION,
|
||||
"Initialize interfaces failed.");
|
||||
|
||||
CreateConfiguration(format);
|
||||
|
||||
|
@ -36,24 +36,24 @@ AVCodecServiceProxy::~AVCodecServiceProxy()
|
||||
int32_t AVCodecServiceProxy::GetSubSystemAbility(IStandardAVCodecService::AVCodecSystemAbility subSystemId,
|
||||
const sptr<IRemoteObject> &listener, sptr<IRemoteObject> &object)
|
||||
{
|
||||
CHECK_AND_RETURN_RET_LOG(listener != nullptr, AVCE_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "listener is nullptr");
|
||||
CHECK_AND_RETURN_RET_LOG(listener != nullptr, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "listener is nullptr");
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
bool ret = data.WriteInterfaceToken(AVCodecServiceProxy::GetDescriptor());
|
||||
CHECK_AND_RETURN_RET_LOG(ret, AVCE_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "Failed to write descriptor");
|
||||
CHECK_AND_RETURN_RET_LOG(ret, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "Failed to write descriptor");
|
||||
|
||||
(void)data.WriteInt32(static_cast<int32_t>(subSystemId));
|
||||
(void)data.WriteRemoteObject(listener);
|
||||
int error =
|
||||
Remote()->SendRequest(static_cast<uint32_t>(AVCodecServiceInterfaceCode::GET_SUBSYSTEM), data, reply, option);
|
||||
CHECK_AND_RETURN_RET_LOG(error == 0, AVCE_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED,
|
||||
CHECK_AND_RETURN_RET_LOG(error == 0, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED,
|
||||
"Create av_codec proxy failed, error: %{public}d", error);
|
||||
|
||||
object = reply.ReadRemoteObject();
|
||||
CHECK_AND_RETURN_RET_LOG(object != nullptr, AVCE_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "Remote object is nullptr");
|
||||
CHECK_AND_RETURN_RET_LOG(object != nullptr, AVCS_ERR_IPC_GET_SUB_SYSTEM_ABILITY_FAILED, "Remote object is nullptr");
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
} // namespace MediaAVCodec
|
||||
|
@ -112,7 +112,7 @@ int32_t AVCodecServer::GetSubSystemAbility(IStandardAVCodecService::AVCodecSyste
|
||||
AVCodecServerManager::GetInstance().DestroyStubObject(*stubType, stubObject);
|
||||
stubObject = nullptr;
|
||||
AVCODEC_LOGE("SetDeathListener failed");
|
||||
return AVCE_ERR_IPC_SET_DEATH_LISTENER_FAILED;
|
||||
return AVCS_ERR_IPC_SET_DEATH_LISTENER_FAILED;
|
||||
}
|
||||
|
||||
return AVCS_ERR_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user