1ba487d97Sopenharmony_ci/*
2ba487d97Sopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd.
3ba487d97Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4ba487d97Sopenharmony_ci * you may not use this file except in compliance with the License.
5ba487d97Sopenharmony_ci * You may obtain a copy of the License at
6ba487d97Sopenharmony_ci *
7ba487d97Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8ba487d97Sopenharmony_ci *
9ba487d97Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10ba487d97Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11ba487d97Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12ba487d97Sopenharmony_ci * See the License for the specific language governing permissions and
13ba487d97Sopenharmony_ci * limitations under the License.
14ba487d97Sopenharmony_ci */
15ba487d97Sopenharmony_ci
16ba487d97Sopenharmony_ci/**
17ba487d97Sopenharmony_ci * @addtogroup MultiMedia_MediaCommon
18ba487d97Sopenharmony_ci * @{
19ba487d97Sopenharmony_ci *
20ba487d97Sopenharmony_ci * @brief Provides data types and media formats required for recording and playing audio and videos.
21ba487d97Sopenharmony_ci *
22ba487d97Sopenharmony_ci *
23ba487d97Sopenharmony_ci * @since 1.0
24ba487d97Sopenharmony_ci * @version 1.0
25ba487d97Sopenharmony_ci */
26ba487d97Sopenharmony_ci
27ba487d97Sopenharmony_ci/**
28ba487d97Sopenharmony_ci * @file media_errors.h
29ba487d97Sopenharmony_ci *
30ba487d97Sopenharmony_ci * @brief Declares the <b>media_errors</b> class to define errors that may occur during media operations.
31ba487d97Sopenharmony_ci *
32ba487d97Sopenharmony_ci *
33ba487d97Sopenharmony_ci * @since 1.0
34ba487d97Sopenharmony_ci * @version 1.0
35ba487d97Sopenharmony_ci */
36ba487d97Sopenharmony_ci
37ba487d97Sopenharmony_ci#ifndef MEDIA_ERRORS_H
38ba487d97Sopenharmony_ci#define MEDIA_ERRORS_H
39ba487d97Sopenharmony_ci
40ba487d97Sopenharmony_ci#include <cstdint>
41ba487d97Sopenharmony_ci
42ba487d97Sopenharmony_cinamespace OHOS {
43ba487d97Sopenharmony_cinamespace Media {
44ba487d97Sopenharmony_ciconstexpr int MODULE_MEDIA = 1;
45ba487d97Sopenharmony_ciconstexpr int SUBSYS_MEDIA = 30;
46ba487d97Sopenharmony_ci
47ba487d97Sopenharmony_ciusing ErrCode = int32_t;
48ba487d97Sopenharmony_ciconstexpr int SUBSYSTEM_BIT_NUM = 21;
49ba487d97Sopenharmony_ciconstexpr int MODULE_BIT_NUM = 16;
50ba487d97Sopenharmony_ci
51ba487d97Sopenharmony_ci/**
52ba487d97Sopenharmony_ci * @brief Generates a start error code with a unique identifier based on specified subsystem and module bit numbers.
53ba487d97Sopenharmony_ci *
54ba487d97Sopenharmony_ci * @param subsystem Indicates the subsystem bit number.
55ba487d97Sopenharmony_ci * @param module Indicates the module bit number.
56ba487d97Sopenharmony_ci * @return
57ba487d97Sopenharmony_ci * @since 1.0
58ba487d97Sopenharmony_ci * @version 1.0
59ba487d97Sopenharmony_ci */
60ba487d97Sopenharmony_ciconstexpr ErrCode ErrCodeOffset(unsigned int subsystem, unsigned int module = 0)
61ba487d97Sopenharmony_ci{
62ba487d97Sopenharmony_ci    return (subsystem << SUBSYSTEM_BIT_NUM) | (module << MODULE_BIT_NUM);
63ba487d97Sopenharmony_ci}
64ba487d97Sopenharmony_ci
65ba487d97Sopenharmony_ciconstexpr int32_t BASE_MEDIA_ERR_OFFSET = ErrCodeOffset(SUBSYS_MEDIA, MODULE_MEDIA);
66ba487d97Sopenharmony_ci
67ba487d97Sopenharmony_ci/** Invalid data size that has been read */
68ba487d97Sopenharmony_ciconst int32_t  ERR_INVALID_READ = -1;
69ba487d97Sopenharmony_ci
70ba487d97Sopenharmony_ci/** Success */
71ba487d97Sopenharmony_ciconst int32_t  SUCCESS = 0;
72ba487d97Sopenharmony_ci
73ba487d97Sopenharmony_ci/** Fail */
74ba487d97Sopenharmony_ciconst int32_t  ERROR = BASE_MEDIA_ERR_OFFSET;
75ba487d97Sopenharmony_ci
76ba487d97Sopenharmony_ci/** Status error */
77ba487d97Sopenharmony_ciconst int32_t  ERR_ILLEGAL_STATE = BASE_MEDIA_ERR_OFFSET + 1;
78ba487d97Sopenharmony_ci
79ba487d97Sopenharmony_ci/** Invalid parameter */
80ba487d97Sopenharmony_ciconst int32_t  ERR_INVALID_PARAM = BASE_MEDIA_ERR_OFFSET + 2;
81ba487d97Sopenharmony_ci
82ba487d97Sopenharmony_ci/** Early media preparation */
83ba487d97Sopenharmony_ciconst int32_t  ERR_EARLY_PREPARE = BASE_MEDIA_ERR_OFFSET + 3;
84ba487d97Sopenharmony_ci
85ba487d97Sopenharmony_ci/** No media source */
86ba487d97Sopenharmony_ciconst int32_t  ERR_SOURCE_NOT_SET = BASE_MEDIA_ERR_OFFSET + 4;
87ba487d97Sopenharmony_ci
88ba487d97Sopenharmony_ci/** Invalid operation */
89ba487d97Sopenharmony_ciconst int32_t  ERR_INVALID_OPERATION = BASE_MEDIA_ERR_OFFSET + 5;
90ba487d97Sopenharmony_ci
91ba487d97Sopenharmony_ci/** No idle channel */
92ba487d97Sopenharmony_ciconst int32_t  ERR_NOFREE_CHANNEL = BASE_MEDIA_ERR_OFFSET + 6;
93ba487d97Sopenharmony_ci
94ba487d97Sopenharmony_ci/** Buffer reading failed */
95ba487d97Sopenharmony_ciconst int32_t  ERR_READ_BUFFER = BASE_MEDIA_ERR_OFFSET + 7;
96ba487d97Sopenharmony_ci
97ba487d97Sopenharmony_ci/**  Device not started */
98ba487d97Sopenharmony_ciconst int32_t  ERR_NOT_STARTED = BASE_MEDIA_ERR_OFFSET + 8;
99ba487d97Sopenharmony_ci
100ba487d97Sopenharmony_ci/** Unknown error */
101ba487d97Sopenharmony_ciconst int32_t  ERR_UNKNOWN = BASE_MEDIA_ERR_OFFSET + 200;
102ba487d97Sopenharmony_ci}  // namespace Media
103ba487d97Sopenharmony_ci}  // namespace OHOS
104ba487d97Sopenharmony_ci#endif  // MEDIA_ERRORS_H
105