mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-18 02:55:46 +00:00
debug
This commit is contained in:
parent
1ebe26fd08
commit
c1d4356fd3
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -c -Wall -Wextra -DDEBUG
|
CFLAGS = -c -Wall -Wextra
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
SOURCES = $(shell ls src/*.c)
|
SOURCES = $(shell ls src/*.c)
|
||||||
OBJECTS = $(SOURCES:.c=.o)
|
OBJECTS = $(SOURCES:.c=.o)
|
||||||
|
|||||||
@ -3,8 +3,8 @@
|
|||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "device.h"
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
|
||||||
static int _capture_init_loop(struct device *dev);
|
static int _capture_init_loop(struct device *dev);
|
||||||
|
|||||||
@ -9,8 +9,8 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
#include "device.h"
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
#include "device.h"
|
||||||
|
|
||||||
|
|
||||||
static const char DEFAULT_DEVICE[] = "/dev/video0";
|
static const char DEFAULT_DEVICE[] = "/dev/video0";
|
||||||
|
|||||||
@ -6,9 +6,9 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
|
#include "tools.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "capture.h"
|
#include "capture.h"
|
||||||
#include "tools.h"
|
|
||||||
|
|
||||||
|
|
||||||
static const char _short_opts[] = "hd:f:s:e:tb:q:";
|
static const char _short_opts[] = "hd:f:s:e:tb:q:";
|
||||||
@ -26,6 +26,7 @@ static const struct option _long_opts[] = {
|
|||||||
{"height", required_argument, NULL, 1001},
|
{"height", required_argument, NULL, 1001},
|
||||||
{"v4l2-timeout", required_argument, NULL, 1002},
|
{"v4l2-timeout", required_argument, NULL, 1002},
|
||||||
{"v4l2-error-timeout", required_argument, NULL, 1003},
|
{"v4l2-error-timeout", required_argument, NULL, 1003},
|
||||||
|
{"debug", no_argument, NULL, 5000},
|
||||||
{NULL, 0, NULL, 0},
|
{NULL, 0, NULL, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ static void _parse_options(int argc, char *argv[], struct device *dev) {
|
|||||||
int index;
|
int index;
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
LOG_DEBUG("Parsing CLI options ...");
|
debug = false;
|
||||||
while ((ch = getopt_long(argc, argv, _short_opts, _long_opts, &index)) >= 0) {
|
while ((ch = getopt_long(argc, argv, _short_opts, _long_opts, &index)) >= 0) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 0: break;
|
case 0: break;
|
||||||
@ -75,6 +76,7 @@ static void _parse_options(int argc, char *argv[], struct device *dev) {
|
|||||||
case 1001: OPT_UNSIGNED(dev->height, "--height");
|
case 1001: OPT_UNSIGNED(dev->height, "--height");
|
||||||
case 1002: OPT_UNSIGNED(dev->timeout, "--timeout");
|
case 1002: OPT_UNSIGNED(dev->timeout, "--timeout");
|
||||||
case 1003: OPT_UNSIGNED(dev->error_timeout, "--error-timeout");
|
case 1003: OPT_UNSIGNED(dev->error_timeout, "--error-timeout");
|
||||||
|
case 5000: OPT_TRUE(debug);
|
||||||
case 'h': _help(EXIT_SUCCESS); break;
|
case 'h': _help(EXIT_SUCCESS); break;
|
||||||
default: _help(EXIT_FAILURE); break;
|
default: _help(EXIT_FAILURE); break;
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/tools.h
18
src/tools.h
@ -1,25 +1,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
|
bool debug;
|
||||||
|
|
||||||
|
|
||||||
#define SEP_INFO(_x_ch) \
|
#define SEP_INFO(_x_ch) \
|
||||||
{ for (int _i = 0; _i < 80; ++_i) putchar(_x_ch); putchar('\n'); }
|
{ for (int _i = 0; _i < 80; ++_i) putchar(_x_ch); putchar('\n'); }
|
||||||
|
|
||||||
#define LOG_INFO(_x_msg, ...) \
|
#define LOG_INFO(_x_msg, ...) \
|
||||||
printf("-- INFO -- " _x_msg "\n", ##__VA_ARGS__)
|
printf("-- INFO -- " _x_msg "\n", ##__VA_ARGS__)
|
||||||
|
|
||||||
#ifdef DEBUG
|
#define LOG_DEBUG(_x_msg, ...) \
|
||||||
# define LOG_DEBUG(_x_msg, ...) \
|
if (debug) { printf(" DEBUG -- " _x_msg "\n", ##__VA_ARGS__); }
|
||||||
printf(" DEBUG -- " _x_msg "\n", ##__VA_ARGS__)
|
|
||||||
# define SEP_DEBUG(_x_ch) \
|
#define SEP_DEBUG(_x_ch) \
|
||||||
SEP_INFO(_x_ch)
|
if (debug) { SEP_INFO(_x_ch); }
|
||||||
#else
|
|
||||||
# define LOG_DEBUG(...)
|
|
||||||
# define SEP_DEBUG(_x_ch)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOG_ERROR(_x_msg, ...) \
|
#define LOG_ERROR(_x_msg, ...) \
|
||||||
printf("** ERROR -- " _x_msg "\n", ##__VA_ARGS__)
|
printf("** ERROR -- " _x_msg "\n", ##__VA_ARGS__)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user