Create working prototype
This commit is contained in:
@@ -4,28 +4,35 @@ const startStream = function (streamKey) {
|
||||
})
|
||||
|
||||
pc.oniceconnectionstatechange = e => console.log(e)
|
||||
pc.onicecandidate = e => {
|
||||
console.log("Adding ice candidate: " + e.candidate);
|
||||
if (!e.candidate) {
|
||||
console.log("Done adding candidates. Creating offer.");
|
||||
fetch("/whip/tjuice", {
|
||||
method: "POST",
|
||||
body: pc.localDescription.sdp
|
||||
}).then(resp => {
|
||||
resp.text().then(text => {
|
||||
var answer = {
|
||||
type: "answer",
|
||||
sdp: text
|
||||
}
|
||||
try {
|
||||
console.log("Setting remote description.");
|
||||
pc.setRemoteDescription(answer)
|
||||
} catch (e) {
|
||||
console.log("Error setting remote description: " + e)
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
pc.createOffer().then(offer => {
|
||||
console.log("Setting local description.");
|
||||
pc.setLocalDescription(offer)
|
||||
})
|
||||
pc.addTransceiver('video')
|
||||
pc.addTransceiver('audio')
|
||||
pc.createOffer().then(offer => {
|
||||
fetch("/whip/tjuice", {
|
||||
method: "POST",
|
||||
body: offer.sdp
|
||||
}).then(resp => {
|
||||
resp.text().then(text => {
|
||||
var answer = {
|
||||
type: "answer",
|
||||
sdp: text
|
||||
}
|
||||
try {
|
||||
pc.setLocalDescription(offer).then(
|
||||
pc.setRemoteDescription(answer)
|
||||
)
|
||||
} catch (e) {
|
||||
console.log("Error setting remote description: " + e)
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
||||
|
||||
pc.ontrack = function (event) {
|
||||
console.log(event)
|
||||
@@ -33,7 +40,7 @@ const startStream = function (streamKey) {
|
||||
var ms = new MediaStream()
|
||||
event.streams.forEach(s => {
|
||||
const tracks = s.getTracks()
|
||||
tracks.forEach( t => {
|
||||
tracks.forEach(t => {
|
||||
ms.addTrack(t)
|
||||
})
|
||||
})
|
||||
@@ -60,7 +67,7 @@ displayStreams = function () {
|
||||
})
|
||||
}
|
||||
|
||||
window.onload = function ( ev ) {
|
||||
window.onload = function (ev) {
|
||||
console.log(ev)
|
||||
displayStreams()
|
||||
}
|
Reference in New Issue
Block a user