1 /* 2 * Copyright (C) 2021 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 #ifndef MEDIA_ERRORS_H 16 #define MEDIA_ERRORS_H 17 18 #include <map> 19 #include <string> 20 #include "errors.h" 21 22 namespace OHOS { 23 namespace Media { 24 using MSErrCode = ErrCode; 25 26 // bit 28~21 is subsys, bit 20~16 is Module. bit 15~0 is code 27 constexpr MSErrCode MS_MODULE = 0X01000; 28 constexpr MSErrCode MS_ERR_OFFSET = ErrCodeOffset(SUBSYS_MULTIMEDIA, MS_MODULE); 29 enum MediaServiceErrCode : ErrCode { 30 MSERR_OK = ERR_OK, 31 MSERR_NO_MEMORY = MS_ERR_OFFSET + ENOMEM, // no memory 32 MSERR_INVALID_OPERATION = MS_ERR_OFFSET + ENOSYS, // opertation not be permitted 33 MSERR_INVALID_VAL = MS_ERR_OFFSET + EINVAL, // invalid argument 34 MSERR_UNKNOWN = MS_ERR_OFFSET + 0x200, // unkown error. 35 MSERR_SERVICE_DIED, // media service died 36 MSERR_CREATE_REC_ENGINE_FAILED, // create recorder engine failed. 37 MSERR_CREATE_PLAYER_ENGINE_FAILED, // create player engine failed. 38 MSERR_CREATE_AVMETADATAHELPER_ENGINE_FAILED, // create avmetadatahelper engine failed. 39 MSERR_CREATE_AVCODEC_ENGINE_FAILED, // create avcodec engine failed. 40 MSERR_INVALID_STATE, // the state is not support this operation. 41 MSERR_UNSUPPORT, // unsupport interface. 42 MSERR_UNSUPPORT_AUD_SRC_TYPE, // unsupport audio source type. 43 MSERR_UNSUPPORT_AUD_SAMPLE_RATE, // unsupport audio sample rate. 44 MSERR_UNSUPPORT_AUD_CHANNEL_NUM, // unsupport audio channel. 45 MSERR_UNSUPPORT_AUD_ENC_TYPE, // unsupport audio encoder type. 46 MSERR_UNSUPPORT_AUD_PARAMS, // unsupport audio params(other params). 47 MSERR_UNSUPPORT_VID_SRC_TYPE, // unsupport video source type. 48 MSERR_UNSUPPORT_VID_ENC_TYPE, // unsupport video encoder type. 49 MSERR_UNSUPPORT_VID_PARAMS, // unsupport video params(other params). 50 MSERR_UNSUPPORT_CONTAINER_TYPE, // unsupport container format type. 51 MSERR_UNSUPPORT_PROTOCOL_TYPE, // unsupport protocol type. 52 MSERR_UNSUPPORT_VID_DEC_TYPE, // unsupport video decoder type. 53 MSERR_UNSUPPORT_AUD_DEC_TYPE, // unsupport audio decoder type. 54 MSERR_UNSUPPORT_STREAM, // internal data stream error. 55 MSERR_UNSUPPORT_FILE, // this appears to be a text file. 56 MSERR_UNSUPPORT_SOURCE, // unsupport source type. 57 MSERR_AUD_RENDER_FAILED, // audio render failed. 58 MSERR_AUD_ENC_FAILED, // audio encode failed. 59 MSERR_VID_ENC_FAILED, // video encode failed. 60 MSERR_AUD_DEC_FAILED, // audio decode failed. 61 MSERR_VID_DEC_FAILED, // video decode failed. 62 MSERR_MUXER_FAILED, // stream avmuxer failed. 63 MSERR_DEMUXER_FAILED, // stream demuxer or parser failed. 64 MSERR_OPEN_FILE_FAILED, // open file failed. 65 MSERR_FILE_ACCESS_FAILED, // read or write file failed. 66 MSERR_START_FAILED, // audio/video start failed. 67 MSERR_PAUSE_FAILED, // audio/video pause failed. 68 MSERR_STOP_FAILED, // audio/video stop failed. 69 MSERR_SEEK_FAILED, // audio/video seek failed. 70 MSERR_NETWORK_TIMEOUT, // network timeout. 71 MSERR_NOT_FIND_CONTAINER, // not find a demuxer. 72 MSERR_DATA_SOURCE_IO_ERROR, // media data source IO failed. 73 MSERR_DATA_SOURCE_OBTAIN_MEM_ERROR, // media data source get mem failed. 74 MSERR_DATA_SOURCE_ERROR_UNKNOWN, // media data source error unknow. 75 MSERR_EXTEND_START = MS_ERR_OFFSET + 0xF000, // extend err start. 76 }; 77 78 // media api error code 79 enum MediaServiceExtErrCode : ErrCode { 80 MSERR_EXT_OK = 0, 81 MSERR_EXT_NO_MEMORY = 1, // no memory. 82 MSERR_EXT_OPERATE_NOT_PERMIT = 2, // opertation not be permitted. 83 MSERR_EXT_INVALID_VAL = 3, // invalid argument. 84 MSERR_EXT_IO = 4, // IO error. 85 MSERR_EXT_TIMEOUT = 5, // network timeout. 86 MSERR_EXT_UNKNOWN = 6, // unknown error. 87 MSERR_EXT_SERVICE_DIED = 7, // media service died. 88 MSERR_EXT_INVALID_STATE = 8, // the state is not support this operation. 89 MSERR_EXT_UNSUPPORT = 9, // unsupport interface. 90 MSERR_EXT_EXTEND_START = 100, // extend err start. 91 }; 92 93 // media api9 error code 94 enum MediaServiceExtErrCodeAPI9 : ErrCode { 95 MSERR_EXT_API9_OK = 0, // use for determine error 96 MSERR_EXT_API9_NO_PERMISSION = 201, // permission denied (AccessToken). 97 MSERR_EXT_API9_PERMISSION_DENIED = 202, // permission denied (system API). 98 MSERR_EXT_API9_INVALID_PARAMETER = 401, // invalid parameter. 99 MSERR_EXT_API9_UNSUPPORT_CAPABILITY = 801, // unsupport api. 100 MSERR_EXT_API9_NO_MEMORY = 5400101, // no memory. 101 MSERR_EXT_API9_OPERATE_NOT_PERMIT = 5400102, // opertation not be permitted. 102 MSERR_EXT_API9_IO = 5400103, // IO error. 103 MSERR_EXT_API9_TIMEOUT = 5400104, // opertate timeout. 104 MSERR_EXT_API9_SERVICE_DIED = 5400105, // media service died. 105 MSERR_EXT_API9_UNSUPPORT_FORMAT = 5400106, // unsupport format. 106 }; 107 108 __attribute__((visibility("default"))) std::string MSErrorToString(MediaServiceErrCode code); 109 __attribute__((visibility("default"))) std::string MSExtErrorToString(MediaServiceExtErrCode code); 110 __attribute__((visibility("default"))) std::string MSErrorToExtErrorString(MediaServiceErrCode code); 111 __attribute__((visibility("default"))) MediaServiceExtErrCode MSErrorToExtError(MediaServiceErrCode code); 112 113 __attribute__((visibility("default"))) std::string MSExtErrorAPI9ToString(MediaServiceExtErrCodeAPI9 code, 114 const std::string& param1, const std::string& param2); 115 __attribute__((visibility("default"))) std::string MSErrorToExtErrorAPI9String(MediaServiceErrCode code, 116 const std::string& param1, const std::string& param2); 117 __attribute__((visibility("default"))) MediaServiceExtErrCodeAPI9 MSErrorToExtErrorAPI9(MediaServiceErrCode code); 118 119 __attribute__((visibility("default"))) std::string MSExtAVErrorToString(MediaServiceExtErrCodeAPI9 code); 120 } // namespace Media 121 } // namespace OHOS 122 #endif // MEDIA_ERRORS_H 123