1 /*  Copyright (c) MediaArea.net SARL. All Rights Reserved.
2  *
3  *  Use of this source code is governed by a BSD-style license that can
4  *  be found in the License.html file in the root of the source tree.
5  */
6 
7 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 //
9 // Information about PGS files
10 //
11 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 
13 //---------------------------------------------------------------------------
14 #ifndef MediaInfo_File_Eia608H
15 #define MediaInfo_File_Eia608H
16 //---------------------------------------------------------------------------
17 
18 //---------------------------------------------------------------------------
19 #include "MediaInfo/File__Analyze.h"
20 #include <vector>
21 #include <bitset>
22 //---------------------------------------------------------------------------
23 
24 namespace MediaInfoLib
25 {
26 
27 //***************************************************************************
28 // Class File_Eia608
29 //***************************************************************************
30 
31 static const int8u Eia608_Rows=15; //Screen size, specified by the standard
32 static const int8u Eia608_Columns=32; //Screen size, specified by the standard
33 class File_Eia608 : public File__Analyze
34 {
35 public :
36     //In
37     int8u   cc_type;
38     #if MEDIAINFO_EVENTS
39         int8u   MuxingMode;
40     #endif //MEDIAINFO_EVENTS
41 
42     //Constructor/Destructor
43     File_Eia608();
44     ~File_Eia608();
45 
46 private :
47     //Streams management
48     void Streams_Fill();
49     void Streams_Finish();
50 
51     //Synchro
52     void Read_Buffer_Unsynched();
53 
54     //Buffer - Global
55     void Read_Buffer_Init();
56     void Read_Buffer_Continue();
57     void Read_Buffer_AfterParsing();
58 
59     //Function
60     void Standard (int8u Character);
61 
62     std::vector<std::vector<int8u> > XDS_Data;
63     size_t XDS_Level;
64     bool TextMode; //CC or T
65     bool DataChannelMode; //if true, CC2/CC4/T2/T4
66 
67     void XDS(int8u cc_data_1, int8u cc_data_2);
68     void XDS();
69     void XDS_Current();
70     void XDS_Current_ProgramName();
71     void XDS_Current_ContentAdvisory();
72     void XDS_Current_CopyAndRedistributionControlPacket();
73     void XDS_PublicService();
74     void XDS_PublicService_NationalWeatherService();
75     void XDS_Channel();
76     void XDS_Channel_NetworkName();
77     void Special(int8u cc_data_1, int8u cc_data_2);
78     void Special_10(int8u cc_data_2);
79     void Special_11(int8u cc_data_2);
80     void Special_12(int8u cc_data_2);
81     void Special_13(int8u cc_data_2);
82     void Special_14(int8u cc_data_2);
83     void Special_17(int8u cc_data_2);
84     void PreambleAddressCode(int8u cc_data_1, int8u cc_data_2);
85 
86     //An attribute consists of Attribute_Color_*, optionally OR'd with Attribute_Underline and/or Attribute_Italic
87     enum attributes
88     {
89         Attribute_Color_White   =0x00,
90         Attribute_Color_Green   =0x01,
91         Attribute_Color_Blue    =0x02,
92         Attribute_Color_Cyan    =0x03,
93         Attribute_Color_Red     =0x04,
94         Attribute_Color_Yellow  =0x05,
95         Attribute_Color_Magenta =0x06,
96         Attribute_Underline     =0x10,
97         Attribute_Italic        =0x20,
98     };
99 
100     struct character
101     {
102         wchar_t Value;
103         int8u   Attribute;
104 
charactercharacter105         character()
106             :
107             Value(L' '),
108             Attribute(0x00)
109         {
110         }
111     };
112     void Character_Fill(wchar_t Character);
113     void HasChanged();
114     void Illegal(int8u cc_data_1, int8u cc_data_2);
115     struct stream
116     {
117         vector<vector<character> > CC_Displayed;
118         vector<vector<character> > CC_NonDisplayed;
119         bool    InBack; //The back buffer is written
120         size_t  x;
121         size_t  y;
122         int8u   Attribute_Current;
123         size_t  RollUpLines;
124         bool    Synched;
125 
streamstream126         stream()
127         {
128             InBack=false;
129             x=0;
130             y=Eia608_Rows-1;
131             Attribute_Current=0;
132             RollUpLines=0;
133             Synched=false;
134         }
135     };
136     std::vector<stream*> Streams;
137 
138     int8u cc_data_1_Old;
139     int8u cc_data_2_Old;
140     bool   HasContent;
141     std::bitset<8> DataDetected; //1=CC1, 2=CC2, 3=T1, 4=T2, 5=XDS
142 };
143 
144 } //NameSpace
145 
146 #endif
147