Advertisement
Guest User

MPEG2TransportStreamMultiplexor4iOS.hh

a guest
Dec 23rd, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.94 KB | None | 0 0
  1. /**********
  2. This library is free software; you can redistribute it and/or modify it under
  3. the terms of the GNU Lesser General Public License as published by the
  4. Free Software Foundation; either version 2.1 of the License, or (at your
  5. option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
  6.  
  7. This library is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
  10. more details.
  11.  
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this library; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
  15. **********/
  16. // "liveMedia"
  17. // Copyright (c) 1996-2011 Live Networks, Inc.  All rights reserved.
  18. // A class for generating MPEG-2 Transport Stream from one or more input
  19. // Elementary Stream data sources
  20. // C++ header
  21.  
  22. #ifndef _MPEG2_TRANSPORT_STREAM_MULTIPLEXOR_4_IOS_HH
  23. #define _MPEG2_TRANSPORT_STREAM_MULTIPLEXOR_4_IOS_HH
  24.  
  25. #ifndef _FRAMED_SOURCE_HH
  26. #include "FramedSource.hh"
  27. #endif
  28. #ifndef _MPEG_1OR2_DEMUX_HH
  29. #include "MPEG1or2Demux.hh" // for SCR
  30. #endif
  31.  
  32. //#define PID_TABLE_SIZE 256
  33. #define PID_TABLE_SIZE 8192
  34.  
  35. class MPEG2TransportStreamMultiplexor4iOS: public FramedSource {
  36. protected:
  37.   MPEG2TransportStreamMultiplexor4iOS(UsageEnvironment& env);
  38.   virtual ~MPEG2TransportStreamMultiplexor4iOS();
  39.  
  40.   virtual void awaitNewBuffer(unsigned char* oldBuffer) = 0;
  41.       // implemented by subclasses
  42.  
  43.   void handleNewBuffer(unsigned char* buffer, unsigned bufferSize,
  44.                int mpegVersion, MPEG1or2Demux::SCR scr);
  45.   // called by "awaitNewBuffer()"
  46.   // Note: For MPEG-4 video, set "mpegVersion" to 4; for H.264 video, set "mpegVersion" to 5.
  47.  
  48. private:
  49.   // Redefined virtual functions:
  50.   virtual void doGetNextFrame();
  51.  
  52. private:
  53.   void deliverDataToClient(u_int16_t pid, unsigned char* buffer, unsigned bufferSize,
  54.                unsigned& startPositionInBuffer);
  55.  
  56.   void deliverPATPacket();
  57.   void deliverPMTPacket(Boolean hasChanged);
  58.  
  59.   void setProgramStreamMap(unsigned frameSize);
  60.  
  61. protected:
  62.   Boolean fHaveVideoStreams;
  63.  
  64. private:
  65.   unsigned fOutgoingPacketCounter;
  66.   unsigned fProgramMapVersion;
  67.   u_int8_t fPreviousInputProgramMapVersion, fCurrentInputProgramMapVersion;
  68.       // These two fields are used if we see "program_stream_map"s in the input.
  69.  
  70.   enum SEGMENT_STATE{NEED_PAT,NEED_PMT,NEED_KEYFRAME,STARTED};
  71.  
  72.   struct {
  73.     unsigned counter;
  74.     int      seconds;
  75.     SEGMENT_STATE segmentState_;
  76.     u_int8_t streamType; // for use in Program Maps
  77.   } fPIDState[PID_TABLE_SIZE];
  78.   u_int16_t fPCR_PID, fCurrentPID;
  79.       // Note: We map 8-bit stream_ids directly to PIDs
  80.   MPEG1or2Demux::SCR fPCR;
  81.  
  82.   unsigned char* fInputBuffer;
  83.   unsigned fInputBufferSize, fInputBufferBytesUsed;
  84.   Boolean fIsFirstAdaptationField;
  85. };
  86.  
  87. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement