Skip to content

Commit 0e25e1a

Browse files
committed
Provide correct StreamInfo to receiver interceptors
1 parent f5d98ce commit 0e25e1a

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

rtpcodec.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,26 @@ func codecParametersFuzzySearch(
143143
return RTPCodecParameters{}, codecMatchNone
144144
}
145145

146-
// Given a CodecParameters find the RTX CodecParameters if one exists.
146+
// Given a CodecParameters find the RTX PayloadType.
147147
func findRTXPayloadType(needle PayloadType, haystack []RTPCodecParameters) PayloadType {
148+
rtxParam := findRTXCodecParameters(needle, haystack)
149+
if rtxParam != nil {
150+
return rtxParam.PayloadType
151+
}
152+
153+
return PayloadType(0)
154+
}
155+
156+
// Given a CodecParameters find the RTX CodecParameters if one exists.
157+
func findRTXCodecParameters(needle PayloadType, haystack []RTPCodecParameters) *RTPCodecParameters {
148158
aptStr := fmt.Sprintf("apt=%d", needle)
149-
for _, c := range haystack {
159+
for i, c := range haystack {
150160
if aptStr == c.SDPFmtpLine {
151-
return c.PayloadType
161+
return &haystack[i]
152162
}
153163
}
154164

155-
return PayloadType(0)
165+
return nil
156166
}
157167

158168
// For now, only FlexFEC is supported.

rtpreceiver.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,20 @@ func (r *RTPReceiver) startReceive(parameters RTPReceiveParameters) error { //no
218218
return fmt.Errorf("%w: %d", errRTPReceiverWithSSRCTrackStreamNotFound, parameters.Encodings[i].SSRC)
219219
}
220220

221+
rtxPayloadType := PayloadType(0)
222+
rtxParam := findRTXCodecParameters(globalParams.Codecs[0].PayloadType, globalParams.Codecs)
223+
if rtxParam != nil {
224+
rtxPayloadType = rtxParam.PayloadType
225+
}
226+
221227
streams.streamInfo = createStreamInfo(
222228
"",
223229
parameters.Encodings[i].SSRC,
224-
0, 0, 0, 0, 0,
230+
parameters.Encodings[i].RTX.SSRC,
231+
parameters.Encodings[i].FEC.SSRC,
232+
globalParams.Codecs[0].PayloadType,
233+
rtxPayloadType,
234+
findFECPayloadType(globalParams.Codecs),
225235
codec,
226236
globalParams.HeaderExtensions,
227237
)
@@ -233,7 +243,17 @@ func (r *RTPReceiver) startReceive(parameters RTPReceiveParameters) error { //no
233243
}
234244

235245
if rtxSsrc := parameters.Encodings[i].RTX.SSRC; rtxSsrc != 0 {
236-
streamInfo := createStreamInfo("", rtxSsrc, 0, 0, 0, 0, 0, codec, globalParams.HeaderExtensions)
246+
streamInfo := createStreamInfo(
247+
"",
248+
rtxSsrc,
249+
0,
250+
0,
251+
rtxPayloadType,
252+
0,
253+
0,
254+
rtxParam.RTPCodecCapability,
255+
globalParams.HeaderExtensions,
256+
)
237257
rtpReadStream, rtpInterceptor, rtcpReadStream, rtcpInterceptor, err := r.transport.streamsForSSRC(
238258
rtxSsrc,
239259
*streamInfo,

0 commit comments

Comments
 (0)