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