Skip to content

Commit 36cc229

Browse files
committed
Migrate examples to pion/webrtc@v3
delete gstreamer-cli, wasn't able to make work with /v2 delete sfu-ws, going to re-implement and make simpler
1 parent f0586b4 commit 36cc229

File tree

33 files changed

+209
-1698
lines changed

33 files changed

+209
-1698
lines changed

c-data-channels/bridge.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ inline void bridge_on_message(GoOnMessageFunc cb, GoDataChannel d, GoDataChannel
3838
import "C"
3939

4040
import (
41-
"github.com/pion/webrtc/v2"
41+
"github.com/pion/webrtc/v3"
4242
)
4343

4444
var store = map[C.GoDataChannel]*webrtc.DataChannel{}

c-data-channels/webrtc.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55

66
"github.com/pion/example-webrtc-applications/internal/signal"
7-
"github.com/pion/webrtc/v2"
7+
"github.com/pion/webrtc/v3"
88
)
99

1010
// Run contains pure Go codes to do the heavy lifting. In fact, the codes
@@ -54,14 +54,22 @@ func Run(f func(*webrtc.DataChannel)) {
5454
panic(err)
5555
}
5656

57+
// Create channel that is blocked until ICE Gathering is complete
58+
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)
59+
5760
// Sets the LocalDescription, and starts our UDP listeners
5861
err = peerConnection.SetLocalDescription(answer)
5962
if err != nil {
6063
panic(err)
6164
}
6265

66+
// Block until ICE Gathering is complete, disabling trickle ICE
67+
// we do this because we only can exchange one signaling message
68+
// in a production application you should exchange ICE Candidates via OnICECandidate
69+
<-gatherComplete
70+
6371
// Output the answer in base64 so we can paste it in browser
64-
fmt.Println(signal.Encode(answer))
72+
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))
6573

6674
// Block forever
6775
select {}

gocv-receive/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ This example requires you have GoCV and ffmpeg installed, these are the supporte
1212
* Follow the setup instructions for [GoCV](https://github.com/hybridgroup/gocv)
1313
* `sudo apt-get install ffmpeg`
1414

15-
### Download gocv-receive
15+
### Build gocv-receive
1616
```
17-
go get github.com/pion/example-webrtc-applications/gocv-receive
17+
go build -tags gocv
1818
```
1919

2020
### Open gocv-receive example page

gocv-receive/main.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
"github.com/pion/example-webrtc-applications/internal/signal"
1616
"github.com/pion/rtcp"
17-
"github.com/pion/webrtc/v2"
18-
"github.com/pion/webrtc/v2/pkg/media/ivfwriter"
17+
"github.com/pion/webrtc/v3"
18+
"github.com/pion/webrtc/v3/pkg/media/ivfwriter"
1919
"gocv.io/x/gocv"
2020
)
2121

@@ -140,29 +140,24 @@ func createWebRTCConn(ffmpegIn io.Writer) {
140140
panic(err)
141141
}
142142

143-
if _, err = peerConnection.AddTransceiver(webrtc.RTPCodecTypeVideo); err != nil {
144-
panic(err)
145-
}
146-
147143
// Set a handler for when a new remote track starts, this handler copies inbound RTP packets,
148144
// replaces the SSRC and sends them back
149-
peerConnection.OnTrack(func(track *webrtc.Track, receiver *webrtc.RTPReceiver) {
145+
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
150146
// Send a PLI on an interval so that the publisher is pushing a keyframe every rtcpPLIInterval
151-
// This is a temporary fix until we implement incoming RTCP events, then we would push a PLI only when a viewer requests it
152147
go func() {
153148
ticker := time.NewTicker(time.Second * 3)
154149
for range ticker.C {
155-
errSend := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: track.SSRC()}})
150+
errSend := peerConnection.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}})
156151
if errSend != nil {
157152
fmt.Println(errSend)
158153
}
159154
}
160155
}()
161156

162-
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().Name)
157+
fmt.Printf("Track has started, of type %d: %s \n", track.PayloadType(), track.Codec().RTPCodecCapability.MimeType)
163158
for {
164159
// Read RTP packets being sent to Pion
165-
rtp, readErr := track.ReadRTP()
160+
rtp, _, readErr := track.ReadRTP()
166161
if readErr != nil {
167162
panic(readErr)
168163
}
@@ -194,13 +189,20 @@ func createWebRTCConn(ffmpegIn io.Writer) {
194189
panic(err)
195190
}
196191

192+
// Create channel that is blocked until ICE Gathering is complete
193+
gatherComplete := webrtc.GatheringCompletePromise(peerConnection)
194+
197195
// Sets the LocalDescription, and starts our UDP listeners
198196
err = peerConnection.SetLocalDescription(answer)
199197
if err != nil {
200198
panic(err)
201199
}
202200

203-
// Output the answer in base64 so we can paste it in browser
204-
fmt.Println(signal.Encode(answer))
201+
// Block until ICE Gathering is complete, disabling trickle ICE
202+
// we do this because we only can exchange one signaling message
203+
// in a production application you should exchange ICE Candidates via OnICECandidate
204+
<-gatherComplete
205205

206+
// Output the answer in base64 so we can paste it in browser
207+
fmt.Println(signal.Encode(*peerConnection.LocalDescription()))
206208
}

gstreamer-cli/README.md

-68
This file was deleted.

gstreamer-cli/jsfiddle/demo.css

-4
This file was deleted.

gstreamer-cli/jsfiddle/demo.details

-5
This file was deleted.

gstreamer-cli/jsfiddle/demo.html

-14
This file was deleted.

gstreamer-cli/jsfiddle/demo.js

-40
This file was deleted.

0 commit comments

Comments
 (0)