Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend debugger + vid/aud toggle #18

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions api-server/webrtc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
from flask import request
from flask_socketio import emit

class DebugTools:
@staticmethod
def log_transport(self):
'''
Dev Function to log the transport method used in the WebSocket connection.
'''
transport = request.args.get('transport', 'unknown')
self.log_message('DEBUG', f'Connection transport: {transport}')


def setup_webrtc(app, socketio, session_storage, log_message):

@socketio.on('offer')
def handle_offer(data):
to_sid = session_storage[data['meeting_id']]['users'][data['to']]
Expand Down
30 changes: 27 additions & 3 deletions client/src/pages/MeetingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,33 @@ const MeetingPage = () => {
}
}, []);

const toggleMute = () => setIsMuted(!isMuted);
const toggleVideo = () => setIsVideoOff(!isVideoOff);
const toggleMute = () => {
setIsMuted(prevState => {
const newMutedState = !prevState;
// Mute or unmute the audio track in the local stream
if (rtcHandler.current && rtcHandler.current.localStream) {
rtcHandler.current.localStream.getAudioTracks().forEach(track => {
console.log(track);
track.enabled = !newMutedState;
});
}
return newMutedState;
});
};

const toggleVideo = () => {
setIsVideoOff(prevState => {
const newVideoState = !prevState;
// Turn on or off the video track in the local stream
if (rtcHandler.current && rtcHandler.current.localStream) {
rtcHandler.current.localStream.getVideoTracks().forEach(track => {
console.log(track);
track.enabled = !newVideoState;
});
}
return newVideoState;
});
};

const sendMessage = (e) => {
e.preventDefault();
Expand All @@ -76,7 +101,6 @@ const MeetingPage = () => {
};

if (!username || !rtcHandler.current) {
// wait for username and rtcHandler
return null;
}

Expand Down
4 changes: 0 additions & 4 deletions client/src/services/chatHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class ChatHandler {
sendMessage(text) {
this.socket.emit('chat_message', { meeting_id: this.meeting_id, text: text, sender: this.username });
}

setChatHistoryListener(listener) {
this.setChatHistory = listener;
}
}

export default ChatHandler;
7 changes: 7 additions & 0 deletions client/src/services/rtcHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class RTCHandler {
try {
this.localStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
this.hasMediaDevices = true;

// Log out details of the localStream
console.log("Local Stream:", this.localStream);

this.localStream.getTracks().forEach(track => {
console.log(`Track kind: ${track.kind}, Track ID: ${track.id}, Track enabled: ${track.enabled}`);
});
} catch (err) {
console.warn('No media devices found or access denied:', err);
toast.error('No media devices found or access denied. Continuing without video/audio.');
Expand Down
Loading