~audio-recorder/audio-recorder/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _TIMER_H_
#define _TIMER_H_

#include <glib.h>
#include <gdk/gdk.h>
#include "log.h"
#include <gst/gst.h>

// Uncomment this to show debug messages from timer.c and timer-parser.c
//#define DEBUG_TIMER

#if defined(DEBUG_TIMER) || defined(DEBUG_ALL)
#define LOG_TIMER LOG_MSG
#else
#define LOG_TIMER(x, ...)
#endif

void parser_module_init();
void parser_module_exit();

void timer_module_init();
void timer_module_exit();

void timer_set_debug_flag(gboolean on_off);

void timer_func_start();
void timer_func_stop();

void timer_evaluate_triggers(GstClockTimeDiff time_diff, gdouble rms);

void timer_module_reset(gint for_state);

typedef struct {
    gchar action;      // recording action: 'S' = start, 'T' = stop, 'P' = pause
    gchar action_prep; // action preposition: 'a' = after
    gchar data_type;   // data type: 't' = time data, 'f' = file size, 'l' = label
    gdouble val[3];     // data: hh, mm, ss | file size | silence/voice/audio/sound duration
    gchar label[12];   // textual action: "silence" | ("sound" | "voice" | "audio") | ("bytes" | "kb" | "mb" | "gb" | "tb")

    gchar threshold_unit[10]; // level/threshold unit: "dB" (decibel) | "%" or empty
    gdouble threshold;      // level/threshold value in dB, % or plain value [0 - 1.0]

    gint day_of_year; // Internal flag. Used to check if the clock has gone around to next day

    gdouble norm_secs; // = tr->val[0]*3600 + tr->val[1]*60 + tr->val[2] seconds
    gdouble norm_threshold; // = threshold converted to [0 - 1.0] from threshold_unit

    gdouble time_above; // Internal value. Count seconds when above threshold limit
    gdouble time_below; // Internal value. Count seconds when under threshold limit

    gboolean done;    // Internal value. TRUE when timer command has been executed
} TimerRec;

GList *parser_parse_actions(gchar *txt);

void parser_print_rec(TimerRec *tr);
void parser_print_list(GList *list);
void parser_free_list();

void timer_settings_changed();

const gchar *parser_get_action_name(gchar action);

#endif