Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Release WebRTC@v2.0.0

qingwen-guan edited this pageNov 23, 2021 ·3 revisions

The Pion team is very excited to annouce v2.0.0, our 4th release that includes 5th months of work! With this release we have lots of new features, performance improvements and bug fixes.

This release does introduce a few breaking changes. We had accumulated a fair amount of technical debt, and these changes were needed to allow us to move forward on things like ORTC and TURN.

Please read these changes carefully, most of these things aren't caught at compile time and could save a lot of time debugging. Each change will have a linked commit, so looking atexamples/ should show what code you need to change in your application.

Breaking Changes

Imports have changed

We now use 'github.com/pion'

We have moved fromgithub.com/pions/webrtc ->github.com/pion/webrtc. Thank you to Ion Pana for makinggithub.com/pion available!

This release is a new major version

This moves us fromgithub.com/pion/webrtc ->github.com/pion/webrtc/v2. We version our libraries, allowing us to distribute old versions still if we need.

To quickly rewrite everything you can use the following commands

    find . -type f -name '*.go' | xargs sed -i '' 's/github.com\/pion\/webrtc/github.com\/pion\/webrtc\/v2/g'    find . -type f -name '*.go' | xargs sed -i '' 's/github.com\/pions\/webrtc/github.com\/pion\/webrtc\/v2/g' # If you are still using github.com/pions/webrtc

Unified Plan is now the default SDP format

This change will affect you if you are receiving media, or sending multiple tracks. If you have already done this migration for your Javascript this will feel very similar.

You must call AddTransceiver for every incoming track

// Allow us to receive 1 audio track, and 2 video tracksif _, err = peerConnection.AddTransceiver(webrtc.RTPCodecTypeAudio); err != nil {panic(err)} else if _, err = peerConnection.AddTransceiver(webrtc.RTPCodecTypeVideo); err != nil {panic(err)} else if _, err = peerConnection.AddTransceiver(webrtc.RTPCodecTypeVideo); err != nil {panic(err)}

This was changed with1202db

The RTC prefix was removed from structs in the webrtc package

  • This makes it so the names don't stutter when the package name is added.
  • webrtc.RTCPeerConnection becamewebrtc.PeerConnection, for example

This was changed with0e7086

SetLocalDescription is no longer called implicitly byCreateOffer andCreateAnswer

BeforeCreateOffer andCreateAnswer would implicitly callSetLocationDescription for you, now you need to call it explicitly.

This was changed because it diverged from the WebRTC RFC. To fix this update your code like below

Before

  answer, err := peerConnection.CreateAnswer(nil)  if err != nil {    return err  }

After

  answer, err := peerConnection.CreateAnswer(nil)  if err != nil {    return err  }  err = peerConnection.SetLocalDescription(answer)  if err != nil {    return nil  }

This was changed withb67f73

Media API

The Track API has been rewritten to remove Channels from the public API. This was done because we ran into the following issues.

  • Using tight loops to read/write from Channels to exchange RTP/RTCP packets is more expensive than I realized
  • We were unable to return errors when reading/write RTP or RTCP
  • We were unable to close channels (or risk causing a panic if the user writes to them)
  • Packet drops because the buffered channel (size 15) is not large enough to handle surges.

We also gained some unforeseen benefits moving to the new API.

  • A Track can be added to multiplePeerConnections now. The most common use-case so far has been building SFUs, and this feature will reduce complexity for everyone. This also more closely follows the browser implementation of WebRTC.

RTPReceiver is now emitted viaonTrack

Before
peerConnection.OnTrack(func(track *webrtc.Track) {})
After
peerConnection.OnTrack(func(track *webrtc.Track, receiver *webrtc.RTPReceiver) {})

RTCP is now received viaRTPSender andRTPReceiver instead ofTrack

Before
peerConnection.OnTrack(func(track *webrtc.Track) {    <-track.RTCPPackets})
After
peerConnection.OnTrack(func(track *webrtc.Track, receiver *webrtc.RTPReceiver) {    pkt, header, err := receiver.ReadRTCP()})

RTP is now received viaRead orReadRTP onTrack, instead of a channel

Before
peerConnection.OnTrack(func(track *webrtc.Track) {    <-track.Packets})
After
peerConnection.OnTrack(func(track *webrtc.Track, receiver *webrtc.RTPReceiver) {    pkt, err := track.ReadRTP()})

RTP is now written viaWrite,WriteRTP orWriteSample onTrack, instead of send on a channel

Before
peerConnection.OnTrack(func(track *webrtc.Track) {    vp8Track.RawRTP <- &rtp.Packet{}})
After
peerConnection.OnTrack(func(track *webrtc.Track, receiver *webrtc.RTPReceiver) {    i, err := track.WriteRTP(&rtp.Packet{})})

Raw and Sample tracks now share a constructor

The only behavior difference is that the user must supply a SSRC for Sample tracks. A random uint32 is all that should be needed in most cases.

Before
    peerConnection.NewRawRTPTrack(outboundPayloadType, outboundSSRC, "video", "pion")    pcOffer.NewSampleTrack(DefaultPayloadTypeVP8, "video", "pion")
After
    peerConnection.NewTrack(outboundPayloadType, outboundSSRC, "video", "pion")

This was changed with6aeb34

Correct incorrect APIs

  • Instead of returningice.ConnectionState theOnICEConnectionStateChange callback should return awebrtc.RTCIceConnectionState. This was changed withbf422e0
  • webrtc.AddIceCandidate should take awebrtc.RTCIceCandidateInit instead of a string. This was changed with0e619e2
  • Trickle ICE: Changed candidate gathering from synchronous to asynchronous.This change has not landed in master yet

Names were made more consistent across the codebase

  • Track:Ssrc renamedSSRC
  • OAuthCredential:MacKey renamedMACKey
  • SessionDescription:Sdp renamedSDP
  • sdp.AttrKeyRtcpMux renamedsdp.AttrKeyRTCPMux

This was changed with9cba54

DataChannel API

The RTCDataChannel API, specifically the Payload objects, feels weird. One alternative was suggested in webrtc#365: Instead of passing a single byte inSend andOnMessage we could experiment with passingio.Readers. This has the added advantage that it can work with any message size.

TODO: update docs

Don't expose locks

The RTCPeerConnection object used to expose their Lock. These locks are now made private.

This was changed because the user never has to hold this lock, and could cause a deadlock if they did

This was changed with5fcbc7

Expose state safely

Previously state was exposed via attributes. This cannot safely be used concurrently. The state is now exposed using methods instead. This allow the library to add locking when needed.

New Features

example-webrtc-applications repository

We know have a repository for examples that use 3rd party libraries, or are more complicated then the standard example.

We would love to see what the community can build, come check out what we have and contribute more atexample-webrtc-applications

WASM

Experimental support for WASM has been added. You can now compile Pion WebRTC withgoos=js goarch=wasm. When settinggoos=js the Pion API will act as a wrapper around the JavaScript WebRTC API. This change allows you to use the same code on the server and in the browser in many cases. We aim to keep the API for both implementations as similar as possible.

ORTC

The ORTC API has been added. Internally the WebRTC API is now also backed by the ORTC API.

QUIC

Experimental support for webrtc-quic has been added. This has been tested between two pion clients. It has not yet been tested with chromium's or other experimental implementations.

Out of tree

All code that is re-usable has been moved outside of thepion/webrtc repository. We want to share our work with the greater Go community.

Sign up for theGolang Slack and join the #pion channel for discussions and support

If you need commercial support/don't want to use public methods you can contact us atteam@pion.ly

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp