diff options
Diffstat (limited to 'server/multiplexer.h')
-rw-r--r-- | server/multiplexer.h | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/server/multiplexer.h b/server/multiplexer.h new file mode 100644 index 0000000..9959009 --- /dev/null +++ b/server/multiplexer.h @@ -0,0 +1,134 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * multiplexer.h + * + * Wed Aug 31 13:05:18 CEST 2005 + * Copyright 2005 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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" +#ifndef __MIAV_MULTIPLEXER_H__ +#define __MIAV_MULTIPLEXER_H__ + +#include "iso11172-1.h" +#include "iso11172-2.h" +#include "iso11172-3.h" + +#include "file.h" +#include "multicast.h" +#include "info.h" +#include "frame.h" + +#include "threadsafe_queue_priority.h" + +/** + * Multiplexer configuration + */ +// How many packets should we put in one pack +#define PACKETS_PER_PACK 3 + +// How many packets bewteen audio packs +#define AUDIO_PACKET_FREQUENCY 10 + +// How many packs bewteen system headers +#define SYSTEM_HEADER_FREQUENCY 5 + +// Size of video or audio data pr. packet +#define PACKET_SIZE 2028 + +/** + * Other stuff + */ +// The number of streamtypes. +#define NUM_TYPES 2 + +// Enum of the streamtypes. +typedef enum { + TYPE_VIDEO, + TYPE_AUDIO +} StreamType; + + +class Multiplexer { +public: + Multiplexer(File *file, Multicast *m, Info *info, volatile bool *running, + ThreadSafeQueuePriority *video_queue, + ThreadSafeQueuePriority *audio_queue); + ~Multiplexer(); + + void multiplex(); + +private: + int Write(void* data, int size); + int Write(char* data, int size); + int Write(unsigned long long int val); + int Write(long long int val); + int Write(long int val); + int Write(unsigned long int val); + int Write(int val); + int Write(unsigned int val); + int Write(short int val); + int Write(unsigned short int val); + + unsigned long long int SCR; + + double written[NUM_TYPES]; + + void iso11172_stream(); + bool pack(); + void system_header(); + bool packet(); + bool packet(StreamType type); + /* + void audio_packet(); + void video_packet(); + + void audio_data(ISO11172_3::header *header); + void audio_data_layer_I(ISO11172_3::header *header); + void audio_data_layer_II(ISO11172_3::header *header); + void audio_data_layer_III(ISO11172_3::header *header); + + void video_data(ISO11172_2::sequence_header_1 *header1, + ISO11172_2::sequence_header_2 *header2); + */ + // Frequency variables + unsigned int write_system_header; + unsigned int write_audio_packet; + + Frame *getFrame(StreamType type); + int read_stream(char *buf, unsigned int size, StreamType type); + + Frame *frame[NUM_TYPES]; + unsigned int frame_number[NUM_TYPES]; + unsigned int read[NUM_TYPES]; + + File *file; + Multicast *multicast; + Info *info; + volatile bool *running; + + // Audio Header + bool audio_header_read; + + ThreadSafeQueuePriority *queue[NUM_TYPES]; +}; + +#endif/*__MIAV_MULTIPLEXER_H__*/ |