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