-
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 enable_recording api for audiobridge plugin. #2674
Conversation
rajneeshksoni
commented
May 26, 2021
•
edited
Loading
edited
- Added support in audio bridge plugin to start/stop recording in the middle of call.
- This is using the similar structure as "enable_recording" of videoroom plugin.
- WAV file is created with start timestamp so that audiobridge output can be combined with mrj dumps from videoroom
- i think it still have issue, when the 'janus_audiobridge_mixer_thread' is not closed, we probably need to update the wav header during the audioroom destroy call.
Thanks for your contribution, @rajneeshksoni! Please make sure you sign our CLA, as it's a required step before we can merge 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.
Thanks! We don't use the recording to WAV, so I can't say I care much about the feature, but I understand how you and others may actually benefit from this.
I added a few notes inline, mostly editorial.
@rajneeshksoni any update on my notes above? As a side note, please notice that there's apparently conflicts now that we've merged some new things in master. I suspect it may impact some code you moved around, since part of the changes are optional support for stereo mixing. |
@lminiero Sorry for the delay, i'll fix the conflict and update as per review comments. |
- remove the usage of lock and using atomic int
@lminiero can you check the fixes and provide your feedback. |
@rajneeshksoni I already have a review planned, but I'll need time to do that and go into the details, especially since there's recent merges to take into account. I'll get back to you as soon as I do that. |
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.
Added a few minor notes inline. I'll try to make some tests later today 👍
@rajneeshksoni I tested it and it seems to be working as expected 👍 I think there's something missing in the API, though, that is the filename you want to save to. At the moment, you can only specify a filename when creating the room, but that assumes your willingness to start recording something right away. With your new functionality, you may want to only start recording later, which means you didn't have the option of specifying where to save and with with filename base, but only an on/off trigger: as a result, all files were created in the folder I started Janus from. I think the |
@lminiero regarding "record_file" parameter in enable_recording, i have change the recording file naming format. it also contain the time stamp, e.g. for filename 'audiobridge', file is currently saved as audiobridge-timestamp. |
That's not how the AudioBrdge plugin works: |
@lminiero Since i have added "-timestamp" as well in the name, so i am but confused how 'record_file' should handle appending timestamp in the filename. Appending timestamp in filename is important for later combining with video. |
That's already what your code is trying to do, which means it would be broken if people passed
If |
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 changes! I still see some problems with the user-provided filenames, though: I've added a few comments inline.
@@ -1047,6 +1062,9 @@ static struct janus_json_parameter join_parameters[] = { | |||
{"rtp", JSON_OBJECT, 0}, | |||
{"secret", JSON_STRING, 0} | |||
}; | |||
static struct janus_json_parameter record_parameters[] = { | |||
{"record", JANUS_JSON_BOOL, JANUS_JSON_PARAM_REQUIRED} |
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.
Since there's record_file
too, now, it should be validates as well.
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.
record_file is optional parameter, if user do not supply parameter we are using default name. Do we still need to add it for validation ?
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.
ALL parameters need to be validated, optional or not. You'll see that we have a lot of parameters defined without JANUS_JSON_PARAM_REQUIRED
, for instance.
|
||
char filename[255]; | ||
if(audiobridge->record_file) { | ||
g_snprintf(filename, 255, "%s-%"SCNi64, audiobridge->record_file,audiobridge->rec_start_time); |
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 just be "%s"
, not "%s-%"SCNi64
: record_file
contains the .wav
extension already, which means you'd be appending the time after the extension, breaking it. There's no need to add the current time to the filename when it's provided by the end user: as explained in another comment, in that case it's the user's responsibility to provide unique filenames, or risk overwriting previous recordings otherwise.
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 wanted to record the timestamp in filename so that it can be used for audio video synchronisation, i fear if timestamp is added in with the API call, the delay between API call may not reflect the exact time.
Can we add ".wav" after the timestamp ?
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.
Again, that's not something YOU have to worry about. If people provide record_file
, than they may put the timestamp in the filename yourself. If you don't provide it, then your pattern does the job.
Can we add ".wav" after the timestamp ?
No, it would be a breaking change (since yout changes impact how recordings are started after create
too).
char extfilename[255]; | ||
if(audiobridge->record_file) { | ||
g_snprintf(extfilename, 255, "%s-%"SCNi64".%s", audiobridge->record_file, | ||
audiobridge->rec_start_time,rec_tempext); |
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.
Same here, no need for the start time. You can refer to how the code was before, to see how we handled that case ("%s%s%s"
).
I've made some tests and it looks like the feature doesn't work if there's no one in the room: in that case, if I stop the recording and then start it again, when a new person joins it will keep on recording media to the old file, and will probably result in a broken file when we try to update the header (because the filename we were keeping track of will be different than before). I suspect that's because of how the mixer thread works, which does close to nothing when the room is empty: as such, when the recording is stopped and then started again, when it reaches your code it finds the recording status the same as before, and so thinks nothing has changed. That said, I think this is something I can address myself. To speed things up, I'll address my notes above as well (missing parameter, recording file without timestamp), and maybe think of an alternative |
@lminiero I'll analyze the above issue and create separate PR for it. |
No need, I'm looking at it right now 👍 |
The above commit fixes it for me: it was enough to move the WAV init/update before the |
working for me. |