Open TheSalarKhan opened 6 years ago
Although a messy PR https://github.com/webrtc/apprtc/pull/346 it does setup two peerconnections, clones the mediastream and sends it back. It was reverted in the end since Chrome did not handle the cloned mediastream like that really well. I plan to revisit it and not use cloned mediastreams but in the meanwhile it might give you some hints on how to get it working, just ignore all the callstats stuff which have since been pulled out.
Thanks @KaptenJansson. The PR that you've linked me to gets this accomplished using two peerconnection objects, and thats cool. But I'd still like to know how do we get this working with just a single peer connection object. I would love to know the ICE candidate/ offer-answer dance that's taking place to make that possible. I have gone through the executing by putting breakpoints several times, and I've tried to replicate that to the best of my knowledge. But even after that this thing only works in apprtc and not in the example I've shown.
If it helps I'd like to add that the only thing that I've not been able to get working, is the firing of the on remote stream added method - i.e. the method in which we actually link the video to the html element. If I run this example and wait for a bit, and then get the stream manually and add it to the video element - using chrome dev tools console - I'm able to get it working.
Thanks once again for the amazing work that you and others are doing. Cheers! :metal:
Loopback on a single peerconnection violates the webrtc spec as we disable DTLS (a single peerconnection can only have one of two roles, server or client) and use SDES (allows a single peerconnection to have both client and server role). I would refrain of implementing this. This will be replaced in AppRTC when someone has cycles to fix it.
Browsers and versions affected OS: Archlinux x86_64 Browser: Google Chrome
Description By reading the apprtc code it seems that the loopback is implemented pretty simply. All that is done is a second websocket is created that registers to the same room as the websocket connection. Then all it does is convert any offers it receives to answers, and for all other messages, like the ICE candidates, it transmits them without any change. I'll reference to the comment in loopback.js
Steps to reproduce Here's the index.html and main.js that I am using. All the rest of the files are being used from the appr.tc project.
index.html
main.js
Expected results The call should establish with the video and audio playing in the remote video html element.
Actual results The call does establish, ICE connection state is 'complete' and that of the RTCPeerConnection is 'stable'. But 'onremotestreamadded' never gets called so the video does not show up on the remote video element. Although, adding the stream manually through the developer console works out.
I've been looking at this for well over two weeks but I have been unable to find out the reason its not working. Any help would be highly appreciated. Thanks to all apprtc folks. :+1:
Link to project: https://github.com/TheSalarKhan/WTRtc/tree/private-salar-loopback