-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·39 lines (30 loc) · 1.3 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import publisher from "./publisher";
import viewer from "./viewer";
// Configure WHIP API endpoint and token
// whipUrl example: https://director.millicast.com/api/whip/<streamName>
// Token example: https://director.millicast.com/api/whip/<streamName>
if (!(import.meta.env.VITE_WHIP_URL &&
import.meta.env.VITE_PUBLISH_TOKEN &&
import.meta.env.VITE_WHEP_URL)) {
throw new Error('Missing environment variables')
}
const whipUrl = import.meta.env.VITE_WHIP_URL
const publishinToken = import.meta.env.VITE_PUBLISH_TOKEN
console.log('Starting WHIP publisher')
console.log('WHIP endpoing: ', whipUrl)
console.log('WHIP Token: ', publishinToken)
// Start publishing
await publisher({url: whipUrl, token: publishinToken, simulcast: true})
// Configure WHEP API endpoint
const whepUrl = import.meta.env.VITE_WHEP_URL
// You can configure an optional subscriber token if enabled
const subscriberToken = import.meta.env.VITE_SUBSCRIBER_TOKEN
// Select video where we want to reproduce the stream
const whepVideo = document.getElementById('whep')
// Add your wanted video media element desired configurations
whepVideo.muted = true
whepVideo.controls = true
console.log('Starting WHEP viewer')
console.log('WHEP endpoing: ', whepUrl)
// Start reproducing the stream
await viewer(whepUrl, whepVideo, subscriberToken)