File: webcam_options.c

package info (click to toggle)
lebiniou 3.30-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,240 kB
  • sloc: ansic: 19,339; sh: 4,154; makefile: 893; awk: 148
file content (82 lines) | stat: -rw-r--r-- 2,055 bytes parent folder | download
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
/*
 *  Copyright 1994-2019 Olivier Girondel
 *
 *  This file is part of lebiniou.
 *
 *  lebiniou is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  lebiniou is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
 */

#include "webcam.h"

extern int hflip, vflip, webcams;
extern char *video_base;


static void
process_token(const char *tok)
{
  gchar **varval = NULL, **vv;

  // printf(">>>>>>>>> token: '%s' <<<<<<<<<<<<<\n", tok);
  varval = g_strsplit(tok, ":", 0);

  vv = varval;

  if (!strcmp((const char *)*vv, "webcams")) {
    vv++;
    assert(NULL != *vv);
    webcams = xatol(*vv);
    VERBOSE(printf("[E] webcam: grabbing %d device%s\n", webcams, (webcams == 1) ? "" : "s"));
  } if (!strcmp((const char *)*vv, "device")) {
    vv++;
    assert(NULL != *vv);
    VERBOSE(printf("[E] webcam: device set to %s\n", *vv));
    free(video_base);
    video_base = strdup(*vv);
  } else if (!strcmp((const char *)*vv, "hflip")) {
    VERBOSE(printf("[E] webcam: set horizontal flip\n"));
    hflip = !hflip;
  } else if (!strcmp((const char *)*vv, "vflip")) {
    VERBOSE(printf("[E] webcam: set vertical flip\n"));
    vflip = !vflip;
  }

  g_strfreev(varval);
}


static void
process_options(const char *options)
{
  gchar **tokens  = NULL, **tok;

  tokens = g_strsplit(options, ",", 0);

  for (tok = tokens ; *tok != NULL; tok++)
    process_token(*tok);

  g_strfreev(tokens);
}


void
parse_options()
{
  char *options = NULL;

  options = getenv("LEBINIOU_WEBCAM");

  if (NULL != options)
    process_options(options);
}