/* -*- 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. */ #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 "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, volatile bool *running, ThreadSafeQueuePriority *video_queue, ThreadSafeQueuePriority *audio_queue); ~Multiplexer(); void multiplex(); protected: int Write(void* data, int size); int Write(char* data, int size); int Write(uint64_t val); int Write(int64_t val); int Write(int32_t val); int Write(uint32_t val); int Write24(uint32_t val); /* int Write(int val); int Write(unsigned int val); */ int Write(int16_t val); int Write(uint16_t val); uint64_t SCR; double written[NUM_TYPES]; void iso11172_stream(); void pack_header(); 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 uint32_t write_system_header; uint32_t 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; volatile bool *running; // Audio Header bool audio_header_read; ThreadSafeQueuePriority *queue[NUM_TYPES]; }; #endif/*__MIAV_MULTIPLEXER_H__*/