xref: /OK3568_Linux_fs/external/common_algorithm/misc/include/rkdemuxer.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright (c) 2022 Rockchip, Inc. All Rights Reserved.
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */
16 
17 #ifndef __RKDEMUXER_H__
18 #define __RKDEMUXER_H__
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 #include <stdint.h>
23 
24 #define DEMUXER_VIDEO_YUV420SP_10BIT 0
25 #define DEMUXER_VIDEO_YUV420SP 1
26 
27 typedef struct _RKDEMUXER_READ_PACKET_CALLBACK_S {
28     void (*read_video_packet)(void *);
29     void (*read_audio_packet)(void *);
30 } RKDEMUXER_READ_PACKET_CALLBACK_S;
31 
32 typedef struct StDemuxerInput{
33     void    *ptr;
34     int8_t   s8ReadModeFlag;
35     int8_t   s8VideoEnableFlag;
36     int8_t   s8AudioEnableFlag;
37 } DemuxerInput;
38 
39 typedef struct StDemuxerParam{
40     int32_t  s32TotalTime;
41     int8_t  *pVideoCodec;
42     int32_t  s32VideoWidth;
43     int32_t  s32VideoHeigh;
44     int8_t   s8VideoFormat;
45     int32_t  s32VideoAvgFrameRate;
46     int32_t  s32VideoTimeBaseNum;
47     int32_t  s32VideoTimeBaseDen;
48     int64_t  s64VideoFirstPTS;
49     int8_t  *pAudioCodec;
50     int32_t  s32AudioChannels;
51     int32_t  s32AudioSampleRate;
52     int8_t   s8AudioFormat;
53     int64_t  s64AudioFirstPTS;
54     int32_t  s32AudioTimeBaseNum;
55     int32_t  s32AudioTimeBaseDen;
56     RKDEMUXER_READ_PACKET_CALLBACK_S pstReadPacketCallback;
57 } DemuxerParam;
58 
59 typedef struct StDemuxerPacket{
60     void    *ptr;
61     int8_t   s8EofFlag;
62     int8_t   s8SpecialFlag;
63     int8_t  *s8PacketData;
64     int32_t  s32PacketSize;
65     int32_t  s32Series;
66     int64_t  s64Pts;
67     int64_t  s64Duration;
68     int64_t  s64Pos;
69 } DemuxerPacket;
70 
71 int rkdemuxer_init(void **demuxer_cfg, DemuxerInput *ptr);
72 void rkdemuxer_deinit(void **demuxer_cfg);
73 int rkdemuxer_get_param(void *demuxer_cfg, const char *input_name, DemuxerParam *ptr);
74 int rkdemuxer_read_packet_start(void *demuxer_cfg, int64_t startPts);
75 int rkdemuxer_read_packet_stop(void *demuxer_cfg);
76 int rkdemuxer_read_one_video_packet(void *demuxer_cfg, DemuxerPacket *output_packet);
77 int rkdemuxer_read_one_audio_packet(void *demuxer_cfg, DemuxerPacket *output_packet);
78 int rkdemuxer_read_video_duration(void *demuxer_cfg, int64_t *duration);
79 int rkdemuxer_read_audio_duration(void *demuxer_cfg, int64_t *duration);
80 int rkdemuxer_seek_video_pts(void *demuxer_cfg, int64_t seekPts);
81 int rkdemuxer_seet_audio_pts(void *demuxer_cfg, int64_t seekPts);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 #endif
87