File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ type Payloader interface {
15
15
// Packetizer packetizes a payload
16
16
type Packetizer interface {
17
17
Packetize (payload []byte , samples uint32 ) []* Packet
18
+ GeneratePadding (samples uint32 ) []* Packet
18
19
EnableAbsSendTime (value int )
19
20
SkipSamples (skippedSamples uint32 )
20
21
}
@@ -98,6 +99,38 @@ func (p *packetizer) Packetize(payload []byte, samples uint32) []*Packet {
98
99
return packets
99
100
}
100
101
102
+ // GeneratePadding returns required padding-only packages
103
+ func (p * packetizer ) GeneratePadding (samples uint32 ) []* Packet {
104
+ // Guard against an empty payload
105
+ if samples == 0 {
106
+ return nil
107
+ }
108
+
109
+ packets := make ([]* Packet , samples )
110
+
111
+ for i := 0 ; i < int (samples ); i ++ {
112
+ pp := make ([]byte , 255 )
113
+ pp [254 ] = 255
114
+
115
+ packets [i ] = & Packet {
116
+ Header : Header {
117
+ Version : 2 ,
118
+ Padding : true ,
119
+ Extension : false ,
120
+ Marker : false ,
121
+ PayloadType : p .PayloadType ,
122
+ SequenceNumber : p .Sequencer .NextSequenceNumber (),
123
+ Timestamp : p .Timestamp , // Use latest timestamp
124
+ SSRC : p .SSRC ,
125
+ CSRC : []uint32 {},
126
+ },
127
+ Payload : pp ,
128
+ }
129
+ }
130
+
131
+ return packets
132
+ }
133
+
101
134
// SkipSamples causes a gap in sample count between Packetize requests so the
102
135
// RTP payloads produced have a gap in timestamps
103
136
func (p * packetizer ) SkipSamples (skippedSamples uint32 ) {
You can’t perform that action at this time.
0 commit comments