-
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 support for binary data recordings #2481
Conversation
} else { | ||
g_snprintf(filename, 256, "rec-%"SCNu64"-data", id); | ||
} | ||
rec->drc_file = g_strdup(filename); |
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.
nit: you could simplify this (and get rid of the intermediate filename
buffer) with just:
if(filename_text != NULL) {
rec->drc_file = g_strdup_printf("%s-data", filename_text);
} else {
rec->drc_file = g_strdup_printf("rec-%"SCNu64"-data", id);
}
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.
Oh I wasn't aware of g_strdup_printf
: since we do the same thing in a few other places as well (core and plugins), for the moment I'll keep this as it is, and then once we merge I'll change them all in a single commit. Thanks for the heads up!
@@ -2073,8 +2130,7 @@ void janus_recordplay_update_recordings_list(void) { | |||
*ext = '\0'; | |||
const char *textcodec = janus_recordplay_parse_codec(recordings_path, | |||
rec->drc_file, NULL, sizeof(NULL), NULL); | |||
if(textcodec) | |||
rec->textdata = TRUE; /* Binary recordings not supported yet */ | |||
rec->textdata = textcodec && (!strcasecmp(textcodec, "text")); |
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.
nit: no need for the extra parentheses around !strcasecmp()
here
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.
True, I just thought it made it less ambiguous.
Merging. |
This PR expands on the effort made by @ricardo-salgado-tekever in #2468, and adds support for recording binary data channels too, rather than just text data channels. It also fixed a few other things I noticed.
In mjr files, binary recordings are now marked as "binary" (where text-based data channel recordings were already marked as "text"). Since there's no way to know what data is stored in those files and so we can't expect a specific extension for the destination file as we do for other formats, while text based data recordings are still converted to
.srt
files, the postprocessor converts binary recordings to raw files instead: meaning that it will just extract the data from each packet, and append it one after the other in the file name you provide. This should be the easiest and simplest way of handling them, rather than ignoring them altogether.To test all this, I modified the Record&Play plugin to support saving data recordings as well (Ricardo's patch only added support for playout). To test this, you can add
?data=text
or?data=binary
as a query string argument to therecordplaytest.html
demo page, and the demo will show a text area where you can input some text: when you press enter, the message is sent to the plugin and saved to the file in the format you asked for. At the same time, the playout of a recording including data will render the messages in the same box (notice that binary data will simply be rendered as the presence of an ArrayBuffer object).This seems to be working fine in my setup: if you're using Record&Play in your applications, please test to ensure you don't encounter any regression. I plan to merge soon otherwise.