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

What does sender.generateKeyFrame() do when sender.track is null, ended or disabled? #185

Closed
jan-ivar opened this issue Jun 6, 2023 · 9 comments

Comments

@jan-ivar
Copy link
Member

jan-ivar commented Jun 6, 2023

Is sender.generateKeyFrame() expected to work if we have a null send track?

Maybe yes since it says it "MUST send black frames (video)" and "SHOULD send one black frame per second"?

@fippo
Copy link
Collaborator

fippo commented Jun 6, 2023

if the encoder has no input it can not produce a frame? Should I mention that awaiting generateKeyFrame is a flawed idea?

@jan-ivar
Copy link
Member Author

jan-ivar commented Jun 6, 2023

The input would be black frames no?

@youennf
Copy link
Collaborator

youennf commented Jun 6, 2023

The input would be black frames no?

Only for muted/enabled=false track.
For null tracks, If [track](https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-track) is null then the [RTCRtpSender](https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender) does not send.

This paragraph seems to induce that black frames are sent for ended tracks.
I am not sure browsers are doing this though (safari does not AFAIK except maybe if the track is muted/disabled while ended), we should check this.

My understanding matches @fippo's understanding, the promise will resolve when a key frame is generated, which may be very long if the track is not outputting any frame (canvas capture say).

For a null track, we can do whatever we want, the current behaviour will wait for a frame, which can only happen if an actual track is set via replaceTrack.

@jan-ivar jan-ivar changed the title What does sender.generateKeyFrame() do when sender.track is null? What does sender.generateKeyFrame() do when sender.track is null, ended or disabled? Jun 7, 2023
@jan-ivar
Copy link
Member Author

jan-ivar commented Jun 7, 2023

Thanks @youennf for correcting that null should not send. I misread that. I suppose step 1 is figuring out what the different browsers emit for disabled, ended, and null. But since all but ended may be transient, the answer may be that the promise simply doesn't resolve for a long time or ever.

@jan-ivar
Copy link
Member Author

jan-ivar commented Jun 7, 2023

Actually even ended is transient here if replaceTrack is used.

@youennf
Copy link
Collaborator

youennf commented Oct 5, 2023

Are we good there or do we need any clarification in the spec?

@jan-ivar
Copy link
Member Author

jan-ivar commented Oct 5, 2023

Promise will not resolve and we can close this issue.

@jan-ivar jan-ivar closed this as completed Oct 5, 2023
@youennf
Copy link
Collaborator

youennf commented Oct 5, 2023

Summary:

  • If the track is disabled and sender is sending, black frames will be generated and generateKeyFrame will trigger a key frame and will resolve
  • If the sender is not sending any frame, generateKeyFrame will never resolve.

@alvestrand
Copy link
Contributor

Note: in other contexts, we (Chrome) have found it necessary to generate a frame when a keyframe is asked for, even if we would normally not do so (for instance when capturing a tab that doesn't have any change).

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

4 participants