diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-10-27 12:13:03 +0200 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2011-10-27 12:13:03 +0200 | 
| commit | 408e980a83437ed621fa99ae0cd8d2bc6579f5ba (patch) | |
| tree | 7f73587d84487f989bca966a22fc1c85c3f8397b /server | |
| parent | 7d8e6af2df12442c1c133956b3acf3fdbc496423 (diff) | |
Fix warnings and error (due to bitrot)master-old
Diffstat (limited to 'server')
| -rw-r--r-- | server/Makefile.am | 2 | ||||
| -rw-r--r-- | server/audio_encoder.cc | 2 | ||||
| -rw-r--r-- | server/info_console.cc | 6 | ||||
| -rw-r--r-- | server/info_console.h | 6 | ||||
| -rw-r--r-- | server/iso11172-1.h | 91 | ||||
| -rw-r--r-- | server/libfame_wrapper.cc | 2 | ||||
| -rw-r--r-- | server/liblame_wrapper.cc | 11 | ||||
| -rw-r--r-- | server/miav_server.cc | 9 | ||||
| -rw-r--r-- | server/mov_encoder.cc | 2 | ||||
| -rw-r--r-- | server/multicast.cc | 5 | ||||
| -rw-r--r-- | server/multicast_configuration.h | 4 | ||||
| -rw-r--r-- | server/multiplexer.cc | 108 | ||||
| -rw-r--r-- | server/server_status.cc | 2 | 
13 files changed, 142 insertions, 108 deletions
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;  | 
