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