From c5ab3a0ea0dfe35dd1927c2ca3c9f27be9db2ebd Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 17 Sep 2005 16:36:25 +0000 Subject: *** empty log message *** --- src/multiplexer.cc | 64 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 5 deletions(-) (limited to 'src/multiplexer.cc') diff --git a/src/multiplexer.cc b/src/multiplexer.cc index d479627..a94c150 100644 --- a/src/multiplexer.cc +++ b/src/multiplexer.cc @@ -187,7 +187,7 @@ bool Multiplexer::packet(StreamType type) if(framesize != PACKET_SIZE) return false; - written[type] += (double)PACKET_SIZE / (double)frame[type]->bitrate; + written[type] += (double)PACKET_SIZE / (double)frame[type]->size;//bitrate; return true; } @@ -235,10 +235,57 @@ bool Multiplexer::packet() void Multiplexer::system_header() { info->info("\t\t[System Header]"); - + // system_header_start_code (32 bits) file->Write((void*)ISO11172_1::system_header_start_code, SIZEOF(ISO11172_1::system_header_start_code)); + + ISO11172_1::system_header header; + unsigned long int *h_u = (unsigned long int *)&header; + unsigned long int *h_l = (unsigned long int *)(((char*)&header) + sizeof(unsigned int)); + + header.marker_bit1 = header.marker_bit2 = header.marker_bit3 = 1; + + header.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 + + *h_u = htonl(*h_u); + *h_l = htonl(*h_l); + + file->Write((char*)h_l, sizeof(*h_l)); + file->Write((char*)h_u, sizeof(*h_u)); + unsigned int *d; + + 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 + + d = (unsigned int*)&audio_stream_description; + *d = htonl(*d); + file->Write((char*)d, sizeof(*d)); + + 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 + + d = (unsigned int*)&video_stream_description; + *d = htonl(*d); + file->Write((char*)d, sizeof(*d)); + + /* // old code! // header_length (16 bits) char system_header_length[] = "\x00\x0C"; file->Write(system_header_length, SIZEOF(system_header_length)); @@ -265,7 +312,9 @@ void Multiplexer::system_header() // reserved_byte (8 bit) char reserved_byte[] = "\xFF"; file->Write(reserved_byte, SIZEOF(reserved_byte)); + */ + /* { // Audio // stream_id (8 bit) char stream_id[] = "\xC0"; @@ -289,6 +338,7 @@ void Multiplexer::system_header() char reserved_byte[] = "\xE0\x2E"; file->Write(reserved_byte, SIZEOF(reserved_byte)); } + */ } #define MASK3 0x7 @@ -355,10 +405,10 @@ bool Multiplexer::pack() ); */ unsigned int *hton_header_u = (unsigned int *)&header; - unsigned int *hton_header_l = (unsigned int *)((char*)&header + sizeof(unsigned int)); + unsigned int *hton_header_l = (unsigned int *)(((char*)&header) + sizeof(unsigned int)); - *hton_header_u = htonl(*hton_header_u); *hton_header_l = htonl(*hton_header_l); + *hton_header_u = htonl(*hton_header_u); file->Write((char*)hton_header_u, sizeof(*hton_header_u)); file->Write((char*)hton_header_l, sizeof(*hton_header_l)); @@ -401,8 +451,12 @@ void Multiplexer::multiplex() { #ifdef BYPASS + int frmsz; char buf[1024]; - while(*running) file->Write(buf, read_stream(buf, sizeof(buf), BYPASS)); + do { + frmsz = read_stream(buf, sizeof(buf), BYPASS); + file->Write(buf, frmsz); + } while(frmsz == sizeof(buf)); return; #else/*BYPASS*/ -- cgit v1.2.3