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 #ifndef MEDIA_AVCODEC_AV_COMMOM_H 16 #define MEDIA_AVCODEC_AV_COMMOM_H 17 18 #include <vector> 19 #include <string> 20 #include "meta/format.h" 21 #include "buffer/avsharedmemory.h" 22 23 namespace OHOS { 24 namespace MediaAVCodec { 25 using Format = Media::Format; 26 using AVSharedMemory = Media::AVSharedMemory; 27 /** 28 * @brief Media type 29 * 30 * @since 3.1 31 * @version 3.1 32 */ 33 enum MediaType : int32_t { 34 /** 35 * track is audio. 36 */ 37 MEDIA_TYPE_AUD = 0, 38 /** 39 * track is video. 40 */ 41 MEDIA_TYPE_VID = 1, 42 /** 43 * track is subtitle. 44 */ 45 MEDIA_TYPE_SUBTITLE = 2, 46 /** 47 * track is timed metadata. 48 */ 49 MEDIA_TYPE_TIMED_METADATA = 5, 50 }; 51 52 /** 53 * @brief 54 * 55 * @since 3.1 56 * @version 3.1 57 */ 58 enum class VideoPixelFormat : int32_t { 59 UNKNOWN = -1, 60 YUV420P = 0, 61 /** 62 * yuv 420 planar. 63 */ 64 YUVI420 = 1, 65 /** 66 * NV12. yuv 420 semiplanar. 67 */ 68 NV12 = 2, 69 /** 70 * NV21. yvu 420 semiplanar. 71 */ 72 NV21 = 3, 73 /** 74 * format from surface. 75 */ 76 SURFACE_FORMAT = 4, 77 /** 78 * RGBA. 79 */ 80 RGBA = 5, 81 /** 82 * RGBA1010102. 83 * since 6.0 84 */ 85 RGBA1010102 = 6, 86 }; 87 88 /** 89 * @brief the struct of geolocation 90 * 91 * @param latitude float: latitude in degrees. Its value must be in the range [-90, 90]. 92 * @param longitude float: longitude in degrees. Its value must be in the range [-180, 180]. 93 * @since 3.1 94 * @version 3.1 95 */ 96 struct Location { 97 float latitude = 0; 98 float longitude = 0; 99 }; 100 101 /** 102 * @brief Enumerates the seek mode. 103 */ 104 enum AVSeekMode : uint8_t { 105 /* seek to sync sample after the time */ 106 SEEK_MODE_NEXT_SYNC = 0, 107 /* seek to sync sample before the time */ 108 SEEK_MODE_PREVIOUS_SYNC, 109 /* seek to sync sample closest to time */ 110 SEEK_MODE_CLOSEST_SYNC, 111 }; 112 113 /** 114 * @brief Enumerates the video rotation. 115 * 116 * @since 3.2 117 * @version 3.2 118 */ 119 enum VideoRotation : uint32_t { 120 /** 121 * Video without rotation 122 */ 123 VIDEO_ROTATION_0 = 0, 124 /** 125 * Video rotated 90 degrees 126 */ 127 VIDEO_ROTATION_90 = 90, 128 /** 129 * Video rotated 180 degrees 130 */ 131 VIDEO_ROTATION_180 = 180, 132 /** 133 * Video rotated 270 degrees 134 */ 135 VIDEO_ROTATION_270 = 270, 136 }; 137 138 /** 139 * @brief Enumerates the state change reason. 140 * 141 * @since 3.2 142 * @version 3.2 143 */ 144 enum StateChangeReason { 145 /** 146 * audio/video state change by user 147 */ 148 USER = 1, 149 /** 150 * audio/video state change by system 151 */ 152 BACKGROUND = 2, 153 }; 154 155 /** 156 * @brief Enumerates the output format. 157 * 158 * @since 10 159 * @version 4.0 160 */ 161 enum OutputFormat : uint32_t { 162 /** 163 * output format default mp4 164 */ 165 OUTPUT_FORMAT_DEFAULT = 0, 166 /** 167 * output format mp4 168 */ 169 OUTPUT_FORMAT_MPEG_4 = 2, 170 /** 171 * output format m4a 172 */ 173 OUTPUT_FORMAT_M4A = 6, 174 }; 175 176 enum VideoOrientationType : int32_t { 177 /** 178 * No rotation or default 179 */ 180 ROTATE_NONE = 0, 181 /** 182 * Rotation by 90 degrees 183 */ 184 ROTATE_90, 185 /** 186 * Rotation by 180 degrees 187 */ 188 ROTATE_180, 189 /** 190 * Rotation by 270 degrees 191 */ 192 ROTATE_270, 193 /** 194 * Flip horizontally 195 */ 196 FLIP_H, 197 /** 198 * Flip vertically 199 */ 200 FLIP_V, 201 /** 202 * Flip horizontally and rotate 90 degrees 203 */ 204 FLIP_H_ROT90, 205 /** 206 * Flip vertically and rotate 90 degrees 207 */ 208 FLIP_V_ROT90, 209 /** 210 * Flip horizontally and rotate 180 degrees 211 */ 212 FLIP_H_ROT180, 213 /** 214 * Flip vertically and rotate 180 degrees 215 */ 216 FLIP_V_ROT180, 217 /** 218 * Flip horizontally and rotate 270 degrees 219 */ 220 FLIP_H_ROT270, 221 /** 222 * Flip vertically and rotate 270 degrees 223 */ 224 FLIP_V_ROT270 225 }; 226 } // namespace MediaAVCodec 227 } // namespace OHOS 228 #endif // MEDIA_AVCODEC_AV_COMMOM_H