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

Send PLI when starting a paused stream #2645

Merged
merged 1 commit into from
Apr 26, 2021
Merged

Conversation

xadhoom
Copy link
Contributor

@xadhoom xadhoom commented Apr 21, 2021

We have noticed that sometimes resuming a paused stream takes long (even 10 seconds or more) before getting displayed on the subscriber. This depends on framerate / frame size (eg. on a nHD stream from a webcam with a somewhat high fps takes less than a desktop stream shared in FHD with maybe 3/5 fps), but also on the rtcp feedback from the browser that may not be immediate.

By sending a pli when starting the stream, the restart is more consistent.

This is a wip for the following reasons:

  • makes sense to always send a pli request or is better to add a parameter to the start request?
  • I'm not sure about the guard for the janus_videoroom_reqpli call, the one here is taken from the recording portion and seems ok
  • maybe is better to call it only if the subscriber is paused, so get's triggered only on stream resume?

@januscla
Copy link

Thanks for your contribution, @xadhoom! Please make sure you sign our CLA, as it's a required step before we can merge this.

@lminiero
Copy link
Member

I think you're modifying the wrong part of the code, if you want to resume a paused stream. The start request is used to send your SDP answer, as a subscriber, to the offer the plugin sent you, and so the negotiation is still ongoing. For startup, we already have a PLI when the PeerConnection goes up, in janus_videoroom_setup_media:

	janus_videoroom_reqpli(p, "New subscriber available");

There already is a PLI also for video subscriptions that had been paused via configure requests:

	janus_videoroom_reqpli(publisher, "Restoring video for subscriber");

@lminiero
Copy link
Member

Ok, I think I understand the point now: this is a start in response to a previous pause. Then yes, to answer your question above:

  • maybe is better to call it only if the subscriber is paused, so get's triggered only on stream resume?

I think this should only be done if the PC was up and previously paused, not always (otherwise it will try to always send a PLI during negotiation, before the PC even exists).

@xadhoom xadhoom force-pushed the master branch 2 times, most recently from acaa528 to 0befda2 Compare April 21, 2021 15:15
@xadhoom
Copy link
Contributor Author

xadhoom commented Apr 21, 2021

I think this should only be done if the PC was up and previously paused, not always (otherwise it will try to always send a PLI during negotiation, before the PC even exists).

Ok, moved inside the "paused" block, in order to be triggered only if the stream was previously paused.

@xadhoom xadhoom force-pushed the master branch 2 times, most recently from 2cba85f to e28ce0f Compare April 21, 2021 15:23
if(feed && g_atomic_int_get(&feed->started, 1)) {
/* Send a FIR */
janus_videoroom_reqpli(feed, "Subscriber start");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the if(subscriber->paused above, though. Indentation should be fixed too.
As a side note, I'd move the *feed initialization right before the check, since it's unused if we're not in subscriber->paused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, moved inside the paused if, along with the needed initialization and indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something is wrong into the g_atomic_int_get(&feed->started, 1), investigating on it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something is wrong into the g_atomic_int_get(&feed->started, 1), investigating on it

ok, it was if(feed && feed->session && g_atomic_int_get(&feed->session->started)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@xadhoom xadhoom changed the title WIP: Send PLI when starting a paused stream Send PLI when starting a paused stream Apr 21, 2021
@lminiero
Copy link
Member

Merging, thanks! 👍

@lminiero lminiero merged commit 541c00e into meetecho:master Apr 26, 2021
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Apr 29, 2021
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Jul 29, 2021
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Jul 29, 2021
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Jul 29, 2021
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Aug 2, 2021
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Nov 14, 2021
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Dec 7, 2021
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c

(cherry picked from commit 1827315)
heavyrain2012 pushed a commit to heavyrain2012/janus-gateway that referenced this pull request Jan 29, 2022
* meetecho_master: (345 commits)
  Remove support for framemarking RTP extension (meetecho#2640)
  Prevent race conditions on socket close in SIP and NoSIP plugins (meetecho#2599)
  Fixed overflow runtime error
  Fix for race condition between VideoRoom publisher leaving and subscriber hanging up (fixes meetecho#2582) (meetecho#2637)
  Send PLI when starting a paused stream (meetecho#2645)
  Prevent too high shift exponent
  Fixed type of seq/ts in file-based Streaming mountpoint threads
  Fix missing g_thread_unref when a streaming helper thread quits.
  Added custom headers for SIP INFO request (meetecho#2644)
  Free participant->user_id_str in case of opus enc/decoder error.
  Reject flexfec when offered, as still unsupported (see meetecho#2639)
  Don't add rtx ssrc if m-line is recvonly/inactive (see meetecho#2639)
  Added NULL checks for json_dumps (see meetecho#2629)
  Parse custom headers, if required, in successful REGISTER response (fixes meetecho#2636)
  Timestamp correction for janus-pp-rec (meetecho#2573)
  Don't chain error handler to success handler in Janus.httpAPICall (meetecho#2569)
  Add missing library link for WS event handler (fixes meetecho#2628)
  Fixed broken switch in Streaming plugin when using helper threads
  Resolves meetecho#2624 jansson double referencing (meetecho#2634)
  Unlock mountpoints mutex after the spawning of helper threads.
  ...

# Conflicts:
#	transports/janus_mqtt.c

(cherry picked from commit 1827315)
(cherry picked from commit b9318b7)
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

Successfully merging this pull request may close these issues.

None yet

3 participants