]> git.vomp.tv Git - vompclient.git/blob - demuxer.h
Widescreen support, segfault fix on livetv interrupt
[vompclient.git] / demuxer.h
1 /*
2     Copyright 2005 Mark Calderbank
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 /*
22
23 Thanks goes to Jon Gettler of the MVPMC project and Stephen Rice for
24 the demuxer in mvpmc. It was used in the creation of this Demuxer,
25 however, no code was copied verbatim.
26
27 */
28
29
30 #ifndef DEMUXER_H
31 #define DEMUXER_H
32
33 #include <stdio.h>
34 #include <memory.h>
35 #include "stream.h"
36 #include "log.h"
37 #include "defines.h"
38 #include "callback.h"
39
40 class Demuxer
41 {
42   public:
43     Demuxer();
44     ~Demuxer();
45     static Demuxer* getInstance();
46     int init(Callback* callback);
47     void reset();
48     void flush();
49     void flushAudio();
50     void seek();
51     void setVideoStream(int id);
52     void setAudioStream(int id);
53     int writeAudio(int fd) { return audiostream.drain(fd); }
54     int writeVideo(int fd) { return videostream.drain(fd); }
55     int scan(UCHAR* buf, int len);
56     int put(UCHAR* buf, int len);
57
58     int getAspectRatio();
59
60     enum AspectRatio
61     {
62       ASPECT_4_3  = 2,
63       ASPECT_16_9 = 3
64     };
65
66   private:
67     static Demuxer* instance;
68     Stream videostream;
69     Stream audiostream;
70     int shutdown();
71     int initted;
72     int seeking;
73     UCHAR* inbuf;
74
75     void setAspectRatio();
76     Callback* callback;
77
78     int video_current, audio_current;
79     int state_frametype, state_framepos;
80     int state_stream_fill, state_vid_parsed;
81     int frame_length;
82     int parse_find_frame(int len);
83     int parse_video_frame(int len, int* full);
84     int parse_audio_frame(int len, int* full);
85     int parse_private1_frame(int len, int* full);
86     void parse_video_details(UCHAR* buf, int len);
87
88     UCHAR* local_frame;
89     static const int demuxMemory = 2097152;
90     static const int Demuxer::FrameRates[9];
91
92     enum FRAMETYPE
93     {
94       FRAMETYPE_PRIVATE_1 = 0xbd,
95
96       FRAMETYPE_AUD0 = 0xc0,
97       FRAMETYPE_AUD1,
98       FRAMETYPE_AUD2,
99       FRAMETYPE_AUD3,
100       FRAMETYPE_AUD4,
101       FRAMETYPE_AUD5,
102       FRAMETYPE_AUD6,
103       FRAMETYPE_AUD7,
104       FRAMETYPE_AUD8,
105       FRAMETYPE_AUD9,
106       FRAMETYPE_AUD10,
107       FRAMETYPE_AUD11,
108       FRAMETYPE_AUD12,
109       FRAMETYPE_AUD13,
110       FRAMETYPE_AUD14,
111       FRAMETYPE_AUD15,
112       FRAMETYPE_AUD16,
113       FRAMETYPE_AUD17,
114       FRAMETYPE_AUD18,
115       FRAMETYPE_AUD19,
116       FRAMETYPE_AUD20,
117       FRAMETYPE_AUD21,
118       FRAMETYPE_AUD22,
119       FRAMETYPE_AUD23,
120       FRAMETYPE_AUD24,
121       FRAMETYPE_AUD25,
122       FRAMETYPE_AUD26,
123       FRAMETYPE_AUD27,
124       FRAMETYPE_AUD28,
125       FRAMETYPE_AUD29,
126       FRAMETYPE_AUD30,
127       FRAMETYPE_AUD31,
128       FRAMETYPE_AUDMAX = FRAMETYPE_AUD31,
129
130       FRAMETYPE_VID0 = 0xe0,
131       FRAMETYPE_VID1,
132       FRAMETYPE_VID2,
133       FRAMETYPE_VID3,
134       FRAMETYPE_VID4,
135       FRAMETYPE_VID5,
136       FRAMETYPE_VID6,
137       FRAMETYPE_VID7,
138       FRAMETYPE_VID8,
139       FRAMETYPE_VID9,
140       FRAMETYPE_VID10,
141       FRAMETYPE_VID11,
142       FRAMETYPE_VID12,
143       FRAMETYPE_VID13,
144       FRAMETYPE_VID14,
145       FRAMETYPE_VID15,
146       FRAMETYPE_VIDMAX = FRAMETYPE_VID15
147     };
148
149     int horizontal_size;
150     int vertical_size;
151     enum AspectRatio aspect_ratio;
152     int frame_rate;
153     int bit_rate;
154
155     int cbAspectRatio;
156 };
157
158 #endif