10

So here's the story, I'm building a WebRTC app and I have to record the stream on server.

"WebRTC is p2p dude, choose a media server"

Yes, I know, please avoid this comment ;)

But then I tought about one thing, what if I force all the stream to use the TURN server. The packets are going through the server, so I guess I can take them and save it

The question is how to do this.

Any suggestions?

Manza
  • 3,427
  • 4
  • 36
  • 57
  • Well, the packets are encrypted using whatever was negotiated via DTLS. So, the big thing would be your turn server getting those certificates and decrypting, then reencrypting each packets as it comes through the server... – Benjamin Trent Oct 03 '14 at 16:09
  • i might be wrong, but unless the peers are unable to find each other( both have to be behind different symmetric NAT ), they wont even bother talking to stun/turn server, in one scenario( both peers in same network), I kept the server_config as [] and the peers didn't care, they were communicating like nothing happened. – mido Oct 04 '14 at 04:25
  • 2
    @mido, not exaclty. If you don't use STUN or TURN the only peer generated are type "host". If you are using TURN and STUN there will be generated also relay and srflx types. But you can force to use TURN dropping all the other candidates (and use only relay type) during the ICE gathering. – Manza Oct 06 '14 at 09:10
  • @Manza, bit late, but have you looked at kurento media server. – mido Jun 05 '15 at 03:19

2 Answers2

7

TURN servers are intended to be relayed media, which means that media streams are not decrypted, mux'ed, processed, or recorded. I get that you're asking to avoid the "choose a media server" comment, but that's like saying "I need put in this screw; which hammer should I use? Please don't tell me to get a screwdriver." - The hammer isn't the right tool.

You can still use WebRTC and p2p, but the media server (like Jitsi, for example) acts as a peer in a star topology, where all streams are sent to the media server, and can be recorded, relayed, bundled, etc.

xdumaine
  • 10,096
  • 6
  • 62
  • 103
3

You can use a WebRTC gateway like Janus or Kurento (I assume you have figured it out by now :) )

lucpattyn
  • 51
  • 2
  • Yep, I discovered Kurento few days ago. Already started to play with it. Didn't know about Janus btw, thanks for the hint. – Manza Nov 16 '15 at 10:08