from Hacker News

Untangling the WebRTC Flow

by pkcsecurity on 10/22/14, 7:59 PM with 7 comments

  • by moron4hire on 10/22/14, 8:41 PM

    Your article is very good, but I only know that because I've been through this myself. I'm not sure I would have completely understood WebRTC until I implemented it in an application by myself for the first time. Once you get it, it's actually quite simple. I think it's the unfamiliarity of the various terms like ICE, STUN/TURN, and SDP, and everyone treating the issue like everyone should A) already know what those are, or B) be able to figure out the implications once given the acronym definition. If you're going from WebSockets to WebRTC, there is a lot of new terminology to swallow all at once.

    But you definitely helped clear up some of the rougher points for me. Like, I didn't realize that createOffer should be called after the negotiationNeeded event occurred. I just call it immediately after creating my DataChannel (I'm doing text-only transmissions as part of a system to combine inputs from multiple devices to play a game). I had wondered what the negotiationNeeded event was all about, but none of the articles I'd found had really said anything clear about it, and it wasn't in any of the example code I found.

    And I found all of this through MDN! The existing documentation for WebRTC is apparently really bad. And that's quite disappointing, because I've usually found MDN to either be excellent or merely incomplete, not specifically having documentation that was poor.

    Again, thanks for this.

  • by AjithAntony on 10/22/14, 8:54 PM

    Does anyone happen to know how one is expected to choose the output audio device? Seems like every WebRTC app just uses the default output which is completely the wrong thing to do when using a headset.
  • by MichaelGG on 10/23/14, 1:01 AM

    Why would any sane person bring SDP into WebRTC? They had a fresh slate to get things right, and instead they end up making it worse than the SIP headache. SDP, the spec that suggests people might use SDP to setup chess games is a terrible format. In fact, unless they changed the offer answer model, there's actually no way to determine what single codec is in use. It's one of those things where every vendor sorta does something, and relies on tons of interop and guessing to actually come up with an implementation. Plus it's yet another custom parser with a strange format. And deliberately clipped in verbosity (for a text format) because the SIP authors were terrified of IP fragmentation and actually spec'd a hardcoded MTU size.

    Edit: Frustration aside, this is a really nice explanation, thanks.

  • by acron0 on 10/22/14, 11:26 PM

    I found http://peerjs.com/ really, really helpful when attempting a webRTC project. Like most people, I found the spec to be a lot of gibberish and even the majority of examples are hard to follow. PeerJS 'just works'.