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 &param1, const std::string &param2)>;
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,                               "unkown 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_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION, "video unsupported color space conversion"}};
74 
75 const std::map<AVCodecServiceErrCode, OH_AVErrCode> AVCSERRCODE_TO_OHAVCODECERRCODE = {
76     {AVCS_ERR_OK,                                  AV_ERR_OK},
77     {AVCS_ERR_NO_MEMORY,                           AV_ERR_NO_MEMORY},
78     {AVCS_ERR_INVALID_OPERATION,                   AV_ERR_OPERATE_NOT_PERMIT},
79     {AVCS_ERR_INVALID_VAL,                         AV_ERR_INVALID_VAL},
80     {AVCS_ERR_INVALID_DATA,                        AV_ERR_INVALID_VAL},
81     {AVCS_ERR_UNKNOWN,                             AV_ERR_UNKNOWN},
82     {AVCS_ERR_SERVICE_DIED,                        AV_ERR_SERVICE_DIED},
83     {AVCS_ERR_CREATE_AVCODEC_STUB_FAILED,          AV_ERR_UNKNOWN},
84     {AVCS_ERR_INVALID_STATE,                       AV_ERR_INVALID_STATE},
85     {AVCS_ERR_UNSUPPORT,                           AV_ERR_UNSUPPORT},
86     {AVCS_ERR_UNSUPPORT_AUD_SRC_TYPE,              AV_ERR_UNSUPPORT},
87     {AVCS_ERR_UNSUPPORT_AUD_SAMPLE_RATE,           AV_ERR_UNSUPPORT},
88     {AVCS_ERR_UNSUPPORT_AUD_CHANNEL_NUM,           AV_ERR_UNSUPPORT},
89     {AVCS_ERR_UNSUPPORT_AUD_ENC_TYPE,              AV_ERR_UNSUPPORT},
90     {AVCS_ERR_UNSUPPORT_AUD_PARAMS,                AV_ERR_UNSUPPORT},
91     {AVCS_ERR_UNSUPPORT_VID_SRC_TYPE,              AV_ERR_UNSUPPORT},
92     {AVCS_ERR_UNSUPPORT_VID_ENC_TYPE,              AV_ERR_UNSUPPORT},
93     {AVCS_ERR_UNSUPPORT_VID_PARAMS,                AV_ERR_UNSUPPORT},
94     {AVCS_ERR_UNSUPPORT_FILE_TYPE,                 AV_ERR_UNSUPPORT},
95     {AVCS_ERR_UNSUPPORT_PROTOCOL_TYPE,             AV_ERR_UNSUPPORT},
96     {AVCS_ERR_UNSUPPORT_VID_DEC_TYPE,              AV_ERR_UNSUPPORT},
97     {AVCS_ERR_UNSUPPORT_AUD_DEC_TYPE,              AV_ERR_UNSUPPORT},
98     {AVCS_ERR_UNSUPPORT_STREAM,                    AV_ERR_UNSUPPORT},
99     {AVCS_ERR_UNSUPPORT_SOURCE,                    AV_ERR_UNSUPPORT},
100     {AVCS_ERR_AUD_RENDER_FAILED,                   AV_ERR_UNSUPPORT},
101     {AVCS_ERR_AUD_ENC_FAILED,                      AV_ERR_UNKNOWN},
102     {AVCS_ERR_VID_ENC_FAILED,                      AV_ERR_UNKNOWN},
103     {AVCS_ERR_AUD_DEC_FAILED,                      AV_ERR_UNKNOWN},
104     {AVCS_ERR_VID_DEC_FAILED,                      AV_ERR_UNKNOWN},
105     {AVCS_ERR_MUXER_FAILED,                        AV_ERR_UNKNOWN},
106     {AVCS_ERR_DEMUXER_FAILED,                      AV_ERR_UNKNOWN},
107     {AVCS_ERR_OPEN_FILE_FAILED,                    AV_ERR_IO},
108     {AVCS_ERR_FILE_ACCESS_FAILED,                  AV_ERR_IO},
109     {AVCS_ERR_START_FAILED,                        AV_ERR_UNKNOWN},
110     {AVCS_ERR_PAUSE_FAILED,                        AV_ERR_UNKNOWN},
111     {AVCS_ERR_STOP_FAILED,                         AV_ERR_UNKNOWN},
112     {AVCS_ERR_SEEK_FAILED,                         AV_ERR_UNKNOWN},
113     {AVCS_ERR_NETWORK_TIMEOUT,                     AV_ERR_TIMEOUT},
114     {AVCS_ERR_NOT_FIND_FILE,                       AV_ERR_UNSUPPORT},
115     {AVCS_ERR_NOT_ENOUGH_DATA,                     AV_ERR_UNKNOWN},
116     {AVCS_ERR_END_OF_STREAM,                       AV_ERR_UNKNOWN},
117     {AVCS_ERR_CONFIGURE_MISMATCH_CHANNEL_COUNT,    AV_ERR_UNSUPPORT},
118     {AVCS_ERR_MISMATCH_SAMPLE_RATE,                AV_ERR_UNSUPPORT},
119     {AVCS_ERR_MISMATCH_BIT_RATE,                   AV_ERR_UNSUPPORT},
120     {AVCS_ERR_CONFIGURE_ERROR,                     AV_ERR_UNSUPPORT},
121     {AVCS_ERR_EXTEND_START,                        AV_ERR_EXTEND_START},
122     {AVCS_ERR_DECRYPT_FAILED,                      AV_ERR_DRM_DECRYPT_FAILED},
123     {AVCS_ERR_CODEC_PARAM_INCORRECT,               AV_ERR_INVALID_VAL},
124     {AVCS_ERR_INPUT_DATA_ERROR,                    AV_ERR_INPUT_DATA_ERROR},
125     {AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION, AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION},
126     };
127 
128 const std::map<OH_AVErrCode, std::string> OHAVCODECERRCODE_INFOS = {
129     {AV_ERR_OK,                                       "success"},
130     {AV_ERR_NO_MEMORY,                                "no memory"},
131     {AV_ERR_OPERATE_NOT_PERMIT,                       "operation not be permitted"},
132     {AV_ERR_INVALID_VAL,                              "invalid argument"},
133     {AV_ERR_IO,                                       "IO error"},
134     {AV_ERR_TIMEOUT,                                  "network timeout"},
135     {AV_ERR_UNKNOWN,                                  "unkown error"},
136     {AV_ERR_SERVICE_DIED,                             "avcodec service died"},
137     {AV_ERR_INVALID_STATE,                            "the state is not support this operation"},
138     {AV_ERR_UNSUPPORT,                                "unsupport interface"},
139     {AV_ERR_INPUT_DATA_ERROR,                         "input data error"},
140     {AV_ERR_EXTEND_START,                             "extend err start"},
141     {AV_ERR_DRM_BASE,                                 "drm error base"},
142     {AV_ERR_DRM_DECRYPT_FAILED,                       "decrypt failed"},
143     {AV_ERR_VIDEO_BASE,                               "video error base"},
144     {AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION, "video unsupported color space conversion"},
145 };
146 
147 const std::map<Status, AVCodecServiceErrCode> STATUS_TO_AVCSERRCODE = {
148     {Status::END_OF_STREAM, AVCodecServiceErrCode::AVCS_ERR_OK},
149     {Status::OK, AVCodecServiceErrCode::AVCS_ERR_OK},
150     {Status::NO_ERROR, AVCodecServiceErrCode::AVCS_ERR_OK},
151     {Status::ERROR_UNKNOWN, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
152     {Status::ERROR_PLUGIN_ALREADY_EXISTS, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
153     {Status::ERROR_INCOMPATIBLE_VERSION, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
154     {Status::ERROR_NO_MEMORY, AVCodecServiceErrCode::AVCS_ERR_NO_MEMORY},
155     {Status::ERROR_WRONG_STATE, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION},
156     {Status::ERROR_UNIMPLEMENTED, AVCodecServiceErrCode::AVCS_ERR_UNSUPPORT},
157     {Status::ERROR_INVALID_PARAMETER, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
158     {Status::ERROR_INVALID_DATA, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
159     {Status::ERROR_MISMATCHED_TYPE, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
160     {Status::ERROR_TIMED_OUT, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
161     {Status::ERROR_UNSUPPORTED_FORMAT, AVCodecServiceErrCode::AVCS_ERR_UNSUPPORT_FILE_TYPE},
162     {Status::ERROR_NOT_ENOUGH_DATA, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
163     {Status::ERROR_NOT_EXISTED, AVCodecServiceErrCode::AVCS_ERR_OPEN_FILE_FAILED},
164     {Status::ERROR_AGAIN, AVCodecServiceErrCode::AVCS_ERR_TRY_AGAIN},
165     {Status::ERROR_PERMISSION_DENIED, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
166     {Status::ERROR_NULL_POINTER, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},
167     {Status::ERROR_INVALID_OPERATION, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION},
168     {Status::ERROR_CLIENT, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
169     {Status::ERROR_SERVER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
170     {Status::ERROR_DELAY_READY, AVCodecServiceErrCode::AVCS_ERR_OK},
171     {Status::ERROR_INVALID_STATE, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION},
172     {Status::ERROR_INVALID_BUFFER_SIZE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
173     {Status::ERROR_UNEXPECTED_MEMORY_TYPE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
174     {Status::ERROR_CREATE_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
175     {Status::ERROR_NULL_POINT_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
176     {Status::ERROR_INVALID_BUFFER_ID, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
177     {Status::ERROR_INVALID_BUFFER_STATE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
178     {Status::ERROR_NO_FREE_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
179     {Status::ERROR_NO_DIRTY_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
180     {Status::ERROR_NO_CONSUMER_LISTENER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
181     {Status::ERROR_NULL_BUFFER_QUEUE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
182     {Status::ERROR_WAIT_TIMEOUT, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
183     {Status::ERROR_OUT_OF_RANGE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
184     {Status::ERROR_NULL_SURFACE, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
185     {Status::ERROR_SURFACE_INNER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
186     {Status::ERROR_NULL_SURFACE_BUFFER, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
187     {Status::ERROR_IPC_WRITE_INTERFACE_TOKEN, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
188     {Status::ERROR_IPC_SEND_REQUEST, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},
189     {Status::ERROR_DRM_DECRYPT_FAILED, AVCodecServiceErrCode::AVCS_ERR_DECRYPT_FAILED}};
190 
191 const std::map<int32_t, AVCodecServiceErrCode> VPEERROR_TO_AVCSERRCODE = {
192     {0, AVCodecServiceErrCode::AVCS_ERR_OK},
193     {63635468, AVCodecServiceErrCode::AVCS_ERR_NO_MEMORY},         // 63635468: no memory
194     {63635494, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION}, // 63635494: opertation not be permitted
195     {63635478, AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL},       // 63635478: invalid argument
196     {63635968, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},           // 63635968: unknow error
197     {63635969, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},           // 63635969: video processing engine init failed
198     {63635970, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},           // 63635970: extension not found
199     {63635971, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},           // 63635971: extension init failed
200     {63635972, AVCodecServiceErrCode::AVCS_ERR_UNKNOWN},           // 63635972: extension process failed
201     {63635973,
202      AVCodecServiceErrCode::AVCS_ERR_VIDEO_UNSUPPORT_COLOR_SPACE_CONVERSION}, // 63635973: extension is not implemented
203     {63635974, AVCodecServiceErrCode::AVCS_ERR_UNSUPPORT},                    // 63635974: not supported operation
204     {63635975, AVCodecServiceErrCode::AVCS_ERR_INVALID_STATE}}; // 63635975: the state is not support this operation
205 
ErrorMessageOk(const std::string & param1,const std::string & param2)206 std::string ErrorMessageOk(const std::string &param1, const std::string &param2)
207 {
208     (void)param1;
209     (void)param2;
210     return "success";
211 }
212 
ErrorMessageNoPermission(const std::string & param1,const std::string & param2)213 std::string ErrorMessageNoPermission(const std::string &param1, const std::string &param2)
214 {
215     std::string message = "Try to do " + param1 + " failed. User should request permission " + param2 + " first.";
216     return message;
217 }
218 
ErrorMessageInvalidParameter(const std::string & param1,const std::string & param2)219 std::string ErrorMessageInvalidParameter(const std::string &param1, const std::string &param2)
220 {
221     (void)param2;
222     std::string message = "The Parameter " + param1 + " is invalid. Please check the type and range.";
223     return message;
224 }
225 
ErrorMessageUnsupportCapability(const std::string & param1,const std::string & param2)226 std::string ErrorMessageUnsupportCapability(const std::string &param1, const std::string &param2)
227 {
228     (void)param2;
229     std::string message = "Function " + param1 + " can not work correctly due to limited device capability.";
230     return message;
231 }
232 
ErrorMessageNoMemory(const std::string & param1,const std::string & param2)233 std::string ErrorMessageNoMemory(const std::string &param1, const std::string &param2)
234 {
235     (void)param2;
236     std::string message = "Create " + param1 + " failed due to system memory.";
237     return message;
238 }
239 
ErrorMessageOperateNotPermit(const std::string & param1,const std::string & param2)240 std::string ErrorMessageOperateNotPermit(const std::string &param1, const std::string &param2)
241 {
242     (void)param2;
243     std::string message = "The operate " + param1 + " failed due to not permit in current state.";
244     return message;
245 }
246 
ErrorMessageIO(const std::string & param1,const std::string & param2)247 std::string ErrorMessageIO(const std::string &param1, const std::string &param2)
248 {
249     (void)param2;
250     std::string message = "IO error happened due to " + param1 + ".";
251     return message;
252 }
253 
ErrorMessageTimeout(const std::string & param1,const std::string & param2)254 std::string ErrorMessageTimeout(const std::string &param1, const std::string &param2)
255 {
256     std::string message = "Timeout happend when " + param1 + " due to " + param2 + ".";
257     return message;
258 }
259 
ErrorMessageServiceDied(const std::string & param1,const std::string & param2)260 std::string ErrorMessageServiceDied(const std::string &param1, const std::string &param2)
261 {
262     (void)param1;
263     (void)param2;
264     std::string message = "AVCodec Serviced Died.";
265     return message;
266 }
267 
ErrorMessageUnsupportFormat(const std::string & param1,const std::string & param2)268 std::string ErrorMessageUnsupportFormat(const std::string &param1, const std::string &param2)
269 {
270     (void)param2;
271     std::string message = "The format " + param1 + " is not support.";
272     return message;
273 }
274 
AVCSErrorToString(AVCodecServiceErrCode code)275 std::string AVCSErrorToString(AVCodecServiceErrCode code)
276 {
277     if (AVCS_ERRCODE_INFOS.count(code) != 0) {
278         return AVCS_ERRCODE_INFOS.at(code);
279     }
280 
281     return "unkown error";
282 }
283 
OHAVErrCodeToString(OH_AVErrCode code)284 std::string OHAVErrCodeToString(OH_AVErrCode code)
285 {
286     if (OHAVCODECERRCODE_INFOS.count(code) != 0) {
287         return OHAVCODECERRCODE_INFOS.at(code);
288     }
289 
290     return "unkown error";
291 }
292 
AVCSErrorToOHAVErrCodeString(AVCodecServiceErrCode code)293 std::string AVCSErrorToOHAVErrCodeString(AVCodecServiceErrCode code)
294 {
295     if (AVCS_ERRCODE_INFOS.count(code) != 0 && AVCSERRCODE_TO_OHAVCODECERRCODE.count(code) != 0) {
296         OH_AVErrCode extCode = AVCSERRCODE_TO_OHAVCODECERRCODE.at(code);
297         if (OHAVCODECERRCODE_INFOS.count(extCode) != 0) {
298             return OHAVCODECERRCODE_INFOS.at(extCode);
299         }
300     }
301 
302     return "unkown error";
303 }
304 
AVCSErrorToOHAVErrCode(AVCodecServiceErrCode code)305 OH_AVErrCode AVCSErrorToOHAVErrCode(AVCodecServiceErrCode code)
306 {
307     if (AVCS_ERRCODE_INFOS.count(code) != 0 && AVCSERRCODE_TO_OHAVCODECERRCODE.count(code) != 0) {
308         return AVCSERRCODE_TO_OHAVCODECERRCODE.at(code);
309     }
310 
311     return AV_ERR_UNKNOWN;
312 }
313 
StatusToAVCodecServiceErrCode(Status code)314 AVCodecServiceErrCode StatusToAVCodecServiceErrCode(Status code)
315 {
316     if (STATUS_TO_AVCSERRCODE.count(code) != 0) {
317         return STATUS_TO_AVCSERRCODE.at(code);
318     }
319 
320     return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN;
321 }
322 
VPEErrorToAVCSError(int32_t code)323 AVCodecServiceErrCode VPEErrorToAVCSError(int32_t code)
324 {
325     if (VPEERROR_TO_AVCSERRCODE.count(code) != 0) {
326         return VPEERROR_TO_AVCSERRCODE.at(code);
327     }
328 
329     return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN;
330 }
331 } // namespace MediaAVCodec
332 } // namespace OHOS
333