• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef MEDIA_DESCRIPTION_H
17 #define MEDIA_DESCRIPTION_H
18 
19 #include "format.h"
20 
21 namespace OHOS {
22 namespace MediaAVCodec {
23 /**
24  * @brief Provides the uniform container for storing the media description.
25  */
26 using MediaDescription = Format;
27 
28 /**
29  * @brief Provides the key's definition for MediaDescription.
30  */
31 class MediaDescriptionKey {
32 public:
33     /**
34      * Key for track index, value type is uint32_t
35      */
36     static constexpr std::string_view MD_KEY_TRACK_INDEX = "track_index";
37 
38     /**
39      * Key for track type, value type is uint8_t, see {link @MediaTrackType}
40      */
41     static constexpr std::string_view MD_KEY_TRACK_TYPE = "track_type";
42 
43     /**
44      * Key for codec mime type, value type is string
45      */
46     static constexpr std::string_view MD_KEY_CODEC_MIME = "codec_mime";
47 
48     /**
49      * Key for codec name, value type is string
50      */
51     static constexpr std::string_view MD_KEY_CODEC_NAME = "codec_name";
52 
53     /**
54      * Key for duration, value type is int64_t
55      */
56     static constexpr std::string_view MD_KEY_DURATION = "duration";
57 
58     /**
59      * Key for bitrate, value type is int64_t
60      */
61     static constexpr std::string_view MD_KEY_BITRATE = "bitrate";
62 
63     /**
64      * Key for max input size, value type is uint32_t
65      */
66     static constexpr std::string_view MD_KEY_MAX_INPUT_SIZE = "max_input_size";
67 
68     /**
69      * Key for max input buffer count, value type is int32_t
70      */
71     static constexpr std::string_view MD_KEY_MAX_INPUT_BUFFER_COUNT = "max_input_buffer_count";
72 
73     /**
74      * Key for max output buffer count, value type is int32_t
75      */
76     static constexpr std::string_view MD_KEY_MAX_OUTPUT_BUFFER_COUNT = "max_output_buffer_count";
77 
78     /**
79      * Key for video width, value type is int32_t
80      */
81     static constexpr std::string_view MD_KEY_WIDTH = "width";
82 
83     /**
84      * Key for video height, value type is int32_t
85      */
86     static constexpr std::string_view MD_KEY_HEIGHT = "height";
87 
88     /**
89      * Key for video pixelformat, value type is int32_t, see {link @MediaPixelFormat}
90      */
91     static constexpr std::string_view MD_KEY_PIXEL_FORMAT = "pixel_format";
92 
93     /**
94      * Key for video scale type, value type is int32_t
95      */
96     static constexpr std::string_view MD_KEY_SCALE_TYPE = "scale_type";
97 
98     /**
99      * Key for video rotation angle, value type is int32_t
100      */
101     static constexpr std::string_view MD_KEY_ROTATION_ANGLE = "rotation_angle";
102 
103     /**
104      * Key for video frame rate, value type is double.
105      */
106     static constexpr std::string_view MD_KEY_FRAME_RATE = "frame_rate";
107 
108     /**
109      * Key for video capture rate, value type is double
110      */
111     static constexpr std::string_view MD_KEY_CAPTURE_RATE = "capture_rate";
112 
113     /**
114      * Key for the interval of key frame. value type is int32_t, the unit is milliseconds.
115      * A negative value means no key frames are requested after the first frame. A zero
116      * value means a stream containing all key frames is requested.
117      */
118     static constexpr std::string_view MD_KEY_I_FRAME_INTERVAL = "i_frame_interval";
119 
120     /**
121      * Key for the request a I-Frame immediately. value type is boolean
122      */
123     static constexpr std::string_view MD_KEY_REQUEST_I_FRAME = "req_i_frame";
124 
125     /**
126      * Key for video YUV value range flag, value type is bool
127      */
128     static constexpr std::string_view MD_KEY_RANGE_FLAG = "range_flag";
129 
130     /**
131      * Key for video color primaries, value type is int32_t, see {link @ColorPrimary}
132      */
133     static constexpr std::string_view MD_KEY_COLOR_PRIMARIES = "color_primaries";
134 
135     /**
136      * Key for video transfer characteristics, value type is int32_t, see {link @TransferCharacteristic}
137      */
138     static constexpr std::string_view MD_KEY_TRANSFER_CHARACTERISTICS = "transfer_characteristics";
139 
140     /**
141      * Key for video maxtrix coefficients, value type is int32_t, see {link @MaxtrixCoefficient}
142      */
143     static constexpr std::string_view MD_KEY_MATRIX_COEFFICIENTS = "matrix_coefficients";
144 
145     /**
146      * Key for video encode bitrate mode, the value type is int32_t, see {link @VideoEncodeBitrateMode}
147      */
148     static constexpr std::string_view MD_KEY_VIDEO_ENCODE_BITRATE_MODE = "video_encode_bitrate_mode";
149 
150     /**
151      * Key for encode profile, the value type is int32_t
152      */
153     static constexpr std::string_view MD_KEY_PROFILE = "codec_profile";
154 
155     /**
156      * key for the desired encoding quality, the value type is uint32_t, this key is only supported for encoders that
157      * are configured in constant quality mode
158      */
159     static constexpr std::string_view MD_KEY_QUALITY = "quality";
160 
161     /**
162      * Key for audio channel count, value type is uint32_t
163      */
164     static constexpr std::string_view MD_KEY_CHANNEL_COUNT = "channel_count";
165 
166     /**
167      * Key for audio sample rate, value type is uint32_t
168      */
169     static constexpr std::string_view MD_KEY_SAMPLE_RATE = "sample_rate";
170 
171     /**
172      * Key for track count in the container, value type is uint32_t
173      */
174     static constexpr std::string_view MD_KEY_TRACK_COUNT = "track_count";
175 
176     /**
177      * Key for container format type, value type is string
178      */
179     static constexpr std::string_view MD_KEY_CONTAINER_FORMAT = "container_format";
180 
181     /**
182      * custom key prefix, media service will pass through to HAL.
183      */
184     static constexpr std::string_view MD_KEY_CUSTOM_PREFIX = "vendor.custom";
185 
186     /**
187      * Key for codec specific data buffer, vlaue type is uint8_t*
188      */
189     static constexpr std::string_view MD_KEY_CODEC_CONFIG = "codec_config";
190 
191     /**
192      * Key for audio channel layout, value type is int64_t
193      */
194     static constexpr std::string_view MD_KEY_CHANNEL_LAYOUT = "channel_layout";
195 
196     /**
197      * Key for audio sample format, value type is uint32_t
198      */
199     static constexpr std::string_view MD_KEY_AUDIO_SAMPLE_FORMAT = "audio_sample_format";
200 
201     /**
202      * Key for the number of bits used to encode each sample, value type is uint32_t
203      */
204     static constexpr std::string_view MD_KEY_BITS_PER_CODED_SAMPLE = "bits_per_coded_sample";
205 
206     /**
207      * Key for aac type, value type is uint32_t
208      */
209     static constexpr std::string_view MD_KEY_AAC_IS_ADTS = "aac_is_adts";
210 
211     /**
212      * Key for aac sbr, value type is uint32_t
213      */
214     static constexpr std::string_view MD_KEY_SBR = "sbr";
215 
216     /**
217      * Key for compliance level, value type is int32_t
218      */
219     static constexpr std::string_view MD_KEY_COMPLIANCE_LEVEL = "compliance_level";
220 
221     /**
222      * Key for vorbis identification header, value type is uint8_t*
223      */
224     static constexpr std::string_view MD_KEY_IDENTIFICATION_HEADER = "identification_header";
225 
226     /**
227      * Key for vorbis setup header, value type is uint8_t*
228      */
229     static constexpr std::string_view MD_KEY_SETUP_HEADER = "setup_header";
230 
231     /**
232      * Key for audio frame size, means samples per frame, value type is int32_t*
233      */
234     static constexpr std::string_view MD_KEY_AUDIO_SAMPLES_PER_FRAME = "audio_samples_per_frame";
235 
236     /**
237      * Key for Number of delayed video frames, value type is uint32_t
238      */
239     static constexpr std::string_view MD_KEY_VIDEO_DELAY = "video_delay";
240 
241 private:
242     MediaDescriptionKey() = delete;
243     ~MediaDescriptionKey() = delete;
244 };
245 
246 /**
247  * @brief
248  *
249  * @since 4.0
250  * @version 4.0
251  */
252 enum ColorPrimary : int32_t {
253     COLOR_PRIMARY_BT709 = 1,
254     COLOR_PRIMARY_UNSPECIFIED = 2,
255     COLOR_PRIMARY_BT470_M = 4,
256     COLOR_PRIMARY_BT601_625 = 5,
257     COLOR_PRIMARY_BT601_525 = 6,
258     COLOR_PRIMARY_SMPTE_ST240 = 7,
259     COLOR_PRIMARY_GENERIC_FILM = 8,
260     COLOR_PRIMARY_BT2020 = 9,
261     COLOR_PRIMARY_SMPTE_ST428 = 10,
262     COLOR_PRIMARY_P3DCI = 11,
263     COLOR_PRIMARY_P3D65 = 12,
264 };
265 
266 /**
267  * @brief
268  *
269  * @since 4.0
270  * @version 4.0
271  */
272 enum TransferCharacteristic : int32_t {
273     TRANSFER_CHARACTERISTIC_BT709 = 1,
274     TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2,
275     TRANSFER_CHARACTERISTIC_GAMMA_2_2 = 4,
276     TRANSFER_CHARACTERISTIC_GAMMA_2_8 = 5,
277     TRANSFER_CHARACTERISTIC_BT601 = 6,
278     TRANSFER_CHARACTERISTIC_SMPTE_ST240 = 7,
279     TRANSFER_CHARACTERISTIC_LINEAR = 8,
280     TRANSFER_CHARACTERISTIC_LOG = 9,
281     TRANSFER_CHARACTERISTIC_LOG_SQRT = 10,
282     TRANSFER_CHARACTERISTIC_IEC_61966_2_4 = 11,
283     TRANSFER_CHARACTERISTIC_BT1361 = 12,
284     TRANSFER_CHARACTERISTIC_IEC_61966_2_1 = 13,
285     TRANSFER_CHARACTERISTIC_BT2020_10BIT = 14,
286     TRANSFER_CHARACTERISTIC_BT2020_12BIT = 15,
287     TRANSFER_CHARACTERISTIC_PQ = 16,
288     TRANSFER_CHARACTERISTIC_SMPTE_ST428 = 17,
289     TRANSFER_CHARACTERISTIC_HLG = 18,
290 };
291 
292 /**
293  * @brief
294  *
295  * @since 4.0
296  * @version 4.0
297  */
298 enum MatrixCoefficient : int32_t {
299     MATRIX_COEFFICIENT_IDENTITY = 0,
300     MATRIX_COEFFICIENT_BT709 = 1,
301     MATRIX_COEFFICIENT_UNSPECIFIED = 2,
302     MATRIX_COEFFICIENT_FCC = 4,
303     MATRIX_COEFFICIENT_BT601_625 = 5,
304     MATRIX_COEFFICIENT_BT601_525 = 6,
305     MATRIX_COEFFICIENT_SMPTE_ST240 = 7,
306     MATRIX_COEFFICIENT_YCGCO = 8,
307     MATRIX_COEFFICIENT_BT2020_NCL = 9,
308     MATRIX_COEFFICIENT_BT2020_CL = 10,
309     MATRIX_COEFFICIENT_SMPTE_ST2085 = 11,
310     MATRIX_COEFFICIENT_CHROMATICITY_NCL = 12,
311     MATRIX_COEFFICIENT_CHROMATICITY_CL = 13,
312     MATRIX_COEFFICIENT_ICTCP = 14,
313 };
314 } // namespace MediaAVCodec
315 } // namespace OHOS
316 #endif // MEDIA_DESCRIPTION_H
317