-
Notifications
You must be signed in to change notification settings - Fork 1
/
packet.go
169 lines (128 loc) · 4.08 KB
/
packet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package rkcodec
/*
#include <rockchip/mpp_packet.h>
RK_S32 MppPktSeg_getType(const MppPktSeg seg) {
return seg.type;
}
void MppPktSeg_setType(MppPktSeg seg, RK_S32 type) {
seg.type = type;
}
*/
import "C"
func NewMppPacket() (*MppPacket, MppRet) {
cPacket := C.MppPacket(nil)
ret := MppRet(C.mpp_packet_new(&cPacket))
return &MppPacket{c: &cPacket}, ret
}
func (packet *MppPacket) Init(data []byte, size int64) MppRet {
return MppRet(C.mpp_packet_init(packet.c, C.CBytes(data), C.size_t(size)))
}
func (packet *MppPacket) InitWithBuffer(buffer *MppBuffer) MppRet {
return MppRet(C.mpp_packet_init_with_buffer(packet.c, buffer.c))
}
func (packet *MppPacket) CopyInit(src *MppPacket) MppRet {
return MppRet(C.mpp_packet_copy_init(packet.c, *src.c))
}
func (packet *MppPacket) Deinit() MppRet {
return MppRet(C.mpp_packet_deinit(packet.c))
}
func (packet *MppPacket) GetData() []byte {
return C.GoBytes(C.mpp_packet_get_data(*packet.c), C.int(C.mpp_packet_get_size(*packet.c)))
}
func (packet *MppPacket) SetData(data []byte) {
C.mpp_packet_set_data(*packet.c, C.CBytes(data))
C.mpp_packet_set_size(*packet.c, C.size_t(len(data)))
}
func (packet *MppPacket) SetPts(pts int64) {
C.mpp_packet_set_pts(*packet.c, C.RK_S64(pts))
}
func (packet *MppPacket) GetPts() int64 {
return int64(C.mpp_packet_get_pts(*packet.c))
}
func (packet *MppPacket) SetDts(dts int64) {
C.mpp_packet_set_dts(*packet.c, C.RK_S64(dts))
}
func (packet *MppPacket) GetDts() int64 {
return int64(C.mpp_packet_get_dts(*packet.c))
}
func (packet *MppPacket) SetFlag(flag uint32) {
C.mpp_packet_set_flag(*packet.c, C.RK_U32(flag))
}
func (packet *MppPacket) GetFlag() uint32 {
return uint32(C.mpp_packet_get_flag(*packet.c))
}
func (packet *MppPacket) SetEos() MppRet {
return MppRet(C.mpp_packet_set_eos(*packet.c))
}
func (packet *MppPacket) ClrEos() MppRet {
return MppRet(C.mpp_packet_clr_eos(*packet.c))
}
func (packet *MppPacket) GetEos() uint32 {
return uint32(C.mpp_packet_get_eos(*packet.c))
}
func (packet *MppPacket) SetExtraData() MppRet {
return MppRet(C.mpp_packet_set_extra_data(*packet.c))
}
func (packet *MppPacket) SetBuffer(buffer *MppBuffer) {
C.mpp_packet_set_buffer(*packet.c, buffer.c)
}
func (packet *MppPacket) GetBuffer() *MppBuffer {
return &MppBuffer{c: C.mpp_packet_get_buffer(*packet.c)}
}
func (packet *MppPacket) Read(offset int64, data []byte) MppRet {
return MppRet(C.mpp_packet_read(*packet.c, C.size_t(offset), C.CBytes(data), C.size_t(len(data))))
}
func (packet *MppPacket) Write(offset int64, data []byte) MppRet {
return MppRet(C.mpp_packet_write(*packet.c, C.size_t(offset), C.CBytes(data), C.size_t(len(data))))
}
func (packet *MppPacket) HasMeta() int32 {
return int32(C.mpp_packet_has_meta(*packet.c))
}
func (packet *MppPacket) GetMeta() *MppMeta {
return &MppMeta{c: C.mpp_packet_get_meta(*packet.c)}
}
func (packet *MppPacket) IsPartition() uint32 {
return uint32(C.mpp_packet_is_partition(*packet.c))
}
func (packet *MppPacket) IsSoi() uint32 {
return uint32(C.mpp_packet_is_soi(*packet.c))
}
func (packet *MppPacket) IsEoi() uint32 {
return uint32(C.mpp_packet_is_eoi(*packet.c))
}
type MppPktSeg struct {
c C.struct_MppPktSeg_t
}
func (seg *MppPktSeg) GetIndex() int32 {
return int32(seg.c.index)
}
func (seg *MppPktSeg) SetIndex(index int32) {
seg.c.index = cS32(index)
}
func (seg *MppPktSeg) GetType() int32 {
return int32(C.MppPktSeg_getType(seg.c))
}
func (seg *MppPktSeg) SetType(t int32) {
C.MppPktSeg_setType(seg.c, cS32(t))
}
func (seg *MppPktSeg) GetOffset() uint32 {
return uint32(seg.c.offset)
}
func (seg *MppPktSeg) SetOffset(offset uint32) {
seg.c.offset = cU32(offset)
}
func (seg *MppPktSeg) GetLength() uint32 {
return uint32(seg.c.len)
}
func (seg *MppPktSeg) SetLength(length uint32) {
seg.c.len = cU32(length)
}
func (seg *MppPktSeg) Next() *MppPktSeg {
return &MppPktSeg{c: *seg.c.next}
}
// func (packet *MppPacket) GetSengmentNb() uint32 {
// return uint32(C.mpp_packet_get_sengment_nb(*packet.c))
// }
// func (packet *MppPacket) GetSengment(index uint32) *MppPktSeg {
// return &MppPktSeg{c: C.mpp_packet_get_sengment(*packet.c, C.RK_U32(index))}
// }