-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.c
102 lines (95 loc) · 2.8 KB
/
options.c
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
/**
* Some portion of code was copied from libav.
*/
#include "options.h"
#include <stdlib.h>
#include <libavutil/common.h>
#include <libavutil/parseutils.h>
const char *
xg_border_style_name(int id)
{
int i;
for (i=0; i<FF_ARRAY_ELEMS(XG_BORDER_STYLES); i++)
if (XG_BORDER_STYLES[i].id == id)
return XG_BORDER_STYLES[i].name;
return NULL;
}
error_t
parse_opt(int key, char *arg, struct argp_state *state)
{
struct arguments *arguments = state->input;
int i;
switch (key) {
case 'i':
arguments->display = arg;
break;
case 's':
if (av_parse_video_size(&arguments->width, &arguments->height, arg) < 0)
return ARGP_ERR_UNKNOWN;
arguments->video_size = arg;
return 0;
case 'x':
arguments->x = atoi(arg);
break;
case 'y':
arguments->y = atoi(arg);
break;
case 'r':
if (av_parse_video_rate(&arguments->framerate, arg) < 0)
return ARGP_ERR_UNKNOWN;
arguments->frame_rate = arg;
return 0;
case 'M':
arguments->draw_mouse = false;
break;
case 'm':
arguments->draw_mouse_highlight = false;
break;
case 'f':
arguments->follow_mouse = (!arg || strcasecmp("center", arg) == 0)
? -1
: atoi(arg);
break;
case 'F':
arguments->follow_mouse = 0;
break;
case 'c':
arguments->follow_mouse = -1;
break;
case 'b':
if (!arg) {
arguments->border_style = XG_BORDER_DEFAULT;
return 0;
}
for (i=0; i<FF_ARRAY_ELEMS(XG_BORDER_STYLES); i++)
if (strcasecmp(XG_BORDER_STYLES[i].name, arg) == 0) {
arguments->border_style = XG_BORDER_STYLES[i].id;
return 0;
}
return ARGP_ERR_UNKNOWN;
case 256:
arguments->benchmark = true;
return 0;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
void
default_arguments(struct arguments *arguments)
{
arguments->display = ":0.0";
arguments->video_size = "hd720";
arguments->x = 0;
arguments->y = 0;
arguments->width = 1280;
arguments->height = 720;
arguments->frame_rate = "25";
arguments->framerate = (AVRational) { 25, 1 };
arguments->draw_mouse = true;
arguments->draw_mouse_highlight
= true;
arguments->follow_mouse = 100;
arguments->border_style = XG_BORDER_DASHED;
arguments->benchmark = false;
}