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 #include "avcodec_errors.h"
17 #include <map>
18 #include <string>
19
20 namespace OHOS {
21 namespace MediaAVCodec {
22 using namespace Media;
23 using ErrorMessageFunc = std::function<std::string(const std::string ¶m1, const std::string ¶m2)>;
24 const std::map<AVCodecServiceErrCode, std::string> AVCS_ERRCODE_INFOS = {
25 {AVCS_ERR_OK, "success"},
26 {AVCS_ERR_NO_MEMORY, "no memory"},
27 {AVCS_ERR_INVALID_OPERATION, "operation not be permitted"},
28 {AVCS_ERR_INVALID_VAL, "invalid argument"},
29 {AVCS_ERR_UNKNOWN, "unknown error"},
30 {AVCS_ERR_SERVICE_DIED, "avcodec service died"},
31 {AVCS_ERR_CREATE_AVCODEC_STUB_FAILED, "create avcodec sub service failed"},
32 {AVCS_ERR_INVALID_STATE, "the state is not support this operation"},
33 {AVCS_ERR_UNSUPPORT, "unsupport interface"},
34 {AVCS_ERR_UNSUPPORT_AUD_SRC_TYPE, "unsupport audio source type"},
35 {AVCS_ERR_UNSUPPORT_AUD_SAMPLE_RATE, "unsupport audio sample rate"},
36 {AVCS_ERR_UNSUPPORT_AUD_CHANNEL_NUM, "unsupport audio channel"},
37 {AVCS_ERR_UNSUPPORT_AUD_ENC_TYPE, "unsupport audio encoder type"},
38 {AVCS_ERR_UNSUPPORT_AUD_PARAMS, "unsupport audio params(other params)"},
39 {AVCS_ERR_UNSUPPORT_VID_SRC_TYPE, "unsupport video source type"},
40 {AVCS_ERR_UNSUPPORT_VID_ENC_TYPE, "unsupport video encoder type"},
41 {AVCS_ERR_UNSUPPORT_VID_PARAMS, "unsupport video params(other params)"},
42 {AVCS_ERR_UNSUPPORT_FILE_TYPE, "unsupport file format type"},
43 {AVCS_ERR_UNSUPPORT_PROTOCOL_TYPE, "unsupport protocol type"},
44 {AVCS_ERR_UNSUPPORT_VID_DEC_TYPE, "unsupport video decoder type"},
45 {AVCS_ERR_UNSUPPORT_AUD_DEC_TYPE, "unsupport audio decoder type"},
46 {AVCS_ERR_UNSUPPORT_STREAM, "internal data stream error"},
47 {AVCS_ERR_UNSUPPORT_SOURCE, "unsupport source type"},
48 {AVCS_ERR_AUD_ENC_FAILED, "audio encode failed"},
49 {AVCS_ERR_AUD_RENDER_FAILED, "audio render failed"},
50 {AVCS_ERR_VID_ENC_FAILED, "video encode failed"},
51 {AVCS_ERR_AUD_DEC_FAILED, "audio decode failed"},
52 {AVCS_ERR_VID_DEC_FAILED, "video decode failed"},
53 {AVCS_ERR_MUXER_FAILED, "stream avmuxer failed"},
54 {AVCS_ERR_DEMUXER_FAILED, "stream demuxer or parser failed"},
55 {AVCS_ERR_OPEN_FILE_FAILED, "open file failed"},
56 {AVCS_ERR_FILE_ACCESS_FAILED, "read or write file failed"},
57 {AVCS_ERR_START_FAILED, "audio or video start failed"},
58 {AVCS_ERR_PAUSE_FAILED, "audio or video pause failed"},
59 {AVCS_ERR_STOP_FAILED, "audio or video stop failed"},
60 {AVCS_ERR_SEEK_FAILED, "audio or video seek failed"},
61 {AVCS_ERR_NETWORK_TIMEOUT, "network timeout"},
62 {AVCS_ERR_NOT_FIND_FILE, "not find a file"},
63 {AVCS_ERR_NOT_ENOUGH_DATA, "audio output buffer not enough of a pack"},
64 {AVCS_ERR_END_OF_STREAM, "end of stream"},
65 {AVCS_ERR_CONFIGURE_MISMATCH_CHANNEL_COUNT, "missing channel count attribute in configure"},
66 {AVCS_ERR_MISMATCH_SAMPLE_RATE, "missing sample rate attribute in configure"},
67 {AVCS_ERR_MISMATCH_BIT_RATE, "missing bit rate attribute in configure"},
68 {AVCS_ERR_CONFIGURE_ERROR, "compression level incorrect in flac encoder"},
69 {AVCS_ERR_DECRYPT_FAILED, "decrypt protected content failed"},
70 {AVCS_ERR_CODEC_PARAM_INCORRECT, "video codec param check failed"},
71 {AVCS_ERR_EXTEND_START, "extend start error code"},
72 {AVCS_ERR_INPUT_DATA_ERROR, "there is somthing wrong for input data"},
73 {AVCS_ERR_TRY_AGAIN, "try again later"},
74 {AVCS_ERR_STREAM_CHANGED, "video stream changed"},
75 {AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION, "video unsupported color space conversion"}};
76
77 const std::map<AVCodecServiceErrCode, OH_AVErrCode> AVCSERRCODE_TO_OHAVCODECERRCODE = {
78 {AVCS_ERR_OK, AV_ERR_OK},
79 {AVCS_ERR_NO_MEMORY, AV_ERR_NO_MEMORY},
80 {AVCS_ERR_INVALID_OPERATION, AV_ERR_OPERATE_NOT_PERMIT},
81 {AVCS_ERR_INVALID_VAL, AV_ERR_INVALID_VAL},
82 {AVCS_ERR_INVALID_DATA, AV_ERR_INVALID_VAL},
83 {AVCS_ERR_UNKNOWN, AV_ERR_UNKNOWN},
84 {AVCS_ERR_SERVICE_DIED, AV_ERR_SERVICE_DIED},
85 {AVCS_ERR_CREATE_AVCODEC_STUB_FAILED, AV_ERR_UNKNOWN},
86 {AVCS_ERR_INVALID_STATE, AV_ERR_INVALID_STATE},
87 {AVCS_ERR_UNSUPPORT, AV_ERR_UNSUPPORT},
88 {AVCS_ERR_UNSUPPORT_AUD_SRC_TYPE, AV_ERR_UNSUPPORT},
89 {AVCS_ERR_UNSUPPORT_AUD_SAMPLE_RATE, AV_ERR_UNSUPPORT},
90 {AVCS_ERR_UNSUPPORT_AUD_CHANNEL_NUM, AV_ERR_UNSUPPORT},
91 {AVCS_ERR_UNSUPPORT_AUD_ENC_TYPE, AV_ERR_UNSUPPORT},
92 {AVCS_ERR_UNSUPPORT_AUD_PARAMS, AV_ERR_UNSUPPORT},
93 {AVCS_ERR_UNSUPPORT_VID_SRC_TYPE, AV_ERR_UNSUPPORT},
94 {AVCS_ERR_UNSUPPORT_VID_ENC_TYPE, AV_ERR_UNSUPPORT},
95 {AVCS_ERR_UNSUPPORT_VID_PARAMS, AV_ERR_UNSUPPORT},
96 {AVCS_ERR_UNSUPPORT_FILE_TYPE, AV_ERR_UNSUPPORT},
97 {AVCS_ERR_UNSUPPORT_PROTOCOL_TYPE, AV_ERR_UNSUPPORT},
98 {AVCS_ERR_UNSUPPORT_VID_DEC_TYPE, AV_ERR_UNSUPPORT},
99 {AVCS_ERR_UNSUPPORT_AUD_DEC_TYPE, AV_ERR_UNSUPPORT},
100 {AVCS_ERR_UNSUPPORT_STREAM, AV_ERR_UNSUPPORT},
101 {AVCS_ERR_UNSUPPORT_SOURCE, AV_ERR_UNSUPPORT},
102 {AVCS_ERR_AUD_RENDER_FAILED, AV_ERR_UNSUPPORT},
103 {AVCS_ERR_AUD_ENC_FAILED, AV_ERR_UNKNOWN},
104 {AVCS_ERR_VID_ENC_FAILED, AV_ERR_UNKNOWN},
105 {AVCS_ERR_AUD_DEC_FAILED, AV_ERR_UNKNOWN},
106 {AVCS_ERR_VID_DEC_FAILED, AV_ERR_UNKNOWN},
107 {AVCS_ERR_MUXER_FAILED, AV_ERR_UNKNOWN},
108 {AVCS_ERR_DEMUXER_FAILED, AV_ERR_UNKNOWN},
109 {AVCS_ERR_OPEN_FILE_FAILED, AV_ERR_IO},
110 {AVCS_ERR_FILE_ACCESS_FAILED, AV_ERR_IO},
111 {AVCS_ERR_START_FAILED, AV_ERR_UNKNOWN},
112 {AVCS_ERR_PAUSE_FAILED, AV_ERR_UNKNOWN},
113 {AVCS_ERR_STOP_FAILED, AV_ERR_UNKNOWN},
114 {AVCS_ERR_SEEK_FAILED, AV_ERR_UNKNOWN},
115 {AVCS_ERR_NETWORK_TIMEOUT, AV_ERR_TIMEOUT},
116 {AVCS_ERR_NOT_FIND_FILE, AV_ERR_UNSUPPORT},
117 {AVCS_ERR_NOT_ENOUGH_DATA, AV_ERR_UNKNOWN},
118 {AVCS_ERR_END_OF_STREAM, AV_ERR_UNKNOWN},
119 {AVCS_ERR_CONFIGURE_MISMATCH_CHANNEL_COUNT, AV_ERR_UNSUPPORT},
120 {AVCS_ERR_MISMATCH_SAMPLE_RATE, AV_ERR_UNSUPPORT},
121 {AVCS_ERR_MISMATCH_BIT_RATE, AV_ERR_UNSUPPORT},
122 {AVCS_ERR_CONFIGURE_ERROR, AV_ERR_UNSUPPORT},
123 {AVCS_ERR_EXTEND_START, AV_ERR_EXTEND_START},
124 {AVCS_ERR_DECRYPT_FAILED, AV_ERR_DRM_DECRYPT_FAILED},
125 {AVCS_ERR_CODEC_PARAM_INCORRECT, AV_ERR_INVALID_VAL},
126 {AVCS_ERR_INPUT_DATA_ERROR, AV_ERR_INPUT_DATA_ERROR},
127 {AVCS_ERR_TRY_AGAIN, AV_ERR_TRY_AGAIN_LATER},
128 {AVCS_ERR_STREAM_CHANGED, AV_ERR_STREAM_CHANGED},
129 {AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION, AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION},
130 };
131
132 const std::map<OH_AVErrCode, std::string> OHAVCODECERRCODE_INFOS = {
133 {AV_ERR_OK, "success"},
134 {AV_ERR_NO_MEMORY, "no memory"},
135 {AV_ERR_OPERATE_NOT_PERMIT, "operation not be permitted"},
136 {AV_ERR_INVALID_VAL, "invalid argument"},
137 {AV_ERR_IO, "IO error"},
138 {AV_ERR_TIMEOUT, "network timeout"},
139 {AV_ERR_UNKNOWN, "unknown error"},
140 {AV_ERR_SERVICE_DIED, "avcodec service died"},
141 {AV_ERR_INVALID_STATE, "the state is not support this operation"},
142 {AV_ERR_UNSUPPORT, "unsupport interface"},
143 {AV_ERR_INPUT_DATA_ERROR, "input data error"},
144 {AV_ERR_EXTEND_START, "extend err start"},
145 {AV_ERR_DRM_BASE, "drm error base"},
146 {AV_ERR_DRM_DECRYPT_FAILED, "decrypt failed"},
147 {AV_ERR_VIDEO_BASE, "video error base"},
148 {AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION, "video unsupported color space conversion"},
149 {AV_ERR_TRY_AGAIN_LATER, "try again later"},
150 {AV_ERR_STREAM_CHANGED, "video stream changed"},
151 };
152
153 const std::map<Status, AVCodecServiceErrCode> STATUS_TO_AVCSERRCODE = {
154 {Status::END_OF_STREAM, AVCodecServiceErrCode::AVCS_ERR_OK},
155 {Status::OK, AVCodecServiceErrCode::AVCS_ERR_OK},
156 {Status::NO_ERROR, AVCodecServiceErrCode::AVCS_ERR_OK},
157 {Status::ERROR_UNKNOWN, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
158 {Status::ERROR_PLUGIN_ALREADY_EXISTS, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
159 {Status::ERROR_INCOMPATIBLE_VERSION, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
160 {Status::ERROR_NO_MEMORY, AVCodecServiceErrCode::AVCS_ERR_NO_MEMORY},
161 {Status::ERROR_WRONG_STATE, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION},
162 {Status::ERROR_UNIMPLEMENTED, AVCodecServiceErrCode::AVCS_ERR_UNSUPPORT},
163 {Status::ERROR_INVALID_PARAMETER, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
164 {Status::ERROR_INVALID_DATA, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
165 {Status::ERROR_MISMATCHED_TYPE, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
166 {Status::ERROR_TIMED_OUT, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
167 {Status::ERROR_UNSUPPORTED_FORMAT, AVCodecServiceErrCode::AVCS_ERR_UNSUPPORT_FILE_TYPE},
168 {Status::ERROR_NOT_ENOUGH_DATA, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
169 {Status::ERROR_NOT_EXISTED, AVCodecServiceErrCode::AVCS_ERR_OPEN_FILE_FAILED},
170 {Status::ERROR_AGAIN, AVCodecServiceErrCode::AVCS_ERR_TRY_AGAIN},
171 {Status::ERROR_PERMISSION_DENIED, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
172 {Status::ERROR_NULL_POINTER, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
173 {Status::ERROR_INVALID_OPERATION, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION},
174 {Status::ERROR_CLIENT, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
175 {Status::ERROR_SERVER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
176 {Status::ERROR_DELAY_READY, AVCodecServiceErrCode::AVCS_ERR_OK},
177 {Status::ERROR_INVALID_STATE, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION},
178 {Status::ERROR_INVALID_BUFFER_SIZE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
179 {Status::ERROR_UNEXPECTED_MEMORY_TYPE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
180 {Status::ERROR_CREATE_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
181 {Status::ERROR_NULL_POINT_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
182 {Status::ERROR_INVALID_BUFFER_ID, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
183 {Status::ERROR_INVALID_BUFFER_STATE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
184 {Status::ERROR_NO_FREE_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
185 {Status::ERROR_NO_DIRTY_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
186 {Status::ERROR_NO_CONSUMER_LISTENER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
187 {Status::ERROR_NULL_BUFFER_QUEUE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
188 {Status::ERROR_WAIT_TIMEOUT, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
189 {Status::ERROR_OUT_OF_RANGE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
190 {Status::ERROR_NULL_SURFACE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
191 {Status::ERROR_SURFACE_INNER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
192 {Status::ERROR_NULL_SURFACE_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
193 {Status::ERROR_IPC_WRITE_INTERFACE_TOKEN, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
194 {Status::ERROR_IPC_SEND_REQUEST, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
195 {Status::ERROR_DRM_DECRYPT_FAILED, AVCodecServiceErrCode::AVCS_ERR_DECRYPT_FAILED},
196 {Status::ERROR_PACKET_CONVERT_FAILED, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}};
197
198 const std::map<int32_t, AVCodecServiceErrCode> VPEERROR_TO_AVCSERRCODE = {
199 {0, AVCodecServiceErrCode::AVCS_ERR_OK},
200 {63635468, AVCodecServiceErrCode::AVCS_ERR_NO_MEMORY}, // 63635468: no memory
201 {63635494, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION}, // 63635494: opertation not be permitted
202 {63635478, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL}, // 63635478: invalid argument
203 {63635968, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635968: unknow error
204 {63635969, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635969: video processing engine init failed
205 {63635970, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635970: extension not found
206 {63635971, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635971: extension init failed
207 {63635972, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN}, // 63635972: extension process failed
208 {63635973,
209 AVCodecServiceErrCode::AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION}, // 63635973: extension is not implemented
210 {63635974, AVCodecServiceErrCode::AVCS_ERR_UNSUPPORT}, // 63635974: not supported operation
211 {63635975, AVCodecServiceErrCode::AVCS_ERR_INVALID_STATE}}; // 63635975: the state is not support this operation
212
ErrorMessageOk(const std::string & param1,const std::string & param2)213 std::string ErrorMessageOk(const std::string ¶m1, const std::string ¶m2)
214 {
215 (void)param1;
216 (void)param2;
217 return "success";
218 }
219
ErrorMessageNoPermission(const std::string & param1,const std::string & param2)220 std::string ErrorMessageNoPermission(const std::string ¶m1, const std::string ¶m2)
221 {
222 std::string message = "Try to do " + param1 + " failed. User should request permission " + param2 + " first.";
223 return message;
224 }
225
ErrorMessageInvalidParameter(const std::string & param1,const std::string & param2)226 std::string ErrorMessageInvalidParameter(const std::string ¶m1, const std::string ¶m2)
227 {
228 (void)param2;
229 std::string message = "The Parameter " + param1 + " is invalid. Please check the type and range.";
230 return message;
231 }
232
ErrorMessageUnsupportCapability(const std::string & param1,const std::string & param2)233 std::string ErrorMessageUnsupportCapability(const std::string ¶m1, const std::string ¶m2)
234 {
235 (void)param2;
236 std::string message = "Function " + param1 + " can not work correctly due to limited device capability.";
237 return message;
238 }
239
ErrorMessageNoMemory(const std::string & param1,const std::string & param2)240 std::string ErrorMessageNoMemory(const std::string ¶m1, const std::string ¶m2)
241 {
242 (void)param2;
243 std::string message = "Create " + param1 + " failed due to system memory.";
244 return message;
245 }
246
ErrorMessageOperateNotPermit(const std::string & param1,const std::string & param2)247 std::string ErrorMessageOperateNotPermit(const std::string ¶m1, const std::string ¶m2)
248 {
249 (void)param2;
250 std::string message = "The operation " + param1 + " failed due to not permit in current state.";
251 return message;
252 }
253
ErrorMessageIO(const std::string & param1,const std::string & param2)254 std::string ErrorMessageIO(const std::string ¶m1, const std::string ¶m2)
255 {
256 (void)param2;
257 std::string message = "IO error happened due to " + param1 + ".";
258 return message;
259 }
260
ErrorMessageTimeout(const std::string & param1,const std::string & param2)261 std::string ErrorMessageTimeout(const std::string ¶m1, const std::string ¶m2)
262 {
263 std::string message = "Timeout happened when " + param1 + " due to " + param2 + ".";
264 return message;
265 }
266
ErrorMessageServiceDied(const std::string & param1,const std::string & param2)267 std::string ErrorMessageServiceDied(const std::string ¶m1, const std::string ¶m2)
268 {
269 (void)param1;
270 (void)param2;
271 std::string message = "AVCodec Serviced Died.";
272 return message;
273 }
274
ErrorMessageUnsupportFormat(const std::string & param1,const std::string & param2)275 std::string ErrorMessageUnsupportFormat(const std::string ¶m1, const std::string ¶m2)
276 {
277 (void)param2;
278 std::string message = "The format " + param1 + " is not support.";
279 return message;
280 }
281
AVCSErrorToString(AVCodecServiceErrCode code)282 std::string AVCSErrorToString(AVCodecServiceErrCode code)
283 {
284 if (AVCS_ERRCODE_INFOS.count(code) != 0) {
285 return AVCS_ERRCODE_INFOS.at(code);
286 }
287
288 return "unknown error";
289 }
290
OHAVErrCodeToString(OH_AVErrCode code)291 std::string OHAVErrCodeToString(OH_AVErrCode code)
292 {
293 if (OHAVCODECERRCODE_INFOS.count(code) != 0) {
294 return OHAVCODECERRCODE_INFOS.at(code);
295 }
296
297 return "unknown error";
298 }
299
AVCSErrorToOHAVErrCodeString(AVCodecServiceErrCode code)300 std::string AVCSErrorToOHAVErrCodeString(AVCodecServiceErrCode code)
301 {
302 if (AVCS_ERRCODE_INFOS.count(code) != 0 && AVCSERRCODE_TO_OHAVCODECERRCODE.count(code) != 0) {
303 OH_AVErrCode extCode = AVCSERRCODE_TO_OHAVCODECERRCODE.at(code);
304 if (OHAVCODECERRCODE_INFOS.count(extCode) != 0) {
305 return OHAVCODECERRCODE_INFOS.at(extCode);
306 }
307 }
308
309 return "unknown error";
310 }
311
AVCSErrorToOHAVErrCode(AVCodecServiceErrCode code)312 OH_AVErrCode AVCSErrorToOHAVErrCode(AVCodecServiceErrCode code)
313 {
314 if (AVCS_ERRCODE_INFOS.count(code) != 0 && AVCSERRCODE_TO_OHAVCODECERRCODE.count(code) != 0) {
315 return AVCSERRCODE_TO_OHAVCODECERRCODE.at(code);
316 }
317
318 return AV_ERR_UNKNOWN;
319 }
320
StatusToAVCodecServiceErrCode(Status code)321 AVCodecServiceErrCode StatusToAVCodecServiceErrCode(Status code)
322 {
323 if (STATUS_TO_AVCSERRCODE.count(code) != 0) {
324 return STATUS_TO_AVCSERRCODE.at(code);
325 }
326
327 return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN;
328 }
329
VPEErrorToAVCSError(int32_t code)330 AVCodecServiceErrCode VPEErrorToAVCSError(int32_t code)
331 {
332 if (VPEERROR_TO_AVCSERRCODE.count(code) != 0) {
333 return VPEERROR_TO_AVCSERRCODE.at(code);
334 }
335
336 return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN;
337 }
338 } // namespace MediaAVCodec
339 } // namespace OHOS
340