4

I am doing a WebRTC implementation with Angular and SIPjs. Remote media works OK, but I have problems to add the local media because the sender´s track property returns null instead of the MediaStreamTrack object being supposedly right stored.

I am using SIPjs 0.13.6, the problem happens in, at least, both Chrome, Version 73.0.3683.86 (Official Build) (64-bit), and Firefox 65.0.2 (64-bit). SIP server is Asterisk inside a Docker,

var localStream = new MediaStream();

pc.getSenders().forEach(function(sender) {
   localStream.addTrack(sender.track); //throws error because it says is null
});

I did these tests with the following results, the thing is the track is supposedly there but when I try to access, it is null...


 console.log("peer connection array og sender objects:");
 console.log(pc.getSenders());

Result, it seems to be one mediaStreamTrack inside the first element of the array returned by the getSenders() method:

I cant post pictures because I need more reputation to do it, so I must dio these way:

[RTCRtpSender]
    0: RTCRtpSender
        dtmf: RTCDTMFSender {ontonechange: null, canInsertDTMF: false, toneBuffer: ""}
        track: MediaStreamTrack {kind: "audio", id: "26f1da43-56f3-48d8-882f- 
        03f9b4dad7d5", label: "Default - External Microphone (Conexant ISST 
        Audio)", enabled: true, muted: false, …}
    __proto__: RTCRtpSender
length: 1
__proto__: Array(0)

Next, I access the first object of that array:

console.log("first element of the array sender objects");
console.log(pc.getSenders()[0]);

Result, as you see, here start the weird (for me) things. The object seems to have a null track, but when you display the object, the MediaStreamTrack object seems to be there...


RTCRtpSender {track: null, dtmf: RTCDTMFSender}
    dtmf: RTCDTMFSender {ontonechange: null, canInsertDTMF: false, 
        toneBuffer: ""}
    track: MediaStreamTrack {kind: "audio", id: "26f1da43-56f3-48d8-882f- 
        03f9b4dad7d5", label: "Default - External Microphone (Conexant ISST 
        Audio)", enabled: true, muted: false, …}
__proto__: RTCRtpSender

The third thing I did, was trying to access the track's property value:


console.log("the track of the sender above is");
console.log(pc.getSenders()[0].track);

And it shows null:

null

Then it throws an error when I try to iterate over the getSenders() result to get each sender's track and add it to a MediaStream object like shown in the first piece of code of the post

Fran
  • 111
  • 1
  • 3

0 Answers0