summaryrefslogtreecommitdiff
path: root/server/multiplexer.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-10-27 12:13:03 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2011-10-27 12:13:03 +0200
commit408e980a83437ed621fa99ae0cd8d2bc6579f5ba (patch)
tree7f73587d84487f989bca966a22fc1c85c3f8397b /server/multiplexer.cc
parent7d8e6af2df12442c1c133956b3acf3fdbc496423 (diff)
Fix warnings and error (due to bitrot)master-old
Diffstat (limited to 'server/multiplexer.cc')
-rw-r--r--server/multiplexer.cc108
1 files changed, 56 insertions, 52 deletions
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, ...