00001 /********** 00002 This library is free software; you can redistribute it and/or modify it under 00003 the terms of the GNU Lesser General Public License as published by the 00004 Free Software Foundation; either version 2.1 of the License, or (at your 00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) 00006 00007 This library is distributed in the hope that it will be useful, but WITHOUT 00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00009 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00010 more details. 00011 00012 You should have received a copy of the GNU Lesser General Public License 00013 along with this library; if not, write to the Free Software Foundation, Inc., 00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00015 **********/ 00016 // "liveMedia" 00017 // Copyright (c) 1996-2008 Live Networks, Inc. All rights reserved. 00018 // A class for generating MPEG-2 Transport Stream from one or more input 00019 // Elementary Stream data sources 00020 // C++ header 00021 00022 #ifndef _MPEG2_TRANSPORT_STREAM_MULTIPLEXOR_HH 00023 #define _MPEG2_TRANSPORT_STREAM_MULTIPLEXOR_HH 00024 00025 #ifndef _FRAMED_SOURCE_HH 00026 #include "FramedSource.hh" 00027 #endif 00028 #ifndef _MPEG_1OR2_DEMUX_HH 00029 #include "MPEG1or2Demux.hh" // for SCR 00030 #endif 00031 00032 #define PID_TABLE_SIZE 256 00033 00034 class MPEG2TransportStreamMultiplexor: public FramedSource { 00035 protected: 00036 MPEG2TransportStreamMultiplexor(UsageEnvironment& env); 00037 virtual ~MPEG2TransportStreamMultiplexor(); 00038 00039 virtual void awaitNewBuffer(unsigned char* oldBuffer) = 0; 00040 // implemented by subclasses 00041 00042 void handleNewBuffer(unsigned char* buffer, unsigned bufferSize, 00043 int mpegVersion, MPEG1or2Demux::SCR scr); 00044 // called by "awaitNewBuffer()" 00045 00046 private: 00047 // Redefined virtual functions: 00048 virtual void doGetNextFrame(); 00049 00050 private: 00051 void deliverDataToClient(u_int8_t pid, unsigned char* buffer, unsigned bufferSize, 00052 unsigned& startPositionInBuffer); 00053 00054 void deliverPATPacket(); 00055 void deliverPMTPacket(Boolean hasChanged); 00056 00057 void setProgramStreamMap(unsigned frameSize); 00058 00059 protected: 00060 Boolean fHaveVideoStreams; 00061 00062 private: 00063 unsigned fOutgoingPacketCounter; 00064 unsigned fProgramMapVersion; 00065 u_int8_t fPreviousInputProgramMapVersion, fCurrentInputProgramMapVersion; 00066 // These two fields are used if we see "program_stream_map"s in the input. 00067 struct { 00068 unsigned counter; 00069 u_int8_t streamType; // for use in Program Maps 00070 } fPIDState[PID_TABLE_SIZE]; 00071 u_int8_t fPCR_PID, fCurrentPID; 00072 // Note: We map 8-bit stream_ids directly to PIDs 00073 MPEG1or2Demux::SCR fPCR; 00074 unsigned char* fInputBuffer; 00075 unsigned fInputBufferSize, fInputBufferBytesUsed; 00076 Boolean fIsFirstAdaptationField; 00077 }; 00078 00079 #endif
1.5.2