File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,14 @@ func (rp *RawPacket) Buffer() []byte {
112112 return rp .buffer
113113}
114114
115+ // Write writes data bytes from data buffer to the underlying RawPacket.
116+ func (rp * RawPacket ) Write (data []byte ) (int , error ) {
117+ rp .buffer = data
118+ rp .inUse = len (data )
119+ rp .isFree = true
120+ return rp .inUse , nil
121+ }
122+
115123// InUse returns the number of valid bytes in the packet buffer.
116124// Several function modify the inUse variable, for example when copying payload or setting extensions
117125// in the RTP packet. Thus "buffer[0:inUse]" is the slice inside the buffer that will be sent or
@@ -123,6 +131,12 @@ func (rp *RawPacket) InUse() int {
123131// *** RTP specific functions start here ***
124132
125133// DataPacket RTP packet type to define RTP specific functions
134+ //
135+ // if you want to copy incoming RTP packet as-is. For example
136+ // when you need to redirect RTP packet from WebRTC to plain RTP:
137+ // pkt := rtp.DataPacket{}
138+ // pkt.Write(buf.Bytes())
139+ // session.WriteData(&pkt)
126140type DataPacket struct {
127141 RawPacket
128142 payloadLength int16
You can’t perform that action at this time.
0 commit comments