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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/**
* @file snapshot.c Snapshot Video-Filter
*
* Copyright (C) 2010 Creytiv.com
*/
#include <string.h>
#include <re.h>
#include <rem.h>
#include <baresip.h>
#include "png_vf.h"
/**
* @defgroup snapshot snapshot
*
* Take snapshot of the video stream and save it as PNG-files
*
*
* Commands:
*
\verbatim
snapshot Take video snapshot
\endverbatim
*/
static bool flag_enc, flag_dec;
static int encode(struct vidfilt_enc_st *st, struct vidframe *frame)
{
(void)st;
if (!frame)
return 0;
if (flag_enc) {
flag_enc = false;
png_save_vidframe(frame, "snapshot-send");
}
return 0;
}
static int decode(struct vidfilt_dec_st *st, struct vidframe *frame)
{
(void)st;
if (!frame)
return 0;
if (flag_dec) {
flag_dec = false;
png_save_vidframe(frame, "snapshot-recv");
}
return 0;
}
static int do_snapshot(struct re_printf *pf, void *arg)
{
(void)pf;
(void)arg;
/* NOTE: not re-entrant */
flag_enc = flag_dec = true;
return 0;
}
static struct vidfilt snapshot = {
LE_INIT, "snapshot", NULL, encode, NULL, decode,
};
static const struct cmd cmdv[] = {
{"snapshot", 0, 0, "Take video snapshot", do_snapshot },
};
static int module_init(void)
{
vidfilt_register(&snapshot);
return cmd_register(baresip_commands(), cmdv, ARRAY_SIZE(cmdv));
}
static int module_close(void)
{
vidfilt_unregister(&snapshot);
cmd_unregister(baresip_commands(), cmdv);
return 0;
}
EXPORT_SYM const struct mod_export DECL_EXPORTS(snapshot) = {
"snapshot",
"vidfilt",
module_init,
module_close
};
|