Skip to content

Commit 8520c66

Browse files
committed
add SetIsFree, SetBuffer, SetInUse public methods to RawPacket struct
1 parent 75c6a1c commit 8520c66

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/net/rtp/packets.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,32 @@ func (rp *RawPacket) InUse() int {
120120
return rp.inUse
121121
}
122122

123+
// SetIsFree sets isFree attr
124+
func (rp *RawPacket) SetIsFree(v bool) {
125+
rp.isFree = v
126+
}
127+
128+
// SetBuffer set buffer
129+
func (rp *RawPacket) SetBuffer(b []byte) {
130+
rp.buffer = b
131+
}
132+
133+
// SetInUse sets real buffer size
134+
func (raw *RawPacket) SetInUse(iu int) {
135+
raw.inUse = iu
136+
}
137+
123138
// *** RTP specific functions start here ***
124139

125140
// DataPacket RTP packet type to define RTP specific functions
141+
//
142+
// if you want to copy incoming RTP packet as-is. For example
143+
// when you need to redirect RTP packet from WebRTC to plain RTP:
144+
// pkt := rtp.DataPacket{}
145+
// pkt.SetBuffer(buf.Bytes())
146+
// pkt.SetInUse(buf.Len())
147+
// pkt.SetIsFree(true)
148+
// session.WriteData(&pkt)
126149
type DataPacket struct {
127150
RawPacket
128151
payloadLength int16

0 commit comments

Comments
 (0)