I have RTCPeerConnection between 2 peers. These 2 peers can exchange messages and everything works fine in their communication. But now I would like to add a stream to this RTCPeerConnection. I do It like that:
if(stream)if(This.myRTCMediaConnections[id][hash].addTrack){
stream.getTracks().forEach(function(track){
This.myRTCMediaConnections[id][hash].addTrack(track,stream)
})
}
else This.myRTCMediaConnections[id][hash].addStream(stream)
after I do so the ontrack event fires on another side:
this.myRTCMediaConnections[id][hash].ontrack=function(e){
if(CAE(This.callRequests,id)){
delete This.callRequests[id]
This.insertVideoElement(logicGroupName,targetId,id,hash,e.streams[0],!noVideo)
}
}
where I add video element like this:
video.srcObject=stream
However it creates an empty video tag where "loadeddata" event never fires which means that there is something wrong with the received stream.
Can anyone guide me what I am doing wrong and is there a way to add stream to existing RTCPeerConnection?
Thanks!