1  /*
2  * Copyright (C) 2011 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 TEXT_DESCRIPTIONS_H_
18 
19 #define TEXT_DESCRIPTIONS_H_
20 
21 #include <binder/Parcel.h>
22 #include <media/stagefright/foundation/ABase.h>
23 
24 namespace android {
25 
26 class TextDescriptions {
27 public:
28     enum {
29         IN_BAND_TEXT_3GPP             = 0x01,
30         OUT_OF_BAND_TEXT_SRT          = 0x02,
31 
32         GLOBAL_DESCRIPTIONS           = 0x100,
33         LOCAL_DESCRIPTIONS            = 0x200,
34     };
35 
36     static status_t getParcelOfDescriptions(
37             const uint8_t *data, ssize_t size,
38             uint32_t flags, int timeMs, Parcel *parcel);
39 private:
40     TextDescriptions();
41 
42     enum {
43         // These keys must be in sync with the keys in TimedText.java
44         KEY_DISPLAY_FLAGS                 = 1, // int
45         KEY_STYLE_FLAGS                   = 2, // int
46         KEY_BACKGROUND_COLOR_RGBA         = 3, // int
47         KEY_HIGHLIGHT_COLOR_RGBA          = 4, // int
48         KEY_SCROLL_DELAY                  = 5, // int
49         KEY_WRAP_TEXT                     = 6, // int
50         KEY_START_TIME                    = 7, // int
51         KEY_STRUCT_BLINKING_TEXT_LIST     = 8, // List<CharPos>
52         KEY_STRUCT_FONT_LIST              = 9, // List<Font>
53         KEY_STRUCT_HIGHLIGHT_LIST         = 10, // List<CharPos>
54         KEY_STRUCT_HYPER_TEXT_LIST        = 11, // List<HyperText>
55         KEY_STRUCT_KARAOKE_LIST           = 12, // List<Karaoke>
56         KEY_STRUCT_STYLE_LIST             = 13, // List<Style>
57         KEY_STRUCT_TEXT_POS               = 14, // TextPos
58         KEY_STRUCT_JUSTIFICATION          = 15, // Justification
59         KEY_STRUCT_TEXT                   = 16, // Text
60 
61         KEY_GLOBAL_SETTING                = 101,
62         KEY_LOCAL_SETTING                 = 102,
63         KEY_START_CHAR                    = 103,
64         KEY_END_CHAR                      = 104,
65         KEY_FONT_ID                       = 105,
66         KEY_FONT_SIZE                     = 106,
67         KEY_TEXT_COLOR_RGBA               = 107,
68     };
69 
70     static status_t extractSRTLocalDescriptions(
71             const uint8_t *data, ssize_t size,
72             int timeMs, Parcel *parcel);
73     static status_t extract3GPPGlobalDescriptions(
74             const uint8_t *data, ssize_t size,
75             Parcel *parcel, int depth);
76     static status_t extract3GPPLocalDescriptions(
77             const uint8_t *data, ssize_t size,
78             int timeMs, Parcel *parcel, int depth);
79 
80     DISALLOW_EVIL_CONSTRUCTORS(TextDescriptions);
81 };
82 
83 }  // namespace android
84 #endif  // TEXT_DESCRIPTIONS_H_
85