This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
generated from VitorLuizC/typescript-library-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stream view limiter not working (#44)
- Loading branch information
1 parent
fa3b886
commit 2f3c315
Showing
8 changed files
with
119 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,46 @@ | ||
async function onMyStreamAdded(stream) { | ||
console.log('added mystream:', stream); | ||
if(stream.kind == 'video') { | ||
let receiver = await window.atm0sSession.takeReceiver('video'); | ||
let element = document.getElementById('my_video'); | ||
element.srcObject = receiver.stream; | ||
element.receiver = receiver; | ||
receiver.switch(stream); | ||
} | ||
console.log('added mystream:', stream); | ||
if (stream.kind == 'video') { | ||
let receiver = await window.atm0sSession.takeReceiver('video'); | ||
let element = document.getElementById('my_video'); | ||
element.srcObject = receiver.stream; | ||
element.receiver = receiver; | ||
receiver.switch(stream); | ||
} | ||
|
||
if(stream.kind == 'audio') { | ||
let receiver = window.atm0sSession.takeReceiver('audio'); | ||
let element = document.getElementById('my_audio'); | ||
element.srcObject = receiver.stream; | ||
receiver.switch(stream); | ||
} | ||
if (stream.kind == 'audio') { | ||
let receiver = window.atm0sSession.takeReceiver('audio'); | ||
let element = document.getElementById('my_audio'); | ||
element.srcObject = receiver.stream; | ||
receiver.switch(stream); | ||
} | ||
} | ||
|
||
async function boot() { | ||
const urlSearchParams = new URLSearchParams(window.location.search); | ||
const params = Object.fromEntries(urlSearchParams.entries()); | ||
const urlSearchParams = new URLSearchParams(window.location.search); | ||
const params = Object.fromEntries(urlSearchParams.entries()); | ||
|
||
let video_stream = await navigator.mediaDevices.getUserMedia({audio: false, video: true}); | ||
let session = Atm0s.createSession(params['server'] || [''], { | ||
roomId: params['room'] || 'demo', | ||
peerId: params['peer'] || 'echo-client-' + new Date().getTime(), | ||
token: params['token'], | ||
senders: [ | ||
{ stream: video_stream, name: 'video_main', kind: 'video', simulcast: true } | ||
], | ||
receivers: { | ||
audio: 1, | ||
video: 1 | ||
} | ||
}); | ||
window.atm0sSession = session; | ||
session.connect(); | ||
session.on('stream_added', onMyStreamAdded); | ||
let video_stream = await navigator.mediaDevices.getUserMedia({ audio: false, video: true }); | ||
let session = Atm0s.createSession(params['server'] || [''], { | ||
roomId: params['room'] || 'demo', | ||
peerId: params['peer'] || 'echo-client-' + new Date().getTime(), | ||
token: params['token'], | ||
senders: [{ stream: video_stream, name: 'video_main', kind: 'video', simulcast: true }], | ||
receivers: { | ||
audio: 1, | ||
video: 1, | ||
}, | ||
logLevel: 5, | ||
}); | ||
window.atm0sSession = session; | ||
session.connect(); | ||
session.on('mystream_added', onMyStreamAdded); | ||
|
||
document.getElementById('quality').onchange = (event) => { | ||
let layers = event.target.value.split('-'); | ||
let element = document.getElementById('my_video'); | ||
element.receiver.limit(50, parseInt(layers[0]), parseInt(layers[1])); | ||
} | ||
document.getElementById('quality').onchange = (event) => { | ||
let layers = event.target.value.split('-'); | ||
let element = document.getElementById('my_video'); | ||
element.receiver.limit(50, 0, 0, parseInt(layers[0]), parseInt(layers[1])); | ||
}; | ||
} | ||
|
||
boot(); | ||
boot(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters