Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
WebRTC - How to add MediaStream to existing RTCPeerConnection (which has not any MediaStream attached)

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!