Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/medooze/whip-whep-js
WHIP and WHEP clients javascript module
https://github.com/medooze/whip-whep-js
webrtc whep whip
Last synced: about 1 month ago
JSON representation
WHIP and WHEP clients javascript module
- Host: GitHub
- URL: https://github.com/medooze/whip-whep-js
- Owner: medooze
- License: mit
- Created: 2021-09-10T09:42:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-29T07:30:07.000Z (7 months ago)
- Last Synced: 2024-10-30T10:04:49.859Z (about 2 months ago)
- Topics: webrtc, whep, whip
- Language: JavaScript
- Homepage:
- Size: 65.4 KB
- Stars: 67
- Watchers: 10
- Forks: 15
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build status](https://github.com/medooze/whip-whep-js/workflows/build/badge.svg)](https://github.com/medooze/whip-whep-js/actions?query=workflow%3Abuild) [![npm package](https://img.shields.io/npm/v/whip-whep.svg?label=npm:whip-whep)](https://www.npmjs.com/package/whip-whep)
# whip.js
WHIP client javascript module## Example
```
import { WHIPClient } from "whip.js"//Get mic+cam
const stream = await navigator.mediaDevices.getUserMedia({audio:true, video:true});//Create peerconnection
const pc = new RTCPeerConnection({ bundlePolicy: "max-bundle" });//Send all tracks
for (const track of stream.getTracks()) {
//You could add simulcast too here
pc.addTransceiver(track, { 'direction': 'sendonly' });
}//Create whip client
const whip = new WHIPClient();const url = "https://whip.test/whip/endpoint";
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IndoaXAgdGVzdCIsImlhdCI6MTUxNjIzOTAyMn0.jpM01xu_vnSXioxQ3I7Z45bRh5eWRBEY2WJPZ6FerR8";//Start publishing
whip.publish(pc, url, token);```
# whep.js
WHEP client javascript module## Example
```
import { WHEPClient } from "whep.js"//Create peerconnection
const pc = window.pc = new RTCPeerConnection({ bundlePolicy: "max-bundle" });//Add recv only transceivers
pc.addTransceiver("audio");
pc.addTransceiver("video");pc.ontrack = (event) =>
{
console.log(event)
if (event.track.kind == "video")
document.querySelector("video").srcObject = event.streams[0];
}//Create whep client
const whep = new WHEPClient();const url = "https://whep.test/whep/endpoint";
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtaWxsaWNhc3QiOnsidHlwZSI6IlN1YnNjcmliZSIsInNlcnZlcklkIjoidmlld2VyMSIsInN0cmVhbUFjY291bnRJZCI6InRlc3QiLCJzdHJlYW1OYW1lIjoidGVzdCJ9LCJpYXQiOjE2NzY2NDkxOTd9.ZE8Ftz9qiS04zTKBqP1MHZTOh8dvI73FBraleQM9h1A"//Start viewing
whep.view(pc, url, token);```