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