1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MEDIA_AVCODEC_ERRORS_H 17 #define MEDIA_AVCODEC_ERRORS_H 18 19 #include <map> 20 #include <string> 21 #include "native_averrors.h" 22 #include "errors.h" 23 #include "common/status.h" 24 25 namespace OHOS { 26 namespace MediaAVCodec { 27 using AVCSErrCode = ErrCode; 28 29 // bit 28~21 is subsys, bit 20~16 is Module. bit 15~0 is code 30 // confirm module offset 31 constexpr AVCSErrCode AVCS_MODULE = 10; 32 constexpr AVCSErrCode AVCS_ERR_OFFSET = ErrCodeOffset(SUBSYS_MULTIMEDIA, AVCS_MODULE); 33 typedef enum AVCodecServiceErrCode : ErrCode { 34 AVCS_ERR_OK = ERR_OK, 35 AVCS_ERR_NO_MEMORY = AVCS_ERR_OFFSET + ENOMEM, // no memory 36 AVCS_ERR_INVALID_OPERATION = AVCS_ERR_OFFSET + ENOSYS, // opertation not be permitted 37 AVCS_ERR_INVALID_VAL = AVCS_ERR_OFFSET + EINVAL, // invalid argument 38 AVCS_ERR_UNKNOWN = AVCS_ERR_OFFSET + 0x200, // unkown error. 39 AVCS_ERR_SERVICE_DIED, // avcodec service died 40 AVCS_ERR_CREATE_AVCODEC_SUB_SERVICE_FAILED, // create avcodec sub service failed. 41 AVCS_ERR_CREATE_MUXER_SUB_SERVICE_FAILED, // create muxer sub service failed. 42 AVCS_ERR_CREATE_DEMUXER_SUB_SERVICE_FAILED, // create demuxer sub service failed. 43 AVCS_ERR_CREATE_SOURCE_SUB_SERVICE_FAILED, // create source sub service failed. 44 AVCS_ERR_INVALID_STATE, // the state is not support this operation. 45 AVCS_ERR_UNSUPPORT, // unsupport interface. 46 AVCS_ERR_UNSUPPORT_AUD_SRC_TYPE, // unsupport audio source type. 47 AVCS_ERR_UNSUPPORT_AUD_SAMPLE_RATE, // unsupport audio sample rate. 48 AVCS_ERR_UNSUPPORT_AUD_CHANNEL_NUM, // unsupport audio channel. 49 AVCS_ERR_UNSUPPORT_AUD_ENC_TYPE, // unsupport audio encoder type. 50 AVCS_ERR_UNSUPPORT_AUD_PARAMS, // unsupport audio params(other params). 51 AVCS_ERR_UNSUPPORT_VID_SRC_TYPE, // unsupport video source type. 52 AVCS_ERR_UNSUPPORT_VID_ENC_TYPE, // unsupport video encoder type. 53 AVCS_ERR_UNSUPPORT_VID_PARAMS, // unsupport video params(other params). 54 AVCS_ERR_UNSUPPORT_FILE_TYPE, // unsupport file format type. 55 AVCS_ERR_UNSUPPORT_PROTOCOL_TYPE, // unsupport protocol type. 56 AVCS_ERR_UNSUPPORT_VID_DEC_TYPE, // unsupport video decoder type. 57 AVCS_ERR_UNSUPPORT_AUD_DEC_TYPE, // unsupport audio decoder type. 58 AVCS_ERR_UNSUPPORT_STREAM, // internal data stream error. 59 AVCS_ERR_UNSUPPORT_SOURCE, // unsupport source type. 60 AVCS_ERR_AUD_RENDER_FAILED, // audio render failed. 61 AVCS_ERR_AUD_ENC_FAILED, // audio encode failed. 62 AVCS_ERR_VID_ENC_FAILED, // video encode failed. 63 AVCS_ERR_AUD_DEC_FAILED, // audio decode failed. 64 AVCS_ERR_VID_DEC_FAILED, // video decode failed. 65 AVCS_ERR_MUXER_FAILED, // stream avmuxer failed. 66 AVCS_ERR_DEMUXER_FAILED, // stream demuxer or parser failed. 67 AVCS_ERR_OPEN_FILE_FAILED, // open file failed. 68 AVCS_ERR_FILE_ACCESS_FAILED, // read or write file failed. 69 AVCS_ERR_START_FAILED, // audio/video start failed. 70 AVCS_ERR_PAUSE_FAILED, // audio/video pause failed. 71 AVCS_ERR_STOP_FAILED, // audio/video stop failed. 72 AVCS_ERR_SEEK_FAILED, // audio/video seek failed. 73 AVCS_ERR_NETWORK_TIMEOUT, // network timeout. 74 AVCS_ERR_NOT_FIND_FILE, // not find a file. 75 AVCS_ERR_DATA_SOURCE_IO_ERROR, // avcodec data source IO failed. 76 AVCS_ERR_DATA_SOURCE_OBTAIN_MEM_ERROR, // avcodec data source get mem failed. 77 AVCS_ERR_DATA_SOURCE_ERROR_UNKNOWN, // avcodec data source error unknow. 78 79 AVCS_ERR_NOT_ENOUGH_DATA, // avcodec output buffer not full of a pack 80 AVCS_ERR_END_OF_STREAM, // the end of stream 81 AVCS_ERR_CONFIGURE_MISMATCH_CHANNEL_COUNT, // not configure channel count attribute 82 AVCS_ERR_MISMATCH_SAMPLE_RATE, // not configure channel sample rate 83 AVCS_ERR_MISMATCH_BIT_RATE, // not configure channel bit rate 84 AVCS_ERR_CONFIGURE_ERROR, // flac encoder configure compression level out of limit 85 AVCS_ERR_INVALID_DATA, // Invalid data found when processing input 86 87 AVCS_ERR_EXTEND_START = AVCS_ERR_OFFSET + 0xF000, // extend err start. 88 } AVCodecServiceErrCode; 89 90 __attribute__((visibility("default"))) std::string AVCSErrorToString(AVCodecServiceErrCode code); 91 __attribute__((visibility("default"))) std::string OHAVErrCodeToString(OH_AVErrCode code); 92 __attribute__((visibility("default"))) std::string AVCSErrorToOHAVErrCodeString(AVCodecServiceErrCode code); 93 __attribute__((visibility("default"))) OH_AVErrCode AVCSErrorToOHAVErrCode(AVCodecServiceErrCode code); 94 __attribute__((visibility("default"))) AVCodecServiceErrCode StatusToAVCodecServiceErrCode(Media::Status code); 95 } // namespace MediaAVCodec 96 } // namespace OHOS 97 #endif // MEDIA_AVCODEC_ERRORS_H 98