~osmoma/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
#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);

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' = clock time h:m:s | 'd' = time duration h,m,s | 'f' = file size | 'l' = label
    gdouble val[3];    // data:               hours,minutes,seconds | file size | silence/voice/audio/sound duration
    gchar label[12];   // label:              "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 the next day

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

    gdouble time_above;// internal value. Count seconds when value _above_ threshold
    gdouble time_below;// internal value. Count seconds when value _below_ threshold

} 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