1 /* 2 * Copyright (c) 2020 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 /** 17 * @addtogroup MultiMedia_MediaCommon 18 * @{ 19 * 20 * @brief Provides data types and media formats required for recording and playing audio and videos. 21 * 22 * 23 * @since 1.0 24 * @version 1.0 25 */ 26 27 /** 28 * @file media_errors.h 29 * 30 * @brief Declares the <b>media_errors</b> class to define errors that may occur during media operations. 31 * 32 * 33 * @since 1.0 34 * @version 1.0 35 */ 36 37 #ifndef MEDIA_ERRORS_H 38 #define MEDIA_ERRORS_H 39 40 #include <cstdint> 41 42 namespace OHOS { 43 namespace Media { 44 constexpr int MODULE_MEDIA = 1; 45 constexpr int SUBSYS_MEDIA = 30; 46 47 using ErrCode = int32_t; 48 constexpr int SUBSYSTEM_BIT_NUM = 21; 49 constexpr int MODULE_BIT_NUM = 16; 50 51 /** 52 * @brief Generates a start error code with a unique identifier based on specified subsystem and module bit numbers. 53 * 54 * @param subsystem Indicates the subsystem bit number. 55 * @param module Indicates the module bit number. 56 * @return 57 * @since 1.0 58 * @version 1.0 59 */ 60 constexpr ErrCode ErrCodeOffset(unsigned int subsystem, unsigned int module = 0) 61 { 62 return (subsystem << SUBSYSTEM_BIT_NUM) | (module << MODULE_BIT_NUM); 63 } 64 65 constexpr int32_t BASE_MEDIA_ERR_OFFSET = ErrCodeOffset(SUBSYS_MEDIA, MODULE_MEDIA); 66 67 /** Invalid data size that has been read */ 68 const int32_t ERR_INVALID_READ = -1; 69 70 /** Success */ 71 const int32_t SUCCESS = 0; 72 73 /** Fail */ 74 const int32_t ERROR = BASE_MEDIA_ERR_OFFSET; 75 76 /** Status error */ 77 const int32_t ERR_ILLEGAL_STATE = BASE_MEDIA_ERR_OFFSET + 1; 78 79 /** Invalid parameter */ 80 const int32_t ERR_INVALID_PARAM = BASE_MEDIA_ERR_OFFSET + 2; 81 82 /** Early media preparation */ 83 const int32_t ERR_EARLY_PREPARE = BASE_MEDIA_ERR_OFFSET + 3; 84 85 /** No media source */ 86 const int32_t ERR_SOURCE_NOT_SET = BASE_MEDIA_ERR_OFFSET + 4; 87 88 /** Invalid operation */ 89 const int32_t ERR_INVALID_OPERATION = BASE_MEDIA_ERR_OFFSET + 5; 90 91 /** No idle channel */ 92 const int32_t ERR_NOFREE_CHANNEL = BASE_MEDIA_ERR_OFFSET + 6; 93 94 /** Buffer reading failed */ 95 const int32_t ERR_READ_BUFFER = BASE_MEDIA_ERR_OFFSET + 7; 96 97 /** Device not started */ 98 const int32_t ERR_NOT_STARTED = BASE_MEDIA_ERR_OFFSET + 8; 99 100 /** Unknown error */ 101 const int32_t ERR_UNKNOWN = BASE_MEDIA_ERR_OFFSET + 200; 102 } // namespace Media 103 } // namespace OHOS 104 #endif // MEDIA_ERRORS_H 105