This quick hack implements the client side of the Kurento one-to-one video call tutorial. It registers with the application server, and implements the caller and callee state machines to initiate a connection, exchange answer/offer, wait for ICE to connect, and then send a predefined video over from the caller to the callee which will then save the received video to a file.
This client is used to run demos for the STUNner Kubernetes ingress gateway for WebRTC.
The usual:
cd kurento-tutorial-client-go/
go build ./...
Must use the NAL frame format for streaming. Recode video:
ffmpeg -i sample_640x360.mkv -an -vcodec libx264 sample_640x360.mkv
Must use the IVF media container for streaming. Recode video:
ffmpeg -i sample_640x360.mkv -vcodec libvpx -s 640x360 sample_640x360.ivf
The code assumes the TURN server runs at the default port UDP/3478 and uses plaintext
authentication with user/pass
. (If not, rewrite the webrtc.Configuration
struct in the source).
Then, identify the public IP address of the TURN server, e.g., for STUNner:
$ export TURN_SERVER_ADDR=$(kubectl get svc stunner -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
We also need the public facing address of the Application server to create, manage and tear-down WebRTC sessions via the WebSocket control connection. For the STUNner tutorials:
$ export APPLICATION_SERVER_ADDR=$(kubectl get svc webrtc-server -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
$ export APPLICATION_SERVER_PORT=$(kubectl get svc webrtc-server -o jsonpath='{.spec.ports[0].port}')
Send/receive the same encoding:
- Sender side:
go run webrtc-client.go caller --peer=test2 --ice-addr="${TURN_SERVER_ADDR}" --url="wss://${APPLICATION_SERVER_ADDR}:${APPLICATION_SERVER_ADDR}/one2one" --debug -file=sample/sample_640x360.ivf
- Receiver side:
go run webrtc-client.go callee --user=test2 --ice-addr="${TURN_SERVER_ADDR}" --url="wss://${APPLICATION_SERVER_ADDR}:${APPLICATION_SERVER_ADDR}/one2one" --debug -file=/tmp/output.ivf
Send H264, receive VP8:
- Sender side:
go run webrtc-client.go caller --peer=test2 --ice-addr="${TURN_SERVER_ADDR}" --url="wss://${APPLICATION_SERVER_ADDR}:${APPLICATION_SERVER_ADDR}/one2one" --debug -file=sample/sample_640x360.h264
- Receiver side:
go run webrtc-client.go callee --user=test2 --ice-addr="${TURN_SERVER_ADDR}" --url="wss://${APPLICATION_SERVER_ADDR}:${APPLICATION_SERVER_ADDR}/one2one" --debug -file=/tmp/output.ivf
Create an ivf or h264 file to be played and run the below script.
demo/run-mirror-traffic.sh -n <NUMBER_OF_CALLS> -m <MODE[rolling|static]> -f <FILE-TO-PLAY>
STUNner development is coordinated on Discord, send us an email to ask an invitation.
Copyright 2021-2022 by its authors. Some rights reserved. See AUTHORS.
MIT License - see LICENSE for full text.
Demo adopted from Kurento. Initial code adopted from pion/webrtc examples.