2 Copyright 2004-2005 Chris Tallon, Marten Richter
4 This file is part of VOMP.
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.
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.
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.
38 //The Allocator and Presenter for VMR9 is also a Presnter for EVR
40 class DsAllocator: public IVMRSurfaceAllocator9, IVMRImagePresenter9, Mutex,IMFVideoDeviceID,
41 IMFTopologyServiceLookupClient,public IMFVideoPresenter,IMFGetService, IQualProp {
44 virtual ~DsAllocator();
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);
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);
57 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID refiid,void ** obj);
58 virtual ULONG STDMETHODCALLTYPE AddRef();
59 virtual ULONG STDMETHODCALLTYPE Release();
61 void LostDevice(IDirect3DDevice9 *d3ddev, IDirect3D9* d3d);
64 virtual HRESULT STDMETHODCALLTYPE GetDeviceID(IID *pDid);
66 virtual HRESULT STDMETHODCALLTYPE InitServicePointers(IMFTopologyServiceLookup *plooky);
67 virtual HRESULT STDMETHODCALLTYPE ReleaseServicePointers();
69 virtual HRESULT STDMETHODCALLTYPE ProcessMessage(MFVP_MESSAGE_TYPE mess,ULONG_PTR mess_para);
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);
78 virtual HRESULT STDMETHODCALLTYPE GetService(const GUID &guid,const IID &iid,LPVOID *obj);
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);
87 void GetNextSurface(LPDIRECT3DSURFACE9 *surf,DWORD *waittime);
88 void DiscardSurfaceandgetWait(DWORD *waittime);
93 void RenegotiateEVRMediaType();
94 void AllocateEVRSurfaces();
95 void FlushEVRSamples();
98 void ResetSyncOffsets();
99 void CalcSyncOffsets(int sync);
100 void CalcJitter(int jitter);
102 vector<IDirect3DSurface9*> surfaces;
103 queue<IMFSample*> emptyevrsamples;
104 queue<IMFSample*> fullevrsamples;
105 //CCritSec objCritSec;
106 IVMRSurfaceAllocatorNotify9* surfallocnotify;
107 void CleanupSurfaces();
114 IMFTransform* mftransform;
115 IMediaEventSink* mediasink;
117 IMFMediaType *mfmediatype;
119 static const int n_stats=126;
120 int sync_offset[n_stats];
121 int jitter_offset[n_stats];
122 unsigned int sync_pos;
123 unsigned int jitter_pos;
130 LONGLONG lastdelframe;