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 AC3 audio elementary stream into frames |
19 | // C++ header |
20 | |
21 | #ifndef _AC3_AUDIO_STREAM_FRAMER_HH |
22 | #define _AC3_AUDIO_STREAM_FRAMER_HH |
23 | |
24 | #ifndef _FRAMED_FILTER_HH |
25 | #include "FramedFilter.hh" |
26 | #endif |
27 | |
28 | class AC3AudioStreamFramer: public FramedFilter { |
29 | public: |
30 | static AC3AudioStreamFramer* |
31 | createNew(UsageEnvironment& env, FramedSource* inputSource, |
32 | unsigned char streamCode = 0); |
33 | // If "streamCode" != 0, then we assume that there's a 1-byte code at the beginning of each chunk of data that we read from |
34 | // our source. If that code is not the value we want, we discard the chunk of data. |
35 | // However, if "streamCode" == 0 (the default), then we don't expect this 1-byte code. |
36 | |
37 | unsigned samplingRate(); |
38 | |
39 | void flushInput(); // called if there is a discontinuity (seeking) in the input |
40 | |
41 | private: |
42 | AC3AudioStreamFramer(UsageEnvironment& env, FramedSource* inputSource, |
43 | unsigned char streamCode); |
44 | // called only by createNew() |
45 | virtual ~AC3AudioStreamFramer(); |
46 | |
47 | static void handleNewData(void* clientData, |
48 | unsigned char* ptr, unsigned size, |
49 | struct timeval presentationTime); |
50 | void handleNewData(unsigned char* ptr, unsigned size); |
51 | |
52 | void parseNextFrame(); |
53 | |
54 | private: |
55 | // redefined virtual functions: |
56 | virtual void doGetNextFrame(); |
57 | |
58 | private: |
59 | struct timeval currentFramePlayTime() const; |
60 | |
61 | private: |
62 | struct timeval fNextFramePresentationTime; |
63 | |
64 | private: // parsing state |
65 | class AC3AudioStreamParser* fParser; |
66 | unsigned char fOurStreamCode; |
67 | friend class AC3AudioStreamParser; // hack |
68 | }; |
69 | |
70 | #endif |
71 | |