summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordeva <deva>2005-10-13 09:08:32 +0000
committerdeva <deva>2005-10-13 09:08:32 +0000
commit56632c4b32abc705f613475c3b78ae7a5dd4a3d2 (patch)
tree1e64789daa4111a30b20b99405c9cc15c0da98c7 /src
parent1d30dc5da0c148982032a2b5a5bdece10b3e80ae (diff)
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/audio_encoder.cc2
-rw-r--r--src/miav_config.h2
-rw-r--r--src/mov_encoder.cc2
-rw-r--r--src/mov_encoder_thread.cc4
-rw-r--r--src/mov_encoder_thread.h2
-rw-r--r--src/mov_encoder_writer.cc32
-rw-r--r--src/mov_encoder_writer.h2
-rw-r--r--src/multicast.cc37
-rw-r--r--src/server.cc5
10 files changed, 39 insertions, 51 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index effa384..6a72a0d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,7 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \
mov_encoder_thread.cc \
mov_encoder_writer.cc \
multicast.cc \
+ multicast_configuration.cc \
multiplexer.cc \
mutex.cc \
network.cc \
@@ -88,6 +89,7 @@ EXTRA_DIST = \
mov_encoder_thread.h \
mov_encoder_writer.h \
multicast.h \
+ multicast_configuration.h \
multiplexer.h \
mutex.h \
network.h \
diff --git a/src/audio_encoder.cc b/src/audio_encoder.cc
index 119268c..6e412c3 100644
--- a/src/audio_encoder.cc
+++ b/src/audio_encoder.cc
@@ -52,7 +52,7 @@ void AudioEncoder::thread_main()
info->info("AudioEncoder::run");
// Run with slightly lower priority than MovEncoderWriter
- // nice(2);
+ nice(1);
Frame *in_frame = NULL;
Frame *out_frame = NULL;
diff --git a/src/miav_config.h b/src/miav_config.h
index 45732c1..a8658f1 100644
--- a/src/miav_config.h
+++ b/src/miav_config.h
@@ -72,7 +72,7 @@ public:
string *readString(char *node);
float readFloat(char *node);
-private:
+protected:
Info *info;
string filename;
diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc
index 1132b63..a4d3483 100644
--- a/src/mov_encoder.cc
+++ b/src/mov_encoder.cc
@@ -77,7 +77,7 @@ void MovEncoder::thread_main()
// int insize = 0;
// Run with slightly lower priority than MovEncoderWriter AND AudioEncoder
- // nice(3);
+ nice(2);
FrameVector *item;
Frame *in_frame;
diff --git a/src/mov_encoder_thread.cc b/src/mov_encoder_thread.cc
index 2e4c16b..6c54191 100644
--- a/src/mov_encoder_thread.cc
+++ b/src/mov_encoder_thread.cc
@@ -29,7 +29,7 @@
#include <errno.h>
#include "miav_config.h"
-MovEncoderThread::MovEncoderThread(const char *cpr, Info *i)
+MovEncoderThread::MovEncoderThread(const char *clientip, const char *cpr, Info *i)
{
info = i;
info->info("MovEncoderThread");
@@ -79,7 +79,7 @@ MovEncoderThread::MovEncoderThread(const char *cpr, Info *i)
audioenc->run();
// Create the multiplexer
- writer = new MovEncoderWriter(cpr,
+ writer = new MovEncoderWriter(clientip, cpr,
video_output_queue,
audio_output_queue,
info);
diff --git a/src/mov_encoder_thread.h b/src/mov_encoder_thread.h
index 3e7c1aa..201a332 100644
--- a/src/mov_encoder_thread.h
+++ b/src/mov_encoder_thread.h
@@ -49,7 +49,7 @@ using namespace std;
class MovEncoderThread {
public:
- MovEncoderThread(const char *cpr, Info *info);
+ MovEncoderThread(const char *clientip, const char *cpr, Info *info);
~MovEncoderThread();
void encode(Frame* frame);
diff --git a/src/mov_encoder_writer.cc b/src/mov_encoder_writer.cc
index 7f3bfec..d533b81 100644
--- a/src/mov_encoder_writer.cc
+++ b/src/mov_encoder_writer.cc
@@ -46,7 +46,9 @@ using namespace std;
#include "multiplexer.h"
-MovEncoderWriter::MovEncoderWriter(const char* cpr,
+#include "multicast_configuration.h"
+
+MovEncoderWriter::MovEncoderWriter(const char *clientip, const char* cpr,
ThreadSafeQueuePriority *video_q,
ThreadSafeQueuePriority *audio_q,
Info *i)
@@ -57,6 +59,7 @@ MovEncoderWriter::MovEncoderWriter(const char* cpr,
// Create path and filename
char fname[256];
string *server_root;
+ string *mcconfig_file;
char birthmonth[3];
char date[32];
@@ -81,15 +84,24 @@ MovEncoderWriter::MovEncoderWriter(const char* cpr,
file = new File(fname, "mpg", info);
- if(config->readBool("server_multicast")) {
- string *addr = config->readString("server_multicast_addr");
- int port = config->readInt("server_multicast_port");
- info->info("Enabling multicast %s : %d", addr->c_str(), port);
- multicast = new Multicast(info, (char*)addr->c_str(), port);
- } else {
- info->info("Disabling multicast");
- multicast = NULL;
- }
+ // Get multicast configuration filename
+ mcconfig_file = config->readString("multicast_configurationfile");
+
+ MulticastConfiguration mcconfig(info, (char*)mcconfig_file->c_str());
+
+ mcastconf_t mcclientconf = mcconfig.getConf((char*)clientip);
+
+ info->info("Client: %s - Enabled: %s - Addr: %s - Port: %d",
+ mcclientconf.client.c_str(),
+ mcclientconf.enabled?"Yes\0":"No\0",
+ mcclientconf.addr.c_str(),
+ mcclientconf.port);
+
+
+ multicast = NULL;
+ if(mcclientconf.enabled) multicast = new Multicast(info,
+ (char*)mcclientconf.addr.c_str(),
+ mcclientconf.port);
video_queue = video_q;
audio_queue = audio_q;
diff --git a/src/mov_encoder_writer.h b/src/mov_encoder_writer.h
index 00d5262..eaf4fc8 100644
--- a/src/mov_encoder_writer.h
+++ b/src/mov_encoder_writer.h
@@ -44,7 +44,7 @@ using namespace std;
class MovEncoderWriter : public Thread {
public:
- MovEncoderWriter(const char* cpr,
+ MovEncoderWriter(const char *clientip, const char* cpr,
ThreadSafeQueuePriority *video_queue,
ThreadSafeQueuePriority *audio_queue,
Info *info);
diff --git a/src/multicast.cc b/src/multicast.cc
index 80be2ce..34c7241 100644
--- a/src/multicast.cc
+++ b/src/multicast.cc
@@ -35,22 +35,6 @@
Multicast::Multicast(Info *i, char *addr, int port)
{
- /*
- Multicast adresses:
- 224.0.0.1 All systems on this subnet
- 224.0.0.2 All routers on this subnet
- 224.0.0.5 OSPF routers
- 224.0.0.6 OSPF designated routers
- 224.0.0.12 DHCP server/relay agent
-server_multicast = true
-server_multicast_addr = "224.0.0.1"
-server_multicast_port = 1234
- */
-
- // Multicast to all systems on this subnet
- // char addr[] = "224.0.0.1";
- // int port = 1234;
-
info = i;
if(!UDPOpen(addr, port)) info->error("Error creating socket %s:%d", addr, port);
}
@@ -61,17 +45,9 @@ Multicast::~Multicast()
void Multicast::Write(void* buf, int size)
{
- // char addr[] = "192.168.0.10";
- // int port = 1234;
-
- if(write(sock, buf, size) != size) {
- info->error("Error Writing to socket.");
- // if(!UDPOpen(addr, port)) info->error("Error creating socket %s:%d", addr, port);
- }
+ if(write(sock, buf, size) != size) info->error("Error Writing to socket.");
}
-#define USE_MULTICAST
-
bool Multicast::is_address_multicast(unsigned long address)
{
if((address & 255) >= 224 && (address & 255) <= 239) {
@@ -106,12 +82,10 @@ bool Multicast::UDPOpen(char *address, int port)
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *) &enable, sizeof(unsigned long int)) < 0)
return false;
-#ifdef USE_MULTICAST
// If the address is multicast, register to the multicast group
- if(is_address_multicast(stAddr.sin_addr.s_addr))
- {
+ if(is_address_multicast(stAddr.sin_addr.s_addr)) {
struct ip_mreq stMreq;
-
+
// Bind the socket to port
stLclAddr.sin_family = AF_INET;
stLclAddr.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -123,10 +97,7 @@ bool Multicast::UDPOpen(char *address, int port)
stMreq.imr_interface.s_addr = INADDR_ANY;
if(setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) & stMreq, sizeof(stMreq)) < 0)
return false;
- }
- else
-#endif
- {
+ } else {
// Bind the socket to port
stLclAddr.sin_family = AF_INET;
stLclAddr.sin_addr.s_addr = htonl(INADDR_ANY);
diff --git a/src/server.cc b/src/server.cc
index 29571d6..34f0b30 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -57,6 +57,7 @@
void newConnection(Socket *socket, Info *info)
{
char cpr[256];
+ char clientip[64];
bool hasCpr = false;
ServerStatus status(info);
@@ -71,6 +72,8 @@ void newConnection(Socket *socket, Info *info)
info->info("CONNECTION OPENED");
info->info("New connection (%s)", inet_ntoa(socket->socketaddr.sin_addr));
+ sprintf(clientip, "%s", inet_ntoa(socket->socketaddr.sin_addr));
+
Network network = Network(socket, info);
while(int ret = network.recvPackage(&h, frame->data, frame->size)) {
@@ -109,7 +112,7 @@ 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(cpr, info);
+ if(!enc) enc = new MovEncoderThread(clientip, cpr, info);
enc->encode(frame);
}