sdp-to-jingle-java

The project started as a java port of the sdpToJingle project. At the moment it is a lot more RFC compliant than its JS counterpart. The intention is to create a library that is able to convert SDP into Jingle messages.

This will come in handy if you want to use Jingle as a signaling layer when using WebRTC with PeerConnection

#Usage Using the library is pretty easy, just have a look at the tests.

WebRTC example

Sending the SDP offer created by the PeerConnection class.

// The SDP offer as created by the PeerConnection class.
SessionDescription.description sdp;

// Generate the Jingle IQ based on the offer.
JingleIQ jingleIq = SdpToJingle.jingleFromSdp(sdp);
// Update to, from and action fields.
jingleIq.setTo(to);
jingleIq.setFrom(from);
jingleIq.setAction(action);

// Send the IQ.

Sending the ICE candidates created by the PeerConnection class.

List<String> iceCandidateList;
String sid = "[YourJingleSessionId]";
String mediaName = "[NameToUseInContentTag]";

JingleIQ jingleIq = SdpToJingle.transportInfoFromSdpStub(iceCandidateList, sid, mediaName);
// Update to and from.
jingleIq.setTo(to);
jingleIq.setFrom(from);

// Send the IQ.

Parsing an SDP offer received from Jingle. (This is assuming you've already created your PeerConnection instance that is ready to be used as well as a ready to use answer SdpObserver object.)

// Convert Jingle to SDP.
String sdpString = SdpToJingle.sdpFromJingle(jingleIq).toString();

// Wrap in a SessionDescription object.
SessionDescription.Type sdpType = SessionDescription.Type.OFFER;
SessionDescription sdp = new SessionDescription(sdpType, sdpString);

// Set as remote description.
peerConnection.setRemoteDescription(answerSdpObserver, sdp);

Parsing an ICE candidate received from Jingle. (This is assuming you've already created your PeerConnection instance and it is ready to be used.)

// Convert Jingle to SDP.
CandidatePacketExtension iceCandidate;
String sdpLine = SdpToJingle.iceCandidateLineFromJingle(iceCandidate);

// Wrap in an IceCandidate object.
IceCandidate webrtcIceCandidate = new IceCandidate("audio", 0, sdpLine);

// Add to PeerConnection.
peerConnection.addIceCandidate(webrtcIceCandidate);