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 {
112
112
return rp .buffer
113
113
}
114
114
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
+
115
123
// InUse returns the number of valid bytes in the packet buffer.
116
124
// Several function modify the inUse variable, for example when copying payload or setting extensions
117
125
// 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 {
123
131
// *** RTP specific functions start here ***
124
132
125
133
// 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)
126
140
type DataPacket struct {
127
141
RawPacket
128
142
payloadLength int16
You can’t perform that action at this time.
0 commit comments