4

enter image description here

localStreams and remoteStreams both are of type “MediaStreamList”. localStreams contains “LocalMediaStream” objects

However, remoteStreams contains “MediaStream” objects

Why so difference?

When I use “localStreams” – it works for me:

localVideo.src = URL.createObjectURL(localStreams[0]);

But if I try to use “remoteStreams” – it doesn’t work:

remoteVideo.src = URL.createObjectURL(remoteStreams[0])

Blobs for “remoteStreams” and “localStreams” are looking same in style.

Why “remoteStreams” doesn’t work for me (in “onaddstream” event or directly) ???

remoteVideo.src = URL.createObjectURL(secondPeer.remoteStreams[0])
"blob:http%3A//localhost%3A8082/78e8821f-90b8-4703-b56d-918ec505e5bf"

Live Demo:--- https://muazkh.appspot.com/?page=WebRTC

Muaz Khan
  • 7,138
  • 9
  • 41
  • 77

1 Answers1

0

LocalMediaStream is being replaced by the MediaStream interface.

On simpl.info/pc, try this from the console in Chrome Stable and Canary:

localPeerConnection.getLocalStreams()[0];
remotePeerConnection.getRemoteStreams()[0];
Sam Dutton
  • 14,775
  • 6
  • 54
  • 64
  • It means that "remote streams attachment" is possible, Sam, for further forwarding? It failed all the time. Experiment shows that it is still failing: https://googledrive.com/host/0B6GWd_dUUTT8V1Fodm9WQldkb28/Attaching-Remote-MediaStreams.html ----- sorry for out of topic question. – Muaz Khan May 25 '13 at 01:33
  • Hi Sam and @MuazKhan the `getRemoteStreams` is now deprecating, do we have work around method? – Xin Jul 27 '18 at 05:32
  • Hi @Xin — take a look at https://webrtc.github.io/samples/src/content/peerconnection/constraints for an alternative (do it yourself!) approach. Also in adapter.js: https://github.com/webrtc/adapter/blob/b5100538591ce6938e24d7912dbba9ebb938ecfb/release/adapter.js#L400 – Sam Dutton Jul 27 '18 at 17:41
  • 1
    Hi @Xin, you can use "peer.getReceivers()". You will get two MediaStreamTrack objects using "receiver.track" property. Now you can merge these tracks using "new MediaStream([track1, track1])" or "stream.addTrack". Example: https://www.webrtc-experiment.com/webrtcpedia/#getremotestreams-alternative – Muaz Khan Jul 28 '18 at 04:29
  • Thank you very much – Xin Aug 08 '18 at 06:15