]> git.vomp.tv Git - vompclient.git/blob - videowin.h
Fix text corruption in channel number display on live tv
[vompclient.git] / videowin.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 VIDEOWIN_H
22 #define VIDEOWIN_H
23
24 #include <stdio.h>
25 #include <string.h>
26 #include <winsock2.h>
27 #include <dshow.h>
28 #include <d3d9.h>
29 #include <vmr9.h>
30 #include <vector>
31
32 #include "defines.h"
33 #include "video.h"
34
35 //#define DS_DEBUG
36 #define NEW_DS_MECHANISMENS
37
38 #ifdef NEW_DS_MECHANISMENS
39 struct VideoFilterDesc {
40     char * displayname;
41     char * friendlyname;
42     bool vmr9;
43     bool vmr9tested;
44 };
45 using namespace std;
46 typedef vector<VideoFilterDesc> VideoFilterDescList;
47 #endif
48
49 class DsSourceFilter;
50 class DsAllocator;
51
52 class VideoWin : public Video
53 {
54 public:
55         VideoWin();
56         virtual ~VideoWin();
57
58         int init(UCHAR format);
59         int shutdown();
60
61         int setFormat(UCHAR format);
62         UCHAR getSupportedFormats() { return 0;};
63         UINT supportedTVsize() { return ASPECT4X3|ASPECT16X9;};
64         UCHAR supportedTVFormats() { return 0;};
65
66         int setConnection(UCHAR connection);
67         int setAspectRatio(UCHAR aspectRatio, int tparx,int tpary);   // This one does the pin 8 scart widescreen switching
68         UCHAR getAspectRatio(){return aspectRatio;};
69         UCHAR getMode(){return mode;};
70         UCHAR getPseudoTVsize() {return pseudotvsize;};
71         int setMode(UCHAR mode);
72         int setTVsize(UCHAR size);               // Is the TV a widescreen?
73         int setDefaultAspect();
74         int setSource();
75         int sync();
76         int play();
77         int dsplay();
78         bool InIframemode() {return iframemode;};
79         int stop();
80         int dsstop();
81         int pause();
82         int dspause();
83         int unPause();
84         int dsunPause();
85         int fastForward();
86         int unFastForward();
87         int reset();
88         int dsreset();
89         int blank();
90         int signalOn();
91         int signalOff();
92         int attachFrameBuffer(); // What does this do?
93 //      ULONG timecodeToFrameNumber(ULLONG timecode);
94 //      ULLONG frameNumberToTimecode(ULONG framenumber);
95         ULLONG getCurrentTimestamp();
96
97         bool loadOptionsfromServer(VDR* vdr);
98         bool saveOptionstoServer();
99         bool addOptionPagesToWTB(WTabBar *wtb);
100         bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);
101         bool handleOptionChanges(Option* option);
102
103         //Writing Data to Videodevice
104         virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos);
105         virtual UINT DeliverMediaSample(UCHAR* buffer, UINT *samplepos);
106         UINT DeliverMediaPacket(const MediaPacket packet, const UCHAR* buffer, UINT *samplepos);
107     virtual  bool dtsTimefix() {if (h264)return videoH264dtsfix; else return videompeg2dtsfix;}
108
109         virtual bool supportsh264();
110         virtual int getTeletextBufferFaktor(){return 4;};
111
112
113         virtual bool supportsAc3();
114
115         enum VideoPresenter {
116                 VMR9,
117                 EVR
118         } ;
119
120
121
122 private:
123         MediaPacket mediapacket;
124 public:
125
126         int getCurrentAudioMediaSample(IMediaSample** ms);
127         int DeliverAudioMediaSample();
128
129         int getCurrentVideoMediaSample(IMediaSample** ms);
130         int DeliverVideoMediaSample();
131         int setAudioStreamType(UCHAR type);
132
133         virtual long long SetStartOffset(long long curreftime, bool *rsync);
134         long long SetStartAudioOffset(long long curreftime, bool *rsync);
135         virtual void ResetTimeOffsets();
136
137         void SetAudioState(bool state){audioon=state;};
138         void SetAudioVolume(long volume);
139
140         void turnVideoOn(){videoon=true;};
141         void turnVideoOff(){videoon=false;};
142
143         virtual bool displayIFrame(const UCHAR* buffer, UINT length);
144
145         const VideoDisplay & getVideoDisplay() { return vd; };
146         bool isVideoOn() {return videoon;};
147         bool isdsinited() {return dsinited;};
148         int lastAType() {return lastaudiomode;};
149         bool changeAType(int type,IMediaSample* ms);
150
151
152         const VideoFilterDescList *getVideoFilterList(int &selected);
153         bool selectVideoFilter(int filter);
154         DsSourceFilter* getSourceFilter() {return sourcefilter;};
155
156         const VideoFilterDescList *getVideoH264FilterList(int &selected);
157         bool selectVideoH264Filter(int filter);
158
159
160 #ifdef DEV
161         int test();
162         int test2();
163 #endif
164 protected:
165         bool setVideoDisplay(VideoDisplay display) { vd = display; return true; };
166
167         VideoDisplay vd;
168
169
170 private:
171         int EnterIframePlayback();
172 #ifdef NEW_DS_MECHANISMENS
173         void dstest();  
174         void initFilterDatabase();
175         IBaseFilter *getVideoFilter();  
176         VideoFilterDescList videofilterlist;
177         int  videofilterselected;
178
179         void initH264FilterDatabase();
180         IBaseFilter *getVideoH264Filter();  
181         VideoFilterDescList videoH264filterlist;
182         int  videoH264filterselected;
183     bool videoH264dtsfix;
184     bool videompeg2dtsfix;
185 #endif
186         int dsInitVideoFilter();
187         IMediaControl* dsmediacontrol;
188
189         IGraphBuilder* dsgraphbuilder;
190         IMediaSample* cur_audio_media_sample;
191         IMediaSample* cur_video_media_sample;
192         IBaseFilter* dsrenderer;
193         IVMRSurfaceAllocatorNotify9  *dsvmrsurfnotify;
194         IReferenceClock *dsrefclock;
195         IMediaFilter* dsmediafilter;
196         IBasicAudio* dsbasicaudio;
197         REFERENCE_TIME cr_time;
198
199         DsSourceFilter* sourcefilter;
200         DsAllocator* allocatorvmr;
201         HANDLE filtermutex;
202         void CleanupDS();
203         bool offsetnotset;
204         bool offsetvideonotset;
205         bool offsetaudionotset;
206         long long startoffset;
207         long long lastrefvideotime;
208         long long lastrefaudiotime;
209         bool dsinited;
210         bool firstsynched;
211         bool audioon;
212         bool videoon;
213         bool iframemode;
214         UCHAR pseudotvsize;
215         REFERENCE_TIME lastreftimeRT;
216         ULLONG lastreftimePTS;
217         int lastaudiomode;
218         int audiovolume;
219         UCHAR aud_type;
220         unsigned int vmrdeinterlacing; 
221         VideoPresenter currentpresenter;
222 #ifdef DS_DEBUG
223         DWORD graphidentifier;
224 #endif
225 };
226
227 #endif
228
229
230