-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP: working with seq, ts rewrite. * WIP: working with single video stream * WIP: allow working with vp8 simulcast * WIP: allow re-enable vp8 egress with vp8 short-term memory * test: add vp8 sim test, packet selector test * feat: h264 simulcast * feat: vp9 svc
- Loading branch information
Showing
35 changed files
with
3,967 additions
and
519 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,61 @@ | ||
import { WHIPClient } from "./whip.js" | ||
import { WHIPClient } from "./whip.js"; | ||
|
||
window.start = async () => { | ||
console.log("Will start"); | ||
if (window.whip_instance) { | ||
window.whip_instance.stop(); | ||
} | ||
|
||
if (window.stream_instance) { | ||
window.stream_instance.getTracks().forEach(track => track.stop()); | ||
} | ||
|
||
//Get mic+cam | ||
const stream = await navigator.mediaDevices.getUserMedia({audio:true, video:true}); | ||
|
||
document.getElementById("video").srcObject = stream; | ||
|
||
//Create peerconnection | ||
const pc = new RTCPeerConnection(); | ||
|
||
//Send all tracks | ||
for (const track of stream.getTracks()) { | ||
//You could add simulcast too here | ||
pc.addTransceiver(track, { | ||
direction: "sendonly", | ||
streams: [stream], | ||
// sendEncodings: [ | ||
// { rid: "0", active: true, scaleResolutionDownBy: 2}, | ||
// { rid: "1", active: true, scaleResolutionDownBy: 2}, | ||
// { rid: "2", active: true }, | ||
// ], | ||
}); | ||
} | ||
|
||
//Create whip client | ||
const whip = new WHIPClient(); | ||
|
||
const url = "/whip/endpoint"; | ||
const token = document.getElementById("room-id").value; | ||
|
||
//Start publishing | ||
whip.publish(pc, url, token); | ||
|
||
window.whip_instance = whip; | ||
window.stream_instance = stream; | ||
} | ||
console.log("Will start"); | ||
if (window.whip_instance) { | ||
window.whip_instance.stop(); | ||
} | ||
|
||
if (window.stream_instance) { | ||
window.stream_instance.getTracks().forEach((track) => track.stop()); | ||
} | ||
|
||
//Get mic+cam | ||
const stream = await navigator.mediaDevices.getUserMedia({ | ||
audio: true, | ||
video: true, | ||
}); | ||
|
||
document.getElementById("video").srcObject = stream; | ||
|
||
//Create peerconnection | ||
const pc = new RTCPeerConnection(); | ||
|
||
//Send all tracks | ||
for (const track of stream.getTracks()) { | ||
//You could add simulcast too here | ||
pc.addTransceiver(track, { | ||
direction: "sendonly", | ||
streams: [stream], | ||
sendEncodings: [ | ||
{ rid: "0", active: true }, | ||
{ rid: "1", active: true }, | ||
{ rid: "2", active: true }, | ||
], | ||
}); | ||
} | ||
|
||
//Create whip client | ||
const whip = new WHIPClient(); | ||
|
||
const url = "/whip/endpoint"; | ||
const token = document.getElementById("room-id").value; | ||
|
||
//Start publishing | ||
whip.publish(pc, url, token); | ||
|
||
window.whip_instance = whip; | ||
window.stream_instance = stream; | ||
}; | ||
|
||
window.stop = async () => { | ||
if (window.whip_instance) { | ||
window.whip_instance.stop(); | ||
} | ||
if (window.whip_instance) { | ||
window.whip_instance.stop(); | ||
} | ||
|
||
if (window.stream_instance) { | ||
window.stream_instance.getTracks().forEach(track => track.stop()); | ||
} | ||
if (window.stream_instance) { | ||
window.stream_instance.getTracks().forEach((track) => track.stop()); | ||
} | ||
|
||
document.getElementById("video").srcObject = null; | ||
} | ||
document.getElementById("video").srcObject = null; | ||
}; |
Oops, something went wrong.