-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'd635c3a7af366849e7663b2105e7a7831579d3a8' into develop
- Loading branch information
Showing
11 changed files
with
139 additions
and
41 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Server } from "ws"; | ||
import { RTCPeerConnection } from "../../packages/webrtc/src"; | ||
import { MediaRecorder } from "../../packages/webrtc/src/nonstandard"; | ||
|
||
// open ./answer.html | ||
|
||
const server = new Server({ port: 8878 }); | ||
console.log("start"); | ||
|
||
server.on("connection", async (socket) => { | ||
const recorder = new MediaRecorder({ | ||
path: `./opus-${Date.now()}.webm`, | ||
numOfTracks: 1, | ||
}); | ||
|
||
const pc = new RTCPeerConnection(); | ||
|
||
pc.addTransceiver("video").onTrack.subscribe(async (track, transceiver) => { | ||
transceiver.sender.replaceTrack(track); | ||
setInterval(() => { | ||
transceiver.receiver.sendRtcpPLI(track.ssrc); | ||
}, 3_000); | ||
}); | ||
|
||
pc.addTransceiver("audio").onTrack.subscribe(async (track, transceiver) => { | ||
transceiver.sender.replaceTrack(track); | ||
await recorder.addTrack(track); | ||
}); | ||
|
||
setTimeout(async () => { | ||
await recorder.stop(); | ||
console.log("stop"); | ||
}, 15_000); | ||
|
||
await pc.setLocalDescription(await pc.createOffer()); | ||
const sdp = JSON.stringify(pc.localDescription); | ||
socket.send(sdp); | ||
|
||
socket.on("message", (data: any) => { | ||
pc.setRemoteDescription(JSON.parse(data)); | ||
}); | ||
}); |
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