New Track API

The Pion WebRTC API has been dramatically redesigned. The design docs
are located here [0]

You can also read the release notes [1] on how to migrate your
application.

[0] https://github.com/pion/webrtc-v3-design
[1] https://github.com/pion/webrtc/wiki/Release-WebRTC@v3.0.0
This commit is contained in:
Sean DuBois
2020-11-11 12:03:08 -08:00
parent 159ba5aca3
commit 7edfb701e0
46 changed files with 1750 additions and 2059 deletions

View File

@@ -7,7 +7,6 @@ import (
"sync/atomic"
"github.com/pion/rtp"
"github.com/pion/sdp/v3"
)
// RTPTransceiver represents a combination of an RTPSender and an RTPReceiver that share a common mid.
@@ -31,7 +30,7 @@ func (t *RTPTransceiver) Sender() *RTPSender {
}
// SetSender sets the RTPSender and Track to current transceiver
func (t *RTPTransceiver) SetSender(s *RTPSender, track *Track) error {
func (t *RTPTransceiver) SetSender(s *RTPSender, track TrackLocal) error {
t.setSender(s)
return t.setSendingTrack(track)
}
@@ -101,7 +100,7 @@ func (t *RTPTransceiver) setDirection(d RTPTransceiverDirection) {
t.direction.Store(d)
}
func (t *RTPTransceiver) setSendingTrack(track *Track) error {
func (t *RTPTransceiver) setSendingTrack(track TrackLocal) error {
t.Sender().setTrack(track)
if track == nil {
t.setSender(nil)
@@ -163,7 +162,7 @@ func satisfyTypeAndDirection(remoteKind RTPCodecType, remoteDirection RTPTransce
// handleUnknownRTPPacket consumes a single RTP Packet and returns information that is helpful
// for demuxing and handling an unknown SSRC (usually for Simulcast)
func handleUnknownRTPPacket(buf []byte, sdesMidExtMap, sdesStreamIDExtMap *sdp.ExtMap) (mid, rid string, payloadType uint8, err error) {
func handleUnknownRTPPacket(buf []byte, midExtensionID, streamIDExtensionID uint8) (mid, rid string, payloadType PayloadType, err error) {
rp := &rtp.Packet{}
if err = rp.Unmarshal(buf); err != nil {
return
@@ -173,12 +172,12 @@ func handleUnknownRTPPacket(buf []byte, sdesMidExtMap, sdesStreamIDExtMap *sdp.E
return
}
payloadType = rp.PayloadType
if payload := rp.GetExtension(uint8(sdesMidExtMap.Value)); payload != nil {
payloadType = PayloadType(rp.PayloadType)
if payload := rp.GetExtension(midExtensionID); payload != nil {
mid = string(payload)
}
if payload := rp.GetExtension(uint8(sdesStreamIDExtMap.Value)); payload != nil {
if payload := rp.GetExtension(streamIDExtensionID); payload != nil {
rid = string(payload)
}