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-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 | |
28 | class ADUFromMP3Source: public FramedFilter { |
29 | public: |
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 | |
42 | protected: |
43 | ADUFromMP3Source(UsageEnvironment& env, |
44 | FramedSource* inputSource, |
45 | Boolean includeADUdescriptors); |
46 | // called only by createNew() |
47 | virtual ~ADUFromMP3Source(); |
48 | |
49 | private: |
50 | // Redefined virtual functions: |
51 | virtual void doGetNextFrame(); |
52 | virtual char const* MIMEtype() const; |
53 | |
54 | private: |
55 | Boolean doGetNextFrame1(); |
56 | |
57 | private: |
58 | Boolean fAreEnqueueingMP3Frame; |
59 | class SegmentQueue* fSegments; |
60 | Boolean fIncludeADUdescriptors; |
61 | unsigned fTotalDataSizeBeforePreviousRead; |
62 | int fScale; |
63 | unsigned fFrameCounter; |
64 | }; |
65 | |
66 | class MP3FromADUSource: public FramedFilter { |
67 | public: |
68 | static MP3FromADUSource* createNew(UsageEnvironment& env, |
69 | FramedSource* inputSource, |
70 | Boolean includeADUdescriptors = True); |
71 | |
72 | protected: |
73 | MP3FromADUSource(UsageEnvironment& env, |
74 | FramedSource* inputSource, |
75 | Boolean includeADUdescriptors); |
76 | // called only by createNew() |
77 | virtual ~MP3FromADUSource(); |
78 | |
79 | private: |
80 | // Redefined virtual functions: |
81 | virtual void doGetNextFrame(); |
82 | virtual char const* MIMEtype() const; |
83 | |
84 | private: |
85 | Boolean needToGetAnADU(); |
86 | void insertDummyADUsIfNecessary(); |
87 | Boolean generateFrameFromHeadADU(); |
88 | |
89 | private: |
90 | Boolean fAreEnqueueingADU; |
91 | class SegmentQueue* fSegments; |
92 | }; |
93 | |
94 | #endif |
95 | |