Ivan Vučica avatar Ivan Vučica committed bb3d0ef

Further work on jingle.

Comments (0)

Files changed (2)

extensions/xep-0166-jingle.js

 		
 		var sdp = SDPToJingle.parseJingleStanza(zxmpp.util.serializedXML(xml));
 		console.log("SDP: " + sdp);
-		peerConnection.processSignalingMessage(sdp);
+		//peerConnection.processSignalingMessage(sdp);
+		var type;
+		if(xml.attr["action"] == "session-accept")
+			type = "answer";
+		peerConnection.setRemoteDescription(new RTCSessionDescription({sdp:sdp, type:type}));
 		return true;
 	}
 	
 
 
 			for(var media in description) {
+				var mediaSdp = "";
 				if(description.hasOwnProperty(media)) {
-					sdp += _generateMediaSdp(media, description[media]);
+					mediaSdp = _generateMediaSdp(media, description[media]);
 				}
-				bundleSdp += " " + media;
+				if(mediaSdp.length)
+				{
+					sdp += mediaSdp;
+					bundleSdp += " " + media;
+				}
 			}
 			return baseSdp + bundleSdp + sdp + "\r\n";
 		},
 		_generateMediaSdp = function(media, description) {
 			// TODO: Remove hardcoded values like "1" which is the mediaport placeholder
+
+			if(!description.port || !description.profile)
+			{
+				console.warn("For some reason, description contained media '" + media + "' without specifying its details. SDPToJingle's _generateMediaSdp will skip this.");
+				console.log(description);
+				return "";
+			}
 			var m = "\r\nm=" + media + " " + description.port + " " + description.profile,
 				rtpmapStr = "a=mid:" + media + "\r\na=rtcp-mux",
-				rtcpStr = "a=rtcp:" + description.port + " IN IP4 " + description['udp-candidates'][0].ip + "\r\n",
+				rtcpStr = "a=rtcp:" + description.port + " IN IP4";
+				if(description['udp-candidates'] && description['udp-candidates'][0])
+					rtcpStr += " " + description['udp-candidates'][0].ip;
+				rtcpStr += "\r\n";
+			var
 				cryptoStr = "",
 				udpCandidateStr = "",
 				iceCandidateStr = "",
 			return _generateJingleFromDescription(description);
 		},
 		parseJingleStanza: function(stanza) {
+                        console.log("*** PARSING INCOMING JINGLE STANZA");
+                        console.log(stanza);
 			var doc = _getXmlDoc(stanza),
 				jingle = doc.childNodes.length ? doc.childNodes[0] : undefined,
 				children = jingle ? jingle.childNodes : undefined,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.