]> git.vomp.tv Git - vompclient.git/blob - video.h
Add more flexible video display options
[vompclient.git] / video.h
1 /*
2     Copyright 2004-2005 Chris Tallon
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef VIDEO_H
22 #define VIDEO_H
23
24 #include <stdio.h>
25 #include "defines.h"
26 #include "draintarget.h"
27 #include "abstractoption.h"
28
29 typedef struct _hmsf
30 {
31   UINT hours;
32   UINT minutes;
33   UINT seconds;
34   UINT frames;
35 } hmsf;
36
37 enum VideoMode {
38         None,
39         Fullscreen,
40         Window, //Not supported on legacy hardware like mvp
41         Quarter,
42         Eighth
43 };
44
45 // New video api
46 typedef struct _VideoDisplay {
47         enum VideoMode mode;
48         enum VideoMode fallbackMode;
49         UINT x,y;
50         UINT width,height;
51 } VideoDisplay;
52
53 class Video: public DrainTarget, public AbstractOption
54 {
55   public:
56     Video();
57     virtual ~Video();
58     static Video* getInstance();
59     //static void setInstance(Video*);
60
61     virtual int init(UCHAR format)=0;
62     virtual int shutdown()=0;
63     virtual int setFormat(UCHAR format)=0;
64     virtual UCHAR getSupportedFormats() { return COMPOSITERGB | SVIDEO;}; // if it returns zero there are no different formats
65     virtual UINT supportedTVsize() { return 0;}; // if no selection is allowed
66     virtual UCHAR supportedTVFormats() { return 0;}; // if no selection is allowed
67
68     virtual int setConnection(UCHAR connection)=0;
69     virtual int setAspectRatio(UCHAR aspectRatio, int tparx,int tpary)=0;   // This one does the pin 8 scart widescreen switching
70     virtual int setMode(UCHAR mode)=0;
71     virtual int setTVsize(UCHAR size)=0;               // Is the TV a widescreen?
72     virtual void executePendingModeChanges() {}; // This is called if you change the output mode and the device take a while for reinitialization
73     virtual int setDefaultAspect()=0;
74     virtual int setSource()=0;
75     virtual int sync()=0;
76     virtual int play()=0;
77     virtual int stop()=0;
78     virtual int pause()=0;
79     virtual int unPause()=0;
80     virtual int fastForward()=0;
81     virtual int unFastForward()=0;
82     virtual int reset()=0;
83     virtual int blank()=0;
84     virtual int signalOn()=0;
85     virtual int signalOff()=0;
86     virtual int attachFrameBuffer()=0; // What does this do?
87 //    virtual ULONG timecodeToFrameNumber(ULLONG timecode)=0; //Obsolete and not HD compatible
88     virtual ULLONG getCurrentTimestamp()=0;
89     virtual bool displayIFrame(const UCHAR* buffer, UINT length)=0;
90     virtual int EnterIframePlayback() {return 1;}; // Must not be implemented
91
92         virtual bool supportsh264(){return false;};
93         virtual bool supportsmpeg2(){return true;};
94         virtual void seth264mode(bool ish264) {h264=ish264;};
95         virtual int getTeletextBufferFaktor(){return 1;};
96
97         virtual bool independentAVStartUp() {return true;};
98
99
100         //Tells, if the device allows an independent startup of audio and video
101         // this needs internal buffers in device and is possible for windows and mvp
102
103         virtual bool PTSIFramePlayback() {return false;};
104         // Tells, if the iframe playback is realized using a manipulation of the pts of the packets
105         //android does it like this...
106
107         virtual bool blockingDrainTarget() { return false;};
108         // if the draintargets blocks, the feed has to be stop when pausing
109
110
111     virtual void turnVideoOn(){};
112     virtual void turnVideoOff(){};
113 //    virtual ULLONG frameNumberToTimecode(ULONG timecode) { return 0; };//Obsolete and not HD compatible
114
115 #ifdef DEV
116     virtual int test() { return 0; }
117     virtual int test2() { return 0; }
118 #endif
119
120     int getMode()           { return mode; }
121     UCHAR getFormat()       { return format; }
122     UINT getScreenWidth()   { return screenWidth; }
123     UINT getScreenHeight()  { return screenHeight; }
124     virtual UCHAR getTVsize()       { return tvsize; }
125
126
127     virtual bool setVideoDisplay(VideoDisplay display);
128
129
130
131
132     //hmsf framesToHMSF(ULONG frames,double fps);
133    // UINT getFPS(); //removed
134
135     // Video formats - AV_SET_VID_DISP_FMT
136     const static UCHAR NTSC = 0;
137     const static UCHAR PAL = 1;
138     const static UCHAR PAL_M = 2;
139     const static UCHAR NTSC_J = 4;
140
141     // Video connections - AV_SET_VID_OUTPUT
142     const static UCHAR COMPOSITERGB = 1;
143     const static UCHAR SVIDEO = 2;
144     const static UCHAR HDMI = 4;
145     const static UCHAR HDMI3D = 16; //For future use
146
147     // Video aspect ratios - AV_SET_VID_RATIO
148     const static UCHAR ASPECT4X3 = 0;
149     const static UCHAR ASPECT16X9 = 1;
150     const static UCHAR ASPECT14X9 = 2; //future use
151
152     // Video modes - AV_SET_VID_MODE
153     const static UCHAR NORMAL = 0;
154     const static UCHAR LETTERBOX = 1;
155 /*
156     Actual Source Aspect      Aspect IOCTL       Mode IOCTL       MODE A            MODE B
157
158           4:3                     4:3             NORMAL          fullframe43       fullframe43
159           4:3                     16:9            NORMAL          fullframe43       fullframe43      -- invalid?
160           4:3                     4:3             LETTERBOX       fullframe43       fullframe43
161           4:3                     16:9            LETTERBOX       fullframe43       fullframe43      -- invalid?
162           16:9                    4:3             NORMAL          chop sides        fullframe169
163           16:9                    16:9            NORMAL          chop sides        fullframe169
164           16:9                    4:3             LETTERBOX       letterbox         letterbox
165           16:9                    16:9            LETTERBOX       chop sides        fullframe169
166
167     Conclusions
168
169     1. There are two chip modes - accessible by reopening the fd
170     2. The video chip knows the aspect ratio purely from the incoming MPEG
171     3. MODE A is for 4:3 TVs, MODE B is for 16:9 TVs
172
173     To switch to MODE A, set the aspect ioctl to 4:3 and reopen the FD.
174     To switch to MODE B, set the aspect ioctl to 16:9 and reopen the FD.
175 */
176
177     const static UCHAR UNKNOWN2 = 2;
178     const static UCHAR QUARTER = 3;
179     const static UCHAR EIGHTH = 4;
180     const static UCHAR ZOOM = 5;
181     const static UCHAR UNKNOWN6 = 6;
182
183
184
185
186   protected:
187
188     virtual int setPosition(int x, int y){return 0;}; //legacy api do  not use, use setVideoDisplay instead
189     static Video* instance;
190     int initted;
191     int fdVideo;
192
193     UCHAR tvsize;
194     UCHAR format;
195     UCHAR connection;
196     UCHAR aspectRatio;
197     int parx,pary;
198     UCHAR mode;
199
200         bool h264;
201
202     UINT screenWidth;
203     UINT screenHeight;
204 };
205
206 #endif