1

To send binary data via the WebRTC/RTCDataChannel binaryType can be set either to "blob" or "arraybuffer".

dataChannel.binaryType = "blob"; 
dataChannel.binaryType = "arraybuffer"; 

I can't find out in what cases binary data should be send as blob and when as ArrayBuffers. Any hint?

David
  • 93
  • 10

1 Answers1

2

The binaryType mostly affects how you receive objects. Whether to send as Blob or ArrayBuffer mostly depends on what you're sending. If you want to send files which you have been reading as blobs (and they're large), then sending them as a blob is the obvious thing to do.

Note that Chrome currently only implements sending ArrayBuffers, star https://bugs.chromium.org/p/webrtc/issues/detail?id=2276 for Blob support.

Philipp Hancke
  • 15,855
  • 2
  • 23
  • 31
  • Do you have an example when to use ArrayBuffers? Is it for streaming? – David Nov 16 '15 at 13:33
  • 1
    see https://github.com/webrtc/samples/tree/gh-pages/src/content/datachannel/filetransfer – Philipp Hancke Nov 16 '15 at 19:37
  • 1
    Philipp, do you know why sending data as ArrayBuffer from Chrome is received as Blob in Firefox? (The "binaryType" is set to "arraybuffer" at the creation of the data channel.) Thanks! – wwgoncalves Oct 23 '20 at 20:04