summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/img_encoder.cc9
-rw-r--r--server/img_encoder.h1
-rw-r--r--server/info_console.cc5
-rw-r--r--server/libfame_wrapper.cc27
-rw-r--r--server/liblame_wrapper.cc14
-rw-r--r--server/libmplex_wrapper.cc1
-rw-r--r--server/miav_server.cc32
-rw-r--r--server/miav_server.h30
-rw-r--r--server/mov_encoder.cc8
-rw-r--r--server/mov_encoder.h1
-rw-r--r--server/mov_encoder_thread.cc13
-rw-r--r--server/mov_encoder_thread.h1
-rw-r--r--server/mov_encoder_writer.cc10
-rw-r--r--server/mov_encoder_writer.h4
-rw-r--r--server/multicast.cc7
-rw-r--r--server/multicast.h1
-rw-r--r--server/multicast_configuration.cc3
-rw-r--r--server/multicast_configuration.h17
-rw-r--r--server/server.cc1
19 files changed, 98 insertions, 87 deletions
diff --git a/server/img_encoder.cc b/server/img_encoder.cc
index df44686..c6670af 100644
--- a/server/img_encoder.cc
+++ b/server/img_encoder.cc
@@ -35,7 +35,7 @@
#include "img_encoder.h"
#include <stdio.h>
-#include "miav_config.h"
+#include "configuration.h"
#include "info.h"
extern "C" {
@@ -52,13 +52,14 @@ ImgEncoder::ImgEncoder(const char* cpr)
{
// Create path and filename
char fname[256];
- std::string *server_root;
+ std::string server_root;
char birthmonth[3];
char date[32];
char encrypted_cpr[32];
// Get server root
- server_root = MIaV::config->readString("server_image_root");
+ if(MIaV::config->get("server_image_root", &server_root))
+ MIaV::info->error("could not read symbol [server_image_root] from conf file!");
// Copy the bytes representing the birth month from the cpr
// [dd][mm][yy]-[nn][nn]
@@ -89,7 +90,7 @@ ImgEncoder::ImgEncoder(const char* cpr)
cnt++;
}
- sprintf(fname, "%s/%s/%s/%s-%s-", server_root->c_str(), birthmonth, encrypted_cpr, cpr, date);
+ sprintf(fname, "%s/%s/%s/%s-%s-", server_root.c_str(), birthmonth, encrypted_cpr, cpr, date);
file = new File(fname, "jpg");
}
diff --git a/server/img_encoder.h b/server/img_encoder.h
index c9b8885..3f069e0 100644
--- a/server/img_encoder.h
+++ b/server/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...
diff --git a/server/info_console.cc b/server/info_console.cc
index da99b7a..fdceb2f 100644
--- a/server/info_console.cc
+++ b/server/info_console.cc
@@ -27,14 +27,15 @@
#include <config.h>
#include "info_console.h"
-#include "miav_config.h"
+#include "configuration.h"
#include <stdio.h>
#include <stdarg.h>
InfoConsole::InfoConsole(): Info()
{
- log_filename = *(MIaV::config->readString("server_log_file"));
+ if(MIaV::config->get("server_log_file", &log_filename))
+ fprintf(stderr, "Could not read symbol [server_log_file] from conf file!\n");
}
InfoConsole::~InfoConsole()
diff --git a/server/libfame_wrapper.cc b/server/libfame_wrapper.cc
index 1b0694a..058a158 100644
--- a/server/libfame_wrapper.cc
+++ b/server/libfame_wrapper.cc
@@ -29,7 +29,7 @@
#include <errno.h>
-#include "miav_config.h"
+#include "configuration.h"
#include "info.h"
#include "frame.h"
@@ -94,13 +94,22 @@ LibFAMEWrapper::LibFAMEWrapper()
// to JPEG), whereas P and B frames are motion compressed, respectively
// predicted from past reference (I or P) frame, or bidirectionally predicted
// from past and future reference frame.
- fame_par.coding = MIaV::config->readString("frame_sequence")->c_str();
+ std::string coding;
+ if(MIaV::config->get("frame_sequence", &coding))
+ MIaV::info->error("Could not read symbol [frame_sequence] from conf file!");
+ fame_par.coding = coding.c_str();
// quality is a percentage, which controls compression versus quality.
- fame_par.quality = MIaV::config->readInt("video_quality");
+ int quality;
+ if(MIaV::config->get("video_quality", &quality))
+ MIaV::info->error("Could not read symbol [video_quality] from conf file!");
+ fame_par.quality = quality;
// Bitrate
- fame_par.bitrate = MIaV::config->readInt("video_bitrate") * 1000; // video bitrate in bytes pr second (0=VBR)
+ int bitrate;
+ if(MIaV::config->get("video_bitrate", &bitrate))
+ MIaV::info->error("Could not read symbol [video_bitrate] from conf file!");
+ fame_par.bitrate = bitrate * 1000; // video bitrate in bytes pr second (0=VBR)
// slices_per_frame is the number of frame slices per frame. More slices provide
// better error recovery. There must be at least one slice per frame, and at most
@@ -133,7 +142,11 @@ LibFAMEWrapper::LibFAMEWrapper()
fame_par.profile = profilename; // profile name
fame_par.total_frames = 0; // total number of frames
- if(strcmp(MIaV::config->readString("encoding_codec")->c_str(), "mpeg4") == 0) {
+ std::string codec;
+ if(MIaV::config->get("encoding_codec", &codec))
+ MIaV::info->error("Could not read symbol [encoding_codec] from conf file!");
+
+ if(strcmp(codec.c_str(), "mpeg4") == 0) {
MIaV::info->info("Using mpeg4 compression.");
fame_object_t *object;
@@ -141,7 +154,7 @@ LibFAMEWrapper::LibFAMEWrapper()
object = fame_get_object(fame_context, "profile/mpeg4/simple");
if(object) fame_register(fame_context, "profile", object);
- } else if(strcmp(MIaV::config->readString("encoding_codec")->c_str(), "mpeg1") == 0) {
+ } else if(strcmp(codec.c_str(), "mpeg1") == 0) {
MIaV::info->info("Using mpeg1 compression.");
fame_object_t *object;
@@ -149,7 +162,7 @@ LibFAMEWrapper::LibFAMEWrapper()
object = fame_get_object(fame_context, "profile/mpeg1");
if(object) fame_register(fame_context, "profile", object);
- } else if(strcmp(MIaV::config->readString("encoding_codec")->c_str(), "mpeg1") == 0) {
+ } else if(strcmp(codec.c_str(), "mpeg1") == 0) {
} else {
MIaV::info->info("Using default (mpeg1) compression.");
}
diff --git a/server/liblame_wrapper.cc b/server/liblame_wrapper.cc
index 9bac35b..2ffd923 100644
--- a/server/liblame_wrapper.cc
+++ b/server/liblame_wrapper.cc
@@ -26,7 +26,7 @@
*/
#include <config.h>
#include "liblame_wrapper.h"
-#include "miav_config.h"
+#include "configuration.h"
#include "info.h"
LibLAMEWrapper::LibLAMEWrapper()
@@ -45,9 +45,17 @@ LibLAMEWrapper::LibLAMEWrapper()
// lame_set_num_samples(gfp, SAMPLES);
// lame_set_num_samples(gfp, 0);
- lame_set_quality(gfp, MIaV::config->readInt("mp3_quality"));
+ int quality;
+ if(MIaV::config->get("mp3_quality", &quality))
+ MIaV::info->error("Could not read symbol [mp3_quality] from conf file!");
+
+ int bitrate;
+ if(MIaV::config->get("mp3_bitrate", &bitrate))
+ MIaV::info->error("Could not read symbol [mp3_bitrate] from conf file!");
+
+ lame_set_quality(gfp, quality);
lame_set_mode(gfp, STEREO);
- lame_set_brate(gfp, MIaV::config->readInt("mp3_bitrate"));
+ lame_set_brate(gfp, bitrate);
lame_set_strict_ISO(gfp, 1);
diff --git a/server/libmplex_wrapper.cc b/server/libmplex_wrapper.cc
index e026656..bfc4452 100644
--- a/server/libmplex_wrapper.cc
+++ b/server/libmplex_wrapper.cc
@@ -26,7 +26,6 @@
*/
#include "config.h"
#include "libmplex_wrapper.h"
-#include "miav_config.h"
#ifdef WITH_LIBMPLEX
diff --git a/server/miav_server.cc b/server/miav_server.cc
index 28c45b6..8cd7a42 100644
--- a/server/miav_server.cc
+++ b/server/miav_server.cc
@@ -27,14 +27,15 @@
// For ETC
#include "config.h"
-#include "miav_server.h"
-#include "miav_config.h"
+#include "configuration.h"
#include "info_console.h"
#include <stdio.h>
#include <string.h>
+#include <string>
+
#include "server.h"
#include "socket.h"
#include "network.h"
@@ -120,19 +121,25 @@ int main(int argc, char *argv[])
fprintf(stderr, "Using config file [%s]\n", config_file);
- MiavConfig cfg(config_file);
- MIaV::initConfig(&cfg);
+ Configuration config(config_file);
+ MIaV::initConfig(&config);
InfoConsole info;
MIaV::initInfo(&info);
- string user;
- if(user_opt) user = string(user_opt);
- else user = *cfg.readString("server_user");
+ std::string user;
+ if(user_opt) user = std::string(user_opt);
+ else {
+ if(config.get("server_user", &user))
+ info.error("Could not read symbol [server_user] from the conf file!");
+ }
- string group;
- if(group_opt) group = string(group_opt);
- else group = *cfg.readString("server_group");
+ std::string group;
+ if(group_opt) group = std::string(group_opt);
+ else {
+ if(config.get("server_group", &group))
+ info.error("Could not read symbol [server_group] from the conf file!");
+ }
// Fetch user id
int uid = -1;
@@ -166,7 +173,10 @@ int main(int argc, char *argv[])
fprintf(stderr, "Running in foreground mode.\n");
}
- int port = MIaV::config->readInt("server_port");
+ int port;
+ if(config.get("server_port", &port))
+ info.error("Could not read symbol [server_port] from the conf file!");
+
pid_t childpid; // variable to store the child's pid
signal(SIGCLD, SIG_IGN); // Ved SIGCHILD til IGNORE maa wait/waitpid ikke kaldes
diff --git a/server/miav_server.h b/server/miav_server.h
deleted file mode 100644
index eeeccf6..0000000
--- a/server/miav_server.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/***************************************************************************
- * miav.h
- *
- * Mon Nov 8 09:59:24 CET 2004
- * Copyright 2004 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.
- */
-#ifndef __LIBMIAV_H__
-#define __LIBMIAV_H__
-
-#endif/*__LIBMIAV_H__*/
diff --git a/server/mov_encoder.cc b/server/mov_encoder.cc
index 15135df..2b10f73 100644
--- a/server/mov_encoder.cc
+++ b/server/mov_encoder.cc
@@ -39,7 +39,7 @@
// For nice
#include <unistd.h>
-#include "miav_config.h"
+#include "configuration.h"
#include "info.h"
#include "libfame_wrapper.h"
@@ -99,7 +99,11 @@ void MovEncoder::thread_main()
*running = false;
// Kick them sleepy ones so they get the message.
- int threads = MIaV::config->readInt("encoding_threads") - 1; // -1 cause we only need the others!
+ int threads;
+ if(MIaV::config->get("encoding_threads", &threads))
+ MIaV::info->error("Could not read the symbol [encoding_threads] from the conf file!");
+ threads -= 1; // -1 cause we only need the others!
+
for(int cnt = 0; cnt < threads; cnt++) {
inputqueue->push(NULL);
}
diff --git a/server/mov_encoder.h b/server/mov_encoder.h
index 9b99959..18a7b46 100644
--- a/server/mov_encoder.h
+++ b/server/mov_encoder.h
@@ -29,7 +29,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#include "config.h"
#ifndef __RTVIDEOREC_ENCODER_H
#define __RTVIDEOREC_ENCODER_H
diff --git a/server/mov_encoder_thread.cc b/server/mov_encoder_thread.cc
index 63bc3c6..24f3a42 100644
--- a/server/mov_encoder_thread.cc
+++ b/server/mov_encoder_thread.cc
@@ -24,10 +24,10 @@
* 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 "miav_config.h"
+#include "configuration.h"
#include "info.h"
MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr)
@@ -50,11 +50,16 @@ MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr)
block = new FrameVector();
- num_frames_in_block = MIaV::config->readString("frame_sequence")->length();
+ std::string blockstring;
+ if(MIaV::config->get("frame_sequence", &blockstring))
+ MIaV::info->error("Could not read the symbol [frame_sequence] from the conf file!");
+
+ num_frames_in_block = blockstring.length();
MIaV::info->info("Frame sequence length %d", num_frames_in_block);
- threads = MIaV::config->readInt("encoding_threads");
+ if(MIaV::config->get("encoding_threads", &threads))
+ MIaV::info->error("Could not read the symbol [encoding_threads] from the conf file!");
movencodersrunning = true;
diff --git a/server/mov_encoder_thread.h b/server/mov_encoder_thread.h
index 1af803d..b2d6fd2 100644
--- a/server/mov_encoder_thread.h
+++ b/server/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__
diff --git a/server/mov_encoder_writer.cc b/server/mov_encoder_writer.cc
index 8f432ee..54c816d 100644
--- a/server/mov_encoder_writer.cc
+++ b/server/mov_encoder_writer.cc
@@ -40,9 +40,8 @@
#include <errno.h>
#include <string>
-using namespace std;
-#include "miav_config.h"
+#include "configuration.h"
#include "info.h"
#include <time.h>
@@ -60,12 +59,13 @@ MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
// Create path and filename
char fname[256];
- string *server_root;
+ std::string server_root;
char birthmonth[3];
char date[32];
// Get server root
- server_root = MIaV::config->readString("server_movie_root");
+ if(MIaV::config->get("server_movie_root", &server_root))
+ MIaV::info->error("Could not read the symbol [server_movie_root] from the conf file!");
// Copy the bytes representing the birth month from the cpr
// [dd][mm][yy]-[nn][nn]
@@ -81,7 +81,7 @@ MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
ltime->tm_mon + 1, // Ranging from 0 to 11
ltime->tm_mday);
- sprintf(fname, "%s/%s/%s/%s-%s-", server_root->c_str(), birthmonth, cpr, cpr, date);
+ sprintf(fname, "%s/%s/%s/%s-%s-", server_root.c_str(), birthmonth, cpr, cpr, date);
file = new File(fname, "mpg");
diff --git a/server/mov_encoder_writer.h b/server/mov_encoder_writer.h
index 88e8bdf..e519ee8 100644
--- a/server/mov_encoder_writer.h
+++ b/server/mov_encoder_writer.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_WRITER_H__
#define __MIAV_MOV_ENCODER_WRITER_H__
@@ -36,9 +35,6 @@
#include "threadsafe_queue_priority.h"
-#include <string>
-using namespace std;
-
// For n_savestate
#include "package.h"
diff --git a/server/multicast.cc b/server/multicast.cc
index 2bb6df1..d78f68b 100644
--- a/server/multicast.cc
+++ b/server/multicast.cc
@@ -24,12 +24,11 @@
* 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 "configuration.h"
#include "info.h"
#include <sys/socket.h>
@@ -59,7 +58,9 @@ Multicast::Multicast(mcastconf_t &mcclientconf)
mcclientconf.addr.c_str(),
mcclientconf.port);
- int mtu = MIaV::config->readInt("udp_packet_size");
+ int mtu;
+ if(MIaV::config->get("udp_packet_size", &mtu))
+ MIaV::info->error("Could not read the symbol [udp_packet_size] from the conf file!");
// Create buffer with the size of MTU
// socklen_t mtu_sz;
diff --git a/server/multicast.h b/server/multicast.h
index d4fa784..1e4978a 100644
--- a/server/multicast.h
+++ b/server/multicast.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_MULTICAST_H__
#define __MIAV_MULTICAST_H__
diff --git a/server/multicast_configuration.cc b/server/multicast_configuration.cc
index 03b4a79..b9ed8db 100644
--- a/server/multicast_configuration.cc
+++ b/server/multicast_configuration.cc
@@ -24,6 +24,8 @@
* 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"
@@ -110,6 +112,7 @@ mcastconf_t &MulticastConfiguration::getConf(char *client)
return global_conf;
}
+*/
#ifdef __TEST_MULTICAST_CONFIGURATION
#include "info_simple.h"
diff --git a/server/multicast_configuration.h b/server/multicast_configuration.h
index 9ff320a..a7aa884 100644
--- a/server/multicast_configuration.h
+++ b/server/multicast_configuration.h
@@ -24,11 +24,10 @@
* 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_MULTICAST_CONFIGURATION_H__
#define __MIAV_MULTICAST_CONFIGURATION_H__
-#include "miav_config.h"
+//#include "miav_config.h"
#include <vector>
#include <string>
@@ -41,16 +40,22 @@ typedef struct {
bool with_audio;
} mcastconf_t;
-class MulticastConfiguration : private MiavConfig {
+class MulticastConfiguration {
public:
- MulticastConfiguration(char *file);
- ~MulticastConfiguration();
+ MulticastConfiguration(char *file){}
+ ~MulticastConfiguration(){}
- mcastconf_t &getConf(char *client);
+ mcastconf_t &getConf(char *client){
+ a.client = "192.168.0.10";
+ return a;
+ }
private:
+ mcastconf_t a;//hack
+
std::vector<mcastconf_t> confs;
mcastconf_t global_conf;
};
+
#endif/*__MIAV_MULTICAST_CONFIGURATION_H__*/
diff --git a/server/server.cc b/server/server.cc
index 0688a3e..5088fa5 100644
--- a/server/server.cc
+++ b/server/server.cc
@@ -50,7 +50,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-#include "miav_config.h"
#include "info.h"
#include "mov_encoder_thread.h"