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_AUD_ENC_FAILED, // audio encode failed. 55 MSERR_VID_ENC_FAILED, // video encode failed. 56 MSERR_AUD_DEC_FAILED, // audio decode failed. 57 MSERR_VID_DEC_FAILED, // video decode failed. 58 MSERR_MUXER_FAILED, // stream muxer failed. 59 MSERR_DEMUXER_FAILED, // stream demuxer or parser failed. 60 MSERR_OPEN_FILE_FAILED, // open file failed. 61 MSERR_FILE_ACCESS_FAILED, // read or write file failed. 62 MSERR_START_FAILED, // audio/video start failed. 63 MSERR_PAUSE_FAILED, // audio/video pause failed. 64 MSERR_STOP_FAILED, // audio/video stop failed. 65 MSERR_SEEK_FAILED, // audio/video seek failed. 66 MSERR_NETWORK_TIMEOUT, // network timeout. 67 MSERR_NOT_FIND_CONTAINER, // not find a demuxer. 68 MSERR_DATA_SOURCE_IO_ERROR, // media data source IO failed. 69 MSERR_DATA_SOURCE_OBTAIN_MEM_ERROR, // media data source get mem failed. 70 MSERR_DATA_SOURCE_ERROR_UNKNOWN, // media data source error unknow. 71 MSERR_EXTEND_START = MS_ERR_OFFSET + 0xF000, // extend err start. 72 }; 73 74 // media api error code 75 enum MediaServiceExtErrCode : ErrCode { 76 MSERR_EXT_OK = 0, 77 MSERR_EXT_NO_MEMORY = 1, // no memory. 78 MSERR_EXT_OPERATE_NOT_PERMIT = 2, // opertation not be permitted. 79 MSERR_EXT_INVALID_VAL = 3, // invalid argument. 80 MSERR_EXT_IO = 4, // IO error. 81 MSERR_EXT_TIMEOUT = 5, // network timeout. 82 MSERR_EXT_UNKNOWN = 6, // unknown error. 83 MSERR_EXT_SERVICE_DIED = 7, // media service died. 84 MSERR_EXT_INVALID_STATE = 8, // the state is not support this operation. 85 MSERR_EXT_UNSUPPORT = 9, // unsupport interface. 86 MSERR_EXT_EXTEND_START = 100, // extend err start. 87 }; 88 89 __attribute__((visibility("default"))) std::string MSErrorToString(MediaServiceErrCode code); 90 __attribute__((visibility("default"))) std::string MSExtErrorToString(MediaServiceExtErrCode code); 91 __attribute__((visibility("default"))) std::string MSErrorToExtErrorString(MediaServiceErrCode code); 92 __attribute__((visibility("default"))) MediaServiceExtErrCode MSErrorToExtError(MediaServiceErrCode code); 93 } // namespace Media 94 } // namespace OHOS 95 #endif // MEDIA_ERRORS_H 96