]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9922: [mod_conference] Auto Energy Level
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 3 May 2017 20:25:04 +0000 (15:25 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 3 May 2017 20:25:04 +0000 (15:25 -0500)
src/mod/formats/mod_local_stream/mod_local_stream.c
src/switch_resample.c

index 1a0d015d12156ccfc5ca8d01dcca15d45c79280a..8edba9aa944da717d06de2626e50424a956ba314 100644 (file)
@@ -1404,7 +1404,7 @@ SWITCH_STANDARD_API(local_stream_function)
                                                stream->write_function(stream, "-ERR invalid auto-volume level for stream: %s\n", source->name);
                                        } else {
                                                if (!source->agc) {
-                                                       switch_agc_create(&source->agc, source->energy_avg, source->energy_low, 10, 3, (1000 / source->interval) * 2);
+                                                       switch_agc_create(&source->agc, source->energy_avg, source->energy_low, 500, 3, (1000 / source->interval) * 2);
                                                } else {
                                                        switch_agc_set_energy_avg(source->agc, source->energy_avg);
                                                        switch_agc_set_energy_low(source->agc, source->energy_low);
index bd981f626f778e746dd2b0eef8590d40f421a89f..c9e1dc97596fcef7ebe849c02761a78786f5c689 100644 (file)
@@ -513,15 +513,23 @@ SWITCH_DECLARE(switch_status_t) switch_agc_feed(switch_agc_t *agc, int16_t *data
                        agc->score_count = 0;
                        agc->score_sum = 0;
                                                                        
-                       if (agc->score_avg > agc->energy_avg + agc->margin) {
-                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] OVER++ SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", 
-                                                                 agc->token, agc->score_avg, agc->energy_avg, agc->margin);
-                               agc->score_over++;
+                       if (agc->score_avg > agc->energy_avg) {
+                               if (agc->score_avg - agc->energy_avg > agc->margin) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] OVER++ SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", 
+                                                                         agc->token, agc->score_avg, agc->energy_avg, agc->margin);
+                                       agc->score_over++;
+                               }
                        } else {
                                agc->score_over = 0;
                        }
 
-                       if (agc->score_avg < agc->energy_avg - agc->margin && (agc->vol < 0 || agc->score_avg > agc->low_energy_point)) {
+                       if (agc->score_avg < agc->low_energy_point) {
+                               agc->score_under = agc->change_factor + 1;
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] BELOW LOW POINT, SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", 
+                                                                 agc->token, agc->score_avg, agc->energy_avg, agc->margin);
+                       } else if (((agc->score_avg < agc->energy_avg) && (agc->energy_avg - agc->score_avg > agc->margin))) {
+                               //&& (agc->vol < 0 || agc->score_avg > agc->low_energy_point)) {
+                               
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] UNDER++ SCORE AVG: %d ENERGY AVG: %d MARGIN: %d\n", 
                                                                  agc->token, agc->score_avg, agc->energy_avg, agc->margin);
                                agc->score_under++;
@@ -536,10 +544,12 @@ SWITCH_DECLARE(switch_status_t) switch_agc_feed(switch_agc_t *agc, int16_t *data
                                agc->vol--;
                                switch_normalize_volume_granular(agc->vol);
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] VOL DOWN %d\n", agc->token, agc->vol);
+                               //agc->score_over = 0;
                        } else if (agc->score_under > agc->change_factor) {
                                agc->vol++;
                                switch_normalize_volume_granular(agc->vol);
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "[%s] VOL UP %d\n", agc->token, agc->vol);
+                               //agc->score_under = 0;
                        }
 
                }