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