-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add pause/resume recording functionality to Record&Play and SIP plugins #2724
Conversation
I remember this was attempted already in #918, which I had several doubts on. I think your patch has a similar issue in how recordings are handled, because the way you're doing it in SIP and Record&Play this will simply introduce big holes in the recording when postprocessing: when you pause and resume after a while, packets will have huge timestamp/seq number changes, which will translate to either a ton of silence, or missing video. |
Yes, that is by design. |
Perhaps this can be ammended by writing silence timespans into the recording header, so that after or during post processing those segments can be skipped? |
I don't think that's correct. A pause/resume should be seamless in the recording too.
MJR headers can't be edited after they're written, and I don't like the idea of making a lot of changes to janus-pp-rec to accomodate this. |
I see the packet timestamps are calculated by recorder, then the solution can be to track the total paused time and subtracting it when calculating timestamps? This should make the pause seamless in both playing and postprocessing. |
The solution is to write packets to the recorder that have consistent RTP headers, as we do in other plugins e.g. for source switching and RTP forwarders. |
Going through the code i see you use |
My guess is that, once you add the context in the mix, you can just trigger its behaviour by changing its SSRC before a resume (which will trick it into thinking the source changed and so headers need to be updated). |
Updated PR with requested changes. Just changing the ssrc did not work - I had to add time offset information. |
From a quick glance to the code I don't think you're using the RTP context correctly. Timestamp offset management is already done automatically by RTP contexts, when the SSRC changes: it looks to me like you're just resetting the sequence number instead, which is why you're forced to manually fix the timestamp. When recording is resumed, it's the SSRCs in the context you have to change ( |
I tried to just reset the ssrc by changing the one in the context, but as I said it does not work - the silence during the pause duration remained in the recording. This is because the base timestamp is reset, but the offset is then calcualted and applied (denoted by the |
Ah I think I understand what you mean now: the SSRC change forces sequence number and timestamp to be updated, but the timestamp will take into account the time that passed, and so a lot of silence will be inserted, which shouldn't indeed happen in this case. That said, I don't think the way you're updating the timestamp offset works, and I don't like the idea of adding new properties to an already crowded structure. It should be possible to do this with the properties already there. |
I have updated CR as requested. I have managed to remove the silence between pauses by overwriting |
Thanks! I'll need time to review, since your changes modifies the code of the context update method as well, which can have a huge impact (we use it pretty much everywhere). |
The context update method has not been functionally changed, I just extracted the |
So basically: if(ssrc != context->a_last_ssrc) {
...
// ts_reset code
// seq_reset code
...
} became: if(ssrc != context->a_last_ssrc) {
...
context->a_ts_reset = TRUE;
context->a_seq_reset = TRUE;
...
}
if(context->a_ts_reset) {
// ts_reset code
}
if(context->a_seq_reset) {
// seq_reset code
} |
Hey @lminiero, if you have the time please take a look. |
It's IETF week so not sure when I'll be able to do a deep dive. I'll try to add some comments to the PR when I can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had another look at the changes: please notice I haven't tested this yet, which will probably not happen before next week.
Updated PR with requested changes. |
Hey @lminiero, any updates? |
@isnumanagic apologies, I went on vacation and forgot about this 🤭 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while, but I found some time to test this: it seemed to work as expected for the brief test I made, even though I didn't push it much. I did notice some UI things, though (pause button still visible when replaying recordings), and some messaging/state things related to how pause/resume are handled that may need fixing (I'll try to make some tests for that too).
Uodated PR with requested changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fixes! I added a couple more notes: I think we're close to merging this ✌️
Updated PR with requested changes |
LGTM now, thanks for all the fixes! Pinging @atoppi to give a review as well (in case I missed anything), and @alexamirante to check if this might cause issues with the way we handle recordings in production. |
this looks good, I just don't get why we need the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left my only question as a separate comment ^
@atoppi It was a design choice. It's more intuitive to set ts_reset and seq_reset flags when resuming recording, than to manually change SSRC, expecting it to reset timestamp and sequence number. |
ok, thanks or clarifying, LGTM 👍 |
Ack, merging then 👍 Thanks for the patience! |
@isnumanagic you created a monster: I'm way too often using the pause/resume feature just to do funny faces! I see a potential for doing TikTok like videos with WebRTC 🤣 |
This PR adds pause/resume functionality to Janus recorder, and implements signaling for it in Record&Play and SIP plugins.
This functionality is useful when relaying sensitive information during recorded meeting. It is implemented by skipping writing of RTP packets during the pause duration. On resume we request PLI to fix any video artifacts that can occur due to skipped frames in recording.