blob: 73b6e31d63b25b197ec34f8c54825d9ad11680ea [file] [log] [blame]
Previr Rangroo7e6ac732017-11-13 20:20:20 -08001/*
2 * Copyright (C) 2018 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 AC4_PARSER_H_
18#define AC4_PARSER_H_
19
20#include <cstdint>
21#include <map>
22#include <string>
23
24#include <media/stagefright/foundation/ABitReader.h>
25
26namespace android {
27
28class AC4Parser {
29public:
30 AC4Parser();
31 virtual ~AC4Parser() { }
32
33 virtual bool parse() = 0;
34
35 struct AC4Presentation {
36 int32_t mChannelMode = -1;
37 int32_t mProgramID = -1;
38 int32_t mGroupIndex = -1;
39
40 // TS 103 190-1 v1.2.1 4.3.3.8.1
41 enum ContentClassifiers {
42 kCompleteMain,
43 kMusicAndEffects,
44 kVisuallyImpaired,
45 kHearingImpaired,
46 kDialog,
47 kCommentary,
48 kEmergency,
49 kVoiceOver
50 };
51
52 uint32_t mContentClassifier = kCompleteMain;
53
54 // ETSI TS 103 190-2 V1.1.1 (2015-09) Table 79: channel_mode
55 enum InputChannelMode {
56 kChannelMode_Mono,
57 kChannelMode_Stereo,
58 kChannelMode_3_0,
59 kChannelMode_5_0,
60 kChannelMode_5_1,
61 kChannelMode_7_0_34,
62 kChannelMode_7_1_34,
63 kChannelMode_7_0_52,
64 kChannelMode_7_1_52,
65 kChannelMode_7_0_322,
66 kChannelMode_7_1_322,
67 kChannelMode_7_0_4,
68 kChannelMode_7_1_4,
69 kChannelMode_9_0_4,
70 kChannelMode_9_1_4,
71 kChannelMode_22_2,
72 kChannelMode_Reserved,
73 };
74
75 bool mHasDialogEnhancements = false;
76 bool mPreVirtualized = false;
77 bool mEnabled = true;
78
79 std::string mLanguage;
80 std::string mDescription;
81 };
82 typedef std::map<uint32_t, AC4Presentation> AC4Presentations;
83
84 const AC4Presentations& getPresentations() const { return mPresentations; }
85
86protected:
87 AC4Presentations mPresentations;
88};
89
90class AC4DSIParser: public AC4Parser {
91public:
92 explicit AC4DSIParser(ABitReader &br);
93 virtual ~AC4DSIParser() { }
94
95 bool parse();
96
97private:
98 bool parseSubstreamDSI(uint32_t presentationID, uint32_t substreamID);
99 bool parseSubstreamGroupDSI(uint32_t presentationID, uint32_t groupID);
100 bool parseLanguageTag(uint32_t presentationID, uint32_t substreamID);
101 bool parseBitrateDsi();
102
103 uint64_t mDSISize;
104 ABitReader& mBitReader;
105};
106
107};
108
109#endif // AC4_PARSER_H_