Revision 9e9237ac

View differences:

html/janus.js
1337 1337
		} else {
1338 1338
			if(adapter.browserDetails.browser === "edge") {
1339 1339
				// This is Edge, add an a=end-of-candidates at the end
1340
				jsep.sdp += "a=end-of-candidates\r\n";
1340
				jsep.sdp = mungeSdpForEdge(jsep.sdp);
1341 1341
			}
1342 1342
			config.pc.setRemoteDescription(
1343 1343
					new RTCSessionDescription(jsep),
......
1371 1371
			} else {
1372 1372
				if(adapter.browserDetails.browser === "edge") {
1373 1373
					// This is Edge, add an a=end-of-candidates at the end
1374
					jsep.sdp += "a=end-of-candidates\r\n";
1374
					jsep.sdp = mungeSdpForEdge(jsep.sdp);
1375 1375
				}
1376 1376
				config.pc.setRemoteDescription(
1377 1377
						new RTCSessionDescription(jsep),
......
1708 1708
			}
1709 1709
			if(adapter.browserDetails.browser === "edge") {
1710 1710
				// This is Edge, add an a=end-of-candidates at the end
1711
				jsep.sdp += "a=end-of-candidates\r\n";
1711
				jsep.sdp = mungeSdpForEdge(jsep.sdp);
1712 1712
			}
1713 1713
			config.pc.setRemoteDescription(
1714 1714
					new RTCSessionDescription(jsep),
......
2138 2138
		pluginHandle.oncleanup();
2139 2139
	}
2140 2140

  
2141
	// Helper method to munge an SDP to Edge, to add a=end-of-candidates to all m-lines
2142
	function mungeSdpForEdge(sdp) {
2143
		// See https://github.com/webrtc/adapter/issues/605
2144
		var lines = sdp.split("\r\n");
2145
		var firstMline = true;
2146
		for(var i=0; i<lines.length; i++) {
2147
			var mline = lines[i].match(/m=(\w+) */);
2148
			if(mline) {
2149
				if(firstMline) {
2150
					firstMline = false;
2151
					continue;
2152
				}
2153
				// Insert an a=end-of-candidates before this line
2154
				lines.splice(i, 0, "a=end-of-candidates"); i++;
2155
				continue;
2156
			}
2157
		}
2158
		// Regenerate SDP
2159
		sdp = lines.join("\r\n");
2160
		if(!sdp.endsWith("\r\n"))
2161
			sdp += "\r\n";
2162
		// Let's add a last a=end-of-candidates
2163
		sdp += "a=end-of-candidates\r\n";
2164
		return sdp;
2165
	}
2166

  
2141 2167
	// Helper methods to parse a media object
2142 2168
	function isAudioSendEnabled(media) {
2143 2169
		Janus.debug("isAudioSendEnabled:", media);
html/janus.nojquery.js
1388 1388
		} else {
1389 1389
			if(adapter.browserDetails.browser === "edge") {
1390 1390
				// This is Edge, add an a=end-of-candidates at the end
1391
				jsep.sdp += "a=end-of-candidates\r\n";
1391
				jsep.sdp = mungeSdpForEdge(jsep.sdp);
1392 1392
			}
1393 1393
			config.pc.setRemoteDescription(
1394 1394
					new RTCSessionDescription(jsep),
......
1422 1422
			} else {
1423 1423
				if(adapter.browserDetails.browser === "edge") {
1424 1424
					// This is Edge, add an a=end-of-candidates at the end
1425
					jsep.sdp += "a=end-of-candidates\r\n";
1425
					jsep.sdp = mungeSdpForEdge(jsep.sdp);
1426 1426
				}
1427 1427
				config.pc.setRemoteDescription(
1428 1428
						new RTCSessionDescription(jsep),
......
1759 1759
			}
1760 1760
			if(adapter.browserDetails.browser === "edge") {
1761 1761
				// This is Edge, add an a=end-of-candidates at the end
1762
				jsep.sdp += "a=end-of-candidates\r\n";
1762
				jsep.sdp = mungeSdpForEdge(jsep.sdp);
1763 1763
			}
1764 1764
			config.pc.setRemoteDescription(
1765 1765
					new RTCSessionDescription(jsep),
......
2185 2185
		pluginHandle.oncleanup();
2186 2186
	}
2187 2187

  
2188
	// Helper method to munge an SDP to Edge, to add a=end-of-candidates to all m-lines
2189
	function mungeSdpForEdge(sdp) {
2190
		// See https://github.com/webrtc/adapter/issues/605
2191
		var lines = sdp.split("\r\n");
2192
		var firstMline = true;
2193
		for(var i=0; i<lines.length; i++) {
2194
			var mline = lines[i].match(/m=(\w+) */);
2195
			if(mline) {
2196
				if(firstMline) {
2197
					firstMline = false;
2198
					continue;
2199
				}
2200
				// Insert an a=end-of-candidates before this line
2201
				lines.splice(i, 0, "a=end-of-candidates"); i++;
2202
				continue;
2203
			}
2204
		}
2205
		// Regenerate SDP
2206
		sdp = lines.join("\r\n");
2207
		if(!sdp.endsWith("\r\n"))
2208
			sdp += "\r\n";
2209
		// Let's add a last a=end-of-candidates
2210
		sdp += "a=end-of-candidates\r\n";
2211
		return sdp;
2212
	}
2213

  
2188 2214
	// Helper methods to parse a media object
2189 2215
	function isAudioSendEnabled(media) {
2190 2216
		Janus.debug("isAudioSendEnabled:", media);

Also available in: Unified diff