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