WebRTC iPad Testing #36
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ipad-testing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This branch begins to get webcam sharing to work with iPads.
Current Status
With this branch you can get an iPad to share webcam with a desktop Firefox browser in very specific circumstances. The iPad must be sharing its own video before it can open someone else's video (mutual calling seems required).
But it does not (yet) work in reverse: if the Firefox user has their webcam on and they click to open the iPad user's webcam, the iPad user will see a black video screen appear from Firefox but the Firefox user will not see any camera open at all for the iPad.
Things Learned
Apple's implementation of WebRTC is "very modern" and only Promise-based syntax is supported
How this was discovered: when watching the server logs about the WebRTC negotiation messages I noticed:
It turns out that in the WebRTC spec, functions such as setLocalDescription() have deprecated the callback functions in favor of Promises in the modern API. BareRTC used the legacy style but Safari supports only the modern Promise-based: so fixing this, Safari was able to send the SDP message before candidates and get us further along.
Also: not sure if important, but in the original code I gave a
new RTCSessionDescription(desc)
object to setLocalDescription and in the new code I pass thedesc
object directly without the RTCSessionDescription wrapper. Firefox and iPad seem happy without the wrapper anyway.iPad must share its local video on the initial offer for the call to connect at all
Currently, per this Guide to WebRTC with Safari in the Wild, iPad does not support receive-only or send-only channels: the async video support where an iPad user is not sharing video but wants to watch video, or vice versa, does not seem currently possible.
The downside: if the offerer adds their video track at the time of connection, then their video will automatically appear on the screen of the answerer when the connection goes through. This is fine if the answerer had the "automatically open their video when they open mine" setting on, so they see the same behavior they would expect. But for users who do not want to auto-open their watcher's camera, the iPad camera would force itself open on their screen anyway, if the iPad adds their own local video to the offer.
Super early on when prototyping BareRTC I discovered the above behavior and removed it because I wanted webcam watching to be asynchronous; but for iPads it may be that asynchronous video is just not going to be supported. (See "Next Ideas", below).
Current Issues
As mentioned above: while mutual video calling seems kosher for the iPad, it doesn't currently work if the non-iPad is the one offering to connect.
Other jank noticed was:
Next Ideas
Add a dummy data channel to work around the send-only/receive-only channels?
Very early in the BareRTC prototyping, when I wanted async camera sharing to work, I noticed that if the offerer was not attaching their video to the connection, they also would not receive video from the answerer, so they couldn't watch the camera. One attempt at a work-around was to add a Data channel to the WebRTC connection, thinking that by adding "something" useful, the offerer could receive the video from the answerer.
(The solution was to add "offerToReceiveVideo: true" on the offer; then the answerer could send their video correctly, and the data channel code was left dangling and not used).
It may be possible to make iPad's experience better by utilizing the data channel: iPads don't support receive-only channels but maybe by adding a data channel to the connection, it can be tricked into thinking it's a two-way call and the iPad can watch a camera without having their own cam added too.
(Hopefully not) iPads may need to be limited to only specifically bidirectional calls
If the data channel idea doesn't pan out -- it will be very unfortunate but the iPad may just need to be limited to only mutual video calls.
How it may have to look, is:
But if the iPad is not sharing its own webcam, or the answerer does not auto-open cameras, to give an error message like: you can't watch this camera from an iPad.