mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-30 21:09:58 +08:00
Hosting the viewer & webrtc logging (#271)
* might fix the stun server issue * still debugging webrtc * another turn server * working on github actions * updating actions file * fixing actions * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * ga * updating viewer * update docs
This commit is contained in:
1 parent
3083c201ed
commit
55ebaaf1b5
9 files changed
+127
-75
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "viewer",
|
||||
"homepage": "https://ethanweber.me/nerfactory-private/",
|
||||
"homepage": ".",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -36,15 +36,25 @@ export default function WebRtcWindow() {
|
||||
username: 'openrelayproject',
|
||||
credential: 'openrelayproject',
|
||||
},
|
||||
// extra STUN server(s):
|
||||
// {
|
||||
// urls: 'stun:stun.l.google.com:19302',
|
||||
// },
|
||||
// extra TURN server(s):
|
||||
// {
|
||||
// urls: 'turn:1830walnut.ddns.net',
|
||||
// username: 'turnuser',
|
||||
// credential: 'turnpassword',
|
||||
// },
|
||||
// {
|
||||
// urls: 'turn:turn.nerfactory.com:3478',
|
||||
// username: 'turnuser',
|
||||
// credential: 'turnpassword',
|
||||
// },
|
||||
],
|
||||
});
|
||||
// connect video
|
||||
pc.addEventListener('track', (evt) => {
|
||||
dispatch({
|
||||
type: 'write',
|
||||
path: 'webrtcState/isConnected',
|
||||
data: true,
|
||||
});
|
||||
if (evt.track.kind === 'video') {
|
||||
[localVideoRef.current.srcObject] = evt.streams; // uses array destructuring
|
||||
}
|
||||
@@ -53,13 +63,16 @@ export default function WebRtcWindow() {
|
||||
|
||||
// for updating the status of the peer connection
|
||||
pc.oniceconnectionstatechange = () => {
|
||||
if (pc.iceConnectionState === 'connected') {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionState
|
||||
console.log(`[webrtc] connectionState: ${ pc.connectionState}`);
|
||||
if (pc.connectionState === 'connecting' || pc.connectionState === 'connected') {
|
||||
console.log('[webrtc] connected');
|
||||
dispatch({
|
||||
type: 'write',
|
||||
path: 'webrtcState/isConnected',
|
||||
data: true,
|
||||
});
|
||||
} else if (pc.iceConnectionState === 'disconnected') {
|
||||
} else {
|
||||
dispatch({
|
||||
type: 'write',
|
||||
path: 'webrtcState/isConnected',
|
||||
@@ -75,17 +88,22 @@ export default function WebRtcWindow() {
|
||||
.createOffer()
|
||||
.then((offer) => {
|
||||
console.log('[webrtc] created offer');
|
||||
console.log(offer);
|
||||
return pcRef.current.setLocalDescription(offer);
|
||||
})
|
||||
.then(() => {
|
||||
console.log('[webrtc] set local description');
|
||||
// wait for ICE gathering to complete
|
||||
console.log('[webrtc] set local description');
|
||||
return new Promise((resolve) => {
|
||||
if (pcRef.current.iceGatheringState === 'complete') {
|
||||
console.log('[webrtc] ICE gathering complete');
|
||||
resolve();
|
||||
} else {
|
||||
const checkState = () => {
|
||||
console.log(
|
||||
`[webrtc] iceGatheringState: ${
|
||||
pcRef.current.iceGatheringState}`,
|
||||
);
|
||||
if (pcRef.current.iceGatheringState === 'complete') {
|
||||
pcRef.current.removeEventListener(
|
||||
'icegatheringstatechange',
|
||||
@@ -94,6 +112,9 @@ export default function WebRtcWindow() {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
console.log(
|
||||
'[webrtc] adding listener for `icegatheringstatechange`',
|
||||
);
|
||||
pcRef.current.addEventListener(
|
||||
'icegatheringstatechange',
|
||||
checkState,
|
||||
@@ -125,7 +146,9 @@ export default function WebRtcWindow() {
|
||||
// set the remote description when the offer is received
|
||||
const cmd = msgpack.decode(new Uint8Array(originalCmd.data));
|
||||
if (cmd.type === 'answer') {
|
||||
console.log('[webrtc] received answer');
|
||||
const answer = cmd.data;
|
||||
console.log(answer);
|
||||
pcRef.current.setRemoteDescription(answer);
|
||||
}
|
||||
});
|
||||
@@ -133,7 +156,7 @@ export default function WebRtcWindow() {
|
||||
websocket.addEventListener('open', () => {
|
||||
// connect webrtc when the websocket is connected
|
||||
pcRef.current = getRTCPeerConnection();
|
||||
console.log('sending offer');
|
||||
console.log('[webrtc] starting process');
|
||||
sendOffer();
|
||||
});
|
||||
}, []); // empty dependency array means only run once
|
||||
|
||||
@@ -79,7 +79,7 @@ class SingleFrameStreamTrack(VideoStreamTrack):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.background_frame = np.ones((480, 640, 3), dtype="uint8") * 255 # white background
|
||||
self.background_frame = np.ones((480, 640, 3), dtype="uint8") * 100 # gray background
|
||||
self.frame = None
|
||||
self.put_frame(self.background_frame)
|
||||
|
||||
|
||||
Reference in new issue
Block a user