-
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
Added changes to pause & resume recorder #918
Added changes to pause & resume recorder #918
Conversation
Thanks for working on this! From a quick glance there are some things that need to be fixed, though:
|
@lminiero below are my comments
|
Just a ping to tell you I haven't forgotten about this PR... I'm just awfully busy this period and can't look into it yet, sorry. That said, |
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.
Tried doing a deeper review. I'm not 100% sure this fits nicely in how we do things in all plugins and in the post-processor, but I'd have to try this. It definitely has interesting concepts, though, so in case I try to tackle this myself later on this would help greatly. Thanks again for working on this!
record.h
Outdated
@@ -48,6 +48,10 @@ typedef struct janus_recorder { | |||
gint64 created; | |||
/*! \brief Media this instance is recording */ | |||
janus_recorder_medium type; | |||
/*! \brief Timestaps for pause and resume the recording */ |
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.
pausing and resuming
record.h
Outdated
@@ -48,6 +48,10 @@ typedef struct janus_recorder { | |||
gint64 created; | |||
/*! \brief Media this instance is recording */ | |||
janus_recorder_medium type; | |||
/*! \brief Timestaps for pause and resume the recording */ | |||
gint64 paused_ts, offset_ts; | |||
/*! \brief Whether recording paused or not */ |
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.
Whether the recording has been paused or not
record.h
Outdated
* @param[in] recorder The janus_recorder instance | ||
* @param[in] boolean Whether to pause or resume | ||
* @returns 0 in case of success, a negative integer otherwise */ | ||
int janus_recorder_pause(janus_recorder *recorder, gboolean pause); |
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'd rather have two separate methods, janus_recorder_pause
and janus_recorder_resume
, as from a semantic perspective a method called janus_recorder_pause
that can be used to resume as well is counter-intuitive.
plugins/janus_videoroom.c
Outdated
@@ -506,6 +506,7 @@ typedef struct janus_videoroom_publisher { | |||
gint64 fir_latest; /* Time of latest sent FIR (to avoid flooding) */ | |||
gint fir_seq; /* FIR sequence number */ | |||
gboolean recording_active; /* Whether this publisher has to be recorded or not */ | |||
gboolean recording_pause; |
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.
This is nitpicking, I know, but recording_paused
is a better name for this. Can you also add a comment on the side, as we do for the other properties?
plugins/janus_videoroom.c
Outdated
@@ -2699,7 +2699,18 @@ static void janus_videoroom_recorder_create(janus_videoroom_publisher *participa | |||
} | |||
} | |||
} | |||
|
|||
static void janus_videoroom_recorder_pause(janus_videoroom_publisher *participant, gboolean paused) { |
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.
See below for the semantic names. In this case, to keep things compact, the name could be changed to janus_videoroom_recorder_status
or something like this, in order to keep the boolean flag.
@@ -3349,6 +3362,28 @@ static void *janus_videoroom_handler(void *data) { | |||
} | |||
} | |||
} | |||
if(record_pause) { |
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.
There is no check here on whether arc
, vrc
or drc
exist. Trying to pause/resume a non existing recording should return an error, while in this case you're always succeeding no matter what.
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.
This is important, because you may set a recording to paused and then start it, and the fact that both succeeded may make you think that you started the recording as paused, and you can resume it later, which is not the case.
plugins/janus_videoroom.c
Outdated
@@ -2964,6 +2975,7 @@ static void *janus_videoroom_handler(void *data) { | |||
publisher->video_active = FALSE; | |||
publisher->data_active = FALSE; | |||
publisher->recording_active = FALSE; | |||
publisher->recording_pause = FALSE; |
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.
This should be reset in hangup_media
as well. As a side note, it might be useful to have this property returned when doing query_session
as well, as we have a section related to recording in there when querying publishers.
plugins/janus_videoroom.c
Outdated
JANUS_LOG(LOG_VERB, "Video keyframe, sending PLI to %"SCNu64" (%s)\n", | ||
participant->user_id, participant->display ? participant->display : "??"); | ||
gateway->relay_rtcp(participant->session->handle, 1, buf, 12); | ||
} |
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.
Why is this request not generating any event to confirm the success?
record.c
Outdated
recorder->offset_ts = (uint32_t) recorder->offset_ts + (ntohl(rtp->timestamp) - (uint32_t)recorder->paused_ts); | ||
JANUS_LOG(LOG_INFO, "RESUME TIME TS = %u OFFSET=%u \n", rtp->timestamp, recorder->paused_ts, recorder->offset_ts); | ||
} | ||
recorder->paused_ts = 0; |
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.
What happens here when you pause/resume more than once? Not sure this would still work. Besides, there's no fix to the sequence numbers, which means they won't be sequential, with big holes in between. This will cause severe issues when trying to replay them via Record&Play, because the recipient will think packets have been missed, and NACK them. This is one of the reasons why I'm insisting on using the RTP context here too, as it's one of the things it takes care of for you.
Closing as this is based on a pull request we since closed (ICE restarts). |
As @lminiero suggested in discussion , i created the pull request to pause & resume the active recording by manipulating RTP Time-stamps.