summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/aa_socket.cc2
-rw-r--r--lib/aa_socket.h2
-rw-r--r--lib/configuration.cc12
-rw-r--r--lib/configuration.h12
-rw-r--r--lib/file.cc2
-rw-r--r--lib/file.h2
-rw-r--r--lib/info.cc5
-rw-r--r--lib/info.h8
-rw-r--r--lib/info_simple.cc6
-rw-r--r--lib/info_simple.h6
-rw-r--r--lib/liblua_wrapper.cc10
-rw-r--r--lib/liblua_wrapper.h10
-rw-r--r--lib/socket.cc4
-rw-r--r--lib/tcp_socket.cc4
-rw-r--r--lib/udp_socket.cc4
-rw-r--r--server/Makefile.am2
-rw-r--r--server/audio_encoder.cc2
-rw-r--r--server/info_console.cc6
-rw-r--r--server/info_console.h6
-rw-r--r--server/iso11172-1.h91
-rw-r--r--server/libfame_wrapper.cc2
-rw-r--r--server/liblame_wrapper.cc11
-rw-r--r--server/miav_server.cc9
-rw-r--r--server/mov_encoder.cc2
-rw-r--r--server/multicast.cc5
-rw-r--r--server/multicast_configuration.h4
-rw-r--r--server/multiplexer.cc108
-rw-r--r--server/server_status.cc2
29 files changed, 194 insertions, 147 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 4e2b923..59561fc 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,8 @@
AM_CXXFLAGS :=
lib_LTLIBRARIES = libmiav.la
+libmiav_la_LIBADD = $(LUA_LIBS)
+libmiav_la_CFLAGS = $(LUA_CFLAGS)
libmiav_la_SOURCES = \
aa_socket.cc \
diff --git a/lib/aa_socket.cc b/lib/aa_socket.cc
index 28ecead..d287789 100644
--- a/lib/aa_socket.cc
+++ b/lib/aa_socket.cc
@@ -13,6 +13,8 @@ using namespace std;
#include <sys/types.h>
#include <sys/socket.h>
+#include <stdio.h>
+#include <string.h>
#include <errno.h>
#include <netinet/in.h>
diff --git a/lib/aa_socket.h b/lib/aa_socket.h
index 0d02723..4ad4f48 100644
--- a/lib/aa_socket.h
+++ b/lib/aa_socket.h
@@ -11,7 +11,7 @@
* Exceptions
*/
struct Network_error {
- Network_error(char *event, char *err) {
+ Network_error(const char *event, char *err) {
error = std::string(err) + " - in " + std::string(event);
}
std::string error;
diff --git a/lib/configuration.cc b/lib/configuration.cc
index 64153d9..7605403 100644
--- a/lib/configuration.cc
+++ b/lib/configuration.cc
@@ -32,7 +32,7 @@ const char preload[] =
"c = 42\n"
"d = \"42\"\n";
-Configuration::Configuration(char *configfile)
+Configuration::Configuration(const char *configfile)
{
// Preload default values.
lua.loadBuffer((char*)preload);
@@ -45,7 +45,7 @@ Configuration::~Configuration()
{
}
-int Configuration::get(char *node, std::string *retval)
+int Configuration::get(const char *node, std::string *retval)
{
try {
*retval = lua.getString(node);
@@ -55,7 +55,7 @@ int Configuration::get(char *node, std::string *retval)
return 0;
}
-int Configuration::get(char *node, std::vector<std::string> *retval)
+int Configuration::get(const char *node, std::vector<std::string> *retval)
{/*
try {
*retval = lua.getString(node);
@@ -67,7 +67,7 @@ int Configuration::get(char *node, std::vector<std::string> *retval)
return 1;
}
-int Configuration::get(char *node, double *retval)
+int Configuration::get(const char *node, double *retval)
{
try {
*retval = lua.getReal(node);
@@ -77,7 +77,7 @@ int Configuration::get(char *node, double *retval)
return 0;
}
-int Configuration::get(char *node, int *retval)
+int Configuration::get(const char *node, int *retval)
{
try {
*retval = lua.getInteger(node);
@@ -87,7 +87,7 @@ int Configuration::get(char *node, int *retval)
return 0;
}
-int Configuration::get(char *node, bool *retval)
+int Configuration::get(const char *node, bool *retval)
{
try {
*retval = lua.getBoolean(node);
diff --git a/lib/configuration.h b/lib/configuration.h
index fba4c01..18e9bc2 100644
--- a/lib/configuration.h
+++ b/lib/configuration.h
@@ -34,14 +34,14 @@
class Configuration {
public:
- Configuration(char *configfile);
+ Configuration(const char *configfile);
~Configuration();
- int get(char *node, std::string *retval);
- int get(char *node, std::vector<std::string> *retval);
- int get(char *node, double *retval);
- int get(char *node, int *retval);
- int get(char *node, bool *retval);
+ int get(const char *node, std::string *retval);
+ int get(const char *node, std::vector<std::string> *retval);
+ int get(const char *node, double *retval);
+ int get(const char *node, int *retval);
+ int get(const char *node, bool *retval);
private:
LibLUAWrapper lua;
diff --git a/lib/file.cc b/lib/file.cc
index bba2f5b..d238c4a 100644
--- a/lib/file.cc
+++ b/lib/file.cc
@@ -43,7 +43,7 @@
#include <stdlib.h>
-File::File(char *fn, char* ext)
+File::File(const char *fn, const char* ext)
{
char path[256];
diff --git a/lib/file.h b/lib/file.h
index 8b241b4..37a2998 100644
--- a/lib/file.h
+++ b/lib/file.h
@@ -39,7 +39,7 @@
class File {
public:
- File(char *filename, char* ext);
+ File(const char *filename, const char* ext);
~File();
int Write(void* data, int size);
diff --git a/lib/info.cc b/lib/info.cc
index 86e4cc4..6d381a3 100644
--- a/lib/info.cc
+++ b/lib/info.cc
@@ -29,11 +29,14 @@
#include <time.h>
#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
Info::Info() {
pthread_mutex_init (&mutex, NULL);
}
-void Info::log(char *fmt, ...)
+void Info::log(const char *fmt, ...)
{
// const time_t t;
FILE *fp;
diff --git a/lib/info.h b/lib/info.h
index b499421..aec643a 100644
--- a/lib/info.h
+++ b/lib/info.h
@@ -41,10 +41,10 @@ public:
Info();
virtual ~Info() {}
- virtual void error(char* fmt, ...) = 0;
- virtual void warn(char* fmt, ...) = 0;
- virtual void info(char* fmt, ...) = 0;
- void log(char* fmt, ...);
+ virtual void error(const char* fmt, ...) = 0;
+ virtual void warn(const char* fmt, ...) = 0;
+ virtual void info(const char* fmt, ...) = 0;
+ void log(const char* fmt, ...);
protected:
// MiavConfig *config;
diff --git a/lib/info_simple.cc b/lib/info_simple.cc
index a3db393..9c78ae8 100644
--- a/lib/info_simple.cc
+++ b/lib/info_simple.cc
@@ -39,7 +39,7 @@ InfoSimple::~InfoSimple()
pthread_mutex_destroy(&mutex);
}
-void InfoSimple::error(char *fmt, ...)
+void InfoSimple::error(const char *fmt, ...)
{
char buf[1024];
@@ -57,7 +57,7 @@ void InfoSimple::error(char *fmt, ...)
fprintf(stderr, "Error: %s\n", buf);
}
-void InfoSimple::warn(char *fmt, ...)
+void InfoSimple::warn(const char *fmt, ...)
{
char buf[1024];
@@ -75,7 +75,7 @@ void InfoSimple::warn(char *fmt, ...)
fprintf(stderr, "Warning: %s\n", buf);
}
-void InfoSimple::info(char *fmt, ...)
+void InfoSimple::info(const char *fmt, ...)
{
char buf[1024];
diff --git a/lib/info_simple.h b/lib/info_simple.h
index 302a371..0dfbe0c 100644
--- a/lib/info_simple.h
+++ b/lib/info_simple.h
@@ -35,9 +35,9 @@ public:
InfoSimple();
~InfoSimple();
- void error(char* fmt, ...);
- void warn(char* fmt, ...);
- void info(char* fmt, ...);
+ void error(const char* fmt, ...);
+ void warn(const char* fmt, ...);
+ void info(const char* fmt, ...);
private:
};
diff --git a/lib/liblua_wrapper.cc b/lib/liblua_wrapper.cc
index 9e06be9..80a05d6 100644
--- a/lib/liblua_wrapper.cc
+++ b/lib/liblua_wrapper.cc
@@ -39,7 +39,7 @@ LibLUAWrapper::~LibLUAWrapper()
lua_close(L);
}
-int LibLUAWrapper::loadFile(char *fname)
+int LibLUAWrapper::loadFile(const char *fname)
{
int s;
@@ -112,7 +112,7 @@ int LibLUAWrapper::loadBuffer(char *buffer)
return 0;
}
-int LibLUAWrapper::getInteger(char *name)
+int LibLUAWrapper::getInteger(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
@@ -125,7 +125,7 @@ int LibLUAWrapper::getInteger(char *name)
return val;
}
-double LibLUAWrapper::getReal(char *name)
+double LibLUAWrapper::getReal(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
@@ -138,7 +138,7 @@ double LibLUAWrapper::getReal(char *name)
return val;
}
-bool LibLUAWrapper::getBoolean(char *name)
+bool LibLUAWrapper::getBoolean(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
@@ -151,7 +151,7 @@ bool LibLUAWrapper::getBoolean(char *name)
return val;
}
-std::string LibLUAWrapper::getString(char *name)
+std::string LibLUAWrapper::getString(const char *name)
{
lua_getfield(L, LUA_GLOBALSINDEX, name);
diff --git a/lib/liblua_wrapper.h b/lib/liblua_wrapper.h
index 30371fe..f83760f 100644
--- a/lib/liblua_wrapper.h
+++ b/lib/liblua_wrapper.h
@@ -40,7 +40,7 @@ public:
* loadFile reads, parses and runs a lue file.
* @return 0 on success 1 on error
*/
- int loadFile(char *fname);
+ int loadFile(const char *fname);
/**
* loadBuffer parses a buffer containing lue code,
@@ -49,10 +49,10 @@ public:
*/
int loadBuffer(char *buffer);
- double getReal(char *name);
- int getInteger(char *name);
- bool getBoolean(char *name);
- std::string getString(char *name);
+ double getReal(const char *name);
+ int getInteger(const char *name);
+ bool getBoolean(const char *name);
+ std::string getString(const char *name);
std::string error();
diff --git a/lib/socket.cc b/lib/socket.cc
index 37e985a..db0cb41 100644
--- a/lib/socket.cc
+++ b/lib/socket.cc
@@ -36,6 +36,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <string.h>
+
Socket::Socket(int port, std::string addr)
{
this->prt = port;
@@ -105,7 +107,7 @@ int Socket::connect()
// }
struct sockaddr_in socketaddr;
- memset((char *) &socketaddr, sizeof(socketaddr), 0);
+ memset((char *) &socketaddr, 0, sizeof(socketaddr));
socketaddr.sin_family = AF_INET;
socketaddr.sin_port = htons(prt);
socketaddr.sin_addr.s_addr = inet_addr(ip);
diff --git a/lib/tcp_socket.cc b/lib/tcp_socket.cc
index 8468df9..7f2b3d9 100644
--- a/lib/tcp_socket.cc
+++ b/lib/tcp_socket.cc
@@ -46,6 +46,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <string.h>
+
TCPSocket::TCPSocket(int port, std::string addr) : Socket(port, addr)
{
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -66,7 +68,7 @@ int TCPSocket::listen(TCPSocket *s)
if(!connected) {
struct sockaddr_in socketaddr;
- memset((char *) &socketaddr, sizeof(socketaddr), 0);
+ memset((char *) &socketaddr, 0, sizeof(socketaddr));
socketaddr.sin_family = AF_INET;
socketaddr.sin_port = htons(prt);
socketaddr.sin_addr.s_addr = htonl(INADDR_ANY);
diff --git a/lib/udp_socket.cc b/lib/udp_socket.cc
index 9668cc6..b265c43 100644
--- a/lib/udp_socket.cc
+++ b/lib/udp_socket.cc
@@ -41,6 +41,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <string.h>
+
#include "info.h"
UDPSocket::UDPSocket(int port, std::string addr) : Socket(port, addr)
@@ -54,7 +56,7 @@ int UDPSocket::write(void *buf, int size)
int n;
if(!connected) {
- memset((char *) &sa, sizeof(sa), 0);
+ memset((char *) &sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(prt);
if (inet_aton(addr.c_str(), &sa.sin_addr)==0) {
diff --git a/server/Makefile.am b/server/Makefile.am
index 7d0ae05..aac5ad2 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -2,7 +2,7 @@ AM_CXXFLAGS :=
bin_PROGRAMS = miav_server
-miav_server_LDADD = ../lib/libmiav.la
+miav_server_LDADD = ../lib/libmiav.la $(LUA_LIBS)
miav_server_SOURCES = \
miav_server.cc \
diff --git a/server/audio_encoder.cc b/server/audio_encoder.cc
index 02538f2..04ae379 100644
--- a/server/audio_encoder.cc
+++ b/server/audio_encoder.cc
@@ -52,7 +52,7 @@ void AudioEncoder::thread_main()
MIaV::info->info("AudioEncoder::run");
// Run with slightly lower priority than MovEncoderWriter
- nice(1);
+ if(nice(1) == -1) MIaV::info->warn("AudioEncoder::run could not set nice.");
Frame *in_frame = NULL;
Frame *out_frame = NULL;
diff --git a/server/info_console.cc b/server/info_console.cc
index fdceb2f..df544dc 100644
--- a/server/info_console.cc
+++ b/server/info_console.cc
@@ -43,7 +43,7 @@ InfoConsole::~InfoConsole()
pthread_mutex_destroy(&mutex);
}
-void InfoConsole::error(char *fmt, ...)
+void InfoConsole::error(const char *fmt, ...)
{
char buf[1024];
@@ -62,7 +62,7 @@ void InfoConsole::error(char *fmt, ...)
log("Error: %s", buf);
}
-void InfoConsole::warn(char *fmt, ...)
+void InfoConsole::warn(const char *fmt, ...)
{
char buf[1024];
@@ -81,7 +81,7 @@ void InfoConsole::warn(char *fmt, ...)
log("Warning: %s", buf);
}
-void InfoConsole::info(char *fmt, ...)
+void InfoConsole::info(const char *fmt, ...)
{
char buf[1024];
diff --git a/server/info_console.h b/server/info_console.h
index c3c4899..6af9c3d 100644
--- a/server/info_console.h
+++ b/server/info_console.h
@@ -35,9 +35,9 @@ public:
InfoConsole();
~InfoConsole();
- void error(char* fmt, ...);
- void warn(char* fmt, ...);
- void info(char* fmt, ...);
+ void error(const char* fmt, ...);
+ void warn(const char* fmt, ...);
+ void info(const char* fmt, ...);
};
#endif/*__MIAV_INFO_CONSOLE_H__*/
diff --git a/server/iso11172-1.h b/server/iso11172-1.h
index ee8f408..48c7726 100644
--- a/server/iso11172-1.h
+++ b/server/iso11172-1.h
@@ -41,51 +41,64 @@ namespace ISO11172_1 {
// Types
////////////////////////////////////////////////////
// 64 bits (8 bytes)
- typedef struct {
- unsigned long long int marker_bit3:1;
- unsigned long long int system_clock_reference3:15;
- unsigned long long int marker_bit2:1;
- unsigned long long int system_clock_reference2:15;
- unsigned long long int marker_bit1:1;
- unsigned long long int system_clock_reference1:3;
- unsigned long long int padding:4;
- unsigned long long int stuffing_byte:8;
- unsigned long long int packet_length:16;
+ typedef union {
+ struct {
+ unsigned long long int marker_bit3:1;
+ unsigned long long int system_clock_reference3:15;
+ unsigned long long int marker_bit2:1;
+ unsigned long long int system_clock_reference2:15;
+ unsigned long long int marker_bit1:1;
+ unsigned long long int system_clock_reference1:3;
+ unsigned long long int padding:4;
+ unsigned long long int stuffing_byte:8;
+ unsigned long long int packet_length:16;
+ } bits;
+ unsigned long long int ulli;
} packet_header;
- typedef struct {
- unsigned long long int marker_bit5:1;
- unsigned long long int mux_rate:22;
- unsigned long long int marker_bit4:1;
- unsigned long long int marker_bit3:1;
- unsigned long long int system_clock_reference3:15;
- unsigned long long int marker_bit2:1;
- unsigned long long int system_clock_reference2:15;
- unsigned long long int marker_bit1:1;
- unsigned long long int system_clock_reference1:3;
- unsigned long long int padding:4;
+ typedef union {
+ struct {
+ unsigned long long int marker_bit5:1;
+ unsigned long long int mux_rate:22;
+ unsigned long long int marker_bit4:1;
+ unsigned long long int marker_bit3:1;
+ unsigned long long int system_clock_reference3:15;
+ unsigned long long int marker_bit2:1;
+ unsigned long long int system_clock_reference2:15;
+ unsigned long long int marker_bit1:1;
+ unsigned long long int system_clock_reference1:3;
+ unsigned long long int padding:4;
+ } bits;
+ unsigned long long int ulli;
} pack_header;
- typedef struct {
- unsigned long long int reserved_byte:8;
- unsigned long long int video_bound:5;
- unsigned long long int marker_bit3:1;
- unsigned long long int system_video_clock_flag:1;
- unsigned long long int system_audio_clock_flag:1;
- unsigned long long int CSPS_flag:1;
- unsigned long long int fixed_flag:1;
- unsigned long long int audio_bound:6;
- unsigned long long int marker_bit2:1;
- unsigned long long int rate_bound:22;
- unsigned long long int marker_bit1:1;
- unsigned long long int header_length:16;
+ typedef union {
+ struct {
+ unsigned long long int reserved_byte:8;
+ unsigned long long int video_bound:5;
+ unsigned long long int marker_bit3:1;
+ unsigned long long int system_video_clock_flag:1;
+ unsigned long long int system_audio_clock_flag:1;
+ unsigned long long int CSPS_flag:1;
+ unsigned long long int fixed_flag:1;
+ unsigned long long int audio_bound:6;
+ unsigned long long int marker_bit2:1;
+ unsigned long long int rate_bound:22;
+ unsigned long long int marker_bit1:1;
+ unsigned long long int header_length:16;
+ unsigned long long int ulli;
+ } bits;
+ unsigned long long int ulli;
} system_header;
- typedef struct {
- unsigned long int STD_buffer_size_bound:13;
- unsigned long int STD_buffer_bound_scale:1;
- unsigned long int market_bits:2;
- unsigned long int stream_id:8;
+ typedef union {
+ struct {
+ unsigned long int STD_buffer_size_bound:13;
+ unsigned long int STD_buffer_bound_scale:1;
+ unsigned long int market_bits:2;
+ unsigned long int stream_id:8;
+ } bits;
+ unsigned long int uli;
} stream_description;
////////////////////////////////////////////////////
diff --git a/server/libfame_wrapper.cc b/server/libfame_wrapper.cc
index 058a158..1a7b860 100644
--- a/server/libfame_wrapper.cc
+++ b/server/libfame_wrapper.cc
@@ -28,6 +28,8 @@
#include "libfame_wrapper.h"
#include <errno.h>
+#include <stdio.h>
+#include <string.h>
#include "configuration.h"
#include "info.h"
diff --git a/server/liblame_wrapper.cc b/server/liblame_wrapper.cc
index 2ffd923..c795c47 100644
--- a/server/liblame_wrapper.cc
+++ b/server/liblame_wrapper.cc
@@ -24,8 +24,13 @@
* 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 <config.h>
+
+#include <stdio.h>
+#include <string.h>
+
#include "configuration.h"
#include "info.h"
@@ -71,7 +76,7 @@ LibLAMEWrapper::LibLAMEWrapper()
lame_set_copyright(gfp, 0); // is there a copyright on the encoded data?
lame_set_original(gfp, 1); // is the encoded data on the original media?
lame_set_error_protection(gfp, 0);// add 2 byte CRC protection to each frame?
- lame_set_padding_type(gfp, PAD_NO); // PAD_NO, PAD_ALL, PAD_ADJUST, PAD_MAX_INDICATOR
+ // lame_set_padding_type(gfp, PAD_NO); // PAD_NO, PAD_ALL, PAD_ADJUST, PAD_MAX_INDICATOR
// 0 = do not pad frames
// 1 = always pad frames
// 2 = adjust padding to satisfy bit rate
@@ -115,7 +120,7 @@ Frame *LibLAMEWrapper::close(Frame *oldframe)
int flush;
- flush = lame_encode_finish(gfp, frame->data + offset, 7200);
+ flush = 0;//lame_encode_finish(gfp, frame->data + offset, 7200);
frame->size = offset + flush;
diff --git a/server/miav_server.cc b/server/miav_server.cc
index 1682dad..1631c77 100644
--- a/server/miav_server.cc
+++ b/server/miav_server.cc
@@ -49,6 +49,8 @@
#include <grp.h>
#include <pwd.h>
+#include <stdlib.h>
+
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#elif defined(HAVE_STDLIB_H) // Solaris has getopt() here
@@ -70,7 +72,7 @@ static const char usage_str[] =
int main(int argc, char *argv[])
{
- char *config_file = ETC"/miav.conf";
+ const char *config_file = ETC"/miav.conf";
int optc;
int lose = 0;
@@ -166,7 +168,10 @@ int main(int argc, char *argv[])
if(!foreground) {
fprintf(stderr, "Entering daemon mode\n");
- daemon(0,0);
+ if(daemon(0,0) == -1) {
+ fprintf(stderr, "Could not fork.\n");
+ exit(1);
+ }
signal (SIGTERM, SIG_IGN);
signal (SIGINT, SIG_IGN);
signal (SIGHUP, SIG_IGN);
diff --git a/server/mov_encoder.cc b/server/mov_encoder.cc
index 2b10f73..df0892d 100644
--- a/server/mov_encoder.cc
+++ b/server/mov_encoder.cc
@@ -73,7 +73,7 @@ void MovEncoder::thread_main()
MIaV::info->info("MovEncoder::run");
// Run with slightly lower priority than MovEncoderWriter AND AudioEncoder
- nice(2);
+ if(nice(2) == -1) MIaV::info->warn("MovEncoder::run could not set nice.");
FrameVector *item;
Frame *in_frame;
diff --git a/server/multicast.cc b/server/multicast.cc
index d78f68b..0b1cd31 100644
--- a/server/multicast.cc
+++ b/server/multicast.cc
@@ -38,6 +38,8 @@
#include <arpa/inet.h>
#include <sys/types.h>
+#include <string.h>
+
// For IP_MTU
//#include <linux/in.h>
//#ifndef IP_MTU
@@ -107,7 +109,8 @@ int Multicast::Write(void* buf, int size)
if(left == 0) {
// MIaV::info->info("Sending full packet");
- write(sock, udp_buffer, udp_buffer_size);
+ if(write(sock, udp_buffer, udp_buffer_size) != udp_buffer_size)
+ MIaV::info->error("Could not write all buffer to socket.");
left = udp_buffer_size;
udp_buffer_pointer = udp_buffer;
}
diff --git a/server/multicast_configuration.h b/server/multicast_configuration.h
index a7aa884..11d04c1 100644
--- a/server/multicast_configuration.h
+++ b/server/multicast_configuration.h
@@ -42,10 +42,10 @@ typedef struct {
class MulticastConfiguration {
public:
- MulticastConfiguration(char *file){}
+ MulticastConfiguration(const char *file){}
~MulticastConfiguration(){}
- mcastconf_t &getConf(char *client){
+ mcastconf_t &getConf(const char *client){
a.client = "192.168.0.10";
return a;
}
diff --git a/server/multiplexer.cc b/server/multiplexer.cc
index 0bce694..b44902e 100644
--- a/server/multiplexer.cc
+++ b/server/multiplexer.cc
@@ -119,18 +119,19 @@ int Multiplexer::Write(unsigned long long int val)
{
int res;
int written = 0;
- unsigned long int *h_u = (unsigned long int *)&val;
- unsigned long int *h_l = (unsigned long int *)(((char*)&val) + sizeof(unsigned long int));
+ unsigned long int h_u = val & 0xffffffff;
+ unsigned long int h_l = (val << 32) & 0xffffffff;
+ // *(unsigned long int *)(((char*)&val) + sizeof(unsigned long int));
- *h_u = htonl(*h_u);
- *h_l = htonl(*h_l);
+ h_u = htonl(h_u);
+ h_l = htonl(h_l);
- if((res = Write((void*)h_l, sizeof(*h_l))) < 0) {
+ if((res = Write(&h_l, sizeof(h_l))) < 0) {
return res;
}
written += res;
- if((res = Write((void*)h_u, sizeof(*h_u))) < 0) {
+ if((res = Write(&h_u, sizeof(h_u))) < 0) {
return res;
}
written += res;
@@ -142,18 +143,19 @@ int Multiplexer::Write(long long int val)
{
int res;
int written = 0;
- unsigned long int *h_u = (unsigned long int *)&val;
- unsigned long int *h_l = (unsigned long int *)(((char*)&val) + sizeof(unsigned long int));
+ unsigned long int h_u = val & 0xffffffff;
+ unsigned long int h_l = (val << 32) & 0xffffffff;
+ //*((unsigned long int *)(((char*)&val) + sizeof(unsigned long int)));
- *h_u = htonl(*h_u);
- *h_l = htonl(*h_l);
+ h_u = htonl(h_u);
+ h_l = htonl(h_l);
- if((res = Write((void*)h_l, sizeof(*h_l))) < 0) {
+ if((res = Write(&h_l, sizeof(h_l))) < 0) {
return res;
}
written += res;
- if((res = Write((void*)h_u, sizeof(*h_u))) < 0) {
+ if((res = Write(&h_u, sizeof(h_u))) < 0) {
return res;
}
written += res;
@@ -276,14 +278,15 @@ bool Multiplexer::packet(StreamType type)
}
ISO11172_1::packet_header header;
- header.marker_bit1 = header.marker_bit2 = header.marker_bit3 = 1;
- header.padding = 0x2; // Must be 2
- header.stuffing_byte = 0xFF;
- header.packet_length = framesize + sizeof(ISO11172_1::packet_header) - sizeof(short);
- header.system_clock_reference1 = TIMECODE32_30(SCR);
- header.system_clock_reference2 = TIMECODE29_15(SCR);
- header.system_clock_reference3 = TIMECODE14_0(SCR);
- Write(*((unsigned long long int*)&header));
+ header.bits.marker_bit1 = header.bits.marker_bit2 =
+ header.bits.marker_bit3 = 1;
+ header.bits.padding = 0x2; // Must be 2
+ header.bits.stuffing_byte = 0xFF;
+ header.bits.packet_length = framesize + sizeof(ISO11172_1::packet_header) - sizeof(short);
+ header.bits.system_clock_reference1 = TIMECODE32_30(SCR);
+ header.bits.system_clock_reference2 = TIMECODE29_15(SCR);
+ header.bits.system_clock_reference3 = TIMECODE14_0(SCR);
+ Write(header.ulli);
Write(buf, framesize);
@@ -352,34 +355,35 @@ void Multiplexer::system_header()
ISO11172_1::system_header header;
- header.marker_bit1 = header.marker_bit2 = header.marker_bit3 = 1;
+ header.bits.marker_bit1 = header.bits.marker_bit2 =
+ header.bits.marker_bit3 = 1;
- header.header_length = 8 - 2 + (NUM_TYPES * 3);
+ header.bits.header_length = 8 - 2 + (NUM_TYPES * 3);
// (sizeof(header) - sizeof(header.header_length)) +
// NUM_TYPES * sizeof(ISO11172_1::stream_description);
- header.rate_bound = 3521; // FIXME: Taken from the example!
- header.audio_bound = 1; // Only 1 audio stream
- header.fixed_flag = 1; // Fixed bitrate (0 indicates vbr)
- header.CSPS_flag = 1; // Standarts compliant? (yes: see lame_set_strict_ISO in liblame_wrapper.cc)
- header.system_audio_clock_flag = 1; // FIXME: What excactly is this??
- header.system_video_clock_flag = 1; // FIXME: What excactly is this??
- header.video_bound = 1; // Only 1 video stream
- header.reserved_byte = 0xFF; // Must be 0xFF
- Write(*((unsigned long long int*)&header));
+ header.bits.rate_bound = 3521; // FIXME: Taken from the example!
+ header.bits.audio_bound = 1; // Only 1 audio stream
+ header.bits.fixed_flag = 1; // Fixed bitrate (0 indicates vbr)
+ header.bits.CSPS_flag = 1; // Standarts compliant? (yes: see lame_set_strict_ISO in liblame_wrapper.cc)
+ header.bits.system_audio_clock_flag = 1; // FIXME: What excactly is this??
+ header.bits.system_video_clock_flag = 1; // FIXME: What excactly is this??
+ header.bits.video_bound = 1; // Only 1 video stream
+ header.bits.reserved_byte = 0xFF; // Must be 0xFF
+ Write(header.ulli);
ISO11172_1::stream_description audio_stream_description;
- audio_stream_description.stream_id = 0xC0;
- audio_stream_description.market_bits = 0x3;
- audio_stream_description.STD_buffer_bound_scale = 0; // Must be 0 for audio streams
- audio_stream_description.STD_buffer_size_bound = 32; // Buffer must be 32 * 128 bytes
- Write(*((unsigned long int*)&audio_stream_description));
+ audio_stream_description.bits.stream_id = 0xC0;
+ audio_stream_description.bits.market_bits = 0x3;
+ audio_stream_description.bits.STD_buffer_bound_scale = 0; // Must be 0 for audio streams
+ audio_stream_description.bits.STD_buffer_size_bound = 32; // Buffer must be 32 * 128 bytes
+ Write(audio_stream_description.uli);
ISO11172_1::stream_description video_stream_description;
- video_stream_description.stream_id = 0xE3;
- video_stream_description.market_bits = 0x3;
- video_stream_description.STD_buffer_bound_scale = 1; // Must be 1 for video streams
- video_stream_description.STD_buffer_size_bound = 46; // Buffer must be 32 * 1024 bytes
- Write(*((unsigned long int*)&video_stream_description));
+ video_stream_description.bits.stream_id = 0xE3;
+ video_stream_description.bits.market_bits = 0x3;
+ video_stream_description.bits.STD_buffer_bound_scale = 1; // Must be 1 for video streams
+ video_stream_description.bits.STD_buffer_size_bound = 46; // Buffer must be 32 * 1024 bytes
+ Write(video_stream_description.uli);
}
/**
@@ -393,13 +397,13 @@ bool Multiplexer::pack()
ISO11172_1::pack_header header;
// Set marker bits to 1
- header.marker_bit1 =
- header.marker_bit2 =
- header.marker_bit3 =
- header.marker_bit4 =
- header.marker_bit5 = 1;
+ header.bits.marker_bit1 =
+ header.bits.marker_bit2 =
+ header.bits.marker_bit3 =
+ header.bits.marker_bit4 =
+ header.bits.marker_bit5 = 1;
- header.padding = 0x2;
+ header.bits.padding = 0x2;
unsigned int video_data_rate;
unsigned int audio_data_rate;
@@ -417,7 +421,7 @@ bool Multiplexer::pack()
PACKETS_PER_PACK, // packets_per_pack,
PACKET_SIZE);// packet_data_size)
- header.mux_rate = Rmux;
+ header.bits.mux_rate = Rmux;
//0x1B82;
SCR = ISO11172_1::SCR(SCR,
@@ -428,9 +432,9 @@ bool Multiplexer::pack()
// SCR = 0x40010003LL;
- header.system_clock_reference1 = TIMECODE32_30(SCR);
- header.system_clock_reference2 = TIMECODE29_15(SCR);
- header.system_clock_reference3 = TIMECODE14_0(SCR);
+ header.bits.system_clock_reference1 = TIMECODE32_30(SCR);
+ header.bits.system_clock_reference2 = TIMECODE29_15(SCR);
+ header.bits.system_clock_reference3 = TIMECODE14_0(SCR);
/*
MIaV::info->info("timecode All: %lld, 1: %lld, 2: %lld, 3: %lld",
SCR,
@@ -439,7 +443,7 @@ bool Multiplexer::pack()
(unsigned long long int)header.system_clock_reference3
);
*/
- Write(*((unsigned long long int*)&header));
+ Write(header.ulli);
if(write_system_header % SYSTEM_HEADER_FREQUENCY == 0) system_header();
// Count this up here, we want a system header in pack 0, 5, ... NOT 4, 9, ...
diff --git a/server/server_status.cc b/server/server_status.cc
index b1837b8..7891164 100644
--- a/server/server_status.cc
+++ b/server/server_status.cc
@@ -29,6 +29,8 @@
#include "udp_socket.h"
#include "status.h"
+#include <stdio.h>
+
int server_status(int port)
{
status_t s;