kijaba Δημοσ. 5 Ιουνίου 2020 Δημοσ. 5 Ιουνίου 2020 (επεξεργασμένο) Καλησπέρα σε όλους, Έχω τον παρακάτω κώδικα που παίζει μέσω WebRTC & Node και προσπαθώ να του προσθέσω αυξομείωση του ήχου. Είναι ένα τσατ με υποστήριξη βίντεο. Αυτό που θέλω να κάνω είναι να αλλάζω την ένταση της εισόδου και έπειτα η έξοδος να παίρνει τον "επεξεργασμένο" ήχο. Έχω βρει το GainNode που θεωρητικά φαίνεται να κάνει τη δουλειά αλλά δε μπορώ να το κάνω να δουλέψει. Όποια βοήθεια ευπρόσδεκτη, ευχαριστώ! HTML Spoiler <video controls id="localVideo" width="640" height="auto" autoplay muted> </video> <video controls id='remoteVideo' width="640" height="auto" autoplay> </video> JS Spoiler "use strict"; // Connecting to socket.io var socket = io.connect('http://localhost:8080'); // The username is requested, sent to the server and displayed in the title var username = prompt('What\'s your username?', "user"); socket.emit('new_client', username); document.title = username + ' - ' + document.title; // When a message is received it's inserted in the page socket.on('message', function(data) { insertMessage(data.username, data.message) }) // When a new client connects, the information is displayed socket.on('new_client', function(username) { $('#chat_zone').prepend('<p><em>' + username + ' has joined the chat!<\/em><\/p>'); }) // When a new client disconnects, the information is displayed socket.on('user_left', function(username) { $('#chat_zone').prepend('<p><em>' + username + ' has left the chat!<\/em><\/p>'); }) // When the form is sent, the message is sent and displayed on the page $('#chat_form').submit(function() { var message = $('#message').val(); socket.emit('message', message); // Sends the message to the others insertMessage(username, message); // Also displays the message on our page $('#message').val('').focus(); // Empties the chat form and puts the focus back on it return false; // Blocks 'classic' sending of the form }); // Adds a message to the page function insertMessage(username, message) { $('#chat_zone').prepend('<p><strong>' + username + '<\/strong>: ' + message + '<\/p>'); } // Updates user list socket.on('get_users', function(users) { console.log("Online users: " + users); $('#users').empty(); for (i = 0; i < users.length; i++) { $('#users').prepend('<li class="list-group-item">' + users[i] + '</li>'); } }) /*********************** video call ***************************/ var localStream; var localVideo = document.getElementById("localVideo"); var remoteVideo = document.getElementById("remoteVideo"); var callButton = document.getElementById("callButton"); var inputLevelSelector = document.getElementById('mic-volume'); var outputLevelSelector = document.getElementById('speaker-volume'); inputLevelSelector.addEventListener('change', changeMicrophoneLevel); outputLevelSelector.addEventListener('change', changeSpeakerLevel); callButton.disabled = true; callButton.onclick = call; navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; navigator.getUserMedia({ audio: true, video: true }, gotStream, //note that we are adding both audio and video function(error) { console.log(error); }); var RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; var SessionDescription = window.RTCSessionDescription || window.mozRTCSessionDescription || window.webkitRTCSessionDescription; var pc = new RTCPeerConnection({ "iceServers": [] }); function gotStream(stream) { // localVideo.src = window.URL.createObjectURL(stream); // DEPRECATED localVideo.srcObject = stream; // UPDATED localStream = stream; callButton.disabled = false; pc.addStream(stream); } pc.onicecandidate = function(event) { console.log(event); if (!event || !event.candidate) { return; } else { socket.emit("video call", { type: "iceCandidate", "candidate": event.candidate }); } }; var remoteStream; pc.onaddstream = function(event) { remoteStream = event.stream; var remoteVideo = document.getElementById("remoteVideo"); // remoteVideo.src = window.URL.createObjectURL(event.stream); // DEPRECATED remoteVideo.srcObject = event.stream; // UPDATED remoteVideo.play(); }; socket.on("video call", function(data) { console.log(data); switch (data.type) { case "iceCandidate": console.log("case : iceCandidate"); pc.addIceCandidate(new RTCIceCandidate(data.candidate)); break; case "offer": console.log("case : offer"); // pc.setRemoteDescription(new SessionDescription(data.description), function() { // DEPRECATED ON FIREFOX // console.log("failure callback"); // }); pc.setRemoteDescription(new SessionDescription(data.description)).then(() => { console.log("failure callback") }); // UPDATE FOR FIREFOX pc.createAnswer(function(description) { pc.setLocalDescription(new SessionDescription(description)); socket.emit("video call", { type: "answer", "description": description }); }, function() { console.log("failure callback") }); break; case "answer": console.log("case : answer"); // pc.setRemoteDescription(new SessionDescription(data.description), function() { // DEPRECATED ON FIREFOX // console.log("failure callback"); // }); pc.setRemoteDescription(new SessionDescription(data.description)).then(function() { // UPDATE FOR FIREFOX console.log("failure callback"); }); break; } }); function call() { console.log("Calling another peer"); console.log(pc.iceConnectionState); console.log(pc); if (pc.iceConnectionState == "closed") { pc = new RTCPeerConnection({ "iceServers": [] }); pc.addStream(localStream); console.log(pc); } pc.createOffer(function(description) { console.log("Creating offer for the other peer"); // pc.setLocalDescription(new SessionDescription(description), function() { // DEPRECATED ON FIREFOX // console.log("failure callback"); // }); pc.setLocalDescription(new SessionDescription(description)).then(function() { // UPDATE FOR FIREFOX console.log("failure callback"); }); socket.emit("video call", { type: "offer", "description": description }); }, function() { console.log("failure callback"); }); }; /************************ datachannel ************************/ var dataChannelOptions = { ordered: false, // do not guarantee order maxRetransmitTime: 3000, // in milliseconds }; // Establish your peer connection using your signaling channel here var dataChannel = pc.createDataChannel("test_datachannel", dataChannelOptions); pc.ondatachannel = function(ev) { console.log('Data channel is created!'); ev.channel.onopen = function() { console.log('Data channel is open and ready to be used.'); dataChannel.send('Hello World!'); }, ev.channel.onerror = function(error) { console.log("Data Channel Error:", error); }, ev.channel.onmessage = function(event) { console.log("Got Data Channel Message:", event.data); }, ev.channel.onclose = function() { console.log("The Data Channel is Closed"); }; }; Επεξ/σία 5 Ιουνίου 2020 από kijaba
Predatorkill Δημοσ. 5 Ιουνίου 2020 Δημοσ. 5 Ιουνίου 2020 Αυτο το εχεις δει; https://www.w3schools.com/tags/av_prop_volume.asp οταν λες επεξεργασμενο ηχο τι εννοεις; Απλα την αυξομειωση του;
kijaba Δημοσ. 5 Ιουνίου 2020 Μέλος Δημοσ. 5 Ιουνίου 2020 Ναι, το συγκειρμένο από το w3 το χρησιμοποιώ για την αυξομίωση του ήχου των stream μέσω ενός slider. Αυτό που θέλω να προσθέσω τώρα είναι η αλλαγή ήχου του μικροφώνου (προφανώς θα γίνεται μέσω gain ( ; )). Ναι, εννοώ τον ήχο μετά την αυξομείωση του.
kijaba Δημοσ. 6 Ιουνίου 2020 Μέλος Δημοσ. 6 Ιουνίου 2020 Κανείς κάποια βοήθεια παιδιά; Έχω κολλήσει με το gainNode και δε μπορώ να βγάλω άκρη 😕
Προτεινόμενες αναρτήσεις
Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε
Πρέπει να είστε μέλος για να αφήσετε σχόλιο
Δημιουργία λογαριασμού
Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!
Δημιουργία νέου λογαριασμούΣύνδεση
Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.
Συνδεθείτε τώρα