FS-8243 8b088c26fbf4eba3daaacfaa6e29ab765f7321ba breaks perfectly working fec, adding back the missing part that actually works in most surroundings

This commit is contained in:
Anthony Minessale 2015-10-03 02:38:00 -05:00
parent 5f210b4d75
commit dcdf4685af

View File

@ -281,6 +281,7 @@ static switch_bool_t switch_opus_has_fec(const uint8_t* payload,int payload_leng
int nb_silk_frames, nb_opus_frames, n, i;
opus_int16 frame_sizes[48];
const unsigned char *frame_data[48];
int frames;
if (payload == NULL || payload_length_bytes <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "corrupted packet (invalid size)\n");
@ -320,6 +321,22 @@ static switch_bool_t switch_opus_has_fec(const uint8_t* payload,int payload_leng
}
}
frames = opus_packet_parse(payload, payload_length_bytes, NULL, frame_data, frame_sizes, NULL);
if (frames < 0) {
return SWITCH_FALSE;
}
if (frame_sizes[0] <= 1) {
return SWITCH_FALSE;
}
for (n = 0; n <= (payload[0]&0x4);n++) {
if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) {
return SWITCH_TRUE; /*this works only for 20 ms frames now, it will return VAD for 40 ms or 60 ms*/
}
}
return SWITCH_FALSE;
}