Compare commits
3 Commits
dda3328667
...
e871d5c268
Author | SHA1 | Date | |
---|---|---|---|
e871d5c268 | |||
![]() |
803de09305 | ||
![]() |
d6f81ff72b |
@ -1,8 +1,20 @@
|
|||||||
const host = window.location.hostname
|
const isSecure = window.location.protocol === 'https:';
|
||||||
const ws0 = new WebSocket(`ws://${host}:3001`);
|
const host = window.location.hostname;
|
||||||
const ws1 = new WebSocket(`ws://${host}:3002`);
|
const ws0builder = isSecure ? `wss://${host}/ws0` : `ws://${host}:3001`;
|
||||||
const pc0 = new RTCPeerConnection({ iceServers: [] });
|
const ws1builder = isSecure ? `wss://${host}/ws1` : `ws://${host}:3002`;
|
||||||
const pc1 = new RTCPeerConnection({ iceServers: [] });
|
const ws0 = new WebSocket(ws0builder);
|
||||||
|
const ws1 = new WebSocket(ws1builder);
|
||||||
|
const config = {
|
||||||
|
iceServers: [
|
||||||
|
{
|
||||||
|
urls: ['stun:dwestgate.us:3478','turn:dwestgate.us:3478?transport=udp'],
|
||||||
|
username: 'webrtcuser',
|
||||||
|
credential: 'webrtccred'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
const pc0 = new RTCPeerConnection(config);
|
||||||
|
const pc1 = new RTCPeerConnection(config);
|
||||||
const video0 = document.getElementById('video0') as HTMLVideoElement;
|
const video0 = document.getElementById('video0') as HTMLVideoElement;
|
||||||
const video1 = document.getElementById('video1') as HTMLVideoElement;
|
const video1 = document.getElementById('video1') as HTMLVideoElement;
|
||||||
|
|
||||||
@ -65,3 +77,20 @@ ws1.onmessage = async (message) => {
|
|||||||
await pc1.addIceCandidate(msg.data);
|
await pc1.addIceCandidate(msg.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: Not yet working
|
||||||
|
// const dc0 = pc0.createDataChannel("keepalive");
|
||||||
|
// dc0.onopen = () =>{
|
||||||
|
// console.log("Data channel 0 open");
|
||||||
|
// setInterval(()=>{
|
||||||
|
// dc0.send("ping");
|
||||||
|
// },10000)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const dc1 = pc1.createDataChannel("keepalive");
|
||||||
|
// dc1.onopen = () =>{
|
||||||
|
// console.log("Data channel 1 open");
|
||||||
|
// setInterval(()=>{
|
||||||
|
// dc1.send("ping");
|
||||||
|
// },10000)
|
||||||
|
// }
|
||||||
|
15
src/ws.ts
15
src/ws.ts
@ -16,7 +16,7 @@ export default class TVWebSocket {
|
|||||||
const audioTrack = this.createAudioTrack(ffmpegProcess);
|
const audioTrack = this.createAudioTrack(ffmpegProcess);
|
||||||
|
|
||||||
|
|
||||||
ffmpegProcess.stdio[2].on('data',data=>{
|
ffmpegProcess.stdio[2].on('data', data => {
|
||||||
// console.log("stdio[2] ",data.toString())
|
// console.log("stdio[2] ",data.toString())
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -185,7 +185,18 @@ export default class TVWebSocket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createPeerConnection = (videoTrack: MediaStreamTrack, audioTrack: MediaStreamTrack): RTCPeerConnection => {
|
createPeerConnection = (videoTrack: MediaStreamTrack, audioTrack: MediaStreamTrack): RTCPeerConnection => {
|
||||||
const peerConnection = new RTCPeerConnection({ iceServers: [] });
|
const peerConnection = new RTCPeerConnection({
|
||||||
|
iceServers: [
|
||||||
|
{
|
||||||
|
urls: 'stun:192.168.0.3:3478'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
urls: 'turn:192.168.0.3:3478?transport=udp',
|
||||||
|
username: 'webrtcuser',
|
||||||
|
credential: 'webrtccred'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
const stream = new MediaStream()
|
const stream = new MediaStream()
|
||||||
stream.addTrack(videoTrack)
|
stream.addTrack(videoTrack)
|
||||||
stream.addTrack(audioTrack);
|
stream.addTrack(audioTrack);
|
||||||
|
Loading…
Reference in New Issue
Block a user