fix digital+ (mhw2) epg (still disabled in epgcache.h!)
[enigma2.git] / lib / dvb / subtitle.h
1 #ifndef __lib_dvb_subtitle_h
2 #define __lib_dvb_subtitle_h
3
4 #include <lib/base/object.h>
5 #include <lib/dvb/idvb.h>
6 #include <lib/dvb/pesparse.h>
7 #include <lib/gdi/gpixmap.h>
8
9 typedef unsigned char __u8;
10
11 struct subtitle_clut_entry
12 {
13         __u8 Y, Cr, Cb, T;
14         __u8 valid;
15 };
16
17 struct subtitle_clut
18 {
19         unsigned char clut_id;
20         unsigned char CLUT_version_number;
21         subtitle_clut_entry entries_2bit[4];
22         subtitle_clut_entry entries_4bit[16];
23         subtitle_clut_entry entries_8bit[256];
24         subtitle_clut *next;
25 };
26
27 struct subtitle_page_region
28 {
29         int region_id;
30         int region_horizontal_address;
31         int region_vertical_address;
32         subtitle_page_region *next;
33 };
34
35 struct subtitle_region_object
36 {
37         int object_id;
38         int object_type;
39         int object_provider_flag;
40
41         int object_horizontal_position;
42         int object_vertical_position;
43
44                 // not supported right now...
45         int foreground_pixel_value;
46         int background_pixel_value;
47
48         subtitle_region_object *next;
49 };
50
51 struct subtitle_region
52 {
53         int region_id;
54         int version_number;
55         int height, width;
56         enum tDepth { bpp2=1, bpp4=2, bpp8=3 } depth;
57
58         ePtr<gPixmap> buffer;
59
60         int clut_id;
61
62         subtitle_region_object *objects;
63
64         subtitle_region *next;
65
66         bool committed;
67 };
68
69 struct subtitle_page
70 {
71         int page_id;
72         time_t page_time_out;
73         int page_version_number;
74         int state;
75         int pcs_size;
76         subtitle_page_region *page_regions;
77
78         subtitle_region *regions;
79
80         subtitle_clut *cluts;
81
82         subtitle_page *next;
83 };
84
85 struct bitstream
86 {
87         __u8 *data;
88         int size;
89         int avail;
90         int consumed;
91 };
92
93 struct eDVBSubtitleRegion
94 {
95         ePtr<gPixmap> m_pixmap;
96         ePoint m_position;
97         eDVBSubtitleRegion &operator=(const eDVBSubtitleRegion &s)
98         {
99                 m_pixmap = s.m_pixmap;
100                 m_position = s.m_position;
101                 return *this;
102         }
103 };
104
105 struct eDVBSubtitlePage
106 {
107         std::list<eDVBSubtitleRegion> m_regions;
108         pts_t m_show_time;
109         eSize m_display_size;
110 };
111
112 class eDVBSubtitleParser
113         :public iObject, public ePESParser, public Object
114 {
115         DECLARE_REF(eDVBSubtitleParser);
116         subtitle_page *m_pages;
117         ePtr<iDVBPESReader> m_pes_reader;
118         ePtr<eConnection> m_read_connection;
119         pts_t m_show_time;
120         Signal1<void,const eDVBSubtitlePage&> m_new_subtitle_page;
121         int m_composition_page_id, m_ancillary_page_id;
122         bool m_seen_eod;
123         eSize m_display_size;
124 public:
125         eDVBSubtitleParser(iDVBDemux *demux);
126         virtual ~eDVBSubtitleParser();
127         int start(int pid, int composition_page_id, int ancillary_page_id);
128         int stop();
129         void connectNewPage(const Slot1<void, const eDVBSubtitlePage&> &slot, ePtr<eConnection> &connection);
130 private:
131         void subtitle_process_line(subtitle_region *region, subtitle_region_object *object, int line, __u8 *data, int len);
132         int subtitle_process_pixel_data(subtitle_region *region, subtitle_region_object *object, int *linenr, int *linep, __u8 *data);
133         int subtitle_process_segment(__u8 *segment);
134         void subtitle_process_pes(__u8 *buffer, int len);
135         void subtitle_redraw_all();
136         void subtitle_reset();
137         void subtitle_redraw(int page_id);
138         void processPESPacket(__u8 *pkt, int len) { subtitle_process_pes(pkt, len); }
139 };
140
141 #endif