str0m icon indicating copy to clipboard operation
str0m copied to clipboard

`Event::MediaAdded` is not fired for medias added in local offer

Open alexlapa opened this issue 1 year ago • 8 comments

The MediaAdded event documentation states that

This event fires both for negotiations triggered by a remote or local offer.

Which is not the case, since it is emitted only for media lines added via remote offer, and it seems that firing these event for local offer is explicitly disabled right here: 0, 1.

And, yeah, while this is an apply_answer() function it is also when local offer is being applied too, so i guess it should also cause MediaAdded event to fire.

So is this an expected behaviour and outdated documentation or a bug? I can prepare a PR if its the second case.

alexlapa avatar Sep 26 '24 15:09 alexlapa

Very good question. 🤔

It sounds like a bug. @xnorpx, @k0nserv, @davibe anyone got thoughts?

lolgesten avatar Sep 26 '24 16:09 lolgesten

We only use direct API, but if I remember correctly, it will fire for local added streams.

xnorpx avatar Sep 26 '24 17:09 xnorpx

I don't think we should fire it when the user explicitly added the media, I believe this aligns with the spec too. I consulted our usage too, we don't expect it to fire on locally added media

k0nserv avatar Sep 26 '24 17:09 k0nserv

So a PR adjusting the doc to that effect?

algesten avatar Sep 26 '24 17:09 algesten

So a PR adjusting the doc to that effect?

I think so yes.

k0nserv avatar Sep 27 '24 10:09 k0nserv

We only use direct API, but if I remember correctly, it will fire for local added streams.

I did verify that when we add our local streams with direct API we are getting MediaAdded events.

(We are not using it)

xnorpx avatar Sep 30 '24 15:09 xnorpx

I did verify that when we add our local streams with direct API we are getting MediaAdded events.

Ah, and I'm using SDP api and not getting MediaAdded for media that's added in local offer.

I don't think we should fire it when the user explicitly added the media, I believe this aligns with the spec too.

I'm okay with both options, just want to be sure that it works as expected and won't change someday.

So a PR adjusting the doc to that effect?

Works for me. I'll prepare a PR (regarding RTX cache drop ratio) in the next few days and i can update this doc there. So feel free to close this issue, or I'll close it after doc is updated.

alexlapa avatar Oct 01 '24 11:10 alexlapa

I did verify that when we add our local streams with direct API we are getting MediaAdded events.

Ok. So PR to fix docs and change this behavior.

algesten avatar Oct 02 '24 19:10 algesten

@xnorpx

I did verify that when we add our local streams with direct API we are getting MediaAdded events.

Wonder if this was with an older str0m? In my fix in #655 I wrote a test for this but I don't find that declare_media results in MediaAdded.

algesten avatar May 18 '25 09:05 algesten

@xnorpx

I did verify that when we add our local streams with direct API we are getting MediaAdded events.

Wonder if this was with an older str0m? In my fix in #655 I wrote a test for this but I don't find that declare_media results in MediaAdded.

Possible, I can see if I get time to verify this again this week.

xnorpx avatar May 18 '25 19:05 xnorpx