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 /**
17  * @file native_avbuffer_info.h
18  *
19  * @brief Provides audio and video buffer info.
20  *
21  * @kit AVCodecKit
22  * @library libnative_media_core.so
23  * @syscap SystemCapability.Multimedia.Media.Core
24  * @since 9
25  */
26 
27 #ifndef NATIVE_AVBUFFER_INFO_H
28 #define NATIVE_AVBUFFER_INFO_H
29 
30 #include <stdint.h>
31 #include <stdio.h>
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 /**
37  * @brief Enumerate the categories of OH_AVCodec's Buffer tags.
38  * @syscap SystemCapability.Multimedia.Media.Core
39  * @since 9
40  */
41 typedef enum OH_AVCodecBufferFlags {
42     AVCODEC_BUFFER_FLAGS_NONE = 0,
43     /** Indicates that the Buffer is an End-of-Stream frame. */
44     AVCODEC_BUFFER_FLAGS_EOS = 1 << 0,
45     /** Indicates that the Buffer contains keyframes. */
46     AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1,
47     /** Indicates that the data contained in the Buffer is only part of a frame. */
48     AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2,
49     /** Indicates that the Buffer contains Codec-Specific-Data. */
50     AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3,
51     /** Flag is used to discard packets which are required to maintain valid decoder state but are not required
52      *  for output and should be dropped after decoding.
53      * @since 12
54      */
55     AVCODEC_BUFFER_FLAGS_DISCARD = 1 << 4,
56     /** Flag is used to indicate packets that contain frames that can be discarded by the decoder,
57      *  I.e. Non-reference frames.
58      * @since 12
59      */
60     AVCODEC_BUFFER_FLAGS_DISPOSABLE = 1 << 5,
61 } OH_AVCodecBufferFlags;
62 
63 /**
64  * @brief Define the Buffer description information of OH_AVCodec
65  * @syscap SystemCapability.Multimedia.Media.Core
66  * @since 9
67  */
68 typedef struct OH_AVCodecBufferAttr {
69     /* Presentation timestamp of this Buffer in microseconds */
70     int64_t pts;
71     /* The size of the data contained in the Buffer in bytes */
72     int32_t size;
73     /* The starting offset of valid data in this Buffer */
74     int32_t offset;
75     /* The flags this Buffer has, which is also a combination of multiple {@link OH_AVCodecBufferFlags}. */
76     uint32_t flags;
77 } OH_AVCodecBufferAttr;
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif // NATIVE_AVBUFFER_INFO_H
84