| 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 | // 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 | |
| 28 | class MPEG1or2AudioStreamFramer: public FramedFilter { |
| 29 | public: |
| 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 | |
| 39 | private: |
| 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 | |
| 53 | private: |
| 54 | // redefined virtual functions: |
| 55 | virtual void doGetNextFrame(); |
| 56 | |
| 57 | private: |
| 58 | void reset(); |
| 59 | struct timeval currentFramePlayTime() const; |
| 60 | |
| 61 | private: |
| 62 | Boolean fSyncWithInputSource; |
| 63 | struct timeval fNextFramePresentationTime; |
| 64 | |
| 65 | private: // parsing state |
| 66 | class MPEG1or2AudioStreamParser* fParser; |
| 67 | friend class MPEG1or2AudioStreamParser; // hack |
| 68 | }; |
| 69 | |
| 70 | #endif |
| 71 | |