Skip to content

Client side Go implementation for the Kurento one-to-one video call tutorial

Notifications You must be signed in to change notification settings

rg0now/kurento-tutorial-client-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kurento tutorial client in Go

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.

Getting started

Install

The usual:

cd kurento-tutorial-client-go/
go build ./...

Prepare video

H264

Must use the NAL frame format for streaming. Recode video:

ffmpeg -i sample_640x360.mkv -an -vcodec libx264 sample_640x360.mkv

VP8

Must use the IVF media container for streaming. Recode video:

ffmpeg -i sample_640x360.mkv  -vcodec libvpx -s 640x360 sample_640x360.ivf

Configure

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}')

Start client

Without transcoding

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

With transcoding

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

Start magic-mirror background traffic

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>

Help

STUNner development is coordinated on Discord, send us an email to ask an invitation.

License

Copyright 2021-2022 by its authors. Some rights reserved. See AUTHORS.

MIT License - see LICENSE for full text.

Acknowledgments

Demo adopted from Kurento. Initial code adopted from pion/webrtc examples.

About

Client side Go implementation for the Kurento one-to-one video call tutorial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages