1 /* 2 * Copyright (c) 2022-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 #ifndef OHOS_IMAGE_COMMON_TYPE_H 17 #define OHOS_IMAGE_COMMON_TYPE_H 18 19 #include <cstdlib> 20 #include <cstdint> 21 #include "data_buffer.h" 22 23 namespace OHOS { 24 namespace DistributedHardware { 25 enum class PipelineType : int32_t { 26 VIDEO = 0, 27 PHOTO_JPEG = 1, 28 }; 29 30 enum class VideoCodecType : int32_t { 31 NO_CODEC = 0, 32 CODEC_H264 = 1, 33 CODEC_H265 = 2, 34 CODEC_MPEG4_ES = 3, 35 }; 36 37 enum class Videoformat : int32_t { 38 YUVI420 = 0, 39 NV12 = 1, 40 NV21 = 2, 41 RGBA_8888 = 3, 42 }; 43 44 class VideoConfigParams { 45 public: VideoConfigParams()46 VideoConfigParams() : videoCodec_(VideoCodecType::NO_CODEC), pixelFormat_(Videoformat::YUVI420), 47 frameRate_(0), width_ (0), height_(0) 48 {} VideoConfigParams(VideoCodecType videoCodec,Videoformat pixelFormat,int32_t frameRate,int32_t width,int32_t height)49 VideoConfigParams(VideoCodecType videoCodec, Videoformat pixelFormat, int32_t frameRate, int32_t width, 50 int32_t height) 51 : videoCodec_(videoCodec), pixelFormat_(pixelFormat), frameRate_(frameRate), width_ (width), height_(height) 52 {} 53 ~VideoConfigParams() = default; 54 55 void SetVideoCodecType(VideoCodecType videoCodec); 56 void SetVideoformat(Videoformat pixelFormat); 57 void SetFrameRate(int32_t frameRate); 58 void SetWidthAndHeight(int32_t width, int32_t height); 59 VideoCodecType GetVideoCodecType() const; 60 Videoformat GetVideoformat() const; 61 int32_t GetFrameRate() const; 62 int32_t GetWidth() const; 63 int32_t GetHeight() const; 64 65 private: 66 VideoCodecType videoCodec_; 67 Videoformat pixelFormat_; 68 int32_t frameRate_; 69 int32_t width_; 70 int32_t height_; 71 }; 72 73 struct ImageUnitInfo { 74 Videoformat colorFormat; 75 int32_t width; 76 int32_t height; 77 int32_t alignedWidth; 78 int32_t alignedHeight; 79 size_t chromaOffset; 80 size_t imgSize; 81 std::shared_ptr<DataBuffer> imgData; 82 }; 83 } // namespace DistributedHardware 84 } // namespace OHOS 85 #endif // OHOS_IMAGE_COMMON_TYPE_H 86