I am using angular 4 and attempting to create screen sharing functionality one to many, but I am having trouble getting a single broadcast to work. I have created a chrome extension to get the media stream from desktopCapture. The offer is being sent from the broadcaster to the user requesting to join the stream with socket.io via node/express. The offer object makes it to the requesting user with no problem (that I can see) but when I call signal on the offer I get the following error.
I am using simple-peer.
my error is Error: signal() called with invalid signal data
at u.signal
code from broadcaster's end:
selectScreen() {
this._window.postMessage('get-sourceId', 'http://localhost:4200/*');
this._window.addEventListener('message', (event) => {
if (event.data.hasOwnProperty('sourceId')) {
localStorage.setItem('DT_SourceId', event.data.sourceId); // now add to items constraints in getUserMedia()
this.screenId = localStorage.getItem('DT_SourceId');
}
else {
//console.log(event.data);
}
});
}
testScreenShare() {
let peerx: any;
let constraints = {
video: {
mandatory: {
chromeMediaSource: 'desktop',
chromeMediaSourceId: this.screenId
}
}
};
this.n.getUserMedia = (this.n.getUserMedia || this.n.webKitGetUserMedia || this.n.mozGetUserMedia || this.n.msGetUserMedia);
this.n.getUserMedia(constraints, (stream) => {
this.stream = stream;
this.video.src = URL.createObjectURL(stream);
this.video.play();
peerx = new SimplePeer({
initiator: location.hash === '#vidInit',
trickle: false,
stream: stream
});
peerx.on('signal', (data) => {
this.targetPeer = data;
localStorage.setItem('offer', JSON.stringify(data)); //used for testing
});
this.peer = peerx;
console.log(this.peer);
}, (err) => {
console.error('failed to get stream', err);
});
}
The code for the user to call signal() on the offer:
ngAfterViewInit(){
this.socketService.onRecieveFeedOffer().subscribe(offer => {
this.offer = offer;
console.log(offer);
this.peer = new SimplePeer({
initiator: location.hash === '#vidInit',
trickle: false
});
this.peer.on('signal', (data) => {
console.log(data);
});
this.peer.on('stream', (stream) => {
this.stream.src = URL.createObjectURL(stream);
this.stream.play();
console.log('stream: ' + stream);
});
});
console.log(this.peer);
}
connect(){
console.log(JSON.stringify(this.offer));
this.peer.signal(this.offer);
}
the offer object stringified for legibility in this post:
{"offer":"{\"type\":\"offer\",\"sdp\":\"v=0\\r\\no=- 4425143461398787910 2 IN IP4 127.0.0.1\\r\\ns=-\\r\\nt=0 0\\r\\na=group:BUNDLE video data\\r\\na=msid-semantic: WMS d35381fe-536d-42e6-a265-a832569174f3\\r\\nm=video 64059 UDP/TLS/RTP/SAVPF 96 98 100 102 127 97 99 101 125\\r\\nc=IN IP4 174.19.208.27\\r\\na=rtcp:9 IN IP4 0.0.0.0\\r\\na=candidate:3519778999 1 udp 2122255103 2001::9d38:90d7:8f5:37b4:3f57:fe83 64058 typ host generation 0 network-id 2 network-cost 50\\r\\na=candidate:1174899823 1 udp 2122194687 192.168.1.124 64059 typ host generation 0 network-id 1\\r\\na=candidate:3343878875 1 udp 1685987071 174.19.208.27 64059 typ srflx raddr 192.168.1.124 rport 64059 generation 0 network-id 1\\r\\na=candidate:2672323655 1 tcp 1518275327 2001::9d38:90d7:8f5:37b4:3f57:fe83 9 typ host tcptype active generation 0 network-id 2 network-cost 50\\r\\na=candidate:142897311 1 tcp 1518214911 192.168.1.124 9 typ host tcptype active generation 0 network-id 1\\r\\na=ice-ufrag:vsZ8\\r\\na=ice-pwd:ZGZ14zkaV4S5F2ScB2SjFpxZ\\r\\na=fingerprint:sha-256 FC:20:BD:29:12:1B:9D:7C:D2:D0:C5:F5:F1:7E:F4:72:C8:CF:4A:71:C1:79:42:29:5A:B6:E6:F8:FE:72:3F:CD\\r\\na=setup:actpass\\r\\na=mid:video\\r\\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\\r\\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\\r\\na=extmap:4 urn:3gpp:video-orientation\\r\\na=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\\r\\na=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\\r\\na=sendrecv\\r\\na=rtcp-mux\\r\\na=rtcp-rsize\\r\\na=rtpmap:96 VP8/90000\\r\\na=rtcp-fb:96 ccm fir\\r\\na=rtcp-fb:96 nack\\r\\na=rtcp-fb:96 nack pli\\r\\na=rtcp-fb:96 goog-remb\\r\\na=rtcp-fb:96 transport-cc\\r\\na=rtpmap:98 VP9/90000\\r\\na=rtcp-fb:98 ccm fir\\r\\na=rtcp-fb:98 nack\\r\\na=rtcp-fb:98 nack pli\\r\\na=rtcp-fb:98 goog-remb\\r\\na=rtcp-fb:98 transport-cc\\r\\na=rtpmap:100 H264/90000\\r\\na=rtcp-fb:100 ccm fir\\r\\na=rtcp-fb:100 nack\\r\\na=rtcp-fb:100 nack pli\\r\\na=rtcp-fb:100 goog-remb\\r\\na=rtcp-fb:100 transport-cc\\r\\na=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\\r\\na=rtpmap:102 red/90000\\r\\na=rtpmap:127 ulpfec/90000\\r\\na=rtpmap:97 rtx/90000\\r\\na=fmtp:97 apt=96\\r\\na=rtpmap:99 rtx/90000\\r\\na=fmtp:99 apt=98\\r\\na=rtpmap:101 rtx/90000\\r\\na=fmtp:101 apt=100\\r\\na=rtpmap:125 rtx/90000\\r\\na=fmtp:125 apt=102\\r\\na=ssrc-group:FID 2041336394 3480224473\\r\\na=ssrc:2041336394 cname:zKUDUdcCRunL6cDe\\r\\na=ssrc:2041336394 msid:d35381fe-536d-42e6-a265-a832569174f3 cd05cea6-a836-4386-862c-dc83953dba02\\r\\na=ssrc:2041336394 mslabel:d35381fe-536d-42e6-a265-a832569174f3\\r\\na=ssrc:2041336394 label:cd05cea6-a836-4386-862c-dc83953dba02\\r\\na=ssrc:3480224473 cname:zKUDUdcCRunL6cDe\\r\\na=ssrc:3480224473 msid:d35381fe-536d-42e6-a265-a832569174f3 cd05cea6-a836-4386-862c-dc83953dba02\\r\\na=ssrc:3480224473 mslabel:d35381fe-536d-42e6-a265-a832569174f3\\r\\na=ssrc:3480224473 label:cd05cea6-a836-4386-862c-dc83953dba02\\r\\nm=application 64061 DTLS/SCTP 5000\\r\\nc=IN IP4 174.19.208.27\\r\\na=candidate:3519778999 1 udp 2122255103 2001::9d38:90d7:8f5:37b4:3f57:fe83 64060 typ host generation 0 network-id 2 network-cost 50\\r\\na=candidate:1174899823 1 udp 2122194687 192.168.1.124 64061 typ host generation 0 network-id 1\\r\\na=candidate:3343878875 1 udp 1685987071 174.19.208.27 64061 typ srflx raddr 192.168.1.124 rport 64061 generation 0 network-id 1\\r\\na=candidate:2672323655 1 tcp 1518275327 2001::9d38:90d7:8f5:37b4:3f57:fe83 9 typ host tcptype active generation 0 network-id 2 network-cost 50\\r\\na=candidate:142897311 1 tcp 1518214911 192.168.1.124 9 typ host tcptype active generation 0 network-id 1\\r\\na=ice-ufrag:vsZ8\\r\\na=ice-pwd:ZGZ14zkaV4S5F2ScB2SjFpxZ\\r\\na=fingerprint:sha-256 FC:20:BD:29:12:1B:9D:7C:D2:D0:C5:F5:F1:7E:F4:72:C8:CF:4A:71:C1:79:42:29:5A:B6:E6:F8:FE:72:3F:CD\\r\\na=setup:actpass\\r\\na=mid:data\\r\\na=sctpmap:5000 webrtc-datachannel 1024\\r\\n\"}"}
So as to save space I won't post the socket.io communications but the offer object is successfully transported to the requesting user. Thanks!