-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathrtpreceiver_go.go
36 lines (28 loc) · 1.04 KB
/
rtpreceiver_go.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
//go:build !js
// +build !js
package webrtc
import "github.com/pion/interceptor"
// SetRTPParameters applies provided RTPParameters the RTPReceiver's tracks.
//
// This method is part of the ORTC API. It is not
// meant to be used together with the basic WebRTC API.
//
// The amount of provided codecs must match the number of tracks on the receiver.
func (r *RTPReceiver) SetRTPParameters(params RTPParameters) {
headerExtensions := make([]interceptor.RTPHeaderExtension, 0, len(params.HeaderExtensions))
for _, h := range params.HeaderExtensions {
headerExtensions = append(headerExtensions, interceptor.RTPHeaderExtension{ID: h.ID, URI: h.URI})
}
r.mu.Lock()
defer r.mu.Unlock()
for ndx, codec := range params.Codecs {
currentTrack := r.tracks[ndx].track
r.tracks[ndx].streamInfo.RTPHeaderExtensions = headerExtensions
currentTrack.mu.Lock()
currentTrack.codec = codec
currentTrack.params = params
currentTrack.mu.Unlock()
}
}