summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2014-05-28 15:05:57 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2014-05-28 15:05:57 +0200
commit0332e496347f6b563abb86d4ef9650bbd6ebc3e1 (patch)
tree74dadbe6e4f3216c8a3c8570e203aad0187febf3 /src
parent8eb0759e2e8a5405b2dd9e6d72d3bd620b51bee4 (diff)
Port server to hugin.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am20
-rw-r--r--src/audio_encoder.cc25
-rw-r--r--src/audio_encoder.h7
-rw-r--r--src/config.h1
-rw-r--r--src/daemon.h1
-rw-r--r--src/encoder.cc4
-rw-r--r--src/file.cc72
-rw-r--r--src/file.h6
-rw-r--r--src/img_encoder.cc21
-rw-r--r--src/img_encoder.h4
-rw-r--r--src/info_console.cc101
-rw-r--r--src/info_console.h53
-rw-r--r--src/info_simple.cc94
-rw-r--r--src/info_simple.h45
-rw-r--r--src/libfame_wrapper.cc30
-rw-r--r--src/libfame_wrapper.h5
-rw-r--r--src/liblame_wrapper.cc62
-rw-r--r--src/liblame_wrapper.h5
-rw-r--r--src/libmplex_wrapper.cc71
-rw-r--r--src/libmplex_wrapper.h5
-rw-r--r--src/miav.cc4
-rw-r--r--src/miav_config.cc25
-rw-r--r--src/miav_config.h7
-rw-r--r--src/miav_daemon.cc37
-rw-r--r--src/miavd.cc2
-rw-r--r--src/mov_encoder.cc20
-rw-r--r--src/mov_encoder.h7
-rw-r--r--src/mov_encoder_thread.cc56
-rw-r--r--src/mov_encoder_thread.h7
-rw-r--r--src/mov_encoder_writer.cc54
-rw-r--r--src/mov_encoder_writer.h6
-rw-r--r--src/multicast.cc44
-rw-r--r--src/multicast.h5
-rw-r--r--src/multicast_configuration.cc63
-rw-r--r--src/multicast_configuration.h2
-rw-r--r--src/multiplexer.cc39
-rw-r--r--src/multiplexer.h4
-rw-r--r--src/network.cc23
-rw-r--r--src/network.h4
-rw-r--r--src/server.cc26
-rw-r--r--src/server.h5
-rw-r--r--src/server_status.cc9
-rw-r--r--src/server_status.h5
-rw-r--r--src/socket.cc24
-rw-r--r--src/socket.h7
-rw-r--r--src/threadsafe_queue_priority.cc3
-rw-r--r--src/threadsafe_queue_priority.h6
47 files changed, 340 insertions, 786 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3e93b4b..fa948df 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,12 +13,13 @@ AM_CXXFLAGS = $(QT_CFLAGS)
miav_CXXFLAGS = $(SDL_CFLAGS) $(DV_CFLAGS) $(IEC61883_CFLAGS) $(QT_CFLAGS) \
-I../include -DPIXMAPS=\"$(datadir)/pixmaps\" \
- -DETC=\"$(prefix)/etc/miav\"
+ -DETC=\"$(prefix)/etc/miav\" -I$(top_srcdir)/hugin
miav_LDADD = $(shell ../tools/MocList o) $(QT_LIBS) $(IEC61883_LIBS) \
$(SDL_LIBS) $(DV_LIBS)
miav_SOURCES = \
+ $(top_srcdir)/hugin/hugin.c \
aa_socket.cc \
cprlisten.cc \
aboutwindow.cc \
@@ -35,31 +36,32 @@ miav_SOURCES = \
mainwindow.cc \
messagebox.cc \
miav.cc \
- miav_config.cc \
- network.cc \
player.cc \
recedge.cc \
+ videowidget.cc \
+ yuv_draw.cc \
+\
socket.cc \
thread.cc \
util.cc \
- videowidget.cc \
- yuv_draw.cc
+ miav_config.cc \
+ network.cc
+
miavd_CXXFLAGS = $(JPEG_CFLAGS) $(FAME_CFLAGS) $(LAME_CFLAGS) $(DV_CFLAGS) \
- $(PTHREAD_CFLAGS) -I../include -DETC=\"$(prefix)/etc/miav\"
+ $(PTHREAD_CFLAGS) -I../include -DETC=\"$(prefix)/etc/miav\" \
+ -I$(top_srcdir)/hugin
miavd_LDADD = $(JPEG_LIBS) $(FAME_LIBS) $(LAME_LIBS) $(DV_LIBS) $(PTHREAD_LIBS)
miavd_SOURCES = \
+ $(top_srcdir)/hugin/hugin.c \
miavd.cc \
audio_encoder.cc \
daemon.cc \
file.cc \
frame.cc \
img_encoder.cc \
- info.cc \
- info_console.cc \
- info_simple.cc \
jpeg_mem_dest.cc \
libfame_wrapper.cc \
liblame_wrapper.cc \
diff --git a/src/audio_encoder.cc b/src/audio_encoder.cc
index 0c82976..a30f3bb 100644
--- a/src/audio_encoder.cc
+++ b/src/audio_encoder.cc
@@ -24,18 +24,19 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#include "audio_encoder.h"
-#include "util.h"
+#include <unistd.h>
+
+#include <hugin.hpp>
+
+#include "util.h"
#include "liblame_wrapper.h"
AudioEncoder::AudioEncoder(ThreadSafeQueuePriority *audio_input_queue,
- ThreadSafeQueuePriority *audio_output_queue,
- Info *i)
+ ThreadSafeQueuePriority *audio_output_queue)
{
- info = i;
- info->info("AudioEncoder");
+ DEBUG(audio, "AudioEncoder");
running = true;
@@ -49,24 +50,24 @@ AudioEncoder::~AudioEncoder()
void AudioEncoder::thread_main()
{
- info->info("AudioEncoder::run");
+ DEBUG(audio, "AudioEncoder::run");
// Run with slightly lower priority than MovEncoderWriter
- if(nice(1) == -1) info->warn("AudioEncoder::run could not set nice.");
+ if(nice(1) == -1) WARN(audio, "AudioEncoder::run could not set nice.");
Frame *in_frame = NULL;
Frame *out_frame = NULL;
- LibLAMEWrapper lame(info);
+ LibLAMEWrapper lame;
while(running) {
in_frame = input_queue->pop();
- if(in_frame == NULL) info->error("AudioEncoder: in_frame == NULL!");
+ if(in_frame == NULL) ERR(audio, "AudioEncoder: in_frame == NULL!");
// Check for end of stream
if(in_frame->endOfFrameStream == true) {
- info->info("endOfFrameStream in AudioEncoder");
+ DEBUG(audio, "endOfFrameStream in AudioEncoder");
running = false;
out_frame = lame.close();
} else {
@@ -82,7 +83,7 @@ void AudioEncoder::thread_main()
output_queue->push(out_frame);
}
- info->info("AudioEncoder::stop");
+ INFO(audio, "AudioEncoder::stop");
}
diff --git a/src/audio_encoder.h b/src/audio_encoder.h
index 9d86178..e84657c 100644
--- a/src/audio_encoder.h
+++ b/src/audio_encoder.h
@@ -34,15 +34,12 @@
#include "thread.h"
#include <pthread.h>
-#include "info.h"
-
#include "threadsafe_queue_priority.h"
class AudioEncoder : public Thread {
public:
AudioEncoder(ThreadSafeQueuePriority *audio_input_queue,
- ThreadSafeQueuePriority *audio_output_queue,
- Info *info);
+ ThreadSafeQueuePriority *audio_output_queue);
~AudioEncoder();
void thread_main();
@@ -50,8 +47,6 @@ public:
volatile bool running;
private:
- Info *info;
-
ThreadSafeQueuePriority *input_queue;
ThreadSafeQueuePriority *output_queue;
};
diff --git a/src/config.h b/src/config.h
index e7101c9..c662dc4 100644
--- a/src/config.h
+++ b/src/config.h
@@ -24,7 +24,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-
#ifndef __CONFIG_IS_LOADED__
#define __CONFIG_IS_LOADED__
diff --git a/src/daemon.h b/src/daemon.h
index 63885b1..1ba88d4 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -22,7 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#ifndef __DAEMON_H__
#define __DAEMON_H__
diff --git a/src/encoder.cc b/src/encoder.cc
index a688585..b712764 100644
--- a/src/encoder.cc
+++ b/src/encoder.cc
@@ -108,9 +108,9 @@ void Encoder::encode()
// If no connection is present, make a new one
if(!s) {
- s = new Socket(port, info);
+ s = new Socket(port);
s->sconnect(ip);
- n = new Network(s, info);
+ n = new Network(s);
}
n_header h;
diff --git a/src/file.cc b/src/file.cc
index 9d86c1c..0f5d0bf 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -24,38 +24,33 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "file.h"
-#include "miav_config.h"
-
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
-
#include <errno.h>
-
-// For ntoh*
#include <netinet/in.h>
-
#include <stdlib.h>
-File::File(Info *i)
+
+#include <hugin.hpp>
+
+#include "miav_config.h"
+
+File::File()
{
- info = i;
fd = 0;
savestate = NO_CHANGE;
filename = new char[1];
extension = new char[1];
}
-File::File(const char *fn, const char* ext, Info *i)
+File::File(const char *fn, const char* ext)
{
char path[256];
- info = i;
-
savestate = SAVE;
filename = new char[strlen(fn) + 1];
@@ -88,9 +83,9 @@ File::~File()
{
close(fd);
- info->info("This session contains the following files...");
+ INFO(file, "This session contains the following files...");
for(unsigned int cnt = 0; cnt < filelist.size(); cnt ++) {
- info->info("[%s]", filelist[cnt].c_str());
+ INFO(file, "[%s]", filelist[cnt].c_str());
}
std::string *trash = config->readString("server_trash");
@@ -98,20 +93,20 @@ File::~File()
switch(savestate) {
case NO_CHANGE:
- info->warn("File had no savestate!");
+ WARN(file, "File had no savestate!");
break;
case SAVE:
- info->info("Files in this session is to be saved.");
+ INFO(file, "Files in this session is to be saved.");
break;
case DELETE:
- info->info("Files in this session is to be deleted (moved to trash).");
+ INFO(file, "Files in this session is to be deleted (moved to trash).");
Move((char*)trash->c_str());
break;
case LATER:
- info->info("Files in this session is stored for later decisson.");
+ INFO(file, "Files in this session is stored for later decisson.");
Move((char*)later->c_str());
break;
}
@@ -133,11 +128,10 @@ int File::Move(char *destination)
// TODO: Move file filelist[cnt] to the destination folder.
strcpy(filename, (char*)filelist[cnt].c_str());
sprintf(newfile, "%s%s", destination, strrchr(filename, '/'));
- if(rename((char*)filelist[cnt].c_str(), newfile) == -1)
- info->error("Error moving file %s to %s:",
- (char*)filelist[cnt].c_str(),
- newfile,
- strerror(errno));
+ if(rename((char*)filelist[cnt].c_str(), newfile) == -1) {
+ ERR(file, "Error moving file %s to %s: %s", (char*)filelist[cnt].c_str(),
+ newfile, strerror(errno));
+ }
}
return 0;
}
@@ -165,7 +159,7 @@ int File::Open()
// If more than 100 files are created in one day, something is terribly wrong!
if(num > 100) {
- info->error("Something is wrong with the path [%s]!", fname);
+ ERR(file, "Something is wrong with the path [%s]!", fname);
exit(1);
}
@@ -176,7 +170,7 @@ int File::Open()
seqnum ++;
- info->info("Output file: %s", fname);
+ INFO(file, "Output file: %s", fname);
return 0;
}
@@ -188,11 +182,11 @@ int File::Write(void* data, int size)
w = write(fd, data, size);
if(w != size) {
- info->info("Wrapping file.");
+ INFO(file, "Wrapping file.");
Open();
w = write(fd, data, size);
if(w != size) {
- info->error("Out of diskspace!");
+ ERR(file, "Out of diskspace!");
return -1;
}
}
@@ -213,7 +207,7 @@ int File::createPath(char* path)
if(strlen(subpath) > 0) createPath(subpath);
- info->info("Checking and/or generating directory: %s", path);
+ INFO(file, "Checking and/or generating directory: %s", path);
// stat(path, &stats);
//if(!S_ISDIR(stats.st_mode) && S_ISREG(stats.st_mode))
@@ -228,25 +222,5 @@ int File::createPath(char* path)
void File::setSaveState(n_savestate s)
{
savestate = s;
- info->info("SETTING SAVESTATE TO: %d", savestate);
-}
-
-#ifdef __TEST_FILE
-#include "info_simple.h"
-
-int main(int argc, char *argv[]) {
- if(argc < 3) {
- fprintf(stderr, "usage:\n\ttest_file [filename] [extension]\n");
- return 1;
- }
-
-
- InfoSimple info;
- File file(argv[1], argv[2], &info);
-
- unsigned int val = 0x01234567;
- file.Write(val);
-
+ INFO(file, "SETTING SAVESTATE TO: %d", savestate);
}
-
-#endif/* __TEST_FILE*/
diff --git a/src/file.h b/src/file.h
index ab2ad4c..2083525 100644
--- a/src/file.h
+++ b/src/file.h
@@ -28,7 +28,6 @@
#ifndef __MIAV_FILE_H__
#define __MIAV_FILE_H__
-#include "info.h"
#include <stdio.h>
#include <vector>
@@ -41,8 +40,8 @@
class File {
public:
- File(Info* info); // Empty constructor for unit tests.
- File(const char *filename, const char* ext, Info* info);
+ File(); // Empty constructor for unit tests.
+ File(const char *filename, const char* ext);
virtual ~File();
virtual int Write(void* data, int size);
@@ -63,7 +62,6 @@ public:
private:
volatile n_savestate savestate;
- Info* info;
std::vector<std::string> filelist;
diff --git a/src/img_encoder.cc b/src/img_encoder.cc
index 28702cf..907f282 100644
--- a/src/img_encoder.cc
+++ b/src/img_encoder.cc
@@ -33,24 +33,21 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
#include "img_encoder.h"
-#include <stdio.h>
-
-#include "miav_config.h"
+#include <stdio.h>
+#include <libdv/dv.h>
+#include <libdv/dv_types.h>
extern "C" {
#include <jpeglib.h>
}
-#include "jpeg_mem_dest.h"
+#include <hugin.hpp>
-// Use libdv
-#include <libdv/dv.h>
-#include <libdv/dv_types.h>
+#include "jpeg_mem_dest.h"
+#include "miav_config.h"
-ImgEncoder::ImgEncoder(const char* cpr, Info *i)
+ImgEncoder::ImgEncoder(const char* cpr)
{
- info = i;
-
// Create path and filename
char fname[256];
string *server_root;
@@ -92,7 +89,7 @@ ImgEncoder::ImgEncoder(const char* cpr, Info *i)
sprintf(fname, "%s/%s/%s/%s-%s-", server_root->c_str(), birthmonth, encrypted_cpr, cpr, date);
- file = new File(fname, "jpg", info);
+ file = new File(fname, "jpg");
}
@@ -157,7 +154,7 @@ void ImgEncoder::writeJPEGFile(int quality, unsigned char *rgb, int image_width,
// Release JPEG compression object
jpeg_destroy_compress(&cinfo);
- info->info("JPEG buffersize: %d", buffersize);
+ DEBUG(jpeg, "JPEG buffersize: %d", buffersize);
file->Write(jpeg_output_buffer, buffersize);
delete jpeg_output_buffer;
}
diff --git a/src/img_encoder.h b/src/img_encoder.h
index 9745a8f..3f069e0 100644
--- a/src/img_encoder.h
+++ b/src/img_encoder.h
@@ -43,7 +43,6 @@
//#include <stdlib.h>
//#include <string.h>
-#include "info.h"
#include "file.h"
#define VIDEO_BUFFER_SIZE (1024*1024) // FIXME: One size fits all...
@@ -51,7 +50,7 @@
class ImgEncoder {
public:
- ImgEncoder(const char* cpr, Info *info);
+ ImgEncoder(const char* cpr);
~ImgEncoder();
void encode(Frame *frame, int quality);
void writeJPEGFile(int quality,
@@ -61,7 +60,6 @@ public:
private:
File *file;
- Info *info;
void getRGB(Frame *frame, unsigned char *rgb);
};
diff --git a/src/info_console.cc b/src/info_console.cc
deleted file mode 100644
index 3a197a9..0000000
--- a/src/info_console.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * info_console.cc
- *
- * Tue May 3 09:35:03 CEST 2005
- * Copyright 2005 Bent Bisballe
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of MIaV.
- *
- * MIaV 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.
- *
- * MIaV 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 MIaV; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include <config.h>
-#include "info_console.h"
-
-#include "miav_config.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-
-InfoConsole::InfoConsole(MiavConfig *c): Info()
-{
- this->config = c;
- log_filename = *(this->config->readString("server_log_file"));
-}
-
-InfoConsole::~InfoConsole()
-{
- pthread_mutex_destroy(&mutex);
-}
-
-void InfoConsole::error(const char *fmt, ...)
-{
- char buf[1024];
-
- pthread_mutex_lock(&mutex);
- // Beginning of safezone
-
- va_list argp;
- va_start(argp, fmt);
- // fprintf(stderr, "Error: ["); vfprintf(stderr, fmt, argp); fprintf(stderr, "]\n"); fflush(stderr);
- vsprintf(buf, fmt, argp);
- va_end(argp);
-
- // End of safezone
- pthread_mutex_unlock(&mutex);
-
- log("Error: %s", buf);
-}
-
-void InfoConsole::warn(const char *fmt, ...)
-{
- char buf[1024];
-
- pthread_mutex_lock(&mutex);
- // Beginning of safezone
-
- va_list argp;
- va_start(argp, fmt);
- // fprintf(stderr, "Warning: ["); vfprintf(stderr, fmt, argp); fprintf(stderr, "]\n"); fflush(stderr);
- vsprintf(buf, fmt, argp);
- va_end(argp);
-
- // End of safezone
- pthread_mutex_unlock(&mutex);
-
- log("Warning: %s", buf);
-}
-
-void InfoConsole::info(const char *fmt, ...)
-{
- char buf[1024];
-
- pthread_mutex_lock(&mutex);
- // Beginning of safezone
-
- va_list argp;
- va_start(argp, fmt);
- // fprintf(stderr, "Info: ["); vfprintf(stderr, fmt, argp); fprintf(stderr, "]\n"); fflush(stderr);
- vsprintf(buf, fmt, argp);
- va_end(argp);
-
- // End of safezone
- pthread_mutex_unlock(&mutex);
-
- log("Info: %s", buf);
-}
diff --git a/src/info_console.h b/src/info_console.h
deleted file mode 100644
index 7ecfda3..0000000
--- a/src/info_console.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * info_console.h
- *
- * Tue May 3 09:35:03 CEST 2005
- * Copyright 2005 Bent Bisballe
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of MIaV.
- *
- * MIaV 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.
- *
- * MIaV 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 MIaV; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "config.h"
-#ifndef __MIAV_INFO_CONSOLE_H__
-#define __MIAV_INFO_CONSOLE_H__
-
-#include "info.h"
-
-#include "miav_config.h"
-
-#include <pthread.h>
-#include <semaphore.h>
-
-#include <string>
-using namespace std;
-
-class InfoConsole: public Info {
-public:
- InfoConsole(MiavConfig *config);
- ~InfoConsole();
-
- void error(const char* fmt, ...);
- void warn(const char* fmt, ...);
- void info(const char* fmt, ...);
-
-private:
-};
-
-#endif/*__MIAV_INFO_CONSOLE_H__*/
diff --git a/src/info_simple.cc b/src/info_simple.cc
deleted file mode 100644
index a3db393..0000000
--- a/src/info_simple.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * info_simple.cc
- *
- * Tue Sep 20 17:00:25 CEST 2005
- * Copyright 2005 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of MIaV.
- *
- * MIaV 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.
- *
- * MIaV 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 MIaV; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "config.h"
-#include "info_simple.h"
-
-#include <stdio.h>
-#include <stdarg.h>
-
-InfoSimple::InfoSimple(): Info()
-{
-}
-
-InfoSimple::~InfoSimple()
-{
- pthread_mutex_destroy(&mutex);
-}
-
-void InfoSimple::error(char *fmt, ...)
-{
- char buf[1024];
-
- pthread_mutex_lock(&mutex);
- // Beginning of safezone
-
- va_list argp;
- va_start(argp, fmt);
- vsprintf(buf, fmt, argp);
- va_end(argp);
-
- // End of safezone
- pthread_mutex_unlock(&mutex);
-
- fprintf(stderr, "Error: %s\n", buf);
-}
-
-void InfoSimple::warn(char *fmt, ...)
-{
- char buf[1024];
-
- pthread_mutex_lock(&mutex);
- // Beginning of safezone
-
- va_list argp;
- va_start(argp, fmt);
- vsprintf(buf, fmt, argp);
- va_end(argp);
-
- // End of safezone
- pthread_mutex_unlock(&mutex);
-
- fprintf(stderr, "Warning: %s\n", buf);
-}
-
-void InfoSimple::info(char *fmt, ...)
-{
- char buf[1024];
-
- pthread_mutex_lock(&mutex);
- // Beginning of safezone
-
- va_list argp;
- va_start(argp, fmt);
- vsprintf(buf, fmt, argp);
- va_end(argp);
-
- // End of safezone
- pthread_mutex_unlock(&mutex);
-
- fprintf(stderr, "Info: %s\n", buf);
-}
diff --git a/src/info_simple.h b/src/info_simple.h
deleted file mode 100644
index 302a371..0000000
--- a/src/info_simple.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * info_simple.h
- *
- * Tue Sep 20 17:00:25 CEST 2005
- * Copyright 2005 Bent Bisballe Nyeng
- * deva@aasimon.org
- ****************************************************************************/
-
-/*
- * This file is part of MIaV.
- *
- * MIaV 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.
- *
- * MIaV 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 MIaV; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-#include "config.h"
-#ifndef __MIAV_INFO_SIMPLE_H__
-#define __MIAV_INFO_SIMPLE_H__
-
-#include "info.h"
-
-class InfoSimple: public Info {
-public:
- InfoSimple();
- ~InfoSimple();
-
- void error(char* fmt, ...);
- void warn(char* fmt, ...);
- void info(char* fmt, ...);
-
-private:
-};
-
-#endif/*__MIAV_INFO_SIMPLE_H__*/
diff --git a/src/libfame_wrapper.cc b/src/libfame_wrapper.cc
index f2e9adb..e4cb4c5 100644
--- a/src/libfame_wrapper.cc
+++ b/src/libfame_wrapper.cc
@@ -24,19 +24,18 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "libfame_wrapper.h"
#include <errno.h>
#include <string.h>
+#include <hugin.hpp>
+
#include "miav_config.h"
#include "frame.h"
-LibFAMEWrapper::LibFAMEWrapper(Info *i)
+LibFAMEWrapper::LibFAMEWrapper()
{
- info = i;
-
// FIXME: Hmmm... should this be detected somewhere?!
int w = 720;
int h = 576;
@@ -66,7 +65,8 @@ LibFAMEWrapper::LibFAMEWrapper(Info *i)
// can then be used for subsequent library calls.)
fame_context = fame_open();
if(!fame_context) {
- info->error("Unable to open FAME context, due to the following error: %s", strerror(errno));
+ ERR(fame, "Unable to open FAME context, due to the following error: %s",
+ strerror(errno));
return;
}
@@ -136,7 +136,7 @@ LibFAMEWrapper::LibFAMEWrapper(Info *i)
if(strcmp(config->readString("encoding_codec")->c_str(), "mpeg4") == 0) {
- info->info("Using mpeg4 compression.");
+ INFO(fame, "Using mpeg4 compression.");
fame_object_t *object;
object = fame_get_object(fame_context, "profile/mpeg4/simple");
@@ -144,7 +144,7 @@ LibFAMEWrapper::LibFAMEWrapper(Info *i)
} else if(strcmp(config->readString("encoding_codec")->c_str(), "mpeg1") == 0) {
- info->info("Using mpeg1 compression.");
+ INFO(fame, "Using mpeg1 compression.");
fame_object_t *object;
object = fame_get_object(fame_context, "profile/mpeg1");
@@ -152,7 +152,7 @@ LibFAMEWrapper::LibFAMEWrapper(Info *i)
} else if(strcmp(config->readString("encoding_codec")->c_str(), "mpeg1") == 0) {
} else {
- info->info("Using default (mpeg1) compression.");
+ INFO(fame, "Using default (mpeg1) compression.");
}
fame_init(fame_context, &fame_par, fame_buffer, FAME_BUFFER_SIZE);
@@ -254,13 +254,13 @@ Frame *LibFAMEWrapper::encode(Frame *dvframe)
// fame_end_frame(fame_context, &stats);
/*
- info->info("frame_number: %d, coding: %c, target_bits: %d, actual_bits: %d, spatial_activity: %d, quant_scale: %f",
- stats.frame_number,
- stats.coding,
- stats.target_bits,
- stats.actual_bits,
- stats.spatial_activity,
- stats.quant_scale);
+ DEBUG(fame "frame_number: %d, coding: %c, target_bits: %d, actual_bits: %d, spatial_activity: %d, quant_scale: %f",
+ stats.frame_number,
+ stats.coding,
+ stats.target_bits,
+ stats.actual_bits,
+ stats.spatial_activity,
+ stats.quant_scale);
*/
/*
fame_frame_statistics_t_ {
diff --git a/src/libfame_wrapper.h b/src/libfame_wrapper.h
index bf9e7b9..db75880 100644
--- a/src/libfame_wrapper.h
+++ b/src/libfame_wrapper.h
@@ -36,14 +36,13 @@
#include <libdv/dv_types.h>
#include "frame.h"
-#include "info.h"
// size specifies the length of the buffer.
#define FAME_BUFFER_SIZE (1024*1024) // FIXME: One size fits all...
class LibFAMEWrapper {
public:
- LibFAMEWrapper(Info *info);
+ LibFAMEWrapper();
~LibFAMEWrapper();
Frame *encode(Frame *dvframe);
@@ -52,8 +51,6 @@ private:
unsigned long long calc_bitrate;
unsigned int frame_number;
- Info* info;
-
// libFAME encoder
// unsigned char *fame_buffer;
fame_parameters_t fame_par;
diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc
index b4a0bd1..f62e6d4 100644
--- a/src/liblame_wrapper.cc
+++ b/src/liblame_wrapper.cc
@@ -24,19 +24,19 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "liblame_wrapper.h"
-#include "miav_config.h"
#include <string.h>
-LibLAMEWrapper::LibLAMEWrapper(Info *i)
-{
- info = i;
+#include <hugin.hpp>
+#include "miav_config.h"
+
+LibLAMEWrapper::LibLAMEWrapper()
+{
// Init library.
if( (gfp = lame_init()) == NULL) {
- info->error("LAME initialization failed (due to malloc failure!)");
+ ERR(lame, "LAME initialization failed (due to malloc failure!)");
return;
}
@@ -74,7 +74,7 @@ LibLAMEWrapper::LibLAMEWrapper(Info *i)
if (lame_init_params(gfp) < 0) {
- info->error("LAME parameter initialization failed.");
+ ERR(lame, "LAME parameter initialization failed.");
return;
}
@@ -195,24 +195,24 @@ Frame *LibLAMEWrapper::encode(Frame *dvframe)
val = lame_encode_buffer(gfp, buffer_l, buffer_r, nsamples, mp3buf, mp3buf_size);
// val = lame_encode_mp3_frame(gfp, buffer_l, buffer_r, mp3buf, mp3buf_size);
- // info->info("Framenr: %d", lame_get_frameNum(gfp));
+ // DEBUG(lame, "Framenr: %d", lame_get_frameNum(gfp));
if(val < 0) {
switch(val) {
case -1: // mp3buf was too small
- info->error("Lame encoding failed, mp3buf was too small.");
+ ERR(lame, "Lame encoding failed, mp3buf was too small.");
break;
case -2: // malloc() problem
- info->error("Lame encoding failed, due to malloc() problem.");
+ ERR(lame, "Lame encoding failed, due to malloc() problem.");
break;
case -3: // lame_init_params() not called
- info->error("Lame encoding failed, lame_init_params() not called.");
+ ERR(lame, "Lame encoding failed, lame_init_params() not called.");
break;
case -4: // psycho acoustic problems
- info->error("Lame encoding failed, due to psycho acoustic problems.");
+ ERR(lame, "Lame encoding failed, due to psycho acoustic problems.");
break;
default:
- info->error("Lame encoding failed, due to unknown error.");
+ ERR(lame, "Lame encoding failed, due to unknown error.");
break;
}
}
@@ -243,7 +243,7 @@ Frame *LibLAMEWrapper::encode(Frame *dvframe)
mp3buf_size - val); // number of valid octets in this stream
*/
- // info->info("VAL: %d - FLUSH_SZ: %d - TOTAL: %d", val, flush_sz, (val + flush_sz));
+ // DEBUG(lame, "VAL: %d - FLUSH_SZ: %d - TOTAL: %d", val, flush_sz, (val + flush_sz));
audio_frame->size = val + flush_sz;
@@ -253,35 +253,35 @@ Frame *LibLAMEWrapper::encode(Frame *dvframe)
// lame_bitrate_kbps(gfp, bitrate_kbps);
lame_bitrate_hist(gfp, bitrate_kbps);
// 32 40 48 56 64 80 96 112 128 160 192 224 256 320
- info->info("%d %d %d %d %d %d %d %d %d %d %d %d %d %d",
- bitrate_kbps[0],
- bitrate_kbps[1],
- bitrate_kbps[2],
- bitrate_kbps[3],
- bitrate_kbps[4],
- bitrate_kbps[5],
- bitrate_kbps[6],
- bitrate_kbps[7],
- bitrate_kbps[8],
- bitrate_kbps[9],
- bitrate_kbps[10],
- bitrate_kbps[11],
- bitrate_kbps[12],
- bitrate_kbps[13]);
+ DEBUG(lame, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d",
+ bitrate_kbps[0],
+ bitrate_kbps[1],
+ bitrate_kbps[2],
+ bitrate_kbps[3],
+ bitrate_kbps[4],
+ bitrate_kbps[5],
+ bitrate_kbps[6],
+ bitrate_kbps[7],
+ bitrate_kbps[8],
+ bitrate_kbps[9],
+ bitrate_kbps[10],
+ bitrate_kbps[11],
+ bitrate_kbps[12],
+ bitrate_kbps[13]);
*/
// while(frame_number != lame_get_frameNum(gfp)) {
calc_bitrate += audio_frame->size;//lame_get_framesize(gfp);
frame_number ++;//= 1;//lame_get_frameNum(gfp);
- // info->info("lame_get_frameNum(gfp) %d ?= frame_number %d", lame_get_frameNum(gfp), frame_number);
+ // DEBUG(lame, "lame_get_frameNum(gfp) %d ?= frame_number %d", lame_get_frameNum(gfp), frame_number);
// }
// Bits pr. second
// 25 * 7 frames pr.second (it seems!)
audio_frame->bitrate = (unsigned int)((double)calc_bitrate / (double)(frame_number)) * 25;
/*
- info->info("Audio size: %d, bitrate: %.4f",
+ DEBUG(lame, "Audio size: %d, bitrate: %.4f",
audio_frame->bitrate,
(float)(config->readInt("mp3_bitrate") * 1000)/(float)(audio_frame->bitrate));
*/
diff --git a/src/liblame_wrapper.h b/src/liblame_wrapper.h
index 43518c8..a4c56c5 100644
--- a/src/liblame_wrapper.h
+++ b/src/liblame_wrapper.h
@@ -36,7 +36,6 @@
#include <lame/lame.h>
#include "frame.h"
-#include "info.h"
#define AUDIO_BUFFER_SIZE DV_AUDIO_MAX_SAMPLES
@@ -47,7 +46,7 @@
class LibLAMEWrapper {
public:
- LibLAMEWrapper(Info *info);
+ LibLAMEWrapper();
~LibLAMEWrapper();
Frame *encode(Frame *dvframe);
@@ -58,8 +57,6 @@ private:
unsigned long long calc_bitrate;
int frame_number;
- Info *info;
-
// LAME stuff
lame_global_flags *gfp;
diff --git a/src/libmplex_wrapper.cc b/src/libmplex_wrapper.cc
index 4164ffe..542d900 100644
--- a/src/libmplex_wrapper.cc
+++ b/src/libmplex_wrapper.cc
@@ -39,13 +39,15 @@
#include <mplex/outputstrm.hpp>
#include <mplex/multiplexor.hpp>
+#include <hugin.hpp>
+
/**
* FrameOutputStream - Wraps the File object
*/
class FrameOutputStream : public OutputStream
{
public:
- FrameOutputStream( Info *info, File *outputfile );
+ FrameOutputStream(File *outputfile );
int Open( );
void Close();
off_t SegmentSize( );
@@ -53,38 +55,36 @@ public:
void Write(uint8_t *data, unsigned int len);
private:
- Info *info;
off_t written;
File *file;
};
-FrameOutputStream::FrameOutputStream( Info *info, File *outputfile )
+FrameOutputStream::FrameOutputStream(File *outputfile )
{
- this->info = info;
file = outputfile;
written = 0;
- info->info("FrameOutputStream - constructor");
+ DEBUG(frame, "FrameOutputStream - constructor");
}
int FrameOutputStream::Open()
{
- // info->info("FrameOutputStream::Open");
+ // DEBUG(frame, "FrameOutputStream::Open");
// Nothing to do here!
return 0;
}
void FrameOutputStream::Close()
{
- // info->info("FrameOutputStream::Close");
+ // DEBUG(frame, "FrameOutputStream::Close");
// Nothing to do here!
}
off_t FrameOutputStream::SegmentSize()
{
- // info->info("FrameOutputStream::SegmentSize - return: %d", written);
+ // DEBUG(frame, "FrameOutputStream::SegmentSize - return: %d", written);
return written;
/*
@@ -97,7 +97,7 @@ off_t FrameOutputStream::SegmentSize()
void FrameOutputStream::NextSegment( )
{
- // info->info("FrameOutputStream::NextSegment");
+ // DEBUG(frame, "FrameOutputStream::NextSegment");
// Nothing to do here!
/*
auto_ptr<char> prev_filename_buf( new char[strlen(cur_filename)+1] );
@@ -122,7 +122,7 @@ void FrameOutputStream::Write( uint8_t *buf, unsigned int len )
unsigned int write;
write = file->Write(buf, len);
written += write;
- // info->info("FrameOutputStream::Write - len: %d", len);
+ // DEBUG(frame, "FrameOutputStream::Write - len: %d", len);
}
/**
@@ -132,7 +132,7 @@ void FrameOutputStream::Write( uint8_t *buf, unsigned int len )
class FrameInputStream : public IBitStream
{
public:
- FrameInputStream( Info *info, ThreadSafeQueuePriority *queue );
+ FrameInputStream(ThreadSafeQueuePriority *queue );
~FrameInputStream();
private:
@@ -140,24 +140,22 @@ private:
size_t ReadStreamBytes( uint8_t *buf, size_t size );
bool EndOfStream();
- Info *info;
ThreadSafeQueuePriority *queue;
bool seen_eof;
Frame *frame;
unsigned int read;
};
-FrameInputStream::FrameInputStream( Info *info, ThreadSafeQueuePriority *queue ) :
+FrameInputStream::FrameInputStream(ThreadSafeQueuePriority *queue ) :
IBitStream()
{
- this->info = info;
this->queue = queue;
seen_eof = false;
frame = NULL;
read = 0;
streamname = "MIaV Stream\0";
- // info->info("FrameInputStream - constructor", seen_eof);
+ // DEBUG(frame, "FrameInputStream - constructor", seen_eof);
/*
if ((fileh = fopen(bs_filename, "rb")) == NULL)
@@ -184,11 +182,11 @@ FrameInputStream::FrameInputStream( Info *info, ThreadSafeQueuePriority *queue )
byteidx = 0;
if (!ReadIntoBuffer()) {
if (buffered==0) {
- info->error( "Unable to read from %s.", streamname);
+ ERR(frame, "Unable to read from %s.", streamname);
}
}
- // info->info("FrameInputStream - leaving constructor", seen_eof);
+ // DEBUG(frame, "FrameInputStream - leaving constructor", seen_eof);
}
@@ -198,7 +196,7 @@ FrameInputStream::FrameInputStream( Info *info, ThreadSafeQueuePriority *queue )
*/
FrameInputStream::~FrameInputStream()
{
- // info->info("FrameInputStream - destructor", seen_eof);
+ // DEBUG(frame, "FrameInputStream - destructor", seen_eof);
// Nothing to do here!
/*
if (fileh)
@@ -219,13 +217,13 @@ Frame *FrameInputStream::getFrame()
bool FrameInputStream::EndOfStream()
{
- // info->info("FrameInputStream::EndOfStream - return: %d", seen_eof);
+ // DEBUG(frame, "FrameInputStream::EndOfStream - return: %d", seen_eof);
return seen_eof;
}
size_t FrameInputStream::ReadStreamBytes( uint8_t *buf, size_t size )
{
- // info->info("FrameInputStream::ReadStreamBytes - size: %d", size);
+ // DEBUG(frame, "FrameInputStream::ReadStreamBytes - size: %d", size);
unsigned int copied = 0;
while( copied < size ) {
@@ -251,7 +249,7 @@ size_t FrameInputStream::ReadStreamBytes( uint8_t *buf, size_t size )
unsigned int doread = (size - copied) < (frame->size - read) ?
size - copied : (frame->size - read);
- //info->info("Requested: %d. Read: %d. Doread: %d. In buffer %d", size, (*read), doread, (*frame)->size);
+ // DEBUG(frame, "Requested: %d. Read: %d. Doread: %d. In buffer %d", size, (*read), doread, (*frame)->size);
memcpy(buf + copied, frame->data + read, doread);
read += doread;
@@ -272,8 +270,7 @@ size_t FrameInputStream::ReadStreamBytes( uint8_t *buf, size_t size )
class MIaVMultiplexJob : public MultiplexJob
{
public:
- MIaVMultiplexJob(Info *info,
- ThreadSafeQueuePriority *video_queue,
+ MIaVMultiplexJob(ThreadSafeQueuePriority *video_queue,
ThreadSafeQueuePriority *audio_queue);
private:
@@ -281,13 +278,11 @@ private:
bool ParseLpcmOpt( const char *optarg );
};
-MIaVMultiplexJob::MIaVMultiplexJob(Info *info,
- ThreadSafeQueuePriority *video_queue,
+MIaVMultiplexJob::MIaVMultiplexJob(ThreadSafeQueuePriority *video_queue,
ThreadSafeQueuePriority *audio_queue) :
MultiplexJob()
{
- // this->info = info;
- // info->info("MIaVMultiplexJob - constructor");
+ // DEBUG(job, "MIaVMultiplexJob - constructor");
outfile_pattern = "/tmp/aaargh.mpg"; // Output file... or something
verbose = 0; // Level of verbosity. 0 = quiet, 1 = normal 2 = verbose/debug
@@ -298,10 +293,10 @@ MIaVMultiplexJob::MIaVMultiplexJob(Info *info,
// Specifies decoder buffers size in kB. [ 20...2000]
if( ! ParseVideoOpt( "500" ) )
- info->error( "Illegal video decoder buffer size(s): %s", "500" );
+ ERR(job, "Illegal video decoder buffer size(s): %s", "500" );
// --lpcm-params | -L samppersec:chan:bits [, samppersec:chan:bits]
- // if( ! ParseLpcmOpt( "48000:2:16" ) ) info->error( "Illegal LPCM option(s): %s", "48000:2:16" );
+ // if( ! ParseLpcmOpt( "48000:2:16" ) ) ERR(job, "Illegal LPCM option(s): %s", "48000:2:16" );
data_rate = 0; //Specify data rate of output stream in kbit/sec (default 0=Compute from source streams)
// Convert from kbit/sec (user spec) to 50B/sec units...
@@ -334,12 +329,12 @@ MIaVMultiplexJob::MIaVMultiplexJob(Info *info,
// is encountered ithe input video
(void)mjpeg_default_handler_verbosity(verbose);
- info->info( "mplex version %s (%s %s)", VERSION,MPLEX_VER, MPLEX_DATE );
+ INFO(mplex, "mplex version %s (%s %s)", VERSION,MPLEX_VER, MPLEX_DATE );
// Connect streams
vector<IBitStream *> inputs;
- if(video_queue) inputs.push_back( new FrameInputStream( info, video_queue ) );
- if(audio_queue) inputs.push_back( new FrameInputStream( info, audio_queue ) );
+ if(video_queue) inputs.push_back(new FrameInputStream(video_queue));
+ if(audio_queue) inputs.push_back(new FrameInputStream(audio_queue));
SetupInputStreams( inputs );
}
@@ -445,12 +440,10 @@ bool MIaVMultiplexJob::ParseVideoOpt( const char *optarg )
return true;
}
-LibMPlexWrapper::LibMPlexWrapper(Info *info,
- File *outputfile,
+LibMPlexWrapper::LibMPlexWrapper(File *outputfile,
ThreadSafeQueuePriority *video_queue,
ThreadSafeQueuePriority *audio_queue)
{
- this->info = info;
this->outputfile = outputfile;
this->video_queue = video_queue;
this->audio_queue = audio_queue;
@@ -463,11 +456,11 @@ LibMPlexWrapper::~LibMPlexWrapper()
void LibMPlexWrapper::multiplex()
{
- // info->info("MPLEX!");
+ // DEBUG(mplex, "MPLEX!");
// sleep(10);
- // info->info("The road goes ever on and on...");
- MIaVMultiplexJob job(info, video_queue, audio_queue);
- FrameOutputStream output( info, outputfile );
+ // DEBUG(mplex, "The road goes ever on and on...");
+ MIaVMultiplexJob job(video_queue, audio_queue);
+ FrameOutputStream output(outputfile);
Multiplexor mux(job, output);
mux.Multiplex();
}
diff --git a/src/libmplex_wrapper.h b/src/libmplex_wrapper.h
index 1be71a1..60c80fe 100644
--- a/src/libmplex_wrapper.h
+++ b/src/libmplex_wrapper.h
@@ -30,14 +30,12 @@
#ifdef WITH_LIBMPLEX
-#include "info.h"
#include "file.h"
#include "threadsafe_queue_priority.h"
class LibMPlexWrapper {
public:
- LibMPlexWrapper(Info *info,
- File *outputfile,
+ LibMPlexWrapper(File *outputfile,
ThreadSafeQueuePriority *video_queue,
ThreadSafeQueuePriority *audio_queue);
~LibMPlexWrapper();
@@ -45,7 +43,6 @@ public:
void multiplex();
private:
- Info *info;
File *outputfile;
ThreadSafeQueuePriority *video_queue;
ThreadSafeQueuePriority *audio_queue;
diff --git a/src/miav.cc b/src/miav.cc
index efdf448..115bd48 100644
--- a/src/miav.cc
+++ b/src/miav.cc
@@ -37,9 +37,9 @@ int main(int argc, char *argv[])
{
QApplication miav_grab(argc, argv);
- MiavConfig cfg(ETC"/miav.conf", NULL);
+ MiavConfig cfg(ETC"/miav.conf");
InfoGui info(&miav_grab, NULL, &cfg);
- config = new MiavConfig(ETC"/miav.conf", &info);
+ config = new MiavConfig(ETC"/miav.conf");
InfoEventHandler *eventhandler = new InfoEventHandler( );
miav_grab.installEventFilter( eventhandler );
diff --git a/src/miav_config.cc b/src/miav_config.cc
index d20055f..cd464f9 100644
--- a/src/miav_config.cc
+++ b/src/miav_config.cc
@@ -24,23 +24,22 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "miav_config.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+#include <hugin.hpp>
+
MiavConfig *config;
MiavConfig::MiavConfig()
{
- info = NULL;
}
-MiavConfig::MiavConfig(const char *file, Info *i)
+MiavConfig::MiavConfig(const char *file)
{
- info = i;
configs = NULL;
filename = string(file);
@@ -49,8 +48,7 @@ MiavConfig::MiavConfig(const char *file, Info *i)
FILE* fp = fopen(file, "r");
if(!fp) {
- if(info) info->error("Error reading configuration file %s\n", file);
- else fprintf(stderr, "Error reading configuration file %s\n", file);
+ ERR(config, "Error reading configuration file %s\n", file);
return;
}
fseek(fp, 0, SEEK_END);
@@ -85,16 +83,8 @@ MiavConfig::~MiavConfig()
*/
void MiavConfig::parseError(const char* msg, _cfg* cfg)
{
- if(info) info->error("Error parsing file %s at line %d:\n\t%s\n\t%s\n",
- filename.c_str(),
- cfg->line,
- cfg->orig,
- msg);
- else fprintf(stderr, "Error parsing file %s at line %d:\n\t%s\n\t%s\n",
- filename.c_str(),
- cfg->line,
- cfg->orig,
- msg);
+ ERR(config, "Error parsing file %s at line %d:\n\t%s\n\t%s\n",
+ filename.c_str(), cfg->line, cfg->orig, msg);
}
_cfg* MiavConfig::readLines(char* raw)
@@ -471,8 +461,7 @@ _cfg *MiavConfig::findNode(const char* node)
if(!strcmp(node, cfg->name->c_str())) return cfg;
cfg = cfg->next;
}
- if(info) info->error("Missing line in configuration file: \"%s\"!\n", node);
- else fprintf(stderr, "Missing line in configuration file: \"%s\"!\n", node);
+ ERR(config, "Missing line in configuration file: \"%s\"!\n", node);
return NULL;
}
diff --git a/src/miav_config.h b/src/miav_config.h
index e98b729..b43e001 100644
--- a/src/miav_config.h
+++ b/src/miav_config.h
@@ -31,10 +31,6 @@
#include <string>
using namespace std;
-#include "info.h"
-// Cyclic include :(
-class Info;
-
typedef enum {
CONFIG_UNKNOWN,
CONFIG_INT,
@@ -65,7 +61,7 @@ typedef struct __cfg {
class MiavConfig {
public:
MiavConfig(); // Empty constructor for unit tests.
- MiavConfig(const char *file, Info *info = NULL);
+ MiavConfig(const char *file);
~MiavConfig();
int readInt(const char *node);
@@ -74,7 +70,6 @@ public:
float readFloat(const char *node);
protected:
- Info *info;
string filename;
_cfg *createSemantics(_cfg *cfg);
diff --git a/src/miav_daemon.cc b/src/miav_daemon.cc
index c044ed9..06a0e53 100644
--- a/src/miav_daemon.cc
+++ b/src/miav_daemon.cc
@@ -24,20 +24,18 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "miav_daemon.h"
-#include "info_console.h"
-#include "miav_config.h"
-
-#include "server.h"
-#include "socket.h"
-
#include <signal.h>
#include <errno.h>
-
#include <stdlib.h>
+#include <hugin.hpp>
+
+#include "miav_config.h"
+#include "server.h"
+#include "socket.h"
+
MiavDaemon::MiavDaemon()
{}
@@ -46,9 +44,8 @@ MiavDaemon::~MiavDaemon()
int MiavDaemon::daemon_main()
{
- MiavConfig cfg(ETC"/miav.conf", NULL);
- InfoConsole info(&cfg);
- config = new MiavConfig(ETC"/miav.conf", &info);
+ MiavConfig cfg(ETC"/miav.conf");
+ config = new MiavConfig(ETC"/miav.conf");
int port = config->readInt("server_port");
pid_t childpid; // variable to store the child's pid
@@ -56,12 +53,12 @@ int MiavDaemon::daemon_main()
signal(SIGCLD, SIG_IGN); // Ved SIGCHILD til IGNORE maa wait/waitpid ikke kaldes
// (ellers kommer der kernel-brok)
- info.info("Starting MIaV server v. %s", VERSION);
- info.info("Listening on port %d", port);
- Socket *socket = new Socket(port, &info);
+ INFO(miav, "Starting MIaV server v. %s", VERSION);
+ INFO(miav, "Listening on port %d", port);
+ Socket *socket = new Socket(port);
if(socket->hasError()) {
- info.error("Listening socket has errors, quitting.");
+ ERR(miav, "Listening socket has errors, quitting.");
delete socket;
return 1;
}
@@ -70,19 +67,19 @@ int MiavDaemon::daemon_main()
Socket *csocket = new Socket(socket->slisten());
if(socket->hasError()) {
- info.error("Server socket has errors, quitting.");
+ ERR(miav, "Server socket has errors, quitting.");
delete csocket;
break;
}
if(csocket->hasError()) {
- info.error("Child socket has errors, quitting.");
+ ERR(miav, "Child socket has errors, quitting.");
delete csocket;
break;
}
if(!csocket->isConnected()) {
- info.error("Child socket is not connected, quitting.");
+ ERR(miav, "Child socket is not connected, quitting.");
delete csocket;
break;
}
@@ -91,11 +88,11 @@ int MiavDaemon::daemon_main()
switch(childpid) {
case -1: // fork() returns -1 on failure
- info.log("Fork error: %s", strerror(errno));
+ ERR(miav, "Fork error: %s", strerror(errno));
exit(1);
case 0: // fork() returns 0 to the child process
delete socket; // Close listen socket.
- newConnection(csocket, &info);
+ newConnection(csocket);
delete csocket; // Close communication socket.
exit(0);
diff --git a/src/miavd.cc b/src/miavd.cc
index 9aba61c..2a9b97b 100644
--- a/src/miavd.cc
+++ b/src/miavd.cc
@@ -37,7 +37,7 @@ int main(int argc, char *argv[])
{
MiavDaemon daemon;
- MiavConfig cfg(ETC"/miav.conf", NULL);
+ MiavConfig cfg(ETC"/miav.conf");
string *user = cfg.readString("server_user");
string *group = cfg.readString("server_group");
diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc
index 640239d..ae78ee2 100644
--- a/src/mov_encoder.cc
+++ b/src/mov_encoder.cc
@@ -39,6 +39,8 @@
// For nice
#include <unistd.h>
+#include <hugin.hpp>
+
#include "miav_config.h"
#include "libfame_wrapper.h"
@@ -46,11 +48,9 @@
MovEncoder::MovEncoder(volatile bool *r, sem_t *r_sem,
ThreadSafeQueueFIFO *in,
ThreadSafeQueuePriority *video_out,
- ThreadSafeQueuePriority *audio_out,
- Info *i)
+ ThreadSafeQueuePriority *audio_out)
{
- info = i;
- info->info("MovEncoder");
+ DEBUG(mov, "MovEncoder");
running = r;
@@ -64,24 +64,24 @@ MovEncoder::MovEncoder(volatile bool *r, sem_t *r_sem,
MovEncoder::~MovEncoder()
{
- info->info("~MovEncoder");
+ DEBUG(mov, "~MovEncoder");
}
// this runs in a thread
void MovEncoder::thread_main()
{
- info->info("MovEncoder::run");
+ DEBUG(mov, "MovEncoder::run");
// Run with slightly lower priority than MovEncoderWriter AND AudioEncoder
- if(nice(2) == -1) info->warn("Could not set MovEncoder nice.");
+ if(nice(2) == -1) WARN(mov, "Could not set MovEncoder nice.");
FrameVector *item;
Frame *in_frame;
Frame *out_v_frame;
Frame *out_a_frame;
- LibFAMEWrapper fame(info);
+ LibFAMEWrapper fame;
// Process until running == false and the queue is empty
while(*running) {
@@ -94,7 +94,7 @@ void MovEncoder::thread_main()
// Check for end of stream
if(in_frame->endOfFrameStream == true) {
- info->info("endOfFrameStream in MovEncoder");
+ DEBUG(mov, "endOfFrameStream in MovEncoder");
// Signal to stop running
*running = false;
@@ -127,7 +127,7 @@ void MovEncoder::thread_main()
}
}
- info->info("MovEncoder::stop");
+ DEBUG(mov, "MovEncoder::stop");
}
diff --git a/src/mov_encoder.h b/src/mov_encoder.h
index 8910f4b..9b99959 100644
--- a/src/mov_encoder.h
+++ b/src/mov_encoder.h
@@ -46,8 +46,6 @@ using namespace std;
#include "thread.h"
#include <pthread.h>
-#include "info.h"
-
#include "threadsafe_queue_priority.h"
#include "threadsafe_queue_fifo.h"
@@ -56,8 +54,7 @@ public:
MovEncoder(volatile bool *r, sem_t *r_sem,
ThreadSafeQueueFIFO *in,
ThreadSafeQueuePriority *video_out,
- ThreadSafeQueuePriority *audio_out,
- Info *info);
+ ThreadSafeQueuePriority *audio_out);
~MovEncoder();
void thread_main();
@@ -65,8 +62,6 @@ public:
volatile bool *running;
private:
- Info *info;
-
// Input queue
ThreadSafeQueueFIFO *inputqueue;
diff --git a/src/mov_encoder_thread.cc b/src/mov_encoder_thread.cc
index 2ff013d..77380d5 100644
--- a/src/mov_encoder_thread.cc
+++ b/src/mov_encoder_thread.cc
@@ -24,15 +24,17 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "mov_encoder_thread.h"
+
#include <errno.h>
+
+#include <hugin.hpp>
+
#include "miav_config.h"
-MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr, Info *i)
+MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr)
{
- info = i;
- info->info("MovEncoderThread");
+ DEBUG(mov, "MovEncoderThread");
// Queue
inputqueue = new ThreadSafeQueueFIFO();
@@ -40,19 +42,19 @@ MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr, Info *
// Initialize read semaphore
sem_init(&read_sem, 0, 0);
- video_output_queue = new ThreadSafeQueuePriority(info);
- audio_input_queue = new ThreadSafeQueuePriority(info);
- audio_output_queue = new ThreadSafeQueuePriority(info);
+ video_output_queue = new ThreadSafeQueuePriority();
+ audio_input_queue = new ThreadSafeQueuePriority();
+ audio_output_queue = new ThreadSafeQueuePriority();
- info->info("video_output_queue: 0x%x", video_output_queue);
- info->info("audio_input_queue: 0x%x", audio_input_queue);
- info->info("audio_output_queue: 0x%x", audio_output_queue);
+ INFO(mov, "video_output_queue: %p", video_output_queue);
+ INFO(mov, "audio_input_queue: %p", audio_input_queue);
+ INFO(mov, "audio_output_queue: %p", audio_output_queue);
block = new FrameVector();
num_frames_in_block = config->readString("frame_sequence")->length();
- info->info("Frame sequence length %d", num_frames_in_block);
+ INFO(mov, "Frame sequence length %d", num_frames_in_block);
threads = config->readInt("encoding_threads");
@@ -65,23 +67,20 @@ MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr, Info *
MovEncoder *movenc = new MovEncoder(&movencodersrunning, &read_sem,
inputqueue,
video_output_queue,
- audio_input_queue,
- info);
+ audio_input_queue);
movenc->run();
encs.push_back(movenc);
}
// Create the audio encoder
audioenc = new AudioEncoder(audio_input_queue,
- audio_output_queue,
- info);
+ audio_output_queue);
audioenc->run();
// Create the multiplexer
writer = new MovEncoderWriter(clientip, cpr,
video_output_queue,
- audio_output_queue,
- info);
+ audio_output_queue);
writer->run();
frame_number = 0;
@@ -90,47 +89,48 @@ MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr, Info *
//#include <unistd.h>
MovEncoderThread::~MovEncoderThread()
{
- info->info("~MovEncoderThread");
+ DEBUG(mov, "~MovEncoderThread");
// First we destroy the movie encoders
for(int cnt = 0; cnt < threads; cnt++) {
encs[cnt]->wait_stop(); // Wait for it to stop
delete encs[cnt]; // Delete it
}
- info->info("Deleted the movie encoders");
+ DEBUG(mov, "Deleted the movie encoders");
// Then we destroy the audio encoder
audioenc->wait_stop(); // Wait for it to stop.
delete audioenc; // delete the audio encoder
- info->info("Deleted the audio encoder");
+ DEBUG(mov, "Deleted the audio encoder");
// Finally we destroy the writer.
writer->wait_stop(); // Wait for it to stop.
delete writer; // delete the writer (end thereby close the file)
- info->info("Deleted the writer");
+ DEBUG(mov, "Deleted the writer");
// Destroy the semaphore.
sem_destroy(&read_sem);
- info->info("~MovEncoderThread::done");
+ DEBUG(mov, "~MovEncoderThread::done");
}
static int output = 0;
void MovEncoderThread::encode(Frame* frame)
{
if(output % 250 == 0) // 25 * 24
- info->info("inputqueue: %d\tvideo_outputqueue: %d\taudio_inputqueue: %d\taudio_outputqueue: %d.",
- inputqueue->size(),
- video_output_queue->size(),
- audio_input_queue->size(),
- audio_output_queue->size());
+ INFO(mov, "inputqueue: %d\tvideo_outputqueue: %d\taudio_inputqueue: %d\t"
+ "audio_outputqueue: %d.",
+ inputqueue->size(),
+ video_output_queue->size(),
+ audio_input_queue->size(),
+ audio_output_queue->size());
output++;
if(frame == NULL) {
- info->info("MovEncoderThread::encode - NULL frame detected.");
+ WARN(mov, "MovEncoderThread::encode - NULL frame detected.");
// Terminate
return;
}
diff --git a/src/mov_encoder_thread.h b/src/mov_encoder_thread.h
index feea8e2..b2d6fd2 100644
--- a/src/mov_encoder_thread.h
+++ b/src/mov_encoder_thread.h
@@ -24,7 +24,6 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#ifndef __MIAV_MOV_ENCODER_THREAD_H__
#define __MIAV_MOV_ENCODER_THREAD_H__
@@ -45,14 +44,12 @@ using namespace std;
#include "audio_encoder.h"
#include "mov_encoder_writer.h"
-#include "info.h"
-
// For savestate_n
#include "package.h"
class MovEncoderThread {
public:
- MovEncoderThread(const char *clientip, const char *cpr, Info *info);
+ MovEncoderThread(const char *clientip, const char *cpr);
~MovEncoderThread();
void encode(Frame* frame);
@@ -60,8 +57,6 @@ public:
void setSaveState(n_savestate savestate);
private:
- Info *info;
-
// FrameVectorQueue *inputqueue;
ThreadSafeQueueFIFO *inputqueue;
FrameVector *block;
diff --git a/src/mov_encoder_writer.cc b/src/mov_encoder_writer.cc
index 1773527..7866995 100644
--- a/src/mov_encoder_writer.cc
+++ b/src/mov_encoder_writer.cc
@@ -24,38 +24,32 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "mov_encoder_writer.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-
#include <pthread.h>
#include <semaphore.h>
-
#include <errno.h>
-
#include <string>
-using namespace std;
+#include <time.h>
-#include "miav_config.h"
+using namespace std;
-#include <time.h>
+#include <hugin.hpp>
+#include "miav_config.h"
#include "multiplexer.h"
#include "libmplex_wrapper.h"
-
#include "multicast_configuration.h"
MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
ThreadSafeQueuePriority *video_q,
- ThreadSafeQueuePriority *audio_q,
- Info *i)
+ ThreadSafeQueuePriority *audio_q)
{
- info = i;
- info->info("MovEncoderWriter");
+ DEBUG(mov, "MovEncoderWriter");
// Create path and filename
char fname[256];
@@ -82,23 +76,21 @@ MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
sprintf(fname, "%s/%s/%s/%s-%s-", server_root->c_str(), birthmonth, cpr, cpr, date);
- file = new File(fname, "mpg", info);
+ file = new File(fname, "mpg");
- MulticastConfiguration mcconfig(info, ETC"/multicast.conf");
+ MulticastConfiguration mcconfig(ETC"/multicast.conf");
mcastconf_t mcclientconf = mcconfig.getConf((char*)clientip);
- info->info("Client: %s - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
- mcclientconf.client.c_str(),
- mcclientconf.enabled?"Yes\0":"No\0",
- mcclientconf.addr.c_str(),
- mcclientconf.port,
- mcclientconf.with_audio?"Yes\0":"No\0");
-
+ INFO(mov, "Client: %s - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
+ mcclientconf.client.c_str(),
+ mcclientconf.enabled?"Yes\0":"No\0",
+ mcclientconf.addr.c_str(),
+ mcclientconf.port,
+ mcclientconf.with_audio?"Yes\0":"No\0");
multicast = NULL;
- if(mcclientconf.enabled) multicast = new Multicast(info,
- mcclientconf);
+ if(mcclientconf.enabled) multicast = new Multicast(mcclientconf);
video_queue = video_q;
audio_queue = audio_q;
@@ -108,30 +100,24 @@ MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
MovEncoderWriter::~MovEncoderWriter()
{
- info->info("~MovEncoderWriter");
+ DEBUG(mov, "~MovEncoderWriter");
delete file;
if(multicast) delete multicast;
}
void MovEncoderWriter::thread_main()
{
- info->info("MovEncoderWriter::run");
+ DEBUG(mov, "MovEncoderWriter::run");
#ifdef WITH_LIBMPLEX
- LibMPlexWrapper mplex(info,
- file,
- video_queue,
- audio_queue);
+ LibMPlexWrapper mplex(file, video_queue, audio_queue);
mplex.multiplex();
#else/*WITH_LIBMPLEX*/
- Multiplexer multiplexer(file, multicast,
- info, &running,
- video_queue,
- audio_queue);
+ Multiplexer multiplexer(file, multicast, &running, video_queue, audio_queue);
multiplexer.multiplex();
#endif/*WITH_LIBMPLEX*/
- info->info("MovEncoderWriter::stop");
+ DEBUG(mov, "MovEncoderWriter::stop");
}
void MovEncoderWriter::setSaveState(n_savestate savestate)
diff --git a/src/mov_encoder_writer.h b/src/mov_encoder_writer.h
index ba9ff16..0732f35 100644
--- a/src/mov_encoder_writer.h
+++ b/src/mov_encoder_writer.h
@@ -32,7 +32,6 @@
#include "thread.h"
#include "file.h"
#include "multicast.h"
-#include "info.h"
#include "threadsafe_queue_priority.h"
@@ -49,8 +48,7 @@ class MovEncoderWriter : public Thread {
public:
MovEncoderWriter(const char *clientip, const char* cpr,
ThreadSafeQueuePriority *video_queue,
- ThreadSafeQueuePriority *audio_queue,
- Info *info);
+ ThreadSafeQueuePriority *audio_queue);
~MovEncoderWriter();
void thread_main();
@@ -60,8 +58,6 @@ public:
volatile bool running;
private:
- Info *info;
-
File *file;
Multicast *multicast;
diff --git a/src/multicast.cc b/src/multicast.cc
index 2f3e7a8..35b0212 100644
--- a/src/multicast.cc
+++ b/src/multicast.cc
@@ -24,42 +24,34 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#include "multicast.h"
-#include "multicast_configuration.h"
-
-#include "miav_config.h"
-
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/param.h>
#include <arpa/inet.h>
#include <sys/types.h>
-
#include <string.h>
+#include <errno.h>
+#include <unistd.h>
-// For IP_MTU
-//#include <linux/in.h>
-//#ifndef IP_MTU
-//#define IP_MTU 14
-//#endif
+#include <hugin.hpp>
-#include <errno.h>
+#include "multicast_configuration.h"
+#include "miav_config.h"
-Multicast::Multicast(Info *i, mcastconf_t &mcclientconf)
+Multicast::Multicast(mcastconf_t &mcclientconf)
{
- info = i;
udp_buffer = NULL;
multicast_audio = mcclientconf.with_audio;
// Open connection socket
if(!UDPOpen(mcclientconf.addr.c_str(), mcclientconf.port))
- info->error("Error creating socket %s:%d",
- mcclientconf.addr.c_str(),
- mcclientconf.port);
+ ERR(multicast, "Error creating socket %s:%d",
+ mcclientconf.addr.c_str(),
+ mcclientconf.port);
int mtu = config->readInt("udp_packet_size");
@@ -71,11 +63,11 @@ Multicast::Multicast(Info *i, mcastconf_t &mcclientconf)
if(udp_buffer_size < 1) udp_buffer_size = 1;
udp_buffer = new char[udp_buffer_size];
udp_buffer_pointer = udp_buffer;
- info->info("UDP packet buffer size %db", udp_buffer_size);
+ DEBUG(multicast, "UDP packet buffer size %db", udp_buffer_size);
//} else {
- // info->error("Error getting MTU size from socket: %s", strerror(errno));
- // return;
+ // ERR(multicast, "Error getting MTU size from socket: %s", strerror(errno));
+ // return;
//}
}
@@ -88,7 +80,7 @@ int Multicast::Write(void* buf, int size)
{
if(!udp_buffer) return 0; // no buffer to write in... better break out!
- // info->info("To send: %d", size);
+ // DEBUG(multicast, "To send: %d", size);
char *p = (char*)buf;
int left = udp_buffer_size - (udp_buffer_pointer - udp_buffer);
@@ -104,12 +96,12 @@ int Multicast::Write(void* buf, int size)
p+=to_copy;
size-=to_copy;
- // info->info("Copied %d - %d to go", to_copy, size);
+ // DEBUG(multicast, "Copied %d - %d to go", to_copy, size);
if(left == 0) {
- // info->info("Sending full packet");
+ // DEBUG(multicast, "Sending full packet");
if(write(sock, udp_buffer, udp_buffer_size) != udp_buffer_size) {
- info->error("Could not write entire buffer to socket.");
+ ERR(multicast, "Could not write entire buffer to socket.");
}
left = udp_buffer_size;
udp_buffer_pointer = udp_buffer;
@@ -121,10 +113,10 @@ int Multicast::Write(void* buf, int size)
bool Multicast::is_address_multicast(unsigned long address)
{
if((address & 255) >= 224 && (address & 255) <= 239) {
- info->info("Address is multicast.");
+ INFO(multicast, "Address is multicast.");
return true;
}
- info->info("Address is NOT multicast.");
+ INFO(multicast, "Address is NOT multicast.");
return false;
}
diff --git a/src/multicast.h b/src/multicast.h
index 08df3e1..d4fa784 100644
--- a/src/multicast.h
+++ b/src/multicast.h
@@ -29,11 +29,10 @@
#define __MIAV_MULTICAST_H__
#include "multicast_configuration.h"
-#include "info.h"
class Multicast {
public:
- Multicast(Info *i, mcastconf_t &mcclientconf);
+ Multicast(mcastconf_t &mcclientconf);
~Multicast();
int Write(void* buf, int size);
@@ -41,8 +40,6 @@ public:
bool multicast_audio;
private:
- Info *info;
-
bool is_address_multicast(unsigned long address);
bool UDPOpen(const char *address, int port);
int sock;
diff --git a/src/multicast_configuration.cc b/src/multicast_configuration.cc
index 217b959..4e097dd 100644
--- a/src/multicast_configuration.cc
+++ b/src/multicast_configuration.cc
@@ -24,13 +24,14 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "config.h"
#include "multicast_configuration.h"
#include <string.h>
-MulticastConfiguration::MulticastConfiguration(Info *info, const char *file)
- : MiavConfig(file, info)
+#include <hugin.hpp>
+
+MulticastConfiguration::MulticastConfiguration(const char *file)
+ : MiavConfig(file)
{
mcastconf_t conf;
@@ -79,22 +80,23 @@ MulticastConfiguration::MulticastConfiguration(Info *info, const char *file)
if(!global) confs.push_back(conf);
// Show the configuration in the log file .
- info->info("Global - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
- global_conf.enabled?"Yes\0":"No\0",
- global_conf.addr.c_str(),
- global_conf.port,
- global_conf.with_audio?"Yes\0":"No\0");
+ DEBUG(multicast, "Global - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
+ global_conf.enabled?"Yes\0":"No\0",
+ global_conf.addr.c_str(),
+ global_conf.port,
+ global_conf.with_audio?"Yes\0":"No\0");
for(unsigned int cnt = 0; cnt < confs.size(); cnt++) {
- info->info("Client: %s - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
- confs[cnt].client.c_str(),
- confs[cnt].enabled?"Yes\0":"No\0",
- confs[cnt].addr.c_str(),
- confs[cnt].port,
- confs[cnt].with_audio?"Yes\0":"No\0");
+ DEBUG(multicast,
+ "Client: %s - Enabled: %s - Addr: %s - Port: %d - WithAudio: %s",
+ confs[cnt].client.c_str(),
+ confs[cnt].enabled?"Yes\0":"No\0",
+ confs[cnt].addr.c_str(),
+ confs[cnt].port,
+ confs[cnt].with_audio?"Yes\0":"No\0");
}
- info->info("Chosing:");
+ DEBUG(multicast, "Chosing:");
}
MulticastConfiguration::~MulticastConfiguration()
@@ -110,34 +112,3 @@ mcastconf_t &MulticastConfiguration::getConf(char *client)
return global_conf;
}
-
-#ifdef __TEST_MULTICAST_CONFIGURATION
-#include "info_simple.h"
-
-int main(int argc, char *argv[]) {
- if(argc < 2) {
- fprintf(stderr, "usage:\n\t%s [filename]\n", argv[0]);
- return 1;
- }
-
- InfoSimple info;
- MulticastConfiguration conf(&info, argv[1]);
-
- mcastconf_t mcconf = conf.getConf("192.168.0.11");
-
- info.warn("Client: %s - Enabled: %s - Addr: %s - Port: %d",
- mcconf.client.c_str(),
- mcconf.enabled?"Yes\0":"No\0",
- mcconf.addr.c_str(),
- mcconf.port);
-
- mcconf = conf.getConf("192.168.0.0");
-
- info.warn("Client: %s - Enabled: %s - Addr: %s - Port: %d",
- mcconf.client.c_str(),
- mcconf.enabled?"Yes\0":"No\0",
- mcconf.addr.c_str(),
- mcconf.port);
-}
-
-#endif/* __TEST_MULTICAST_CONFIGURATION*/
diff --git a/src/multicast_configuration.h b/src/multicast_configuration.h
index b95e503..0de3e29 100644
--- a/src/multicast_configuration.h
+++ b/src/multicast_configuration.h
@@ -43,7 +43,7 @@ typedef struct {
class MulticastConfiguration : private MiavConfig {
public:
- MulticastConfiguration(Info *info, const char *file);
+ MulticastConfiguration(const char *file);
~MulticastConfiguration();
mcastconf_t &getConf(char *client);
diff --git a/src/multiplexer.cc b/src/multiplexer.cc
index 3d889e2..ae51139 100644
--- a/src/multiplexer.cc
+++ b/src/multiplexer.cc
@@ -24,13 +24,14 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-
#include "config.h"
#include "multiplexer.h"
#include <netinet/in.h>
#include <math.h>
+#include <hugin.hpp>
+
#include "util.h"
static uint64_t htonll(uint64_t value)
@@ -74,14 +75,13 @@ static double picture_rate_index[16] = {
RESERVED, RESERVED, RESERVED, RESERVED, RESERVED, RESERVED, RESERVED
};
*/
-Multiplexer::Multiplexer(File *f, Multicast *m, Info *i, volatile bool *r,
+Multiplexer::Multiplexer(File *f, Multicast *m, volatile bool *r,
ThreadSafeQueuePriority *video_q,
ThreadSafeQueuePriority *audio_q)
{
running = r;
file = f;
multicast = m;
- info = i;
frame[TYPE_VIDEO] = NULL;
written[TYPE_VIDEO] = 0.0;
@@ -169,7 +169,7 @@ int Multiplexer::Write(uint16_t val)
Frame *Multiplexer::getFrame(StreamType type)
{
- // info->info("Get %s Frame", type==TYPE_AUDIO?"Audio\0":"Video\0");
+ DEBUG(multiplexer, "Get %s Frame", type==TYPE_AUDIO?"Audio\0":"Video\0");
read[type] = 0;
@@ -199,7 +199,8 @@ int Multiplexer::read_stream(char *buf, unsigned int size, StreamType type)
// check for end of stream
if( frame[type]->endOfFrameStream == true) {
- info->info("endOfFrameStream in Multiplexer %s-stream.", type==TYPE_VIDEO?"video\0":"audio\0");
+ DEBUG(multiplexer, "endOfFrameStream in Multiplexer %s-stream.",
+ type==TYPE_VIDEO?"video\0":"audio\0");
return copied;
}
@@ -209,7 +210,8 @@ int Multiplexer::read_stream(char *buf, unsigned int size, StreamType type)
uint32_t doread = (size - copied) < (frame[type]->size - read[type]) ?
size - copied : (frame[type]->size - read[type]);
- //info->info("Requested: %d. Read: %d. Doread: %d. In buffer %d", size, (*read), doread, (*frame)->size);
+ DEBUG(multiplexer, "Requested: %d. Read: %d. Doread: %d. In buffer %d",
+ size, (*read), doread, (*frame)->size);
memcpy(buf + copied, frame[type]->data + read[type], doread);
read[type] += doread;
@@ -225,7 +227,7 @@ bool Multiplexer::packet(StreamType type)
char buf[PACKET_SIZE];
// Write data
- // info->info("\t\t[%sPacket]", type==TYPE_AUDIO?"Audio\0":"Video\0");
+ DEBUG(multiplexer, "\t\t[%sPacket]", type==TYPE_AUDIO?"Audio\0":"Video\0");
uint16_t framesize = read_stream(buf, PACKET_SIZE, type);
@@ -264,7 +266,8 @@ bool Multiplexer::packet(StreamType type)
*/
bool Multiplexer::packet()
{
- //info->info("\t\tWritten[A]: %f, Written[V]: %f", written[TYPE_AUDIO], written[TYPE_VIDEO]);
+ DEBUG(multiplexer, "\t\tWritten[A]: %f, Written[V]: %f",
+ written[TYPE_AUDIO], written[TYPE_VIDEO]);
StreamType type;
/*
@@ -310,7 +313,7 @@ bool Multiplexer::packet()
*/
void Multiplexer::system_header()
{
- // info->info("\t\t[System Header]");
+ DEBUG(multiplexer, "\t\t[System Header]");
// system_header_start_code (32 bits)
Write((void*)ISO11172_1::system_header_start_code,
@@ -376,7 +379,7 @@ void Multiplexer::pack_header()
header.bits.system_clock_reference2 = TIMECODE29_15(SCR);
header.bits.system_clock_reference3 = TIMECODE14_0(SCR);
/*
- info->info("timecode All: %lld, 1: %lld, 2: %lld, 3: %lld",
+ DEBUG(multiplexer, "timecode All: %lld, 1: %lld, 2: %lld, 3: %lld",
SCR,
(unsigned long long int)header.system_clock_reference1,
(unsigned long long int)header.system_clock_reference2,
@@ -428,7 +431,7 @@ bool Multiplexer::pack()
for(int cnt = 0; cnt < PACKETS_PER_PACK; cnt++)
if(!packet()) return false;
- // info->info("\t]");
+ //DEBUG(multiplexer, "\t]");
return true;
}
@@ -438,18 +441,18 @@ bool Multiplexer::pack()
*/
void Multiplexer::iso11172_stream()
{
- // info->info("[iso11172_stream");
+ // DEBUG(multiplexer, "[iso11172_stream");
while(pack());
- // info->info("]");
- // info->info("[iso11172_end_code]");
+ // DEBUG(multiplexer, "]");
+ // DEBUG(multiplexer, "[iso11172_end_code]");
Write((void*)ISO11172_1::end_code, SIZEOF(ISO11172_1::end_code));
/*
- info->info("false && false = %d", false && false);
- info->info("true && false = %d", true && false);
- info->info("true && true = %d", true && true);
+ DEBUG(multiplexer, "false && false = %d", false && false);
+ DEBUG(multiplexer, "true && false = %d", true && false);
+ DEBUG(multiplexer, "true && true = %d", true && true);
*/
}
@@ -463,7 +466,7 @@ void Multiplexer::multiplex()
char buf[1024];
do {
frmsz = read_stream(buf, sizeof(buf), BYPASS);
- info->info("Wrote %d bytes", frmsz);
+ DEBUG(multiplexer, "Wrote %d bytes", frmsz);
Write(buf, frmsz);
} while(frmsz == sizeof(buf));
return;
diff --git a/src/multiplexer.h b/src/multiplexer.h
index 9b2aed1..889e7cc 100644
--- a/src/multiplexer.h
+++ b/src/multiplexer.h
@@ -34,7 +34,6 @@
#include "file.h"
#include "multicast.h"
-#include "info.h"
#include "frame.h"
#include "threadsafe_queue_priority.h"
@@ -69,7 +68,7 @@ typedef enum {
class Multiplexer {
public:
- Multiplexer(File *file, Multicast *m, Info *info, volatile bool *running,
+ Multiplexer(File *file, Multicast *m, volatile bool *running,
ThreadSafeQueuePriority *video_queue,
ThreadSafeQueuePriority *audio_queue);
~Multiplexer();
@@ -126,7 +125,6 @@ protected:
File *file;
Multicast *multicast;
- Info *info;
volatile bool *running;
// Audio Header
diff --git a/src/network.cc b/src/network.cc
index 50ff810..4196cc9 100644
--- a/src/network.cc
+++ b/src/network.cc
@@ -32,9 +32,10 @@
#include <string.h>
#include <sys/socket.h>
-Network::Network(Socket *gs, Info *ginfo)
+#include <hugin.hpp>
+
+Network::Network(Socket *gs)
{
- info = ginfo;
s = gs;
}
@@ -45,13 +46,13 @@ Network::~Network()
int Network::write(void *buf, int size)
{
if(!s->isConnected()) {
- // info->error("Write attempted to a socket not connected!");
+ ERR(network, "Write attempted to a socket not connected!");
return -1;
}
int n = send(s->ssocket, buf, size, MSG_WAITALL);
if(n == -1) {
- info->error("An error occurred!");
+ ERR(network, "An error occurred!");
}
return n;
@@ -60,13 +61,13 @@ int Network::write(void *buf, int size)
int Network::read(void *buf, int size)
{
if(!s->isConnected()) {
- // info->error("Read attempted from a socket not connected!");
+ ERR(network, "Read attempted from a socket not connected!");
return -1;
}
int n = recv(s->ssocket, buf, size, MSG_WAITALL);
if(n == -1) {
- info->error("An error occurred!");
+ ERR(network, "An error occurred!");
}
return n;
@@ -90,7 +91,7 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz)
struct iovec iovecs[2];
if(!s->isConnected()) {
- // info->error("Write attempted to a socket not connected!");
+ ERR(network, "Write attempted to a socket not connected!");
return -1;
}
@@ -108,7 +109,7 @@ int Network::sendPackage(n_header *h, void* buf, int bufsz)
int n = sendmsg(s->ssocket, &msg, 0);
if(n < 0) {
perror(" sendmsg(s->ssocket, &msg, 0): ");
- info->error("A network error ocurred during sendPackage!");
+ ERR(network, "A network error ocurred during sendPackage!");
return -1;
}
@@ -121,7 +122,7 @@ int Network::recvPackage(n_header *h, void* buf, int bufsz)
struct iovec iovecs[2];
if(!s->isConnected()) {
- // info->error("Read attempted to a socket not connected!");
+ ERR(network, "Read attempted to a socket not connected!");
return -1;
}
@@ -139,12 +140,12 @@ int Network::recvPackage(n_header *h, void* buf, int bufsz)
int n = recvmsg(s->ssocket, &msg, MSG_WAITALL);
if(n < 0) {
- info->error("A network error ocurred during recvPackage!");
+ ERR(network, "A network error ocurred during recvPackage!");
return -1;
}
if(msg.msg_iovlen != 2) {
- info->error("Wrong package format!");
+ ERR(network, "Wrong package format!");
return -1;
}
return n;
diff --git a/src/network.h b/src/network.h
index f64310e..e00dac7 100644
--- a/src/network.h
+++ b/src/network.h
@@ -30,11 +30,10 @@
#include "socket.h"
#include "package.h"
-#include "info.h"
class Network {
public:
- Network(Socket *gs, Info* ginfo);
+ Network(Socket *gs);
~Network();
// Raw communication
@@ -46,7 +45,6 @@ public:
int recvPackage(n_header *h, void* buf, int bufsz);
private:
- Info *info;
Socket *s;
};
diff --git a/src/server.cc b/src/server.cc
index 45d8b48..69e45b6 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -44,6 +44,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <hugin.hpp>
+
#include "miav_config.h"
#include "mov_encoder_thread.h"
@@ -54,12 +56,12 @@
#include "dv.h"
#include "network.h"
-void newConnection(Socket *socket, Info *info)
+void newConnection(Socket *socket)
{
char cpr[256];
char clientip[64];
bool hasCpr = false;
- ServerStatus status(info);
+ ServerStatus status;
n_savestate savestate = LATER;
n_header h;
@@ -69,17 +71,17 @@ void newConnection(Socket *socket, Info *info)
frame = new Frame(NULL, DVPACKAGE_SIZE);
- info->info("CONNECTION OPENED");
- info->info("New connection (%s)", inet_ntoa(socket->socketaddr.sin_addr));
+ INFO(connection, "CONNECTION OPENED");
+ INFO(connection, "New connection (%s)", inet_ntoa(socket->socketaddr.sin_addr));
sprintf(clientip, "%s", inet_ntoa(socket->socketaddr.sin_addr));
- Network network = Network(socket, info);
+ Network network = Network(socket);
while(int ret = network.recvPackage(&h, frame->data, frame->size)) {
status.checkPoint();
if(ret == -1) {
- info->error("A network error ocurred, terminating session");
+ ERR(connection, "A network error ocurred, terminating session");
break;
}
@@ -92,17 +94,17 @@ void newConnection(Socket *socket, Info *info)
if(h.header.h_data.snapshot) {
if(freeze_frame) {
- ImgEncoder(cpr, info).encode(freeze_frame, 100);
+ ImgEncoder(cpr).encode(freeze_frame, 100);
delete freeze_frame;
freeze_frame = NULL;
} else {
- ImgEncoder(cpr, info).encode(frame, 100);
+ ImgEncoder(cpr).encode(frame, 100);
}
}
if(h.header.h_data.savestate != NO_CHANGE) {
savestate = h.header.h_data.savestate;
- info->info("GOT SAVESTATE FROM NETWORK: %d", savestate );
+ INFO(connecion, "GOT SAVESTATE FROM NETWORK: %d", savestate );
}
if(h.header.h_data.freeze) {
@@ -114,14 +116,14 @@ void newConnection(Socket *socket, Info *info)
// This one must be last!
if(h.header.h_data.record) {
// if(!enc) enc = newMovEncoder(cpr);
- if(!enc) enc = new MovEncoderThread(clientip, cpr, info);
+ if(!enc) enc = new MovEncoderThread(clientip, cpr);
enc->encode(frame);
}
frame = new Frame(NULL, DVPACKAGE_SIZE);
}
- info->info("Closing connection...");
+ INFO(connection, "Closing connection...");
// No encoder exists, if this is a pure snapshot (image) connection.
if(enc) {
@@ -132,5 +134,5 @@ void newConnection(Socket *socket, Info *info)
delete enc;
}
- info->info("CONNECTION CLOSED");
+ INFO(connection, "CONNECTION CLOSED");
}
diff --git a/src/server.h b/src/server.h
index 7126a75..ca352c7 100644
--- a/src/server.h
+++ b/src/server.h
@@ -29,9 +29,6 @@
#include "socket.h"
-#include "info.h"
-
-void newConnection(Socket *s, Info* info);
-
+void newConnection(Socket *s);
#endif/*__SERVER_H__*/
diff --git a/src/server_status.cc b/src/server_status.cc
index 7f4714e..67bcb15 100644
--- a/src/server_status.cc
+++ b/src/server_status.cc
@@ -24,15 +24,14 @@
* along with MIaV; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include <config.h>
#include "server_status.h"
#include <stdio.h>
-ServerStatus::ServerStatus(Info *i)
-{
- info = i;
+#include <hugin.hpp>
+ServerStatus::ServerStatus()
+{
gettimeofday(&oldtime, NULL);
for(int cnt = 0; cnt < BUFFERSIZE; cnt++) {
@@ -67,7 +66,7 @@ void ServerStatus::checkPoint()
for(int cnt = 0; cnt < BUFFERSIZE; cnt++) {
total += (double)frametime[cnt];
}
- info->info("Status - fps: %f", 1000000.0 / (total / (double)BUFFERSIZE));
+ INFO(status, "Status - fps: %f", 1000000.0 / (total / (double)BUFFERSIZE));
}
}
diff --git a/src/server_status.h b/src/server_status.h
index 5a7cb6c..82ec8ec 100644
--- a/src/server_status.h
+++ b/src/server_status.h
@@ -28,8 +28,6 @@
#ifndef __MIAV_SERVER_STATUS_H__
#define __MIAV_SERVER_STATUS_H__
-#include "info.h"
-
#include <sys/time.h>
// How many steps to do avarage calculation over.
@@ -40,14 +38,13 @@
class ServerStatus {
public:
- ServerStatus(Info *info);
+ ServerStatus();
~ServerStatus();
void checkPoint();
private:
long long interval;
- Info *info;
unsigned int frametime[BUFFERSIZE];
struct timeval time;
struct timeval oldtime;
diff --git a/src/socket.cc b/src/socket.cc
index b34bae6..1fffc87 100644
--- a/src/socket.cc
+++ b/src/socket.cc
@@ -31,16 +31,16 @@
// for gethostbyname
#include <netdb.h>
-Socket::Socket(Info *ginfo)
+#include <hugin.hpp>
+
+Socket::Socket()
{
- info = ginfo;
connected = false;
err = 0;
}
-Socket::Socket(u_short port, Info *ginfo)
+Socket::Socket(u_short port)
{
- info = ginfo;
connected = false;
err = 0;
@@ -52,7 +52,7 @@ Socket::Socket(u_short port, Info *ginfo)
if (ssocket < 0) {
err = 1;
- info->error("Socket: socket() failed!");
+ ERR(socket, "Socket: socket() failed!");
}
memset((char *) &socketaddr, 0, sizeof(socketaddr));
@@ -73,10 +73,10 @@ Socket::~Socket()
Socket Socket::slisten()
{
- Socket s = Socket(info);
+ Socket s = Socket();
if(err) {
- //info->error("Socket: No socket present!");
+ ERR(socket, "Socket: No socket present!");
return s;
}
if(!connected) {
@@ -84,7 +84,7 @@ Socket Socket::slisten()
err = bind(ssocket, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
if (err) {
- info->error("Socket: bind() failed! %s", strerror(errno));
+ ERR(socket, "Socket: bind() failed! %s", strerror(errno));
return s;
}
@@ -92,7 +92,7 @@ Socket Socket::slisten()
// requests (max 5 in queue)
err = listen(ssocket, 5);
if(err) {
- info->error("Socket: listen() failed! %s", strerror(errno));
+ ERR(socket, "Socket: listen() failed! %s", strerror(errno));
return s;
}
}
@@ -107,7 +107,7 @@ Socket Socket::slisten()
if (s.ssocket < 0) {
s.connected = false;
err = 1;
- info->error("Socket: accept() failed! %s", strerror(errno));
+ ERR(socket, "Socket: accept() failed! %s", strerror(errno));
return s;
}
@@ -121,7 +121,7 @@ int Socket::sconnect(char *addr)
{
if(err) {
connected = false;
- info->error("Socket: No socket present!");
+ ERR(socket, "Socket: No socket present!");
return err;
}
@@ -146,7 +146,7 @@ int Socket::sconnect(char *addr)
err = connect(ssocket, (struct sockaddr*)&socketaddr, sizeof(socketaddr));
if (err) {
connected = false;
- info->error("Socket: connect() failed! %s", strerror(errno));
+ ERR(socket, "Socket: connect() failed! %s", strerror(errno));
return err;
}
// fprintf(stderr, "Socket connected\n");
diff --git a/src/socket.h b/src/socket.h
index df2a133..dde4729 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -37,12 +37,10 @@
#include <sys/socket.h>
#include <arpa/inet.h>
-#include "info.h"
-
class Socket {
public:
- Socket(Info *ginfo);
- Socket(u_short port, Info *ginfo);
+ Socket();
+ Socket(u_short port);
~Socket();
Socket slisten();
int sconnect(char *ip);
@@ -54,7 +52,6 @@ public:
bool connected;
private:
- Info *info;
int err;
};
diff --git a/src/threadsafe_queue_priority.cc b/src/threadsafe_queue_priority.cc
index df7ae8c..3ffe027 100644
--- a/src/threadsafe_queue_priority.cc
+++ b/src/threadsafe_queue_priority.cc
@@ -29,10 +29,9 @@
#include "util.h"
-ThreadSafeQueuePriority::ThreadSafeQueuePriority(Info* i, unsigned int number)
+ThreadSafeQueuePriority::ThreadSafeQueuePriority(unsigned int number)
// : ThreadSafeQueue< Frame* >()
{
- info = i;
framenumber = number;
}
diff --git a/src/threadsafe_queue_priority.h b/src/threadsafe_queue_priority.h
index 8d3cdf1..a310271 100644
--- a/src/threadsafe_queue_priority.h
+++ b/src/threadsafe_queue_priority.h
@@ -35,8 +35,6 @@
#include <queue>
#include <functional>
-#include "info.h"
-
// Method for use, when comparing Frames in priority queue.
template <typename T>
struct priority : std::binary_function<T, T, bool> {
@@ -47,7 +45,7 @@ struct priority : std::binary_function<T, T, bool> {
class ThreadSafeQueuePriority: public ThreadSafeQueue< Frame* > {
public:
- ThreadSafeQueuePriority(Info *info, unsigned int framenumber = 0);
+ ThreadSafeQueuePriority(unsigned int framenumber = 0);
~ThreadSafeQueuePriority();
void push(Frame *frame);
@@ -55,8 +53,6 @@ public:
int size();
private:
- Info* info;
-
unsigned int framenumber;
std::priority_queue< Frame*, std::vector<Frame*>, priority<Frame*> > queue;
};