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, see <https://www.gnu.org/licenses/>.
34 //The Allocator and Presenter for VMR9 is also a Presnter for EVR
36 class DsAllocator: public IVMRSurfaceAllocator9, IVMRImagePresenter9, IMFVideoDeviceID,
37 IMFTopologyServiceLookupClient,public IMFVideoPresenter,IMFGetService, IQualProp {
40 virtual ~DsAllocator();
42 virtual HRESULT STDMETHODCALLTYPE StartPresenting(DWORD_PTR userid);
43 virtual HRESULT STDMETHODCALLTYPE StopPresenting(DWORD_PTR userid);
44 virtual HRESULT STDMETHODCALLTYPE PresentImage(DWORD_PTR userid,VMR9PresentationInfo* presinf);
46 virtual HRESULT STDMETHODCALLTYPE InitializeDevice(DWORD_PTR userid, VMR9AllocationInfo* allocinf,DWORD* numbuf);
47 virtual HRESULT STDMETHODCALLTYPE TerminateDevice(DWORD_PTR userid);
48 virtual HRESULT STDMETHODCALLTYPE GetSurface(DWORD_PTR userid,DWORD surfindex,DWORD surfflags, IDirect3DSurface9** surf);
49 virtual HRESULT STDMETHODCALLTYPE AdviseNotify(IVMRSurfaceAllocatorNotify9* allnoty);
51 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID refiid,void ** obj);
52 virtual ULONG STDMETHODCALLTYPE AddRef();
53 virtual ULONG STDMETHODCALLTYPE Release();
55 void LostDevice(IDirect3DDevice9 *d3ddev, IDirect3D9* d3d);
58 virtual HRESULT STDMETHODCALLTYPE GetDeviceID(IID *pDid);
60 virtual HRESULT STDMETHODCALLTYPE InitServicePointers(IMFTopologyServiceLookup *plooky);
61 virtual HRESULT STDMETHODCALLTYPE ReleaseServicePointers();
63 virtual HRESULT STDMETHODCALLTYPE ProcessMessage(MFVP_MESSAGE_TYPE mess,ULONG_PTR mess_para);
65 virtual HRESULT STDMETHODCALLTYPE OnClockStart(MFTIME systime,LONGLONG startoffset);
66 virtual HRESULT STDMETHODCALLTYPE OnClockStop(MFTIME systime);
67 virtual HRESULT STDMETHODCALLTYPE OnClockPause(MFTIME systime);
68 virtual HRESULT STDMETHODCALLTYPE OnClockRestart(MFTIME systime);
69 virtual HRESULT STDMETHODCALLTYPE OnClockSetRate(MFTIME systime,float rate);
70 virtual HRESULT STDMETHODCALLTYPE GetCurrentMediaType(IMFVideoMediaType **mtype);
72 virtual HRESULT STDMETHODCALLTYPE GetService(const GUID &guid,const IID &iid,LPVOID *obj);
74 virtual HRESULT STDMETHODCALLTYPE get_FramesDrawn(int *val);
75 virtual HRESULT STDMETHODCALLTYPE get_AvgFrameRate(int *val);
76 virtual HRESULT STDMETHODCALLTYPE get_Jitter(int *val);
77 virtual HRESULT STDMETHODCALLTYPE get_AvgSyncOffset(int *val);
78 virtual HRESULT STDMETHODCALLTYPE get_DevSyncOffset(int *val);
79 virtual HRESULT STDMETHODCALLTYPE get_FramesDroppedInRenderer(int *val);
81 void GetNextSurface(LPDIRECT3DSURFACE9 *surf,DWORD *waittime);
82 void DiscardSurfaceandgetWait(DWORD *waittime);
86 void RenegotiateEVRMediaType();
87 void AllocateEVRSurfaces();
88 void FlushEVRSamples();
91 void ResetSyncOffsets();
92 void CalcSyncOffsets(int sync);
93 void CalcJitter(int jitter);
95 std::vector<IDirect3DSurface9*> surfaces;
96 std::queue<IMFSample*> emptyevrsamples;
97 std::queue<IMFSample*> fullevrsamples;
98 //CCritSec objCritSec;
99 IVMRSurfaceAllocatorNotify9* surfallocnotify;
100 void CleanupSurfaces();
106 bool start_get_evr_samples;
108 IMFTransform* mftransform;
109 IMediaEventSink* mediasink;
111 IMFMediaType *mfmediatype;
113 static const int n_stats=126;
114 int sync_offset[n_stats];
115 int jitter_offset[n_stats];
116 unsigned int sync_pos;
117 unsigned int jitter_pos;
124 LONGLONG lastdelframe;