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 Teletext streams
10 //
11 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 
13 //---------------------------------------------------------------------------
14 #ifndef MediaInfo_File_TeletextH
15 #define MediaInfo_File_TeletextH
16 //---------------------------------------------------------------------------
17 
18 //---------------------------------------------------------------------------
19 #include "MediaInfo/File__Analyze.h"
20 #include <bitset>
21 #include <string>
22 //---------------------------------------------------------------------------
23 
24 namespace MediaInfoLib
25 {
26 
27 //***************************************************************************
28 // Class File_Teletext
29 //***************************************************************************
30 
31 class File_Teletext : public File__Analyze
32 {
33 public :
34     File_Teletext();
35     ~File_Teletext();
36 
37     //In
38     #if defined(MEDIAINFO_MPEGPS_YES)
39         bool FromMpegPs;
40     #endif
41 
42 private :
43     //Streams management
44     void Streams_Fill();
45     void Streams_Finish();
46 
47     //Buffer - Synchro
48     bool Synchronize();
49     bool Synched_Test();
50     void Synched_Init();
51 
52     //Buffer - Global
53     void Read_Buffer_Unsynched();
54     void Read_Buffer_Continue();
55 
56     //Buffer - Per element
57     void Header_Parse();
58     void Data_Parse();
59 
60     //Elements
61     void Character_Fill(wchar_t Character);
62     void HasChanged();
63 
64     //Streams
65     struct stream
66     {
67         vector<std::wstring> CC_Displayed_Values;
68         bool IsSubtitle;
69 
streamstream70         stream()
71         {
72             CC_Displayed_Values.resize(26);
73             for (size_t PosY=0; PosY<26; ++PosY)
74                 CC_Displayed_Values[PosY].resize(40, L' ');
75             IsSubtitle=false;
76         }
77 
Clearstream78         void Clear()
79         {
80             for (size_t PosY=0; PosY<26; ++PosY)
81                 for (size_t PosX=0; PosX<40; ++PosX)
82                     CC_Displayed_Values[PosY][PosX]=L' ';
83         }
84 
85     };
86     typedef map<int16u, stream> streams; //Key is Magazine+PageNumber
87     streams Streams;
88     int16u Stream_HasChanged;
89 
90     //Temp
91     int8u   X;
92     int8u   Y;
93     std::bitset<16> C;
94     int8u   PageNumber;
95     int16u  SubCode;
96     int8u   CharacterSubset;
97     int64u  End;
98 
99     //Ancillary
100     #if defined(MEDIAINFO_MPEGPS_YES)
101         File_Teletext* Parser;
102     #endif
103 };
104 
105 } //NameSpace
106 
107 #endif
108