So I am now finally gotten around to getting DTLS-SRTP <-> RTP bridging somewhat stable through rtpengine and I am ready to start working on this again.
I have started work on a javascript implementation of the bfcp protocol which I plan to contribute back into SIP.js eventually.
I have a much deeper understanding of the webrtc internals now and I have the following questions with how I should do things within SIP.js themselves (at least to get some pointers, so I dont waste time digging about blindly).
First of all, I am on node webkit, so I dont have to think about secure websockets and/or permissions etc so that part is OK, I can send a separate screen share just fine by just grabbing another stream from the outset and just not send anything over it (track disabled) when its not in use etc. And the fourth stream is a RTCDataChannel that I intend to send BFCP over for legacy interop.
Now, the use case I am after is for non-bfcp supported endpoints.
The normal way to do it is to try bfcp, and if you dont get a reply, just replace current video stream with either a PIP mux of your screenshare + your own camera or just replace the camera with the screen share.
Now, I am not quite sure if this is feasible. The way I have found so far is to just replace what streams are available on the peerConnection, but this will make a new SDP and force you to renegotiate (and technically re-invite I guess).
What I am trying to figure out, is if there is a way to in place replace the video stream.
Could I for example change the track of the webcam(video/audio) getUserMedia() to read from the track of the desktop share getUserMedia() call instead of reading from its local source?
Is it a better solution to from the outset make an intermediate stream that reads from local and writes to another local (which then would write to the stream that is added onto the peerConnection)?
Am I on the right track at all (no pun intended) by looking at swapping out tracks?