]> git.vomp.tv Git - vompclient.git/blob - videowin.h
Preparations for AC3 passthrough and parser for deinterlacing
[vompclient.git] / videowin.h
1 /*\r
2     Copyright 2004-2005 Chris Tallon\r
3 \r
4     This file is part of VOMP.\r
5 \r
6     VOMP is free software; you can redistribute it and/or modify\r
7     it under the terms of the GNU General Public License as published by\r
8     the Free Software Foundation; either version 2 of the License, or\r
9     (at your option) any later version.\r
10 \r
11     VOMP is distributed in the hope that it will be useful,\r
12     but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14     GNU General Public License for more details.\r
15 \r
16     You should have received a copy of the GNU General Public License\r
17     along with VOMP; if not, write to the Free Software\r
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
19 */\r
20 \r
21 #ifndef VIDEOWIN_H\r
22 #define VIDEOWIN_H\r
23 \r
24 #include <stdio.h>\r
25 #include <string.h>\r
26 #include <winsock2.h>\r
27 #include <dshow.h>\r
28 #include <d3d9.h>\r
29 #include <vmr9.h>\r
30 #include <vector>\r
31 \r
32 #include "defines.h"\r
33 #include "video.h"\r
34 \r
35 //#define DS_DEBUG\r
36 #define NEW_DS_MECHANISMENS\r
37 \r
38 #ifdef NEW_DS_MECHANISMENS\r
39 struct VideoFilterDesc {\r
40     char * displayname;\r
41     char * friendlyname;\r
42     bool vmr9;\r
43     bool vmr9tested;\r
44 };\r
45 using namespace std;\r
46 typedef vector<VideoFilterDesc> VideoFilterDescList;\r
47 #endif\r
48 \r
49 class DsSourceFilter;\r
50 class DsAllocator;\r
51 \r
52 class VideoWin : public Video\r
53 {\r
54 public:\r
55         VideoWin();\r
56         virtual ~VideoWin();\r
57 \r
58         int init(UCHAR format);\r
59         int shutdown();\r
60 \r
61         int setFormat(UCHAR format);\r
62         virtual UCHAR getSupportedFormats() { return 0;};\r
63         int setConnection(UCHAR connection);\r
64         int setAspectRatio(UCHAR aspectRatio);   // This one does the pin 8 scart widescreen switching\r
65         UCHAR getAspectRatio(){return aspectRatio;};\r
66         UCHAR getMode(){return mode;};\r
67         UCHAR getPseudoTVsize() {return pseudotvsize;};\r
68         int setMode(UCHAR mode);\r
69         int setTVsize(UCHAR size);               // Is the TV a widescreen?\r
70         int setDefaultAspect();\r
71         int setSource();\r
72         int setPosition(int x, int y);\r
73         int sync();\r
74         int play();\r
75         int dsplay();\r
76         bool InIframemode() {return iframemode;};\r
77         int stop();\r
78         int dsstop();\r
79         int pause();\r
80         int dspause();\r
81         int unPause();\r
82         int dsunPause();\r
83         int fastForward();\r
84         int unFastForward();\r
85         int reset();\r
86         int dsreset();\r
87         int blank();\r
88         int signalOn();\r
89         int signalOff();\r
90         int attachFrameBuffer(); // What does this do?\r
91 //      ULONG timecodeToFrameNumber(ULLONG timecode);\r
92 //      ULLONG frameNumberToTimecode(ULONG framenumber);\r
93         ULLONG getCurrentTimestamp();\r
94 \r
95         bool loadOptionsfromServer(VDR* vdr);\r
96         bool saveOptionstoServer();\r
97         bool addOptionPagesToWTB(WTabBar *wtb);\r
98         bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane);\r
99         bool handleOptionChanges(Option* option);\r
100 \r
101         //Writing Data to Videodevice\r
102         virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos);\r
103         virtual UINT DeliverMediaSample(UCHAR* buffer, UINT *samplepos);\r
104         UINT DeliverMediaPacket(const MediaPacket packet, const UCHAR* buffer, UINT *samplepos);\r
105     virtual  bool dtsTimefix() {if (h264)return videoH264dtsfix; else return videompeg2dtsfix;}\r
106 \r
107         virtual bool supportsh264();\r
108         virtual int getTeletextBufferFaktor(){return 4;};\r
109 \r
110 \r
111         virtual bool supportsAc3();\r
112 \r
113         enum VideoPresenter {\r
114                 VMR9,\r
115                 EVR\r
116         } ;\r
117 \r
118 \r
119 \r
120 private:\r
121         MediaPacket mediapacket;\r
122 public:\r
123 \r
124         int getCurrentAudioMediaSample(IMediaSample** ms);\r
125         int DeliverAudioMediaSample();\r
126 \r
127         int getCurrentVideoMediaSample(IMediaSample** ms);\r
128         int DeliverVideoMediaSample();\r
129         int setAudioStreamType(UCHAR type);\r
130 \r
131         virtual long long SetStartOffset(long long curreftime, bool *rsync);\r
132         long long SetStartAudioOffset(long long curreftime, bool *rsync);\r
133         virtual void ResetTimeOffsets();\r
134 \r
135         void SetAudioState(bool state){audioon=state;};\r
136         void SetAudioVolume(long volume);\r
137 \r
138         void turnVideoOn(){videoon=true;};\r
139         void turnVideoOff(){videoon=false;};\r
140 \r
141         virtual bool displayIFrame(const UCHAR* buffer, UINT length);\r
142 \r
143         unsigned int getPosx() {return videoposx;};\r
144         unsigned int getPosy() {return videoposy;};\r
145         bool isVideoOn() {return videoon;};\r
146         bool isdsinited() {return dsinited;};\r
147         int lastAType() {return lastaudiomode;};\r
148         bool changeAType(int type,IMediaSample* ms);\r
149 \r
150 \r
151         const VideoFilterDescList *getVideoFilterList(int &selected);\r
152         bool selectVideoFilter(int filter);\r
153         DsSourceFilter* getSourceFilter() {return sourcefilter;};\r
154 \r
155         const VideoFilterDescList *getVideoH264FilterList(int &selected);\r
156         bool selectVideoH264Filter(int filter);\r
157 \r
158 \r
159 #ifdef DEV\r
160         int test();\r
161         int test2();\r
162 #endif\r
163 private:\r
164         int EnterIframePlayback();\r
165 #ifdef NEW_DS_MECHANISMENS\r
166         void dstest();  \r
167         void initFilterDatabase();\r
168         IBaseFilter *getVideoFilter();  \r
169         VideoFilterDescList videofilterlist;\r
170         int  videofilterselected;\r
171 \r
172         void initH264FilterDatabase();\r
173         IBaseFilter *getVideoH264Filter();  \r
174         VideoFilterDescList videoH264filterlist;\r
175         int  videoH264filterselected;\r
176     bool videoH264dtsfix;\r
177     bool videompeg2dtsfix;\r
178 #endif\r
179         int dsInitVideoFilter();\r
180         IMediaControl* dsmediacontrol;\r
181 \r
182         IGraphBuilder* dsgraphbuilder;\r
183         IMediaSample* cur_audio_media_sample;\r
184         IMediaSample* cur_video_media_sample;\r
185         IBaseFilter* dsrenderer;\r
186         IVMRSurfaceAllocatorNotify9  *dsvmrsurfnotify;\r
187         IReferenceClock *dsrefclock;\r
188         IMediaFilter* dsmediafilter;\r
189         IBasicAudio* dsbasicaudio;\r
190         REFERENCE_TIME cr_time;\r
191 \r
192         DsSourceFilter* sourcefilter;\r
193         DsAllocator* allocatorvmr;\r
194         HANDLE filtermutex;\r
195         void CleanupDS();\r
196         bool offsetnotset;\r
197         bool offsetvideonotset;\r
198         bool offsetaudionotset;\r
199         long long startoffset;\r
200         long long lastrefvideotime;\r
201         long long lastrefaudiotime;\r
202         bool dsinited;\r
203         bool firstsynched;\r
204         bool audioon;\r
205         bool videoon;\r
206         bool iframemode;\r
207         UCHAR pseudotvsize;\r
208         REFERENCE_TIME lastreftimeRT;\r
209         ULLONG lastreftimePTS;\r
210         unsigned int videoposx;\r
211         unsigned int videoposy;\r
212         int lastaudiomode;\r
213         int audiovolume;\r
214         UCHAR aud_type;\r
215         unsigned int vmrdeinterlacing; \r
216         VideoPresenter currentpresenter;\r
217 #ifdef DS_DEBUG\r
218         DWORD graphidentifier;\r
219 #endif\r
220 };\r
221 \r
222 #endif\r
223 \r
224 \r
225 \r