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// A filter that breaks up an MPEG (1,2) audio elementary stream into frames
19// C++ header
20
21#ifndef _MPEG_1OR2_AUDIO_STREAM_FRAMER_HH
22#define _MPEG_1OR2_AUDIO_STREAM_FRAMER_HH
23
24#ifndef _FRAMED_FILTER_HH
25#include "FramedFilter.hh"
26#endif
27
28class MPEG1or2AudioStreamFramer: public FramedFilter {
29public:
30 static MPEG1or2AudioStreamFramer*
31 createNew(UsageEnvironment& env, FramedSource* inputSource,
32 Boolean syncWithInputSource = False);
33 // If "syncWithInputSource" is True, the stream's presentation time
34 // will be reset to that of the input source, whenever new data
35 // is read from it.
36
37 void flushInput(); // called if there is a discontinuity (seeking) in the input
38
39private:
40 MPEG1or2AudioStreamFramer(UsageEnvironment& env, FramedSource* inputSource,
41 Boolean syncWithInputSource);
42 // called only by createNew()
43 virtual ~MPEG1or2AudioStreamFramer();
44
45 static void continueReadProcessing(void* clientData,
46 unsigned char* ptr, unsigned size,
47 struct timeval presentationTime);
48 void continueReadProcessing();
49
50 void resetPresentationTime(struct timeval newPresentationTime);
51 // useful if we're being synced with a separate (e.g., video) stream
52
53private:
54 // redefined virtual functions:
55 virtual void doGetNextFrame();
56
57private:
58 void reset();
59 struct timeval currentFramePlayTime() const;
60
61private:
62 Boolean fSyncWithInputSource;
63 struct timeval fNextFramePresentationTime;
64
65private: // parsing state
66 class MPEG1or2AudioStreamParser* fParser;
67 friend class MPEG1or2AudioStreamParser; // hack
68};
69
70#endif
71