• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CREATE_AVMUXER_ENGINE_FAILED,               // create avmuxer engine failed.
41     MSERR_INVALID_STATE,                              // the state is not support this operation.
42     MSERR_UNSUPPORT,                                  // unsupport interface.
43     MSERR_UNSUPPORT_AUD_SRC_TYPE,                     // unsupport audio source type.
44     MSERR_UNSUPPORT_AUD_SAMPLE_RATE,                  // unsupport audio sample rate.
45     MSERR_UNSUPPORT_AUD_CHANNEL_NUM,                  // unsupport audio channel.
46     MSERR_UNSUPPORT_AUD_ENC_TYPE,                     // unsupport audio encoder type.
47     MSERR_UNSUPPORT_AUD_PARAMS,                       // unsupport audio params(other params).
48     MSERR_UNSUPPORT_VID_SRC_TYPE,                     // unsupport video source type.
49     MSERR_UNSUPPORT_VID_ENC_TYPE,                     // unsupport video encoder type.
50     MSERR_UNSUPPORT_VID_PARAMS,                       // unsupport video params(other params).
51     MSERR_UNSUPPORT_CONTAINER_TYPE,                   // unsupport container format type.
52     MSERR_UNSUPPORT_PROTOCOL_TYPE,                    // unsupport protocol type.
53     MSERR_UNSUPPORT_VID_DEC_TYPE,                     // unsupport video decoder type.
54     MSERR_UNSUPPORT_AUD_DEC_TYPE,                     // unsupport audio decoder type.
55     MSERR_UNSUPPORT_STREAM,                           // internal data stream error.
56     MSERR_UNSUPPORT_FILE,                             // this appears to be a text file.
57     MSERR_UNSUPPORT_SOURCE,                           // unsupport source type.
58     MSERR_AUD_RENDER_FAILED,                          // audio render failed.
59     MSERR_AUD_ENC_FAILED,                             // audio encode failed.
60     MSERR_VID_ENC_FAILED,                             // video encode failed.
61     MSERR_AUD_DEC_FAILED,                             // audio decode failed.
62     MSERR_VID_DEC_FAILED,                             // video decode failed.
63     MSERR_MUXER_FAILED,                               // stream avmuxer failed.
64     MSERR_DEMUXER_FAILED,                             // stream demuxer or parser failed.
65     MSERR_OPEN_FILE_FAILED,                           // open file failed.
66     MSERR_FILE_ACCESS_FAILED,                         // read or write file failed.
67     MSERR_START_FAILED,                               // audio/video start failed.
68     MSERR_PAUSE_FAILED,                               // audio/video pause failed.
69     MSERR_STOP_FAILED,                                // audio/video stop failed.
70     MSERR_SEEK_FAILED,                                // audio/video seek failed.
71     MSERR_NETWORK_TIMEOUT,                            // network timeout.
72     MSERR_NOT_FIND_CONTAINER,                         // not find a demuxer.
73     MSERR_DATA_SOURCE_IO_ERROR,                       // media data source IO failed.
74     MSERR_DATA_SOURCE_OBTAIN_MEM_ERROR,               // media data source get mem failed.
75     MSERR_DATA_SOURCE_ERROR_UNKNOWN,                  // media data source error unknow.
76     MSERR_EXTEND_START      = MS_ERR_OFFSET + 0xF000, // extend err start.
77 };
78 
79 // media api error code
80 enum MediaServiceExtErrCode : ErrCode {
81     MSERR_EXT_OK = 0,
82     MSERR_EXT_NO_MEMORY = 1,           // no memory.
83     MSERR_EXT_OPERATE_NOT_PERMIT = 2,  // opertation not be permitted.
84     MSERR_EXT_INVALID_VAL = 3,         // invalid argument.
85     MSERR_EXT_IO = 4,                  // IO error.
86     MSERR_EXT_TIMEOUT = 5,             // network timeout.
87     MSERR_EXT_UNKNOWN = 6,             // unknown error.
88     MSERR_EXT_SERVICE_DIED = 7,        // media service died.
89     MSERR_EXT_INVALID_STATE = 8,       // the state is not support this operation.
90     MSERR_EXT_UNSUPPORT = 9,           // unsupport interface.
91     MSERR_EXT_EXTEND_START = 100,      // extend err start.
92 };
93 
94 // media api9 error code
95 enum MediaServiceExtErrCodeAPI9 : ErrCode {
96     MSERR_EXT_API9_OK = 0,                          // use for determine error
97     MSERR_EXT_API9_NO_PERMISSION = 201,             // permission denied (AccessToken).
98     MSERR_EXT_API9_PERMISSION_DENIED = 202,         // permission denied (system API).
99     MSERR_EXT_API9_INVALID_PARAMETER = 401,         // invalid parameter.
100     MSERR_EXT_API9_UNSUPPORT_CAPABILITY = 801,      // unsupport api.
101     MSERR_EXT_API9_NO_MEMORY = 5400101,             // no memory.
102     MSERR_EXT_API9_OPERATE_NOT_PERMIT = 5400102,    // opertation not be permitted.
103     MSERR_EXT_API9_IO = 5400103,                    // IO error.
104     MSERR_EXT_API9_TIMEOUT = 5400104,               // opertate timeout.
105     MSERR_EXT_API9_SERVICE_DIED = 5400105,          // media service died.
106     MSERR_EXT_API9_UNSUPPORT_FORMAT = 5400106,      // unsupport format.
107 };
108 
109 __attribute__((visibility("default"))) std::string MSErrorToString(MediaServiceErrCode code);
110 __attribute__((visibility("default"))) std::string MSExtErrorToString(MediaServiceExtErrCode code);
111 __attribute__((visibility("default"))) std::string MSErrorToExtErrorString(MediaServiceErrCode code);
112 __attribute__((visibility("default"))) MediaServiceExtErrCode MSErrorToExtError(MediaServiceErrCode code);
113 
114 __attribute__((visibility("default"))) std::string MSExtErrorAPI9ToString(MediaServiceExtErrCodeAPI9 code,
115     const std::string& param1, const std::string& param2);
116 __attribute__((visibility("default"))) std::string MSErrorToExtErrorAPI9String(MediaServiceErrCode code,
117     const std::string& param1, const std::string& param2);
118 __attribute__((visibility("default"))) MediaServiceExtErrCodeAPI9 MSErrorToExtErrorAPI9(MediaServiceErrCode code);
119 
120 __attribute__((visibility("default"))) std::string MSExtAVErrorToString(MediaServiceExtErrCodeAPI9 code);
121 } // namespace Media
122 } // namespace OHOS
123 #endif // MEDIA_ERRORS_H
124