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 
16 #ifndef INTERFACES_INNERKITS_INCLUDE_MEDIA_ERRORS_H
17 #define INTERFACES_INNERKITS_INCLUDE_MEDIA_ERRORS_H
18 
19 #include <cstdint>
20 #include "errors.h"
21 #include "modules.h"
22 
23 namespace OHOS {
24 namespace Media {
25 constexpr int32_t BASE_MEDIA_ERR_OFFSET = ErrCodeOffset(SUBSYS_MULTIMEDIA, MODULE_MEDIA);
26 
27 /* Media defined errors */
28 const int32_t ERR_MEDIA_INVALID_VALUE = -1;                                    // invalid size
29 const uint32_t SUCCESS = 0;                                                    // Operation success
30 const uint32_t ERROR = BASE_MEDIA_ERR_OFFSET;                                  // Operation failed
31 const uint32_t ERR_IPC = BASE_MEDIA_ERR_OFFSET + 1;                            // ipc error
32 const uint32_t ERR_SHAMEM_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 2;               // sharememory error
33 const uint32_t ERR_SHAMEM_DATA_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 3;           // sharememory error
34 const uint32_t ERR_IMAGE_DECODE_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 4;          // image decode error
35 const uint32_t ERR_IMAGE_DATA_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 5;            // image input data error
36 const uint32_t ERR_IMAGE_MALLOC_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 6;          // image malloc error
37 const uint32_t ERR_IMAGE_DATA_UNSUPPORT = BASE_MEDIA_ERR_OFFSET + 7;           // image type unsupported
38 const uint32_t ERR_IMAGE_INIT_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 8;            // image init error
39 const uint32_t ERR_IMAGE_GET_DATA_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 9;        // image get data error
40 const uint32_t ERR_IMAGE_TOO_LARGE = BASE_MEDIA_ERR_OFFSET + 10;               // image data too large
41 const uint32_t ERR_IMAGE_TRANSFORM = BASE_MEDIA_ERR_OFFSET + 11;               // image transform error
42 const uint32_t ERR_IMAGE_COLOR_CONVERT = BASE_MEDIA_ERR_OFFSET + 12;           // image color convert error
43 const uint32_t ERR_IMAGE_CROP = BASE_MEDIA_ERR_OFFSET + 13;                    // crop error
44 const uint32_t ERR_IMAGE_SOURCE_DATA = BASE_MEDIA_ERR_OFFSET + 14;             // image source data error
45 const uint32_t ERR_IMAGE_SOURCE_DATA_INCOMPLETE = BASE_MEDIA_ERR_OFFSET + 15;  // image source data incomplete
46 const uint32_t ERR_IMAGE_MISMATCHED_FORMAT = BASE_MEDIA_ERR_OFFSET + 16;       // image mismatched format
47 const uint32_t ERR_IMAGE_UNKNOWN_FORMAT = BASE_MEDIA_ERR_OFFSET + 17;          // image unknown format
48 const uint32_t ERR_IMAGE_SOURCE_UNRESOLVED = BASE_MEDIA_ERR_OFFSET + 18;       // image source unresolved
49 const uint32_t ERR_IMAGE_INVALID_PARAMETER = BASE_MEDIA_ERR_OFFSET + 19;       // image invalid parameter
50 const uint32_t ERR_IMAGE_DECODE_FAILED = BASE_MEDIA_ERR_OFFSET + 20;           // decode fail
51 const uint32_t ERR_IMAGE_PLUGIN_REGISTER_FAILED = BASE_MEDIA_ERR_OFFSET + 21;  // register plugin fail
52 const uint32_t ERR_IMAGE_PLUGIN_CREATE_FAILED = BASE_MEDIA_ERR_OFFSET + 22;    // create plugin fail
53 const uint32_t ERR_IMAGE_ENCODE_FAILED = BASE_MEDIA_ERR_OFFSET + 23;           // image encode fail
54 const uint32_t ERR_IMAGE_ADD_PIXEL_MAP_FAILED = BASE_MEDIA_ERR_OFFSET + 24;    // image add pixel map fail
55 const uint32_t ERR_IMAGE_HW_DECODE_UNSUPPORT = BASE_MEDIA_ERR_OFFSET + 25;     // image hardware decode unsupported
56 const uint32_t ERR_IMAGE_DECODE_HEAD_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 26;    // image decode head error
57 const uint32_t ERR_IMAGE_DECODE_EXIF_UNSUPPORT = BASE_MEDIA_ERR_OFFSET + 27;   // image decode exif unsupport
58 const uint32_t ERR_IMAGE_PROPERTY_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 28;     // image property not exist
59 
60 const uint32_t ERR_IMAGE_DESIRED_PIXELFORMAT_UNSUPPORTED = BASE_MEDIA_ERR_OFFSET + 29; // desired format unsupported
61 const int32_t ERR_MEDIA_DATA_UNSUPPORT = BASE_MEDIA_ERR_OFFSET + 30;               // media type unsupported
62 const int32_t ERR_MEDIA_TOO_LARGE = BASE_MEDIA_ERR_OFFSET + 31;                    // media data too large
63 const int32_t ERR_MEDIA_MALLOC_FAILED = BASE_MEDIA_ERR_OFFSET + 32;                // media malloc memory failed
64 const int32_t ERR_MEDIA_END_OF_STREAM = BASE_MEDIA_ERR_OFFSET + 33;                // media end of stream error
65 const int32_t ERR_MEDIA_IO_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 34;                  // media io error
66 const int32_t ERR_MEDIA_MALFORMED = BASE_MEDIA_ERR_OFFSET + 35;                    // media malformed error
67 const int32_t ERR_MEDIA_BUFFER_TOO_SMALL = BASE_MEDIA_ERR_OFFSET + 36;             // media buffer too small error
68 const int32_t ERR_MEDIA_OUT_OF_RANGE = BASE_MEDIA_ERR_OFFSET + 37;                 // media out of range error
69 const int32_t ERR_MEDIA_STATUS_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 38;              // media status abnormal error
70 const int32_t ERR_MEDIA_VALUE_INVALID = BASE_MEDIA_ERR_OFFSET + 39;                // media value invalid
71 const int32_t ERR_MEDIA_NULL_POINTER = BASE_MEDIA_ERR_OFFSET + 40;                 // media error operation
72 const int32_t ERR_MEDIA_INVALID_OPERATION = BASE_MEDIA_ERR_OFFSET + 41;            // media invalid operation
73 const int32_t ERR_PLAYER_NOT_INIT = BASE_MEDIA_ERR_OFFSET + 42;                    // media init error
74 const int32_t ERR_MEDIA_EARLY_PREPARE = BASE_MEDIA_ERR_OFFSET + 43;                // media early prepare
75 const int32_t ERR_MEDIA_SEEK_ERR = BASE_MEDIA_ERR_OFFSET + 44;                     // media rewind error
76 const int32_t ERR_MEDIA_PERMISSION_DENIED = BASE_MEDIA_ERR_OFFSET + 45;            // media permission denied
77 const int32_t ERR_MEDIA_DEAD_OBJECT = BASE_MEDIA_ERR_OFFSET + 46;                  // media dead object
78 const int32_t ERR_MEDIA_TIMED_OUT = BASE_MEDIA_ERR_OFFSET + 47;                    // media time out
79 const int32_t ERR_MEDIA_TRACK_NOT_ALL_SUPPORTED = BASE_MEDIA_ERR_OFFSET + 48;      // media track subset support
80 const int32_t ERR_RECORDER_ADAPTER_INIT_FAILED = BASE_MEDIA_ERR_OFFSET + 49;       // media recorder adapter init failed
81 const int32_t ERR_MEDIA_WRITE_PARCEL_FAIL = BASE_MEDIA_ERR_OFFSET + 50;            // write parcel failed
82 const int32_t ERR_MEDIA_READ_PARCEL_FAIL = BASE_MEDIA_ERR_OFFSET + 51;             // read parcel failed
83 const int32_t ERR_MEDIA_NO_AVAIL_BUFFER = BASE_MEDIA_ERR_OFFSET + 52;              // read parcel failed
84 const int32_t ERR_MEDIA_INVALID_PARAM = BASE_MEDIA_ERR_OFFSET + 53;                // media function found invalid param
85 const int32_t ERR_MEDIA_CODEC_ADAPTER_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 54;      // media zcodec adapter not init
86 const int32_t ERR_MEDIA_CREATE_CODEC_ADAPTER_FAILED = BASE_MEDIA_ERR_OFFSET + 55;  // media create zcodec adapter failed
87 const int32_t ERR_MEDIA_CODEC_ADAPTER_NOT_INIT = BASE_MEDIA_ERR_OFFSET + 56;       // media adapter inner not init
88 const int32_t ERR_MEDIA_ZCODEC_CREATE_FAILED = BASE_MEDIA_ERR_OFFSET + 57;         // media adapter inner not init
89 const int32_t ERR_MEDIA_ZCODEC_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 58;             // media zcodec not exist
90 const int32_t ERR_MEDIA_JNI_CLASS_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 59;          // media jni class not found
91 const int32_t ERR_MEDIA_JNI_METHOD_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 60;         // media jni method not found
92 const int32_t ERR_MEDIA_JNI_NEW_OBJ_FAILED = BASE_MEDIA_ERR_OFFSET + 61;           // media jni obj new failed
93 const int32_t ERR_MEDIA_JNI_COMMON_ERROR = BASE_MEDIA_ERR_OFFSET + 62;             // media jni normal error
94 const int32_t ERR_MEDIA_DISTRIBUTE_NOT_SUPPORT = BASE_MEDIA_ERR_OFFSET + 63;       // media distribute not support
95 const int32_t ERR_MEDIA_SOURCE_NOT_SET = BASE_MEDIA_ERR_OFFSET + 64;               // media source not set
96 const int32_t ERR_MEDIA_RTSP_ADAPTER_NOT_INIT = BASE_MEDIA_ERR_OFFSET + 65;        // media rtsp adapter not init
97 const int32_t ERR_MEDIA_RTSP_ADAPTER_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 66;       // media rtsp adapter not exist
98 const int32_t ERR_MEDIA_RTSP_SURFACE_UNSUPPORT = BASE_MEDIA_ERR_OFFSET + 67;       // media rtsp surface not support
99 const int32_t ERR_MEDIA_RTSP_CAPTURE_NOT_INIT = BASE_MEDIA_ERR_OFFSET + 68;        // media rtsp capture init error
100 const int32_t ERR_MEDIA_RTSP_SOURCE_URL_INVALID = BASE_MEDIA_ERR_OFFSET + 69;      // media rtsp source url invalid
101 const int32_t ERR_MEDIA_RTSP_VIDEO_TRACK_NOT_FOUND = BASE_MEDIA_ERR_OFFSET + 70;   // media rtsp can't find video track
102 const int32_t ERR_MEDIA_RTSP_CAMERA_NUM_REACH_MAX = BASE_MEDIA_ERR_OFFSET + 71;    // rtsp camera num reach to max num
103 const int32_t ERR_MEDIA_SET_VOLUME = BASE_MEDIA_ERR_OFFSET + 72;                   // media set volume error
104 const int32_t ERR_MEDIA_NUMBER_OVERFLOW = BASE_MEDIA_ERR_OFFSET + 73;              // media number operation overflow
105 const int32_t ERR_MEDIA_DIS_PLAYER_UNSUPPORTED = BASE_MEDIA_ERR_OFFSET + 74;  // media distribute player unsupporteded
106 const uint32_t ERR_IMAGE_DENCODE_ICC_FAILED = BASE_MEDIA_ERR_OFFSET + 75;          // image dencode ICC fail
107 const uint32_t ERR_IMAGE_ENCODE_ICC_FAILED = BASE_MEDIA_ERR_OFFSET + 76;           // image encode ICC fail
108 const int32_t ERR_DMA_NOT_EXIST = BASE_MEDIA_ERR_OFFSET + 77;
109 const int32_t ERR_DMA_DATA_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 78;
110 const int32_t ERR_SURFACEBUFFER_REFERENCE_FAILED = BASE_MEDIA_ERR_OFFSET + 79;
111 const int32_t ERR_SURFACEBUFFER_UNREFERENCE_FAILED = BASE_MEDIA_ERR_OFFSET + 80;
112 const uint32_t ERR_IMAGE_NAPI_ERROR = BASE_MEDIA_ERR_OFFSET + 81; // napi environmental abnormality
113 const uint32_t ERR_IMAGE_PIXELMAP_CREATE_FAILED = BASE_MEDIA_ERR_OFFSET + 82; // pixelmap create failed
114 // unmarshalling bufferSize parcelling error
115 const uint32_t ERR_IMAGE_BUFFER_SIZE_PARCEL_ERROR = BASE_MEDIA_ERR_OFFSET + 83;
116 const uint32_t ERR_IMAGE_GET_FD_BAD = BASE_MEDIA_ERR_OFFSET + 84; // fd acquisition failed
117 const uint32_t ERR_IMAGE_AI_UNSUPPORTED = BASE_MEDIA_ERR_OFFSET + 85;
118 const uint32_t ERR_IMAGE_AI_ONLY_SR_SUCCESS = BASE_MEDIA_ERR_OFFSET + 86;
119 const uint32_t ERR_IMAGE_AI_UNNECESSARY = BASE_MEDIA_ERR_OFFSET + 87;
120 const uint32_t ERR_IMAGE_DECODE_METADATA_FAILED = BASE_MEDIA_ERR_OFFSET + 88; // decode metadata fail
121 const uint32_t ERR_IMAGE_PICTURE_CREATE_FAILED = BASE_MEDIA_ERR_OFFSET + 89; // picture create failed
122 
123 const uint32_t ERR_IMAGE_READ_PIXELMAP_FAILED = BASE_MEDIA_ERR_OFFSET + 150; // read pixelmap failed
124 const uint32_t ERR_IMAGE_WRITE_PIXELMAP_FAILED = BASE_MEDIA_ERR_OFFSET + 151; // write pixelmap failed
125 const uint32_t ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY = BASE_MEDIA_ERR_OFFSET + 152; // pixelmap not allow modify
126 const uint32_t ERR_IMAGE_CONFIG_FAILED = BASE_MEDIA_ERR_OFFSET + 153; // config error
127 const uint32_t IMAGE_RESULT_JNI_ENV_ABNORMAL = BASE_MEDIA_ERR_OFFSET + 154; // Abnormal JNI environment
128 const uint32_t IMAGE_RESULT_SURFAC_GRALLOC_BUFFER_FAILED = BASE_MEDIA_ERR_OFFSET + 155; // gralloc buffer failed
129 const uint32_t IMAGE_RESULT_CREATE_SURFAC_FAILED = BASE_MEDIA_ERR_OFFSET + 156; // create graphicsurface failed
130 // Failed to obtain parameters for graphicsurface
131 const uint32_t IMAGE_RESULT_SURFAC_GET_PARAMETER_FAILED = BASE_MEDIA_ERR_OFFSET + 157;
132 const uint32_t IMAGE_RESULT_GET_SURFAC_FAILED = BASE_MEDIA_ERR_OFFSET + 158; // get graphicsurface failed
133 const uint32_t IMAGE_RESULT_SURFAC_ACQUIRE_BUFFER_FAILED = BASE_MEDIA_ERR_OFFSET + 159; // Acquire Buffer failed
134 const uint32_t IMAGE_RESULT_SURFAC_REQUEST_BUFFER_FAILED = BASE_MEDIA_ERR_OFFSET + 160; // request Buffer failed
135 const uint32_t IMAGE_RESULT_REGISTER_LISTENER_FAILED = BASE_MEDIA_ERR_OFFSET + 161; // Failed to register listener
136 const uint32_t IMAGE_RESULT_REGISTER_BUFFER_FAILED = BASE_MEDIA_ERR_OFFSET + 162; // Failed to register buffer
137 const uint32_t IMAGE_RESULT_FREAD_FAILED = BASE_MEDIA_ERR_OFFSET + 163; // read file failed
138 const uint32_t IMAGE_RESULT_PEEK_FAILED = BASE_MEDIA_ERR_OFFSET + 164; // peek file failed
139 const uint32_t IMAGE_RESULT_SEEK_FAILED = BASE_MEDIA_ERR_OFFSET + 165; // seek file failed
140 const uint32_t IMAGE_RESULT_STREAM_SIZE_ERROR = BASE_MEDIA_ERR_OFFSET + 166; // stream bad
141 const uint32_t IMAGE_RESULT_FILE_FD_ERROR = BASE_MEDIA_ERR_OFFSET + 167; // file fd is bad
142 const uint32_t IMAGE_RESULT_FILE_DAMAGED = BASE_MEDIA_ERR_OFFSET + 168; // file damaged
143 const uint32_t IMAGE_RESULT_CREATE_DECODER_FAILED = BASE_MEDIA_ERR_OFFSET + 169; // create decoder failed
144 const uint32_t IMAGE_RESULT_CREATE_ENCODER_FAILED = BASE_MEDIA_ERR_OFFSET + 170; // create encoder failed
145 const uint32_t IMAGE_RESULT_CHECK_FORMAT_ERROR = BASE_MEDIA_ERR_OFFSET + 171; // check format failed
146 const uint32_t IMAGE_RESULT_THIRDPART_THIRDPARTSKIA_ERROR = BASE_MEDIA_ERR_OFFSET + 172; // thirdpartskia error
147 const uint32_t IMAGE_RESULT_HW_DECODE_FAILED = BASE_MEDIA_ERR_OFFSET + 173; // hard decode failed
148 const uint32_t IMAGE_RESULT_ALLOCATER_TYPE_ERROR = BASE_MEDIA_ERR_OFFSET + 174; // hard decode failed
149 const uint32_t IMAGE_RESULT_ALPHA_TYPE_ERROR = BASE_MEDIA_ERR_OFFSET + 175; // hard decode failed
150 const uint32_t IMAGE_RESULT_INDEX_INVALID = BASE_MEDIA_ERR_OFFSET + 176; // invalid index
151 const uint32_t IMAGE_RESULT_SAVE_DATA_TO_FILE_FAILED = BASE_MEDIA_ERR_OFFSET + 177; // save data to file failed
152 const uint32_t ERR_EXIF_DECODE_FAILED = BASE_MEDIA_ERR_OFFSET + 178; // exif decode fail
153 const uint32_t IMAGE_RESULT_CREATE_FORMAT_CONVERT_FAILED = BASE_MEDIA_ERR_OFFSET + 179; // create convert format failed
154 
155 const uint32_t ERR_MEDIA_FORMAT_UNSUPPORT = BASE_MEDIA_ERR_OFFSET + 180;
156 const uint32_t ERR_MEDIA_MEMERY_COPY = BASE_MEDIA_ERR_OFFSET + 181;
157 const uint32_t IMAGE_RESULT_FORMAT_CONVERT_FAILED = BASE_MEDIA_ERR_OFFSET + 182; // convert format failed
158 const uint32_t ERR_MEMORY_NOT_SUPPORT = BASE_MEDIA_ERR_OFFSET + 190; // pixelmap set name format not compare
159 const uint32_t ERR_MEDIA_MMAP_FILE_CHANGED = BASE_MEDIA_ERR_OFFSET + 191; // mmap file changed
160 const int32_t ERR_MEDIA_UNKNOWN = BASE_MEDIA_ERR_OFFSET + 200;  // media unknown error
161 const int32_t ERR_MEMORY_COPY_FAILED = BASE_MEDIA_ERR_OFFSET + 206; // media unknown error
162 const int32_t ERR_RESOURCE_UNAVAILABLE = 501; // Resource Unavailable
163 const int32_t COMMON_ERR_INVALID_PARAMETER = 401; // Common error,Invalid parameter
164 const int32_t ERR_MEDIA_NO_EXIF_DATA = 402; // no exif_data info
165 }  // namespace Media
166 }  // namespace OHOS
167 #endif  // INTERFACES_INNERKITS_INCLUDE_MEDIA_ERRORS_H
168