simplewebrtc / SimpleWebRTC

Simplest WebRTC ever
Other
4.66k stars 1.19k forks source link

"Already have a remote stream" when use stopLocalVideo() #688

Open Kubera2017 opened 6 years ago

Kubera2017 commented 6 years ago

I try to build video chat application with multiple rooms. Users can open the site, joins existed (prefixed) rooms, leaves them and rejoin.

First client joins the room, gets into the room, wait for another client, establish the connection. Then second client leaves the room and rejoin. Second's clients action will be "join room" -> "leave it" -> "rejoin the room".

First client log:

SimpleWebRTC {config: {…}, logger: console, capabilities: {…}, connection: SocketIoConnection, webrtc: WebRTC, …}
app.js:8109 room1
app.js:8110 Opening
latest-v3.js:12305 SimpleWebRTC event: localStreamRequested {video: true, audio: true}
latest-v3.js:13141 called true
latest-v3.js:13143 emited1
latest-v3.js:12305 SimpleWebRTC event: readyToCall w3kEIOToMBmjldi0AAAA
latest-v3.js:12305 SimpleWebRTC event: localStream MediaStream {id: "oCLFVoQ3aozBQEHEtIPVyJRK6n2tobvCkoLH", active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}
latest-v3.js:13029 join CB null {clients: {…}}
latest-v3.js:12305 SimpleWebRTC event: joinedRoom room1
>>>>> First visit
latest-v3.js:12305 SimpleWebRTC event: createdPeer Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12489 getting offer {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "offer", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12305 SimpleWebRTC event: negotiationNeeded Event {isTrusted: true, type: "negotiationneeded", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: signalingStateChange Event {isTrusted: true, type: "signalingstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
app.js:18 video added Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12305 SimpleWebRTC event: videoAdded <video autoplay id=​"Friz1VcnIyKAGZJqAAAB_video_incoming">​</video>​ Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12305 SimpleWebRTC event: peerStreamAdded Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting endOfCandidates {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922283729", roomType: "video", type: "endOfCandidates", prefix: "webkit", …}
latest-v3.js:12533 sending answer {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922283729", broadcaster: undefined, roomType: "video", type: "answer", …}
latest-v3.js:12305 SimpleWebRTC event: message {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922283729", broadcaster: undefined, roomType: "video", type: "answer", …}
latest-v3.js:12305 SimpleWebRTC event: signalingStateChange Event {isTrusted: true, type: "signalingstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: iceConnectionStateChange Event {isTrusted: true, type: "iceconnectionstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12533 sending candidate {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922283729", broadcaster: undefined, roomType: "video", type: "candidate", …}
latest-v3.js:12305 SimpleWebRTC event: message {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922283729", broadcaster: undefined, roomType: "video", type: "candidate", …}
latest-v3.js:12533 sending endOfCandidates {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922283729", broadcaster: undefined, roomType: "video", type: "endOfCandidates", …}
latest-v3.js:12305 SimpleWebRTC event: message {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922283729", broadcaster: undefined, roomType: "video", type: "endOfCandidates", …}
latest-v3.js:12305 SimpleWebRTC event: iceConnectionStateChange Event {isTrusted: true, type: "iceconnectionstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: channelOpen RTCDataChannel {label: "simplewebrtc", ordered: true, maxRetransmitTime: 65535, maxRetransmits: 65535, protocol: "", …} Event {isTrusted: true, type: "open", target: RTCDataChannel, currentTarget: RTCDataChannel, eventPhase: 2, …}
>>>>> connection established
>>>>> Visitor leaves the room
app.js:31 video removed  Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
app.js:37 <div class=​"remotes" id=​"activeWindow" style=​"top:​ 100px;​ left:​ 100px;​">​</div>​
latest-v3.js:12305 SimpleWebRTC event: videoRemoved <video autoplay id=​"Friz1VcnIyKAGZJqAAAB_video_incoming">​</video>​ Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12305 SimpleWebRTC event: peerStreamRemoved Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12665 []
latest-v3.js:12666 MediaStream {id:         
"uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn", active: true, onaddtrack: null, 
onremovetrack: null, onactive: null, …}
active: false
id: "uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn"
onactive: null
onaddtrack: null
oninactive: null
onremovetrack: null
__proto__: MediaStream
latest-v3.js:12647 ended
latest-v3.js:12649 MediaStream {id: 
"uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn", active: true, onaddtrack: null, 
onremovetrack: null, onactive: null, …}active: falseid: 
"uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn"onactive: nullonaddtrack: 
nulloninactive: nullonremovetrack: null__proto__: MediaStream
latest-v3.js:12650 (2) [MediaStreamTrack, MediaStreamTrack]
0: MediaStreamTrackenabled: trueid: "38a2a296-ee07-44c1-8e52- 
88fff2482d63"kind: "audio"label: "38a2a296-ee07-44c1-8e52- 
88fff2482d63"muted: falseonended: nullonmute: nullonunmute: null
 >>>>>>>>> readyState: "ended"
__proto__: MediaStreamTrack1: MediaStreamTrackenabled: trueid: "8732d176- 
17de-477b-abec-067d2b17140a"kind: "video"label: "8732d176-17de-477b-abec- 
067d2b17140a"muted: falseonended: nullonmute: nullonunmute: 
>>>>>> nullreadyState: "ended"__proto__: MediaStreamTracklength: 2 
__proto__: Array(0)
latest-v3.js:12305 SimpleWebRTC event: iceConnectionStateChange Event {isTrusted: true, type: "iceconnectionstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: signalingStateChange Event {isTrusted: true, type: "signalingstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: channelClose RTCDataChannel {label: "simplewebrtc", ordered: true, maxRetransmitTime: 65535, maxRetransmits: 65535, protocol: "", …} Event {isTrusted: true, type: "close", target: RTCDataChannel, currentTarget: RTCDataChannel, eventPhase: 2, …}
>>>>> Audio and video streams marked as "readystate: ended"
>>>>> Visitor rejoin
latest-v3.js:12305 SimpleWebRTC event: createdPeer Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12489 getting offer {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "offer", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12305 SimpleWebRTC event: negotiationNeeded Event {isTrusted: true, type: "negotiationneeded", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: signalingStateChange Event {isTrusted: true, type: "signalingstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
app.js:18 video added Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12305 SimpleWebRTC event: videoAdded <video autoplay id=​"Friz1VcnIyKAGZJqAAAB_video_incoming">​</video>​ Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}browserPrefix: "webkit"callbacks: {channelOpen: Array(1), *: Array(1)}channels: {simplewebrtc: RTCDataChannel}closed: trueenableDataChannels: trueid: "Friz1VcnIyKAGZJqAAAB"logger: console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}nick: undefinedoneway: falseparent: WebRTC {config: {…}, logger: console, peers: Array(0), _log: ƒ, _logerror: ƒ, …}pc: PeerConnection {enableChromeNativeSimulcast: false, enableMultiStreamHacks: false, restrictBandwidth: 0, batchIceCandidates: 0, batchedIceCandidates: Array(0), …}receiveMedia: {offerToReceiveAudio: 1, offerToReceiveVideo: 1}sharemyscreen: falsesid: "1522922305907"stream: MediaStreamactive: falseid: "uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn"onactive: nullonaddtrack: nulloninactive: nullonremovetrack: null__proto__: MediaStreamtype: "video"videoEl: video#Friz1VcnIyKAGZJqAAAB_video_incomingaccessKey: ""assignedSlot: nullattributes: NamedNodeMap {0: autoplay, 1: id, autoplay: autoplay, id: id, length: 2}autoplay: truebaseURI: "http://localhost:3000/frame.html"buffered: TimeRanges {length: 0}childElementCount: 0childNodes: NodeList []children: HTMLCollection []classList: DOMTokenList [value: ""]className: ""clientHeight: 0clientLeft: 0clientTop: 0clientWidth: 0contentEditable: "inherit"controls: falsecontrolsList: DOMTokenList [value: ""]crossOrigin: nullcurrentSrc: ""currentTime: 26.77dataset: DOMStringMap {}defaultMuted: falsedefaultPlaybackRate: 1dir: ""disableRemotePlayback: falsedraggable: falseduration: Infinityended: falseerror: nullfirstChild: nullfirstElementChild: nullheight: 0hidden: falseid: "Friz1VcnIyKAGZJqAAAB_video_incoming"innerHTML: ""innerText: ""isConnected: falseisContentEditable: falselang: ""lastChild: nulllastElementChild: nulllocalName: "video"loop: falsemediaKeys: nullmuted: falsenamespaceURI: "http://www.w3.org/1999/xhtml"networkState: 2nextElementSibling: nullnextSibling: nullnodeName: "VIDEO"nodeType: 1nodeValue: nullnonce: ""offsetHeight: 0offsetLeft: 0offsetParent: nulloffsetTop: 0offsetWidth: 0onabort: nullonauxclick: nullonbeforecopy: nullonbeforecut: nullonbeforepaste: nullonblur: nulloncancel: nulloncanplay: nulloncanplaythrough: nullonchange: nullonclick: nullonclose: nulloncontextmenu: nulloncopy: nulloncuechange: nulloncut: nullondblclick: nullondrag: nullondragend: nullondragenter: nullondragleave: nullondragover: nullondragstart: nullondrop: nullondurationchange: nullonemptied: nullonencrypted: nullonended: nullonerror: nullonfocus: nullongotpointercapture: nulloninput: nulloninvalid: nullonkeydown: nullonkeypress: nullonkeyup: nullonload: nullonloadeddata: nullonloadedmetadata: nullonloadstart: nullonlostpointercapture: nullonmousedown: nullonmouseenter: nullonmouseleave: nullonmousemove: nullonmouseout: nullonmouseover: nullonmouseup: nullonmousewheel: nullonpaste: nullonpause: nullonplay: nullonplaying: nullonpointercancel: nullonpointerdown: nullonpointerenter: nullonpointerleave: nullonpointermove: nullonpointerout: nullonpointerover: nullonpointerup: nullonprogress: nullonratechange: nullonreset: nullonresize: nullonscroll: nullonsearch: nullonseeked: nullonseeking: nullonselect: nullonselectstart: nullonstalled: nullonsubmit: nullonsuspend: nullontimeupdate: nullontoggle: nullonvolumechange: nullonwaiting: nullonwaitingforkey: nullonwebkitfullscreenchange: nullonwebkitfullscreenerror: nullonwheel: nullouterHTML: "<video autoplay="" id="Friz1VcnIyKAGZJqAAAB_video_incoming"></video>"outerText: ""ownerDocument: documentparentElement: div#container_Friz1VcnIyKAGZJqAAAB_video_incoming.videoContainerparentNode: div#container_Friz1VcnIyKAGZJqAAAB_video_incoming.videoContainerpaused: trueplaybackRate: 1played: TimeRanges {length: 1}poster: ""prefix: nullpreload: "metadata"previousElementSibling: nullpreviousSibling: nullreadyState: 4remote: RemotePlayback {state: "disconnected", onconnecting: null, onconnect: null, ondisconnect: null}scrollHeight: 0scrollLeft: 0scrollTop: 0scrollWidth: 0seekable: TimeRanges {length: 0}seeking: falseshadowRoot: nullsinkId: ""slot: ""spellcheck: truesrc: (...)srcObject: MediaStream {id: "uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn", active: false, onaddtrack: null, onremovetrack: null, onactive: null, …}style: CSSStyleDeclaration {alignContent: "", alignItems: "", alignSelf: "", alignmentBaseline: "", all: "", …}tabIndex: -1tagName: "VIDEO"textContent: ""textTracks: TextTrackList {length: 0, onchange: null, onaddtrack: null, onremovetrack: null}title: ""translate: truevideoHeight: 2videoWidth: 2volume: 1webkitAudioDecodedByteCount: 0webkitDecodedFrameCount: 1webkitDisplayingFullscreen: falsewebkitDroppedFrameCount: 1webkitSupportsFullscreen: truewebkitVideoDecodedByteCount: 0width: 0__proto__: HTMLVideoElement__proto__: WildEmitter
latest-v3.js:12305 SimpleWebRTC event: peerStreamAdded Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12638 (2) [MediaStreamTrack, MediaStreamTrack]
0: MediaStreamTrack
enabled: true
id: "38a2a296-ee07-44c1-8e52-88fff2482d63"kind: "audio"label: "38a2a296-ee07-44c1-8e52-88fff2482d63"muted: falseonended: nullonmute: nullonunmute: null
readyState: "ended"__proto__: MediaStreamTrack
1: MediaStreamTrack
enabled: true
id: "8732d176-17de-477b-abec-067d2b17140a"kind: "video"label: "8732d176-17de-477b-abec-067d2b17140a"muted: trueonended: nullonmute: nullonunmute: nullreadyState: "ended"__proto__: MediaStreamTracklength: 2__proto__: Array(0)
>>>>>>> latest-v3.js:12639 Already have a remote stream
Peer.handleRemoteStreamAdded @     latest-v3.js:12639
prototype.emit @     latest-v3.js:12294
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12305 SimpleWebRTC event: signalingStateChange Event {isTrusted: true, type: "signalingstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12533 sending answer {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922305907", broadcaster: undefined, roomType: "video", type: "answer", …}
latest-v3.js:12305 SimpleWebRTC event: message {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922305907", broadcaster: undefined, roomType: "video", type: "answer", …}
latest-v3.js:12305 SimpleWebRTC event: iceConnectionStateChange Event {isTrusted: true, type: "iceconnectionstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12533 sending candidate {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922305907", broadcaster: undefined, roomType: "video", type: "candidate", …}
latest-v3.js:12305 SimpleWebRTC event: message {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922305907", broadcaster: undefined, roomType: "video", type: "candidate", …}
latest-v3.js:12533 sending endOfCandidates {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922305907", broadcaster: undefined, roomType: "video", type: "endOfCandidates", …}
latest-v3.js:12305 SimpleWebRTC event: message {to: "Friz1VcnIyKAGZJqAAAB", sid: "1522922305907", broadcaster: undefined, roomType: "video", type: "endOfCandidates", …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting candidate {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "candidate", payload: {…}, …}
latest-v3.js:12489 getting endOfCandidates {to: "w3kEIOToMBmjldi0AAAA", sid: "1522922305907", roomType: "video", type: "endOfCandidates", prefix: "webkit", …}
latest-v3.js:12305 SimpleWebRTC event: iceConnectionStateChange Event {isTrusted: true, type: "iceconnectionstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: channelOpen RTCDataChannel {label: "simplewebrtc", ordered: true, maxRetransmitTime: 65535, maxRetransmits: 65535, protocol: "", …} Event {isTrusted: true, type: "open", target: RTCDataChannel, currentTarget: RTCDataChannel, eventPhase: 2, …}
app.js:31 video removed  Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
app.js:37 <div class=​"remotes" id=​"activeWindow" style=​"top:​ 100px;​ left:​ 100px;​">​</div>​
latest-v3.js:12305 SimpleWebRTC event: videoRemoved <video autoplay id=​"Friz1VcnIyKAGZJqAAAB_video_incoming">​</video>​ Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12305 SimpleWebRTC event: peerStreamRemoved Peer {id: "Friz1VcnIyKAGZJqAAAB", parent: WebRTC, type: "video", oneway: false, sharemyscreen: false, …}
latest-v3.js:12665 []
latest-v3.js:12666 MediaStream {id: "uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn", active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}
latest-v3.js:12647 ended
latest-v3.js:12649 MediaStream {id: "uSeKJG0kD3J5qtXRWaqR6Iz70iatSmHxS0Yn", active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}
latest-v3.js:12650 (2) [MediaStreamTrack, MediaStreamTrack]
latest-v3.js:12305 SimpleWebRTC event: iceConnectionStateChange Event {isTrusted: true, type: "iceconnectionstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: signalingStateChange Event {isTrusted: true, type: "signalingstatechange", target: RTCPeerConnection, currentTarget: RTCPeerConnection, eventPhase: 2, …}
latest-v3.js:12305 SimpleWebRTC event: channelClose RTCDataChannel {label: "simplewebrtc", ordered: true, maxRetransmitTime: 65535, maxRetransmits: 65535, protocol: "", …} Event {isTrusted: true, type: "close", target: RTCDataChannel, currentTarget: RTCDataChannel, eventPhase: 2, …}

At second visit first client can't take video stream: latest-v3.js:12639 Already have a remote stream

var webrtc = new SimpleWebRTC({
// the id/element dom element that will hold "our" video
localVideoEl: 'localVideo',
// the id/element dom element that will hold remote videos
remoteVideosEl: '',
// immediately ask for camera access
autoRequestMedia: false,
debug: true,
detectSpeakingEvents: false
});

webrtc.on('readyToCall', function () {
// you can name it anything
webrtc.joinRoom(room);
});

webrtc.on('videoAdded', function (video, peer) {
console.log('video added', peer);
var remotes = document.getElementById('activeWindow');
//console.log(remotes);
if (remotes) {
    var d = document.createElement('div');
    d.className = 'videoContainer';
    d.id = 'container_' + webrtc.getDomId(peer);
    d.appendChild(video);
    remotes.appendChild(d);
}
});

webrtc.on('videoRemoved', function (video, peer) {
console.log('video removed ', peer);
var remotes = document.getElementById('activeWindow');
var el = document.getElementById('container_' + webrtc.getDomId(peer));
if (remotes && el) {
    remotes.removeChild(el);
}
console.log(document.getElementById('activeWindow')); 
});
var room;

onJoinRoom

    $(".video").clone().appendTo(bV.$dialog)
    .removeClass("markup")
    .attr("id", "localVideo")
    .css({
        top: 300,
        left: 300
    });

    $(".remotes").clone().appendTo(bV.$dialog)
    .attr("id", "activeWindow")
    .css({
        top: 100,
        left: 100
    });

    console.log(webrtc);

    room = bJ.toLowerCase();
    console.log(room);
    console.log('Opening');
    webrtc.startLocalVideo();

onLeaveRoom

    console.log('Closing');
    webrtc.stopLocalVideo();
    webrtc.leaveRoom(room);

    console.log(webrtc);

I make webrtc.startLocalVideo() when client joins room and webrtc.stopLocalVideo() when leaves.

If I bypass webrtc.stopLocalVideo() (don't stop user's camera even then he is not in room) all is ok.

xdumaine commented 6 years ago

This may be a bug with simplewebrtc. Looks like when you leave the room we call end on a peer and handleStreamRemoved() but don't actually null out the stream. Then later, when you get a new stream for them, it gives that message.

@Kubera2017 could you try this in onLeaveRoom -

console.log('Closing');
webrtc.stopLocalVideo();
webrtc.leaveRoom(room);
webrtc.webrtc.peers.forEach(function (peer) { peer.stream = null });

If that fixes your problem, then we may just need to null out the stream when leaving. Let me know.

ne0x commented 6 years ago

I have the same problem. I tried. Unfortunately, the solution doesn't help.

WangYuLue commented 6 years ago

I also have the same problem

JakeTrock commented 6 years ago

@Kubera2017 if you don't have this problem anymore, can you resolve this thread?

Kubera2017 commented 6 years ago

The problem is still exists. And this is the one of crucial features witch is required for building apps with the framework.

JakeTrock commented 6 years ago

alright

codingmikesh commented 6 years ago

stopLocalVideo don't remove the localStreams array in webrtc. You have to reset this array.