innovailable / rtc-lib Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Lesser General Public License v3.0
License: GNU Lesser General Public License v3.0
Hi,
I am trying to swap video streams in the middle of the call, because I need to change resolution dynamically. I found out, that probably only working solution is to remove old Stream
from LocalPeer
, add new Stream
and then renegotiate with all RemotePeer
s.
Problem is, if I renegotiate only once after I removed old Stream
and replaced it with new one, nothing happens.. RemotePeer
thinks it is still the same Stream
(with same stream.stream.id
).
If I renegotiate twice: first time after removing old Stream
and second time after adding new one, it could solve the problem, but another problem appears at the side of the peer which changed the stream.
After recieving an answer from first renegotiation:
Uncaught (in promise) DOMException: Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Failed to set local offer sdp: The m= section with mid='1' should be rejected.
from peer_connection.ts:342
After receiving an answer from second renegotiation:
Uncaught (in promise) DOMException: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Session error code: ERROR_CONTENT. Session error description: The m= section with mid='1' should be rejected..
from peer_connection.ts:293
It seems like a bug to me, or am I misunderstanding something?
This is problematic part of code:
updateVideo(isHd) {
let options = isHd ? this.hdVideoOptions() : this.basicVideoOptions();
this.model.room.local.stream().then(s => {
s.stop();
});
this.model.room.local.removeStream();
this.renegotiateAllPeers(); // Renegotiation #1
this.model.room.local.addStream(options)
.then(newStream => {
this.localStream = newStream;
this.displayStream(this.localStream, $('#myVideo'));
this.renegotiateAllPeers(); // Renegotiation #2
})
.catch((err) => console.error(err.message));
}
renegotiateAllPeers() {
for (let peer of this.peers) {
peer.negotiate();
}
}
It is impossible to send message through DataChannel that I added to LocalPeer (Room.local.addDataChannel), because I don't have option to get this channel, when I want to call send() method on it.
Hello, I have some problems in doing a connection to an existing audio room. I'm creating an audio room, where two or more user can talk to each other:
This is my initial code on opening the page:
`
async initAudioRoom() {
const roomName = "raumname"
const channel = new rtc.WebSocketChannel("wss://easy.innovailable.eu/" + encodeURI(roomName));
const signaling = new rtc.MucSignaling(channel);
const options = {
stun: "stun:stun.innovailable.eu",
}
var room = new rtc.Room(signaling, options)
this.room = room
var current_this = this
this.room.on('peer_joined', function(peer) {
// create a video tag for the peer
const view = $('<video playsinline autoplay>');
$('#peers').append(view);
const ve = new rtc.MediaDomElement(view[0], peer);
// remove the tag after peer leftd
peer.on('left', function() {
view.remove();
});
});
},`
When someone wants to join the audio room I'm doing this:
`
const roomName = "raumname"
try {
// create a local stream from the users camera
const stream = await this.room.local.addStream({ video: false, audio: true });
// display that stream
const ve = new rtc.MediaDomElement($('video'), stream);
} catch(err) {
alert("Unable to get stream, please give permission. You might have to go into settings if you denied before.");
return;
}
try {
await this.room.connect();
} catch(err) {
alert("Unable to join room: " + err.message)
}
`
This works fine.. two or more user can talk to each other. Now I just try to define a function for a user, that only can listen to the users who are in the audio room.. how can I do this? The listening user have already the video tags of the peers, which are in the audio room, at the DOM. But the listening user can't hear anything. I tried something like a Listening Button and this function:
try { await this.room.join(); } catch(err) { alert("Unable to join room: " + err.message) }
Do you have an idea and could help me? Im trying it since days and im not able to finish that.
Thank you very much!
running make all outputs
node_modules/.bin/browserify --extension .ts -p tsify -t [ babelify --extensions .ts ] -s rtc -d --no-bundle-external src/index.ts -o dist/bundle/rtc.js
TypeScript error: /home/gsalvador/rtc-lib-master/node_modules/@types/browserify/index.d.ts(9,23): Error TS2688: Cannot find type definition file for 'node'.
make: *** [Makefile:49: dist/bundle/rtc.js] Error 1
I am experiencing weird bug, with rtc-lib using your public servers. After I connect in my web application to any room at your public WSS wss://easy.innovailable.eu and STUN stun:stun.innovailable.eu server. Everything works fine for 5 minutes and then rtc.Room instance fires closed event without detail. If any other peers are connected all our channels are closed as well.
I have tested it with my friends (Windows and Linux users) and no one has experienced the same bug. All of them were able to stay connected for whole session (up to 1 hour). I have tested it using Chrome and room closed always after exactly 300 seconds (5 minutes). When I tested it using Firefox room closed after 305 - 350 seconds.
When I monitor room WSS request on Network Developer Tools of Chrome it says "CAUTION: Request is not finished yet!" for 300 seconds (while connection works) and when caution disappears room closes. I don't understand why the request is not finished. Can't it be at your WSS side?
Do you have any idea what could cause this problem? 300 seconds doesn't seems like an coincidence, probably it is some timeout, but I have no idea where could be problem.
My setup:
OS: macOs Big Sur 11.1. (20C69)
Tested Browsers:
Google Chrome 88.0.4324.182 (Official Build) (x86_64)
Mozilla Firefox 86.0 (64-bit)
EDIT:
I resolved problem by pinging the signaling server.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.