Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onremotestream called twice for each remote stream #1313

Closed
imaustink opened this issue Jul 24, 2018 · 4 comments
Closed

onremotestream called twice for each remote stream #1313

imaustink opened this issue Jul 24, 2018 · 4 comments

Comments

@imaustink
Copy link

It seems that the ontrack event listener on instances of RTCPeerConnection is being called twice for each peer connection added to the session.

I first observed this behavior in my application and confirmed it is consistent with the videoroom demo.

Since the ontrack handler is native funcationality, that leads me to beleive this is caused by Janus sending the same stream multiple times.

Steps to reproduce:

  1. Open the videoroom demo
  2. Put a break point here
  3. Join the room with a remote peer already in the room
@imaustink
Copy link
Author

Upon further inspection, it seems that ontrack is called once for audio and again for video, which seems alright. However, this results in onremotestream getting called twice twice with the same MediaStream, which seems wrong to me.

@imaustink imaustink changed the title RTCPeerConnection.prototype.ontrack called twice for each remote stream onremotestream called twice for each remote stream Jul 25, 2018
@lminiero
Copy link
Member

Actually it's not an issue or bug, but a direct consequence of when we introduced ontrack support in #942. You can find an explanation in the description there. All the demos handle this, so you can refer to those to see how to do it in your application instead. Closing.

@imaustink
Copy link
Author

Thanks for the quick response, @lminiero!

While I understand this isn't strictly speaking a "bug", I think it makes consuming remote streams just a bit clumsy. I am aware this is on the edge of OCD, but anytime I see an opportunity to make an interface cleaner I will always opt for it, especially in the open source world.

I would be happy to submit a PR to change this behavior, or, at the very least, submit a PR to document this behavior. If you are open to either, please let me know and I would jump at the opportunity to assist.

@lminiero
Copy link
Member

lminiero commented Jul 26, 2018

Since this would mean messing with MediaStream instances, both in janus.js and in the application itself, I think it's not a good idea and would rather keep it the way it is. Besides, how would I know that the fact I only get video the second time means that this is to be added to the audio I got before, and not that audio has been removed? I don't think the way it works now is broken, but should rather be seen as updates to what the current stream is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants