Skip to content

Commit 5d25e38

Browse files
committed
Fix BindRemoteStream StreamInfo
1 parent f5d98ce commit 5d25e38

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-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: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,15 @@ func (r *RTPReceiver) startReceive(parameters RTPReceiveParameters) error { //no
218218
return fmt.Errorf("%w: %d", errRTPReceiverWithSSRCTrackStreamNotFound, parameters.Encodings[i].SSRC)
219219
}
220220

221+
rtxPayloadType := findRTXPayloadType(globalParams.Codecs[0].PayloadType, globalParams.Codecs)
221222
streams.streamInfo = createStreamInfo(
222223
"",
223224
parameters.Encodings[i].SSRC,
224-
0, 0, 0, 0, 0,
225+
parameters.Encodings[i].RTX.SSRC,
226+
parameters.Encodings[i].FEC.SSRC,
227+
globalParams.Codecs[0].PayloadType,
228+
rtxPayloadType,
229+
findFECPayloadType(globalParams.Codecs),
225230
codec,
226231
globalParams.HeaderExtensions,
227232
)
@@ -233,7 +238,17 @@ func (r *RTPReceiver) startReceive(parameters RTPReceiveParameters) error { //no
233238
}
234239

235240
if rtxSsrc := parameters.Encodings[i].RTX.SSRC; rtxSsrc != 0 {
236-
streamInfo := createStreamInfo("", rtxSsrc, 0, 0, 0, 0, 0, codec, globalParams.HeaderExtensions)
241+
streamInfo := createStreamInfo(
242+
"",
243+
rtxSsrc,
244+
0,
245+
0,
246+
rtxPayloadType,
247+
0,
248+
0,
249+
codec,
250+
globalParams.HeaderExtensions,
251+
)
237252
rtpReadStream, rtpInterceptor, rtcpReadStream, rtcpInterceptor, err := r.transport.streamsForSSRC(
238253
rtxSsrc,
239254
*streamInfo,

0 commit comments

Comments
 (0)