Skip to content

Commit

Permalink
Fix RTPSendParameters
Browse files Browse the repository at this point in the history
RTPSendParameters contains an array of encodings.
RTPSender.GetParameters returns RTPSendParameters.
  • Loading branch information
jech authored and Sean-Der committed Dec 6, 2020
1 parent 5ee9a31 commit 0dea1f9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
10 changes: 6 additions & 4 deletions peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,10 +1236,12 @@ func (pc *PeerConnection) startRTPSenders(currentTransceivers []*RTPTransceiver)
for _, transceiver := range currentTransceivers {
if transceiver.Sender() != nil && transceiver.Sender().isNegotiated() && !transceiver.Sender().hasSent() {
err := transceiver.Sender().Send(RTPSendParameters{
Encodings: RTPEncodingParameters{
RTPCodingParameters{
SSRC: transceiver.Sender().ssrc,
PayloadType: transceiver.Sender().payloadType,
Encodings: []RTPEncodingParameters{
{
RTPCodingParameters{
SSRC: transceiver.Sender().ssrc,
PayloadType: transceiver.Sender().payloadType,
},
},
},
})
Expand Down
19 changes: 16 additions & 3 deletions rtpsender.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,21 @@ func (r *RTPSender) Transport() *DTLSTransport {

// GetParameters describes the current configuration for the encoding and
// transmission of media on the sender's track.
func (r *RTPSender) GetParameters() RTPParameters {
return r.api.mediaEngine.getRTPParametersByKind(r.track.Kind(), []RTPTransceiverDirection{RTPTransceiverDirectionSendonly})
func (r *RTPSender) GetParameters() RTPSendParameters {
return RTPSendParameters{
RTPParameters: r.api.mediaEngine.getRTPParametersByKind(
r.track.Kind(),
[]RTPTransceiverDirection{RTPTransceiverDirectionSendonly},
),
Encodings: []RTPEncodingParameters{
{
RTPCodingParameters: RTPCodingParameters{
SSRC: r.ssrc,
PayloadType: r.payloadType,
},
},
},
}
}

// Track returns the RTCRtpTransceiver track, or nil
Expand Down Expand Up @@ -148,7 +161,7 @@ func (r *RTPSender) Send(parameters RTPSendParameters) error {
r.context = TrackLocalContext{
id: r.id,
params: r.api.mediaEngine.getRTPParametersByKind(r.track.Kind(), []RTPTransceiverDirection{RTPTransceiverDirectionSendonly}),
ssrc: parameters.Encodings.SSRC,
ssrc: parameters.Encodings[0].SSRC,
writeStream: writeStream,
}

Expand Down
24 changes: 24 additions & 0 deletions rtpsender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,27 @@ func Test_RTPSender_ReplaceTrack(t *testing.T) {
assert.NoError(t, receiver.Close())
})
}

func Test_RTPSender_GetParameters(t *testing.T) {
lim := test.TimeOut(time.Second * 10)
defer lim.Stop()

report := test.CheckRoutines(t)
defer report()

offerer, answerer, err := newPair()
assert.NoError(t, err)

rtpTransceiver, err := offerer.AddTransceiverFromKind(RTPCodecTypeVideo)
assert.NoError(t, err)

assert.NoError(t, signalPair(offerer, answerer))

parameters := rtpTransceiver.Sender().GetParameters()
assert.NotEqual(t, 0, len(parameters.Codecs))
assert.Equal(t, 1, len(parameters.Encodings))
assert.Equal(t, rtpTransceiver.Sender().ssrc, parameters.Encodings[0].SSRC)

assert.NoError(t, offerer.Close())
assert.NoError(t, answerer.Close())
}
3 changes: 2 additions & 1 deletion rtpsendparameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package webrtc

// RTPSendParameters contains the RTP stack settings used by receivers
type RTPSendParameters struct {
Encodings RTPEncodingParameters
RTPParameters
Encodings []RTPEncodingParameters
}

0 comments on commit 0dea1f9

Please sign in to comment.