]> git.vomp.tv Git - vompclient-marten.git/blob - video.h
Let vomp handle aspect ratio change, better aspect ratio control for HD and SD
[vompclient-marten.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 class Video: public DrainTarget, public AbstractOption
38 {
39   public:
40     Video();
41     virtual ~Video();
42     static Video* getInstance();
43     //static void setInstance(Video*);
44
45     virtual int init(UCHAR format)=0;
46     virtual int shutdown()=0;
47     virtual int setFormat(UCHAR format)=0;
48     virtual UCHAR getSupportedFormats() { return COMPOSITERGB | SVIDEO;}; // if it returns zero there are no different formats
49     virtual UINT supportedTVsize() { return 0;}; // if no selection is allowed
50     virtual UCHAR supportedTVFormats() { return 0;}; // if no selection is allowed
51
52     virtual int setConnection(UCHAR connection)=0;
53     virtual int setAspectRatio(UCHAR aspectRatio, int tparx,int tpary)=0;   // This one does the pin 8 scart widescreen switching
54     virtual int setMode(UCHAR mode)=0;
55     virtual int setTVsize(UCHAR size)=0;               // Is the TV a widescreen?
56     virtual void executePendingModeChanges() {}; // This is called if you change the output mode and the device take a while for reinitialization
57     virtual int setDefaultAspect()=0;
58     virtual int setSource()=0;
59     virtual int setPosition(int x, int y)=0;
60     virtual int sync()=0;
61     virtual int play()=0;
62     virtual int stop()=0;
63     virtual int pause()=0;
64     virtual int unPause()=0;
65     virtual int fastForward()=0;
66     virtual int unFastForward()=0;
67     virtual int reset()=0;
68     virtual int blank()=0;
69     virtual int signalOn()=0;
70     virtual int signalOff()=0;
71     virtual int attachFrameBuffer()=0; // What does this do?
72 //    virtual ULONG timecodeToFrameNumber(ULLONG timecode)=0; //Obsolete and not HD compatible
73     virtual ULLONG getCurrentTimestamp()=0;
74     virtual bool displayIFrame(const UCHAR* buffer, UINT length)=0;
75     virtual int EnterIframePlayback() {return 1;}; // Must not be implemented
76
77         virtual bool supportsh264(){return false;};
78         virtual void seth264mode(bool ish264) {h264=ish264;};
79         virtual int getTeletextBufferFaktor(){return 1;};
80
81         virtual bool independentAVStartUp() {return true;};
82
83
84         //Tells, if the device allows an independent startup of audio and video
85         // this needs internal buffers in device and is possible for windows and mvp
86
87         virtual bool PTSIFramePlayback() {return false;};
88         // Tells, if the iframe playback is realized using a manipulation of the pts of the packets
89         //android does it like this...
90
91         virtual bool blockingDrainTarget() { return false;};
92         // if the draintargets blocks, the feed has to be stop when pausing
93
94
95     virtual void turnVideoOn(){};
96     virtual void turnVideoOff(){};
97 //    virtual ULLONG frameNumberToTimecode(ULONG timecode) { return 0; };//Obsolete and not HD compatible
98
99 #ifdef DEV
100     virtual int test() { return 0; }
101     virtual int test2() { return 0; }
102 #endif
103
104     int getMode()           { return mode; }
105     UCHAR getFormat()       { return format; }
106     UINT getScreenWidth()   { return screenWidth; }
107     UINT getScreenHeight()  { return screenHeight; }
108     UCHAR getTVsize()       { return tvsize; }
109
110
111
112     //hmsf framesToHMSF(ULONG frames,double fps);
113    // UINT getFPS(); //removed
114
115     // Video formats - AV_SET_VID_DISP_FMT
116     const static UCHAR NTSC = 0;
117     const static UCHAR PAL = 1;
118     const static UCHAR PAL_M = 2;
119     const static UCHAR NTSC_J = 4;
120
121     // Video connections - AV_SET_VID_OUTPUT
122     const static UCHAR COMPOSITERGB = 1;
123     const static UCHAR SVIDEO = 2;
124     const static UCHAR HDMI = 4;
125     const static UCHAR HDMI3D = 16; //For future use
126
127     // Video aspect ratios - AV_SET_VID_RATIO
128     const static UCHAR ASPECT4X3 = 0;
129     const static UCHAR ASPECT16X9 = 1;
130     const static UCHAR ASPECT14X9 = 2; //future use
131
132     // Video modes - AV_SET_VID_MODE
133     const static UCHAR NORMAL = 0;
134     const static UCHAR LETTERBOX = 1;
135 /*
136     Actual Source Aspect      Aspect IOCTL       Mode IOCTL       MODE A            MODE B
137
138           4:3                     4:3             NORMAL          fullframe43       fullframe43
139           4:3                     16:9            NORMAL          fullframe43       fullframe43      -- invalid?
140           4:3                     4:3             LETTERBOX       fullframe43       fullframe43
141           4:3                     16:9            LETTERBOX       fullframe43       fullframe43      -- invalid?
142           16:9                    4:3             NORMAL          chop sides        fullframe169
143           16:9                    16:9            NORMAL          chop sides        fullframe169
144           16:9                    4:3             LETTERBOX       letterbox         letterbox
145           16:9                    16:9            LETTERBOX       chop sides        fullframe169
146
147     Conclusions
148
149     1. There are two chip modes - accessible by reopening the fd
150     2. The video chip knows the aspect ratio purely from the incoming MPEG
151     3. MODE A is for 4:3 TVs, MODE B is for 16:9 TVs
152
153     To switch to MODE A, set the aspect ioctl to 4:3 and reopen the FD.
154     To switch to MODE B, set the aspect ioctl to 16:9 and reopen the FD.
155 */
156
157     const static UCHAR UNKNOWN2 = 2;
158     const static UCHAR QUARTER = 3;
159     const static UCHAR EIGHTH = 4;
160     const static UCHAR ZOOM = 5;
161     const static UCHAR UNKNOWN6 = 6;
162
163   protected:
164     static Video* instance;
165     int initted;
166     int fdVideo;
167
168     UCHAR tvsize;
169     UCHAR format;
170     UCHAR connection;
171     UCHAR aspectRatio;
172     int parx,pary;
173     UCHAR mode;
174         bool h264;
175
176     UINT screenWidth;
177     UINT screenHeight;
178 };
179
180 #endif