1 /*
2  *
3  * Copyright 2015 Rockchip Electronics Co., LTD.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 
19 #ifndef __MPP_PACKET_IMPL_H__
20 #define __MPP_PACKET_IMPL_H__
21 
22 #include "mpp_meta.h"
23 
24 #define MPP_PACKET_FLAG_EOS             (0x00000001)
25 #define MPP_PACKET_FLAG_EXTRA_DATA      (0x00000002)
26 #define MPP_PACKET_FLAG_INTERNAL        (0x00000004)
27 
28 typedef union MppPacketStatus_t {
29     RK_U32  val;
30     struct {
31         RK_U32  eos         : 1;
32         RK_U32  extra_data  : 1;
33         RK_U32  internal    : 1;
34         /* packet is inputed on reset mark as discard */
35         RK_U32  discard     : 1;
36 
37         /* for slice input output */
38         RK_U32  partition   : 1;
39         RK_U32  soi         : 1;
40         RK_U32  eoi         : 1;
41     };
42 } MppPacketStatus;
43 
44 /*
45  * mpp_packet_imp structure
46  *
47  * data     : pointer
48  * size     : total buffer size
49  * offset   : valid data start offset
50  * length   : valid data length
51  * pts      : packet pts
52  * dts      : packet dts
53  */
54 typedef struct MppPacketImpl_t {
55     const char      *name;
56 
57     void            *data;
58     void            *pos;
59     size_t          size;
60     size_t          length;
61 
62     RK_S64          pts;
63     RK_S64          dts;
64 
65     MppPacketStatus status;
66     RK_U32          flag;
67 
68     MppBuffer       buffer;
69     MppMeta         meta;
70 } MppPacketImpl;
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 /*
76  * mpp_packet_reset is only used internelly and should NOT be used outside
77  */
78 MPP_RET mpp_packet_reset(MppPacketImpl *packet);
79 MPP_RET mpp_packet_copy(MppPacket dst, MppPacket src);
80 MPP_RET mpp_packet_append(MppPacket dst, MppPacket src);
81 MPP_RET mpp_packet_set_status(MppPacket packet, MppPacketStatus status);
82 MPP_RET mpp_packet_get_status(MppPacket packet, MppPacketStatus *status);
83 
84 /* pointer check function */
85 MPP_RET check_is_mpp_packet(void *ptr);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* __MPP_PACKET_IMPL_H__ */
92