Update WebRTC passive producer handling

This commit is contained in:
Alexey Khit
2023-03-19 17:17:05 +03:00
parent d6d21286c1
commit 13c426e2a9
4 changed files with 68 additions and 43 deletions
+7 -7
View File
@@ -26,13 +26,6 @@
const localTracks = []
if (/video|audio/.test(media)) {
const tracks = ['video', 'audio']
.filter(kind => media.indexOf(kind) >= 0)
.map(kind => pc.addTransceiver(kind, {direction: 'recvonly'}).receiver.track)
localTracks.push(...tracks)
}
if (/camera|microphone/.test(media)) {
const tracks = await getMediaTracks('user', {
video: media.indexOf('camera') >= 0,
@@ -55,6 +48,13 @@
})
}
if (/video|audio/.test(media)) {
const tracks = ['video', 'audio']
.filter(kind => media.indexOf(kind) >= 0)
.map(kind => pc.addTransceiver(kind, {direction: 'recvonly'}).receiver.track)
localTracks.push(...tracks)
}
document.getElementById('video').srcObject = new MediaStream(localTracks)
return pc