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