WebRTC JavaScript publisher library allows adding WebRTC publishing capabilities to your web pages. It uses WHIP signaling.
Use its code in your projects or take it as is for embedding into your pages to connect your users to Nimble Streamer. To learn more about server setup, read WebRTC setup article.
The following codecs can be used:
- H.264/AVC, VP8, VP9 video
- H.265/HEVC video on Apple devices
- Opus audio
Specific codecs can be set via "videocodecs" parameter is WHIP URL.
Use demo publishing page to publish to your Nimble Streamer instance.
<script defer="defer" src="e32af6a81c16a82154b7.bundle.js"></script>
var config = {
whipUrl: 'https://127.0.0.1:8443/live/whip?whipauth=username:password'
};
var publisher = new WebRTCjs(config);
publisher.publish();
<!DOCTYPE html>
<html>
<head>
<script defer="defer" src="e32af6a81c16a82154b7.bundle.js"></script>
</head>
<body>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
var config = {
whipUrl: 'https://127.0.0.1:8443/live/whip?whipauth=username:password',
};
var publisher = new WebRTCjs(config);
publisher.publish();
});
</script>
</body>
</html>
whipUrl
- publishing URL with authorization parameters.logLevel
- the log level:info
, orerror
.videoElement
-<video>
tag to local monitoring published stream.videoSelect
-<select>
tag with available cameras.
onPublisherCreated
- called when publisher instance has been created with the provided configuration. Parameters:settings
.onConnectionStateChange
- called when connection state has changed. Parameters:connectionState
.onOffer
- called when SDP offer is ready. Parameters:offer
.onAnswer
- called when server answer has been received. Parameters:answer
.onConnectionError
- called if connection error happens. Has no parameters.
var config = {
whipUrl: 'https://127.0.0.1:8443/live/whip?whipauth=username:password',
onPublisherCreated: function(settings){ console.log('Ready to WebRTC publishing'); }
};