#define PORT_LONGTEXT N_("TCP port to use to communicate with the video "\
"part of the Bar Graph (default 12345)." \
"Use the same port as the one used in the rc interface." )
-#define BARGRAPH_TEXT N_("Defines if BarGraph information should be send (default 1)")
-#define BARGRAPH_LONGTEXT N_("Defines if BarGraph information should be send. "\
+#define BARGRAPH_TEXT N_("Defines if BarGraph information should be sent (default 1)")
+#define BARGRAPH_LONGTEXT N_("Defines if BarGraph information should be sent. "\
"1 if the information should be sent, 0 otherwise (default 1)." )
#define BARGRAPH_REPETITION_TEXT N_("Sends the barGraph information every n audio packets (default 4)")
#define BARGRAPH_REPETITION_LONGTEXT N_("Defines how often the barGraph information should be sent. "\
"Sends the barGraph information every n audio packets (default 4)." )
-#define SILENCE_TEXT N_("Defines if silence alarm information should be send (default 1)")
-#define SILENCE_LONGTEXT N_("Defines if silence alarm information should be send. "\
+#define SILENCE_TEXT N_("Defines if silence alarm information should be sent (default 1)")
+#define SILENCE_LONGTEXT N_("Defines if silence alarm information should be sent. "\
"1 if the information should be sent, 0 otherwise (default 1)." )
#define TIME_WINDOW_TEXT N_("Time window to use in ms (default 5000)")
#define TIME_WINDOW_LONGTEXT N_("Time Window during when the audio level is measured in ms for silence detection. "\
#define ALARM_THRESHOLD_LONGTEXT N_("Threshold to be attained to raise an alarm. "\
"If the audio level is under the threshold during this time, "\
"an alarm is sent (default 0.1)." )
-#define REPETITION_TIME_TEXT N_("Time between two alamr messages in ms (default 2000)" )
+#define REPETITION_TIME_TEXT N_("Time between two alarm messages in ms (default 2000)" )
#define REPETITION_TIME_LONGTEXT N_("Time between two alarm messages in ms. "\
"This value is used to avoid alarm saturation (default 2000)." )
#define CONNECTION_RESET_TEXT N_("Force connection reset regularly (default 1)" )
set_capability( "audio filter", 0 )
set_category( CAT_AUDIO )
set_subcategory( SUBCAT_AUDIO_AFILTER )
-
- add_string( CFG_PREFIX "address", "localhost", NULL, ADDRESS_TEXT, ADDRESS_LONGTEXT, false )
- add_integer( CFG_PREFIX "port", 12345, NULL, PORT_TEXT, PORT_LONGTEXT, false )
- add_integer( CFG_PREFIX "bargraph", 1, NULL, BARGRAPH_TEXT, BARGRAPH_LONGTEXT, false )
- add_integer( CFG_PREFIX "bargraph_repetition", 4, NULL, BARGRAPH_REPETITION_TEXT, BARGRAPH_REPETITION_LONGTEXT, false )
- add_integer( CFG_PREFIX "silence", 1, NULL, SILENCE_TEXT, SILENCE_LONGTEXT, false )
- add_integer( CFG_PREFIX "time_window", 5000, NULL, TIME_WINDOW_TEXT, TIME_WINDOW_LONGTEXT, false )
- add_float( CFG_PREFIX "alarm_threshold", 0.1, NULL, ALARM_THRESHOLD_TEXT, ALARM_THRESHOLD_LONGTEXT, false )
- add_integer( CFG_PREFIX "repetition_time", 2000, NULL, REPETITION_TIME_TEXT, REPETITION_TIME_LONGTEXT, false )
- add_integer( CFG_PREFIX "connection_reset", 1, NULL, CONNECTION_RESET_TEXT, CONNECTION_RESET_LONGTEXT, false )
-
+
+ add_string( CFG_PREFIX "address", "localhost", ADDRESS_TEXT, ADDRESS_LONGTEXT, false )
+ add_integer( CFG_PREFIX "port", 12345, PORT_TEXT, PORT_LONGTEXT, false )
+ add_integer( CFG_PREFIX "bargraph", 1, BARGRAPH_TEXT, BARGRAPH_LONGTEXT, false )
+ add_integer( CFG_PREFIX "bargraph_repetition", 4, BARGRAPH_REPETITION_TEXT, BARGRAPH_REPETITION_LONGTEXT, false )
+ add_integer( CFG_PREFIX "silence", 1, SILENCE_TEXT, SILENCE_LONGTEXT, false )
+ add_integer( CFG_PREFIX "time_window", 5000, TIME_WINDOW_TEXT, TIME_WINDOW_LONGTEXT, false )
+ add_float( CFG_PREFIX "alarm_threshold", 0.1, ALARM_THRESHOLD_TEXT, ALARM_THRESHOLD_LONGTEXT, false )
+ add_integer( CFG_PREFIX "repetition_time", 2000, REPETITION_TIME_TEXT, REPETITION_TIME_LONGTEXT, false )
+ add_integer( CFG_PREFIX "connection_reset", 1, CONNECTION_RESET_TEXT, CONNECTION_RESET_LONGTEXT, false )
+
set_callbacks( Open, Close )
vlc_module_end ()
p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) );
if( !p_sys )
return VLC_ENOMEM;
-
+
p_sys->bargraph = var_CreateGetIntegerCommand( p_filter, "audiobargraph_a-bargraph" );
p_sys->bargraph_repetition = var_CreateGetIntegerCommand( p_filter, "audiobargraph_a-bargraph_repetition" );
p_sys->silence = var_CreateGetIntegerCommand( p_filter, "audiobargraph_a-silence" );
float sum;
int count = 0;
int i_ret;
-
+
nbChannels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
p_sys->nbChannels = nbChannels;
-
+
i_value = (float*)malloc(nbChannels * sizeof(float));
-
+
for (i=0; i<nbChannels; i++) {
i_value[i] = 0;
}
-
+
/* 1 - Compute the peack values */
for ( i = 0 ; i < (int)(p_in_buf->i_nb_samples); i++ )
{
}
}
max = pow( max, 2 );
-
+
if (p_sys->silence) {
/* 2 - store the new value */
new = (ValueDate_t*)malloc(sizeof(ValueDate_t));
if (p_sys->first == NULL) {
p_sys->first = new;
}
-
+
/* 3 - delete too old values */
while (p_sys->first->date < (new->date - (p_sys->time_window*1000))) {
p_sys->started = 1; // we have enough values to compute a valid total
p_sys->first = p_sys->first->next;
free(current);
}
-
+
/* If last message was sent enough time ago */
if ((p_sys->started) && (p_in_buf->i_pts > p_sys->lastAlarm + (p_sys->repetition_time*1000))) {
-
+
/* 4 - compute the RMS */
current = p_sys->first;
sum = 0.0;
}
sum = sum / count;
sum = sqrt(sum);
-
+
/* 5 - compare it to the threshold */
if (sum < p_sys->alarm_threshold) {
i=1;
i=0;
}
snprintf(message,255,"@audiobargraph_v audiobargraph_v-alarm %d\n",i);
-
+
msg_Dbg( p_filter, "message alarm : %s", message );
//TCPconnection = net_ConnectTCP(p_filter,p_sys->address,p_sys->port);
net_Write(p_filter, p_sys->TCPconnection, NULL, message, strlen(message));
//net_Close(TCPconnection);
-
+
p_sys->lastAlarm = p_in_buf->i_pts;
}
}
else
p_sys->value[i] = p_sys->value[i] - 6;
}*/
-
+
if (p_sys->bargraph) {
/* 6 - sent the message with the values for the BarGraph */
if ((nbChannels > 0) && (p_sys->counter%(p_sys->bargraph_repetition) == 0)) {
}
}
-
+
free(i_value);
-
+
if (p_sys->counter > p_sys->bargraph_repetition*100) {
if (p_sys->connection_reset) {
net_Close(p_sys->TCPconnection);
}
p_sys->counter = 0;
}
-
+
//free(message);
p_sys->counter++;
-
+
return p_in_buf;
}
filter_t * p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
ValueDate_t* current;
-
+
p_sys->last = NULL;
while (p_sys->first != NULL) {
current = p_sys->first;