]> git.vomp.tv Git - vompclient.git/blob - dsallocator.h
Display channel name, duration, resume point and size on recording info screen
[vompclient.git] / dsallocator.h
1 /*
2     Copyright 2004-2005 Chris Tallon, Marten Richter
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 #ifndef DSALLOCATOR_H
21 #define DSALLOCATOR_H
22
23 #include <queue>
24 #include <vector>
25
26
27 using namespace std;
28
29 #include <winsock2.h>
30
31 #include <d3d9.h>
32 #include <dshow.h> 
33 #include <vmr9.h>
34 #include <evr.h>
35 #include "mutex.h"
36
37
38 //The Allocator and Presenter for VMR9 is also a Presnter for EVR
39
40 class DsAllocator: public IVMRSurfaceAllocator9, IVMRImagePresenter9, Mutex,IMFVideoDeviceID, 
41         IMFTopologyServiceLookupClient,public IMFVideoPresenter,IMFGetService, IQualProp {
42 public:
43         DsAllocator();
44         virtual ~DsAllocator();
45
46         virtual HRESULT STDMETHODCALLTYPE StartPresenting(DWORD_PTR userid);
47         virtual HRESULT STDMETHODCALLTYPE StopPresenting(DWORD_PTR userid);
48         virtual HRESULT STDMETHODCALLTYPE PresentImage(DWORD_PTR userid,VMR9PresentationInfo* presinf);
49
50         virtual HRESULT STDMETHODCALLTYPE InitializeDevice(DWORD_PTR userid,
51                 VMR9AllocationInfo* allocinf,DWORD* numbuf);
52         virtual HRESULT STDMETHODCALLTYPE TerminateDevice(DWORD_PTR userid); 
53         virtual HRESULT STDMETHODCALLTYPE GetSurface(DWORD_PTR userid,DWORD surfindex,DWORD surfflags, IDirect3DSurface9** surf);
54         virtual HRESULT STDMETHODCALLTYPE AdviseNotify(IVMRSurfaceAllocatorNotify9* allnoty);
55         
56
57         virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID refiid,void ** obj);
58         virtual ULONG STDMETHODCALLTYPE AddRef();
59         virtual ULONG STDMETHODCALLTYPE Release();
60
61     void LostDevice(IDirect3DDevice9 *d3ddev, IDirect3D9* d3d);
62
63         /* EVR members */
64         virtual HRESULT STDMETHODCALLTYPE GetDeviceID(IID *pDid);
65
66         virtual HRESULT STDMETHODCALLTYPE InitServicePointers(IMFTopologyServiceLookup *plooky);
67         virtual HRESULT STDMETHODCALLTYPE ReleaseServicePointers();
68
69         virtual HRESULT STDMETHODCALLTYPE ProcessMessage(MFVP_MESSAGE_TYPE mess,ULONG_PTR mess_para);
70
71         virtual HRESULT STDMETHODCALLTYPE OnClockStart(MFTIME systime,LONGLONG startoffset);
72         virtual HRESULT STDMETHODCALLTYPE OnClockStop(MFTIME systime);
73         virtual HRESULT STDMETHODCALLTYPE OnClockPause(MFTIME systime);
74         virtual HRESULT STDMETHODCALLTYPE OnClockRestart(MFTIME systime);
75         virtual HRESULT STDMETHODCALLTYPE OnClockSetRate(MFTIME systime,float rate);
76         virtual HRESULT STDMETHODCALLTYPE GetCurrentMediaType(IMFVideoMediaType **mtype);
77
78         virtual HRESULT STDMETHODCALLTYPE GetService(const GUID &guid,const IID &iid,LPVOID *obj);
79
80     virtual HRESULT STDMETHODCALLTYPE get_FramesDrawn(int *val);
81     virtual HRESULT STDMETHODCALLTYPE get_AvgFrameRate(int *val);
82     virtual HRESULT STDMETHODCALLTYPE get_Jitter(int *val);
83     virtual HRESULT STDMETHODCALLTYPE get_AvgSyncOffset(int *val);
84     virtual HRESULT STDMETHODCALLTYPE get_DevSyncOffset(int *val);
85     virtual HRESULT STDMETHODCALLTYPE get_FramesDroppedInRenderer(int *val);
86
87         void GetNextSurface(LPDIRECT3DSURFACE9 *surf,DWORD *waittime);
88         void DiscardSurfaceandgetWait(DWORD *waittime);
89
90
91 protected:
92
93         void RenegotiateEVRMediaType();
94         void AllocateEVRSurfaces();
95         void FlushEVRSamples();
96         void GetEVRSamples();
97
98         void ResetSyncOffsets();
99         void CalcSyncOffsets(int sync);
100         void CalcJitter(int jitter);
101         
102         vector<IDirect3DSurface9*> surfaces;
103         queue<IMFSample*> emptyevrsamples;
104         queue<IMFSample*> fullevrsamples;
105         //CCritSec objCritSec;
106         IVMRSurfaceAllocatorNotify9* surfallocnotify;
107         void CleanupSurfaces();
108         LONG refcount;
109         DWORD vheight;
110         DWORD vwidth;
111         bool inevrmode;
112         bool endofstream;
113     bool start_get_evr_samples;
114
115         IMFTransform* mftransform;
116         IMediaEventSink* mediasink;
117         IMFClock* mfclock;
118         IMFMediaType *mfmediatype;
119
120         static const int n_stats=126;
121         int sync_offset[n_stats];
122         int jitter_offset[n_stats];
123         unsigned int sync_pos;
124         unsigned int jitter_pos;
125         int framesdrawn;
126         int framesdropped;
127         int avg_sync_offset;
128         int dev_sync_offset;
129         int jitter;
130     int avgfps;
131     LONGLONG lastdelframe;
132
133
134
135 };
136
137
138
139
140
141
142
143
144 #endif