Skip to content

Commit

Permalink
Fix postprocessing restamping (broken since commit f51524e for DTX su…
Browse files Browse the repository at this point in the history
…pport)
  • Loading branch information
atoppi committed Oct 27, 2023
1 parent 6b1e64c commit 9de4c13
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/postprocessing/janus-pp-rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,11 @@ int main(int argc, char *argv[]) {
}

/* Run restamping */
if(!video && !data && options.restamp_multiplier > 0) {
gboolean restamping = FALSE;
if(options.restamp_multiplier > 0) {
restamping = TRUE;
}
if(!video && !data && restamping) {
tmp = list;
uint64_t restamping_offset = 0;
double restamp_threshold = (double) options.restamp_min_th/1000;
Expand Down Expand Up @@ -1439,7 +1443,7 @@ int main(int argc, char *argv[]) {
/* Loop */
if(!video && !data) {
if(opus) {
if(janus_pp_opus_process(file, list, &working) < 0) {
if(janus_pp_opus_process(file, list, restamping, &working) < 0) {
JANUS_LOG(LOG_ERR, "Error processing Opus RTP frames...\n");
}
} else if(g711) {
Expand Down
5 changes: 3 additions & 2 deletions src/postprocessing/pp-opus.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int janus_pp_opus_create(char *destination, char *metadata, gboolean multiopus,
// It assumes ALL the packets are of the 20ms kind
#define OPUS_PACKET_DURATION 48 * 20;

int janus_pp_opus_process(FILE *file, janus_pp_frame_packet *list, int *working) {
int janus_pp_opus_process(FILE *file, janus_pp_frame_packet *list, gboolean restamping, int *working) {
if(!file || !list || !working)
return -1;
janus_pp_frame_packet *tmp = list;
Expand Down Expand Up @@ -251,7 +251,8 @@ int janus_pp_opus_process(FILE *file, janus_pp_frame_packet *list, int *working)
AVRational timebase = {1, 48000};

while(*working && tmp != NULL) {
if(tmp->prev != NULL && ((tmp->ts - tmp->prev->ts)/48/20 > 1) && (tmp->seq != tmp->prev->seq+1)) {
/* if restamping is being used, do not evaluate the sequence number jump */
if(tmp->prev != NULL && ((tmp->ts - tmp->prev->ts)/48/20 > 1) && (restamping || (tmp->seq != tmp->prev->seq+1))) {
JANUS_LOG(LOG_WARN, "Lost a packet here? (got seq %"SCNu16" after %"SCNu16", time ~%"SCNu64"s)\n",
tmp->seq, tmp->prev->seq, (tmp->ts-list->ts)/48000);
/* use ts differ to insert silence packet */
Expand Down
2 changes: 1 addition & 1 deletion src/postprocessing/pp-opus.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* Opus stuff */
const char **janus_pp_opus_get_extensions(void);
int janus_pp_opus_create(char *destination, char *metadata, gboolean multiopus, const char *extension, int opusred_pt);
int janus_pp_opus_process(FILE *file, janus_pp_frame_packet *list, int *working);
int janus_pp_opus_process(FILE *file, janus_pp_frame_packet *list, gboolean restamping, int *working);
void janus_pp_opus_close(void);

#endif

0 comments on commit 9de4c13

Please sign in to comment.