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 83 /** 84 * @brief the struct of geolocation 85 * 86 * @param latitude float: latitude in degrees. Its value must be in the range [-90, 90]. 87 * @param longitude float: longitude in degrees. Its value must be in the range [-180, 180]. 88 * @since 3.1 89 * @version 3.1 90 */ 91 struct Location { 92 float latitude = 0; 93 float longitude = 0; 94 }; 95 96 /** 97 * @brief Enumerates the seek mode. 98 */ 99 enum AVSeekMode : uint8_t { 100 /* seek to sync sample after the time */ 101 SEEK_MODE_NEXT_SYNC = 0, 102 /* seek to sync sample before the time */ 103 SEEK_MODE_PREVIOUS_SYNC, 104 /* seek to sync sample closest to time */ 105 SEEK_MODE_CLOSEST_SYNC, 106 }; 107 108 /** 109 * @brief Enumerates the video rotation. 110 * 111 * @since 3.2 112 * @version 3.2 113 */ 114 enum VideoRotation : uint32_t { 115 /** 116 * Video without rotation 117 */ 118 VIDEO_ROTATION_0 = 0, 119 /** 120 * Video rotated 90 degrees 121 */ 122 VIDEO_ROTATION_90 = 90, 123 /** 124 * Video rotated 180 degrees 125 */ 126 VIDEO_ROTATION_180 = 180, 127 /** 128 * Video rotated 270 degrees 129 */ 130 VIDEO_ROTATION_270 = 270, 131 }; 132 133 /** 134 * @brief Enumerates the state change reason. 135 * 136 * @since 3.2 137 * @version 3.2 138 */ 139 enum StateChangeReason { 140 /** 141 * audio/video state change by user 142 */ 143 USER = 1, 144 /** 145 * audio/video state change by system 146 */ 147 BACKGROUND = 2, 148 }; 149 150 /** 151 * @brief Enumerates the output format. 152 * 153 * @since 10 154 * @version 4.0 155 */ 156 enum OutputFormat : uint32_t { 157 /** 158 * output format default mp4 159 */ 160 OUTPUT_FORMAT_DEFAULT = 0, 161 /** 162 * output format mp4 163 */ 164 OUTPUT_FORMAT_MPEG_4 = 2, 165 /** 166 * output format m4a 167 */ 168 OUTPUT_FORMAT_M4A = 6, 169 }; 170 171 enum VideoOrientationType : int32_t { 172 /** 173 * No rotation or default 174 */ 175 ROTATE_NONE = 0, 176 /** 177 * Rotation by 90 degrees 178 */ 179 ROTATE_90, 180 /** 181 * Rotation by 180 degrees 182 */ 183 ROTATE_180, 184 /** 185 * Rotation by 270 degrees 186 */ 187 ROTATE_270, 188 /** 189 * Flip horizontally 190 */ 191 FLIP_H, 192 /** 193 * Flip vertically 194 */ 195 FLIP_V, 196 /** 197 * Flip horizontally and rotate 90 degrees 198 */ 199 FLIP_H_ROT90, 200 /** 201 * Flip vertically and rotate 90 degrees 202 */ 203 FLIP_V_ROT90, 204 /** 205 * Flip horizontally and rotate 180 degrees 206 */ 207 FLIP_H_ROT180, 208 /** 209 * Flip vertically and rotate 180 degrees 210 */ 211 FLIP_V_ROT180, 212 /** 213 * Flip horizontally and rotate 270 degrees 214 */ 215 FLIP_H_ROT270, 216 /** 217 * Flip vertically and rotate 270 degrees 218 */ 219 FLIP_V_ROT270 220 }; 221 } // namespace MediaAVCodec 222 } // namespace OHOS 223 #endif // MEDIA_AVCODEC_AV_COMMOM_H