live
MP3ADUinterleaving.hh
Go to the documentation of this file.
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 3 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-2021 Live Networks, Inc. All rights reserved.
18 // Interleaving of MP3 ADUs
19 // C++ header
20 
21 #ifndef _MP3_ADU_INTERLEAVING_HH
22 #define _MP3_ADU_INTERLEAVING_HH
23 
24 #ifndef _FRAMED_FILTER_HH
25 #include "FramedFilter.hh"
26 #endif
27 
28 // A data structure used to represent an interleaving
29 #define MAX_CYCLE_SIZE 256
30 class Interleaving {
31 public:
32  Interleaving(unsigned cycleSize, unsigned char const* cycleArray);
33  virtual ~Interleaving();
34 
35  unsigned cycleSize() const {return fCycleSize;}
36  unsigned char lookupInverseCycle(unsigned char index) const {
37  return fInverseCycle[index];
38  }
39 
40 private:
41  unsigned fCycleSize;
42  unsigned char fInverseCycle[MAX_CYCLE_SIZE];
43 };
44 
45 // This class is used only as a base for the following two:
46 
48 protected:
51  // abstract base class
53 
55  char const* inputSourceName);
56  static void afterGettingFrame(void* clientData,
57  unsigned numBytesRead,
58  unsigned numTruncatedBytes,
59  struct timeval presentationTime,
60  unsigned durationInMicroseconds);
61  virtual void afterGettingFrame(unsigned numBytesRead,
62  struct timeval presentationTime,
63  unsigned durationInMicroseconds) = 0;
64 };
65 
66 // This class is used to convert an ADU sequence from non-interleaved
67 // to interleaved form:
68 
70 public:
72  Interleaving const& interleaving,
74 
75 protected:
77  Interleaving const& interleaving,
79  // called only by createNew()
80  virtual ~MP3ADUinterleaver();
81 
82 private:
83  // redefined virtual functions:
84  virtual void doGetNextFrame();
85  virtual void afterGettingFrame(unsigned numBytesRead,
86  struct timeval presentationTime,
87  unsigned durationInMicroseconds);
88 
89 private:
91 
92 private:
94  class InterleavingFrames* fFrames;
96  unsigned fII, fICC;
97 };
98 
99 // This class is used to convert an ADU sequence from interleaved
100 // to non-interleaved form:
101 
103 public:
106 
107 protected:
110  // called only by createNew()
112 
113 private:
114  // redefined virtual functions:
115  virtual void doGetNextFrame();
116  virtual void afterGettingFrame(unsigned numBytesRead,
117  struct timeval presentationTime,
118  unsigned durationInMicroseconds);
119 
120 private:
122 
123 private:
124  class DeinterleavingFrames* fFrames;
126 };
127 
128 #endif
129 
#define MAX_CYCLE_SIZE
FramedSource * inputSource() const
Definition: FramedFilter.hh:30
unsigned char lookupInverseCycle(unsigned char index) const
virtual ~Interleaving()
Interleaving(unsigned cycleSize, unsigned char const *cycleArray)
unsigned cycleSize() const
unsigned char fInverseCycle[MAX_CYCLE_SIZE]
static MP3ADUdeinterleaver * createNew(UsageEnvironment &env, FramedSource *inputSource)
virtual ~MP3ADUdeinterleaver()
virtual void afterGettingFrame(unsigned numBytesRead, struct timeval presentationTime, unsigned durationInMicroseconds)
MP3ADUdeinterleaver(UsageEnvironment &env, FramedSource *inputSource)
virtual void doGetNextFrame()
class DeinterleavingFrames * fFrames
virtual void afterGettingFrame(unsigned numBytesRead, struct timeval presentationTime, unsigned durationInMicroseconds)=0
static void afterGettingFrame(void *clientData, unsigned numBytesRead, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
static FramedSource * getInputSource(UsageEnvironment &env, char const *inputSourceName)
MP3ADUinterleaverBase(UsageEnvironment &env, FramedSource *inputSource)
virtual ~MP3ADUinterleaverBase()
virtual ~MP3ADUinterleaver()
void releaseOutgoingFrame()
unsigned char fPositionOfNextIncomingFrame
static MP3ADUinterleaver * createNew(UsageEnvironment &env, Interleaving const &interleaving, FramedSource *inputSource)
Interleaving const fInterleaving
virtual void afterGettingFrame(unsigned numBytesRead, struct timeval presentationTime, unsigned durationInMicroseconds)
MP3ADUinterleaver(UsageEnvironment &env, Interleaving const &interleaving, FramedSource *inputSource)
class InterleavingFrames * fFrames
virtual void doGetNextFrame()