1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved.
18// 'ADU' MP3 streams (for improved loss-tolerance)
19// C++ header
20
21#ifndef _MP3_ADU_HH
22#define _MP3_ADU_HH
23
24#ifndef _FRAMED_FILTER_HH
25#include "FramedFilter.hh"
26#endif
27
28class ADUFromMP3Source: public FramedFilter {
29public:
30 static ADUFromMP3Source* createNew(UsageEnvironment& env,
31 FramedSource* inputSource,
32 Boolean includeADUdescriptors = True);
33
34 void resetInput();
35 // This is called whenever there's a discontinuity in the input MP3 source
36 // (e.g., due to seeking within the source). It causes any still-unprocessed
37 // MP3 frame data within our queue to be discarded, so that it does not
38 // erroneously get used by backpointers from the new MP3 frames.
39
40 Boolean setScaleFactor(int scale);
41
42protected:
43 ADUFromMP3Source(UsageEnvironment& env,
44 FramedSource* inputSource,
45 Boolean includeADUdescriptors);
46 // called only by createNew()
47 virtual ~ADUFromMP3Source();
48
49private:
50 // Redefined virtual functions:
51 virtual void doGetNextFrame();
52 virtual char const* MIMEtype() const;
53
54private:
55 Boolean doGetNextFrame1();
56
57private:
58 Boolean fAreEnqueueingMP3Frame;
59 class SegmentQueue* fSegments;
60 Boolean fIncludeADUdescriptors;
61 unsigned fTotalDataSizeBeforePreviousRead;
62 int fScale;
63 unsigned fFrameCounter;
64};
65
66class MP3FromADUSource: public FramedFilter {
67public:
68 static MP3FromADUSource* createNew(UsageEnvironment& env,
69 FramedSource* inputSource,
70 Boolean includeADUdescriptors = True);
71
72protected:
73 MP3FromADUSource(UsageEnvironment& env,
74 FramedSource* inputSource,
75 Boolean includeADUdescriptors);
76 // called only by createNew()
77 virtual ~MP3FromADUSource();
78
79private:
80 // Redefined virtual functions:
81 virtual void doGetNextFrame();
82 virtual char const* MIMEtype() const;
83
84private:
85 Boolean needToGetAnADU();
86 void insertDummyADUsIfNecessary();
87 Boolean generateFrameFromHeadADU();
88
89private:
90 Boolean fAreEnqueueingADU;
91 class SegmentQueue* fSegments;
92};
93
94#endif
95