liveMedia/include/MP3ADUinterleaving.hh

Go to the documentation of this file.
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-2012 Live Networks, Inc.  All rights reserved.
00018 // Interleaving of MP3 ADUs
00019 // C++ header
00020 
00021 #ifndef _MP3_ADU_INTERLEAVING_HH
00022 #define _MP3_ADU_INTERLEAVING_HH
00023 
00024 #ifndef _FRAMED_FILTER_HH
00025 #include "FramedFilter.hh"
00026 #endif
00027 
00028 // A data structure used to represent an interleaving
00029 #define MAX_CYCLE_SIZE 256
00030 class Interleaving {
00031 public:
00032   Interleaving(unsigned cycleSize, unsigned char const* cycleArray);
00033   virtual ~Interleaving();
00034 
00035   unsigned cycleSize() const {return fCycleSize;}
00036   unsigned char lookupInverseCycle(unsigned char index) const {
00037     return fInverseCycle[index];
00038   }
00039 
00040 private:
00041   unsigned fCycleSize;
00042   unsigned char fInverseCycle[MAX_CYCLE_SIZE];
00043 };
00044 
00045 // This class is used only as a base for the following two:
00046 
00047 class MP3ADUinterleaverBase: public FramedFilter {
00048 protected:
00049   MP3ADUinterleaverBase(UsageEnvironment& env,
00050                         FramedSource* inputSource);
00051       // abstract base class
00052   virtual ~MP3ADUinterleaverBase();
00053 
00054   static FramedSource* getInputSource(UsageEnvironment& env,
00055                                       char const* inputSourceName);
00056   static void afterGettingFrame(void* clientData,
00057                                 unsigned numBytesRead,
00058                                 unsigned numTruncatedBytes,
00059                                 struct timeval presentationTime,
00060                                 unsigned durationInMicroseconds);
00061   virtual void afterGettingFrame(unsigned numBytesRead,
00062                                  struct timeval presentationTime,
00063                                  unsigned durationInMicroseconds) = 0;
00064 };
00065 
00066 // This class is used to convert an ADU sequence from non-interleaved
00067 // to interleaved form:
00068 
00069 class MP3ADUinterleaver: public MP3ADUinterleaverBase {
00070 public:
00071   static MP3ADUinterleaver* createNew(UsageEnvironment& env,
00072                                       Interleaving const& interleaving,
00073                                       FramedSource* inputSource);
00074 
00075 protected:
00076   MP3ADUinterleaver(UsageEnvironment& env,
00077                     Interleaving const& interleaving,
00078                     FramedSource* inputSource);
00079       // called only by createNew()
00080   virtual ~MP3ADUinterleaver();
00081 
00082 private:
00083   // redefined virtual functions:
00084   virtual void doGetNextFrame();
00085   virtual void afterGettingFrame(unsigned numBytesRead,
00086                                  struct timeval presentationTime,
00087                                  unsigned durationInMicroseconds);
00088 
00089 private:
00090   void releaseOutgoingFrame();
00091 
00092 private:
00093   Interleaving const fInterleaving;
00094   class InterleavingFrames* fFrames;
00095   unsigned char fPositionOfNextIncomingFrame;
00096   unsigned fII, fICC;
00097 };
00098 
00099 // This class is used to convert an ADU sequence from interleaved
00100 // to non-interleaved form:
00101 
00102 class MP3ADUdeinterleaver: public MP3ADUinterleaverBase {
00103 public:
00104   static MP3ADUdeinterleaver* createNew(UsageEnvironment& env,
00105                                         FramedSource* inputSource);
00106 
00107 protected:
00108   MP3ADUdeinterleaver(UsageEnvironment& env,
00109                       FramedSource* inputSource);
00110       // called only by createNew()
00111   virtual ~MP3ADUdeinterleaver();
00112 
00113 private:
00114   // redefined virtual functions:
00115   virtual void doGetNextFrame();
00116   virtual void afterGettingFrame(unsigned numBytesRead,
00117                                  struct timeval presentationTime,
00118                                  unsigned durationInMicroseconds);
00119 
00120 private:
00121   void releaseOutgoingFrame();
00122 
00123 private:
00124   class DeinterleavingFrames* fFrames;
00125   unsigned fIIlastSeen, fICClastSeen;
00126 };
00127 
00128 #endif
00129 

Generated on Thu May 17 07:11:45 2012 for live by  doxygen 1.5.2