enable debugging output

main
Steffen Pohle 3 weeks ago
parent b631f0a506
commit 9959ae8e6b

@ -44,6 +44,7 @@ Configuration::Configuration() {
web_height = -1; web_height = -1;
web_width = -1; web_width = -1;
web_imagerefresh = 250; web_imagerefresh = 250;
debug = 0;
filter_ratio = 0.5; filter_ratio = 0.5;
}; };
@ -75,6 +76,7 @@ int Configuration::PrintConfig() {
jp.AddObject("web-size" , to_string(web_width) + "x" + to_string(web_height)); jp.AddObject("web-size" , to_string(web_width) + "x" + to_string(web_height));
jp.AddObject("web-refresh", web_imagerefresh); jp.AddObject("web-refresh", web_imagerefresh);
jp.AddObject("vdev-dumpath", vdev_dumppath); jp.AddObject("vdev-dumpath", vdev_dumppath);
jp.AddObject("debug", debug);
// //
// output the json string // output the json string
@ -124,6 +126,7 @@ int Configuration::LoadFile(std::string fn) {
if (get_resolution(s.c_str(), &vdev_width, &vdev_height) == 0) { if (get_resolution(s.c_str(), &vdev_width, &vdev_height) == 0) {
debug ("Configfile: %s Wrong vdev-size: %s", fn.c_str(), s.c_str()); debug ("Configfile: %s Wrong vdev-size: %s", fn.c_str(), s.c_str());
} }
if (jp.GetValueInt("debug", &i)) debug = i;
// //
// restore language // restore language
@ -138,6 +141,9 @@ int Configuration::LoadArgs(int argc, char **argv) {
if (strcmp(argv[i], "-F") == 0) runasdaemon = 0; if (strcmp(argv[i], "-F") == 0) runasdaemon = 0;
if (strcmp(argv[i], "-D") == 0) runasdaemon = 1; if (strcmp(argv[i], "-D") == 0) runasdaemon = 1;
if (strcmp(argv[i], "-debug") == 0) debug = 1;
if (strcmp(argv[i], "-debug_off") == 0) debug = 0;
if (strcmp(argv[i], "-dump_config") == 0) initflags |= CONF_INITFLAGS_PRINT; if (strcmp(argv[i], "-dump_config") == 0) initflags |= CONF_INITFLAGS_PRINT;
if (strcmp(argv[i], "-config") == 0) { if (strcmp(argv[i], "-config") == 0) {
if (++i < argc) { if (++i < argc) {
@ -253,6 +259,8 @@ void Configuration::Help() {
printf ("Parameters:\n"); printf ("Parameters:\n");
printf (" -F run in foreground\n"); printf (" -F run in foreground\n");
printf (" -D run as daemon\n"); printf (" -D run as daemon\n");
printf (" -debug enable debug output\n");
printf (" -debug_off disable debug output\n");
printf ("\n"); printf ("\n");
printf (" -http_port INT port to listen for http connections\n"); printf (" -http_port INT port to listen for http connections\n");
printf (" -https_port INT port to listen for https connections\n"); printf (" -https_port INT port to listen for https connections\n");

@ -26,6 +26,7 @@
class Configuration { class Configuration {
private: private:
public: public:
int debug;
int http_port; int http_port;
int https_port; int https_port;
std::string ssl_key; std::string ssl_key;
@ -33,7 +34,7 @@ public:
int runasdaemon; int runasdaemon;
std::string filename; std::string filename;
int initflags; int initflags;
int web_height; int web_height;
int web_width; int web_width;
int web_imagerefresh; int web_imagerefresh;

@ -134,6 +134,7 @@ int main(int argc, char **argv) {
config.Help(); config.Help();
return 0; return 0;
} }
debug_enable(config.debug);
pthread_create(&thr_webserver, NULL, &thread_webserver, NULL); pthread_create(&thr_webserver, NULL, &thread_webserver, NULL);
pthread_create(&thr_video, NULL, &thread_video, NULL); pthread_create(&thr_video, NULL, &thread_video, NULL);

@ -189,12 +189,14 @@ int VideoDevice_V4L2::Open() {
// init buffers // init buffers
switch (conf_iomode) { switch (conf_iomode) {
case IOMODE_MMAP: case IOMODE_MMAP:
debug ("setup MMap (memory mapping)");
if (InitMMap() == 0) { if (InitMMap() == 0) {
debug ("could not setup MMap (memory mapping)"); debug ("could not setup MMap (memory mapping)");
Close(); Close();
} }
break; break;
case IOMODE_READ: case IOMODE_READ:
debug ("setup Read (read())");
for (i = 0; i < VDEV_INBUFFERS; i++) { for (i = 0; i < VDEV_INBUFFERS; i++) {
inbuffer[i].size = fmt.fmt.pix.sizeimage; inbuffer[i].size = fmt.fmt.pix.sizeimage;
inbuffer[i].data = (unsigned char*) malloc (fmt.fmt.pix.sizeimage); inbuffer[i].data = (unsigned char*) malloc (fmt.fmt.pix.sizeimage);
@ -417,7 +419,7 @@ int VideoDevice_V4L2::GetFrame(VideoFrame *destframe, VideoFrameFloat *destfloat
return -1; return -1;
case EIO: case EIO:
default: default:
debug ("v4l2_grab IOM_READ: %s dest:%p size:%d", strerror (errno), destframe, fmt.fmt.pix.sizeimage); debugerror ("v4l2_grab IOM_READ: %s dest:%p size:%d", strerror (errno), destframe, fmt.fmt.pix.sizeimage);
return 0; return 0;
} }
} }
@ -442,11 +444,11 @@ int VideoDevice_V4L2::GetFrame(VideoFrame *destframe, VideoFrameFloat *destfloat
return -1; return -1;
case EIO: case EIO:
debug ("error on VIDIOC_DQBUF EIO %s", strerror(errno)); debugerror ("error on VIDIOC_DQBUF EIO %s", strerror(errno));
return 0; return 0;
default: default:
debug ("error on VIDIOC_DQBUF %s", strerror(errno)); debugerror ("error on VIDIOC_DQBUF %s", strerror(errno));
return 0; return 0;
} }
} }

Loading…
Cancel
Save