1 /*
2  * Copyright (c) 2023-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_CAMERA_DPS_MEDIA_FORMAT_H
17 #define OHOS_CAMERA_DPS_MEDIA_FORMAT_H
18 
19 #include "meta_key.h"
20 #include "mime_type.h"
21 
22 namespace OHOS {
23 namespace CameraStandard {
24 namespace DeferredProcessing {
25 const std::string MINE_VIDEO_AVC = Media::Plugins::MimeType::VIDEO_AVC;
26 const std::string MINE_VIDEO_HEVC = Media::Plugins::MimeType::VIDEO_HEVC;
27 const std::string VIDEO_FRAME_COUNT = "com.openharmony.frame_num";
28 const std::string RECORD_SYSTEM_TIMESTAMP = "com.openharmony.recorder.timestamp";
29 
30 enum class MediaInfoKey : uint32_t {
31     META_VALUE_TYPE_NONE,
32     META_VALUE_TYPE_INT32,
33     META_VALUE_TYPE_INT64,
34     META_VALUE_TYPE_FLOAT,
35     META_VALUE_TYPE_DOUBLE,
36     META_VALUE_TYPE_STRING,
37 };
38 
39 enum class ColorRange {
40     COL_RANGE_NONE = -1,
41     COL_RANGE_UNSPECIFIED = 0,
42     COL_RANGE_MPEG = 1,
43     COL_RANGE_JPEG = 2,
44 };
45 
46 enum class PixelFormat {
47     PIX_FMT_NONE    = -1,
48     PIX_FMT_YUV420P = 0,
49     PIX_FMT_YUVI420 = 1,
50     PIX_FMT_NV12 = 2,
51     PIX_FMT_YUV420P10LE = 62,
52 };
53 
54 enum class ColorPrimaries {
55     COL_PRI_RESERVED0 = 0,
56     COL_PRI_BT709     = 1,
57     COL_PRI_BT2020    = 9, // hdr
58 };
59 
60 enum class ColorTransferCharacteristic {
61     COL_TRC_RESERVED0 = 0,
62     COL_TRC_BT709     = 1,
63     COL_TRC_BT2020_10 = 14,
64     COL_TRC_BT2020_12 = 15,
65     COL_TRC_ARIB_STD_B67 = 18,  // colorPrimary  ARIB STD-B67, known as "Hybrid log-gamma"
66 };
67 
68 enum class AVCProfile : int32_t {
69     AVC_PROFILE_BASELINE = 0,
70     AVC_PROFILE_HIGH = 4,
71     AVC_PROFILE_MAIN = 8,
72 };
73 
74 struct CodecInfo {
75     std::string mimeType;
76     ColorRange colorRange;
77     PixelFormat pixelFormat;  // color space pixel format. e.g. YUV420P, NV12 etc.
78     ColorPrimaries colorPrimary;
79     ColorTransferCharacteristic colorTransferCharacter;
80     int32_t profile;
81     int32_t level;
82     int64_t bitRate;
83     int32_t fps;
84     int64_t duration;
85     int32_t numFrames;
86     int32_t width;
87     int32_t height;
88     int32_t rotation;
89     int32_t isHdrvivid;
90     int32_t bitMode;
91 };
92 
93 struct MediaInfo {
94     int64_t recoverTime;
95     int32_t streamCount;
96     std::string creationTime;
97     float latitude;
98     float longitude;
99     CodecInfo codecInfo {};
100     std::string recorderTime;
101 };
102 } // namespace DeferredProcessing
103 } // namespace CameraStandard
104 } // namespace OHOS
105 #endif // OHOS_CAMERA_DPS_MEDIA_FORMAT_H