Merge pull request #1737 in FS/freeswitch from ~THEHUNMONKGROUP/freeswitch:bugfix/FS-11873-addstream-adds-audio-video-tracks-in-random-order-use-spec-compliant-addtrack to master

* commit 'f1bc56d65b44f1d97e1e9c690175fa8757e42c29':
  Fix FS-11873: addStream() adds audio/video tracks in random order
This commit is contained in:
Mike Jerris 2019-05-31 12:55:51 -05:00
commit ed135a21d5
1 changed files with 7 additions and 1 deletions

View File

@ -767,7 +767,13 @@
};
// attachStream = MediaStream;
if (options.attachStream) peer.addStream(options.attachStream);
if (options.attachStream) {
// FreeSWITCH currently orders its answer SDP such that audio m-lines
// always come first, adding the tracks to the peer in that order
// prevents possible m-line ordering validation errors on the client.
options.attachStream.getAudioTracks().forEach(function(track) { peer.addTrack(track, options.attachStream) });
options.attachStream.getVideoTracks().forEach(function(track) { peer.addTrack(track, options.attachStream) });
}
// attachStreams[0] = audio-stream;
// attachStreams[1] = video-stream;