2

I have built webrtc for android and have included the jar file in my project. I want to attach data channel to my PeerConnection object. On web, we do following in javascript :

sendChannel = pc.createDataChannel("sendDataChannel", {reliable: true});

or

sendChannel = pc.createDataChannel("sendDataChannel", {reliable: false});

where pc is the PeerConnection.

I want to do same in Java on Android using native webrtc code. I have little confusion. By looking at Jar file on eclipse, I could see that createDataChannel method of PeerConnection takes two arguments of type String and Init.

PeerConnection.createDataChannel(String, Init)

I could not understand what should I put in the second argument. WebRTC documentation, I found, is for web applications. I have seen the following WebRTC draft document but could not understand clearly.

http://www.w3.org/TR/webrtc/#methods-2

It would be helpful if someone can provide a small example of how it should be used.

Currently, I am trying to do this:

DataChannel dc = this.pc.createDataChannel("sendDataChannel", new DataChannel.Init());
SamFast
  • 1,054
  • 2
  • 16
  • 31

2 Answers2

2

You'd create the Init instance and manipulate the public properties before passing it to createDataChannel: https://code.google.com/p/webrtc/source/browse/trunk/talk/app/webrtc/java/src/org/webrtc/DataChannel.java#35

If you did not find "reliable" there, that is because this does not work anymore. See maxRetransmits and maxRetransmitTimeMs.

Philipp Hancke
  • 15,855
  • 2
  • 23
  • 31
  • Is it OK if I keep the default values for public properties of Init and don't manipulate them? Which of them would be manipulated in a simple use case? – SamFast Mar 23 '15 at 18:32
  • in the simple usecase you don't need to manipulate them, the defaults are ok. If you need to tinker with unreliable channels good luck, I don't know of any demos showing that for the browser even. – Philipp Hancke Mar 24 '15 at 20:05
0

Try to make a new Init and assign it a id if you want otherwise just pass new Init() in second argument it will work.

Jeet Swami
  • 11
  • 1