Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WebRTC JavaScript WHIP publisher library

Notifications You must be signed in to change notification settings

juaoose/webrtcjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebRTC Javascript library

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:

Specific codecs can be set via "videocodecs" parameter is WHIP URL.

Use demo publishing page to publish to your Nimble Streamer instance.

Getting Started

Add library to HTML

<script defer="defer" src="fda0b8224f3acb87a87b.bundle.js"></script>

Usage

var config = {
  whipUrl: 'https://127.0.0.1:8443/live/whip?whipauth=username:password'
};
var publisher = new WebRTCjs(config);
publisher.publish();

Full example

<!DOCTYPE html>
<html>
  <head>
    <script defer="defer" src="fda0b8224f3acb87a87b.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>

Configuration options

  • whipUrl - publishing URL with authorization parameters.
  • logLevel - the log level: info, or error.
  • videoElement - <video> tag to local monitoring published stream.

Callbacks

  • 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.

Callback usage example

var config = {
  whipUrl: 'https://127.0.0.1:8443/live/whip?whipauth=username:password',

  onPublisherCreated: function(settings){ console.log('Ready to WebRTC publishing'); }
};

About

WebRTC JavaScript WHIP publisher library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 58.7%
  • HTML 34.8%
  • Sass 6.5%