Using WebRTC DataChannel for Android

1,990 views
Skip to first unread message

samfast

unread,
Apr 7, 2015, 10:52:22 AM4/7/15
to discuss...@googlegroups.com
Hello All,

I have been trying to implement WebRTC DataChannel for Android Application. I have a question, if my application only uses datachannel and no audio/video, do I need to use 

PeerConnectionFactory.initializeAndroidGlobals(this, false, false, false);
       
PeerConnectionFactory factory = new PeerConnectionFactory();

before creating my PeerConnection object. Whenever I try to do like this, I get the Fatal Signal 11 (SIGSEGV) error. Moreover, I also see the following message in the logcat:

Could not find the method android.media.MediaCodec.setParameters.

Am I doing it a wrong way? I just want to implement PeerConnection with DataChannel like this: 

this.pc = factory.createPeerConnection(RTCConfig.getIceServer(),
     
RTCConfig.getMediaConstraints(), this);
     
dc
= this.pc.createDataChannel("sendDataChannel", new DataChannel.Init());

I am finding it very difficult to implement the DataChannel on Android. I have tried several ways and asked questions many times.

Can anybody give me a sample source code for Android which implements DataChannel? Or Can anybody give me the link to find easy documentation on how to use these above methods when implementing on Android?

Thank you.

Gilded Honour

unread,
Apr 14, 2015, 6:22:01 PM4/14/15
to discuss...@googlegroups.com
Were you able to make it work?

Sojharo Mangi

unread,
Apr 15, 2015, 12:28:27 AM4/15/15
to discuss...@googlegroups.com
Yes,

This is a known bug in WebRTC code for Android. Following threads talk more on this bug:

https://code.google.com/p/webrtc/issues/detail?id=3416

https://code.google.com/p/webrtc/issues/detail?id=3234

The bug is currently in open status. However, there is a workaround available which will work for now. In Android Globals, we need to pass the audio and video parameters as true:

PeerConnectionFactory.initializeAndroidGlobals(getApplicationContext(), true, true, VideoRendererGui.getEGLContext());



On Sun, Apr 12, 2015 at 8:04 AM, Gilded Honour <gilded...@gmail.com> wrote:
Were you able to make it work?

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
 
Sojharo


Gilded Honour

unread,
Apr 15, 2015, 1:22:57 AM4/15/15
to discuss...@googlegroups.com
My issue is that onDataChannels never gets triggered on "Answer" side so the DataChannel doesn't get created on Answer side either. Could I see your code anywhere?
Are you sure those issues are related to this?

Sojharo Mangi

unread,
Apr 16, 2015, 6:04:41 AM4/16/15
to discuss...@googlegroups.com
The issue I was having is different. For implementing this, I am going through the following process:

1. Peer A (who starts sending the file) creates PeerConnection object "pc" and then creates DataChannel on it using pc.createDataChannel()

2. After this, we call the createOffer function i.e. pc.createOffer()

3. Later, if createOffer() was successful, then onCreateSuccess(SessionDescription sdp) will be triggered.

4. Inside this function, you would set local description on pc using pc.setLocalDescription(FilePeer.this, sdp); and send the sdp to other peer using any signalling technique (I used socket.io).

5. After this, other peer would get the answer.

6. Later, you need to follow the whole process of sending and receiving candidates.

7. Peer A already has datachannel object, Peer B would receive the datachannel when onDataChannel would be triggered.

I am able to send the messages between two peers. One of them is on web and other on Android. When I send the message from Android to Web. I get ArrayObject {} and not data.

Yossi Elkrief

unread,
Jul 23, 2015, 6:49:30 AM7/23/15
to discuss-webrtc, soj...@gmail.com
Hi,
I'm trying to follow that exact same flow and can't seem to get it to work.
Do you have any git/gist/open source sample working to show? 

Sojharo Mangi

unread,
Jul 23, 2015, 7:18:16 AM7/23/15
to Yossi Elkrief, discuss-webrtc
My code is property of where I work. However, if you can share some snippets of your code or explain exact problem then it would help.
--
Regards,
 
Sojharo


Yossi Elkrief

unread,
Jul 23, 2015, 9:30:18 AM7/23/15
to discuss-webrtc, soj...@gmail.com
First phase - 
I only want to use the Data channel 
I've made a sample that works with 2 PeerConnections for emulating data transfer - right now just sending a simple string. 
and it's on the same device... 
How do i get it to connect to a different device and is it possible to send bytes via the channel? 

Sojharo Mangi

unread,
Jul 23, 2015, 12:28:09 PM7/23/15
to Yossi Elkrief, discuss-webrtc
Yes, it is possible to send bytes via this channel. I was able to transfer files between devices using this channel. You can enhance your sample and connect signaling server to it and use it to make connection between two different devices.
--
Regards,
 
Sojharo


Reply all
Reply to author
Forward
0 new messages