Tim Yao | cd4e4eb | 2020-07-24 01:47:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_AUDIO_MAT_FRAME_SCANNER_H |
| 18 | #define ANDROID_AUDIO_MAT_FRAME_SCANNER_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <system/audio.h> |
| 22 | #include <audio_utils/spdif/FrameScanner.h> |
| 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | #define MAT_PCM_FRAMES 1536 |
| 27 | #define MAT_RATE_MULTIPLIER 10 |
| 28 | |
| 29 | class MatFrameScanner : public FrameScanner |
| 30 | { |
| 31 | public: |
| 32 | MatFrameScanner(); |
| 33 | virtual ~MatFrameScanner(); |
| 34 | |
| 35 | virtual int getMaxChannels() const { return 5 + 1 + 2; } // 5.1.2 surround |
| 36 | |
| 37 | virtual int getMaxSampleFramesPerSyncFrame() const { return MAT_RATE_MULTIPLIER |
| 38 | * MAT_PCM_FRAMES; } |
| 39 | virtual int getSampleFramesPerSyncFrame() const { return MAT_RATE_MULTIPLIER |
| 40 | * MAT_PCM_FRAMES; } |
| 41 | |
| 42 | virtual bool isFirstInBurst() { return false; } |
| 43 | virtual bool isLastInBurst(); |
| 44 | virtual void resetBurst(); |
| 45 | |
| 46 | virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const; |
| 47 | virtual bool scan(uint8_t byte); |
| 48 | |
| 49 | protected: |
| 50 | // used to recognize the start of a MAT sync frame |
| 51 | static const uint8_t kSyncBytes[]; |
| 52 | int mChunkType; |
| 53 | bool mLastChunk; |
| 54 | |
| 55 | virtual bool parseHeader(); |
| 56 | }; |
| 57 | |
| 58 | } // namespace android |
| 59 | |
| 60 | #endif // ANDROID_AUDIO_MAT_FRAME_SCANNER_H |