]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Merge pull request #487 in FS/freeswitch from ~DRAGOS_OANCEA/freeswitch-dragos:opus...
authorMike Jerris <mike@jerris.com>
Fri, 2 Oct 2015 17:52:51 +0000 (12:52 -0500)
committerMike Jerris <mike@jerris.com>
Fri, 2 Oct 2015 17:52:51 +0000 (12:52 -0500)
* commit '6385fb863a7e800dbb2668fd0ed4e1203b1ba18e':
  FS-8161: mod_opus: Keep FEC enabled only if loss > 10 ( otherwise PLC is supposed to be better)

1  2 
src/mod/codecs/mod_opus/mod_opus.c

index 52dbffc4aaad41e5ad37884c9ee09171d83c8170,74f797512ad108cdd74213b61cc236ecac7e7506..7829effd7a8fd77e5d76dd43f3a441d55eea3590
@@@ -308,17 -309,37 +308,44 @@@ static switch_bool_t switch_opus_has_fe
        return  SWITCH_FALSE;
  }
  
+ /* this is only useful for fs = 8000 hz, the map is only used
+  * at the beginning of the call. */
+ static int switch_opus_get_fec_bitrate(int fs, int loss)
+ {
+       int threshold_bitrates[25] = {
+               15600,15200,15200,15200,14800,
+               14800,14800,14800,14400,14400,
+               14400,14000,14000,14000,13600,
+               13600,13600,13600,13200,13200,
+               13200,12800,12800,12800,12400
+       };
+       if (loss <= 0){
+               return SWITCH_STATUS_FALSE;
+       } 
+       if (fs == 8000) {
+               if (loss >=25) { 
+                       return threshold_bitrates[24];
+               } else {
+                       return threshold_bitrates[loss-1];
+               }
+       }
+       return SWITCH_STATUS_FALSE ; 
+ }
  static switch_status_t switch_opus_info(void * encoded_data, uint32_t len, uint32_t samples_per_second, char *print_text)
  {
 -      int nb_samples;
 -      int nb_frames;
 +      /* nb_silk_frames: number of silk-frames (10 or 20 ms) in an opus frame:  0, 1, 2 or 3 */
 +      /* computed from the 5 MSB (configuration) of the TOC byte (encoded_data[0]) */
 +      /* nb_opus_frames: number of opus frames in the packet */
 +      /* computed from the 2 LSB (p0p1) of the TOC byte */
 +      /* p0p1 = 0  => nb_opus_frames= 1 */
 +      /* p0p1 = 1 or 2  => nb_opus_frames= 2 */
 +      /* p0p1 = 3  =>  given by the 6 LSB of  encoded_data[1] */
 +
 +      int nb_samples, nb_silk_frames, nb_opus_frames, n, i; 
        int audiobandwidth;
        const char *audiobandwidth_str = "UNKNOWN";
        opus_int16 frame_sizes[48];