]> git.vomp.tv Git - vompclient.git/blob - videowin.h
Fix for possible crash when removing bar
[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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 };
44 using namespace std;
45 typedef vector<VideoFilterDesc> VideoFilterDescList;
46 #endif
47
48 class DsSourceFilter;
49 class DsAllocator;
50
51 class VideoWin : public Video
52 {
53   public:
54     VideoWin();
55     ~VideoWin();
56
57     int init(UCHAR format);
58     int shutdown();
59
60     int setFormat(UCHAR format);
61     int setConnection(UCHAR connection);
62     int setAspectRatio(UCHAR aspectRatio);   // This one does the pin 8 scart widescreen switching
63   UCHAR getAspectRatio(){return aspectRatio;};
64   UCHAR getMode(){return mode;};
65   UCHAR getPseudoTVsize() {return pseudotvsize;};
66   int setMode(UCHAR mode);
67     int setTVsize(UCHAR size);               // Is the TV a widescreen?
68     int setDefaultAspect();
69     int setSource();
70     int setPosition(int x, int y);
71     int sync();
72     int play();
73   int dsplay();
74   bool InIframemode() {return iframemode;};
75     int stop();
76   int dsstop();
77     int pause();
78   int dspause();
79     int unPause();
80   int dsunPause();
81     int fastForward();
82     int unFastForward();
83     int reset();
84   int dsreset();
85     int blank();
86     int signalOn();
87     int signalOff();
88     int attachFrameBuffer(); // What does this do?
89     ULONG timecodeToFrameNumber(ULLONG timecode);
90   ULLONG frameNumberToTimecode(ULONG framenumber);
91     ULLONG getCurrentTimestamp();
92
93     //Writing Data to Videodevice
94     virtual void PrepareMediaSample(const MediaPacketList&, UINT samplepos);
95     virtual UINT DeliverMediaSample(const UCHAR* buffer, UINT *samplepos);
96     UINT DeliverMediaPacket(MediaPacket packet, const UCHAR* buffer, UINT *samplepos);
97
98     virtual bool supportsAc3();
99   private:
100     MediaPacket mediapacket;
101   public:
102
103     int getCurrentAudioMediaSample(IMediaSample** ms);
104     int DeliverAudioMediaSample();
105
106     int getCurrentVideoMediaSample(IMediaSample** ms);
107     int DeliverVideoMediaSample();
108
109     virtual long long SetStartOffset(long long curreftime, bool *rsync);
110     long long SetStartAudioOffset(long long curreftime, bool *rsync);
111   virtual void ResetTimeOffsets();
112
113     void SetAudioState(bool state){audioon=state;};
114   void SetAudioVolume(long volume);
115
116     void turnVideoOn(){videoon=true;};
117     void turnVideoOff(){videoon=false;};
118
119     virtual void displayIFrame(const UCHAR* buffer, UINT length);
120
121   unsigned int getPosx() {return videoposx;};
122   unsigned int getPosy() {return videoposy;};
123   bool isVideoOn() {return videoon;};
124   bool isdsinited() {return dsinited;};
125   int lastAType() {return lastaudiomode;};
126   bool changeAType(int type,IMediaSample* ms);
127
128 #ifdef DEV
129     int test();
130     int test2();
131 #endif
132 private:
133   int EnterIframePlayback();
134 #ifdef NEW_DS_MECHANISMENS
135   void dstest();
136   VideoFilterDescList videofilterlist;
137   int  videofilterselected;
138 #endif
139   int dsInitVideoFilter();
140   IMediaControl* dsmediacontrol;
141
142   IGraphBuilder* dsgraphbuilder;
143   IMediaSample* cur_audio_media_sample;
144   IMediaSample* cur_video_media_sample;
145   IBaseFilter* dsvmrrenderer;
146   IVMRSurfaceAllocatorNotify9  *dsvmrsurfnotify;
147   IReferenceClock *dsrefclock;
148   IMediaFilter* dsmediafilter;
149   IBasicAudio* dsbasicaudio;
150   REFERENCE_TIME cr_time;
151
152   DsSourceFilter* sourcefilter;
153   DsAllocator* allocatorvmr;
154   HANDLE filtermutex;
155   void CleanupDS();
156   bool offsetnotset;
157   bool offsetvideonotset;
158   bool offsetaudionotset;
159   long long startoffset;
160   long long lastrefvideotime;
161   long long lastrefaudiotime;
162   bool dsinited;
163   bool firstsynched;
164   bool audioon;
165   bool videoon;
166   bool iframemode;
167   UCHAR pseudotvsize;
168   REFERENCE_TIME lastreftimeRT;
169   ULLONG lastreftimePTS;
170   unsigned int videoposx;
171   unsigned int videoposy;
172   int lastaudiomode;
173   int audiovolume;
174 #ifdef DS_DEBUG
175   DWORD graphidentifier;
176 #endif
177 };
178
179 #endif
180
181
182