00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <atlbase.h>
00025 #include <atlcoll.h>
00026 #include "CoordGeom.h"
00027
00028 #pragma pack(push, 1)
00029 struct SubPicDesc
00030 {
00031 int type;
00032 int w, h, bpp, pitch, pitchUV;
00033 void* bits;
00034 BYTE* bitsU;
00035 BYTE* bitsV;
00036 RECT vidrect;
00037
00038 struct SubPicDesc() {type = 0; w = h = bpp = pitch = pitchUV = 0; bits = NULL; bitsU = bitsV = NULL;}
00039 };
00040 #pragma pack(pop)
00041
00042
00043
00044
00045
00046 [uuid("449E11F3-52D1-4a27-AA61-E2733AC92CC0")]
00047 interface ISubPic : public IUnknown
00048 {
00049 STDMETHOD_(void*, GetObject) () PURE;
00050
00051 STDMETHOD_(REFERENCE_TIME, GetStart) () PURE;
00052 STDMETHOD_(REFERENCE_TIME, GetStop) () PURE;
00053 STDMETHOD_(void, SetStart) (REFERENCE_TIME rtStart) PURE;
00054 STDMETHOD_(void, SetStop) (REFERENCE_TIME rtStop) PURE;
00055
00056 STDMETHOD (GetDesc) (SubPicDesc& spd ) PURE;
00057 STDMETHOD (CopyTo) (ISubPic* pSubPic ) PURE;
00058
00059 STDMETHOD (ClearDirtyRect) (DWORD color ) PURE;
00060 STDMETHOD (GetDirtyRect) (RECT* pDirtyRect ) PURE;
00061 STDMETHOD (SetDirtyRect) (RECT* pDirtyRect ) PURE;
00062
00063 STDMETHOD (GetMaxSize) (SIZE* pMaxSize ) PURE;
00064 STDMETHOD (SetSize) (SIZE pSize , RECT vidrect ) PURE;
00065
00066 STDMETHOD (Lock) (SubPicDesc& spd ) PURE;
00067 STDMETHOD (Unlock) (RECT* pDirtyRect ) PURE;
00068
00069 STDMETHOD (AlphaBlt) (RECT* pSrc, RECT* pDst, SubPicDesc* pTarget = NULL ) PURE;
00070 };
00071
00072 class ISubPicImpl : public CUnknown, public ISubPic
00073 {
00074 protected:
00075 REFERENCE_TIME m_rtStart, m_rtStop;
00076 CRect m_rcDirty;
00077 CSize m_maxsize, m_size;
00078 CRect m_vidrect;
00079
00080 public:
00081 ISubPicImpl();
00082
00083 DECLARE_IUNKNOWN;
00084 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00085
00086
00087
00088 STDMETHODIMP_(REFERENCE_TIME) GetStart();
00089 STDMETHODIMP_(REFERENCE_TIME) GetStop();
00090 STDMETHODIMP_(void) SetStart(REFERENCE_TIME rtStart);
00091 STDMETHODIMP_(void) SetStop(REFERENCE_TIME rtStop);
00092
00093 STDMETHODIMP GetDesc(SubPicDesc& spd) = 0;
00094 STDMETHODIMP CopyTo(ISubPic* pSubPic);
00095
00096 STDMETHODIMP ClearDirtyRect(DWORD color) = 0;
00097 STDMETHODIMP GetDirtyRect(RECT* pDirtyRect);
00098 STDMETHODIMP SetDirtyRect(RECT* pDirtyRect);
00099
00100 STDMETHODIMP GetMaxSize(SIZE* pMaxSize);
00101 STDMETHODIMP SetSize(SIZE size, RECT vidrect);
00102
00103 STDMETHODIMP Lock(SubPicDesc& spd) = 0;
00104 STDMETHODIMP Unlock(RECT* pDirtyRect) = 0;
00105
00106 STDMETHODIMP AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) = 0;
00107 };
00108
00109
00110
00111
00112
00113 [uuid("CF7C3C23-6392-4a42-9E72-0736CFF793CB")]
00114 interface ISubPicAllocator : public IUnknown
00115 {
00116 STDMETHOD (SetCurSize) (SIZE size ) PURE;
00117 STDMETHOD (SetCurVidRect) (RECT curvidrect) PURE;
00118
00119 STDMETHOD (GetStatic) (ISubPic** ppSubPic ) PURE;
00120 STDMETHOD (AllocDynamic) (ISubPic** ppSubPic ) PURE;
00121
00122 STDMETHOD_(bool, IsDynamicWriteOnly) () PURE;
00123
00124 STDMETHOD (ChangeDevice) (IUnknown* pDev) PURE;
00125 };
00126
00127
00128 class ISubPicAllocatorImpl : public CUnknown, public ISubPicAllocator
00129 {
00130 CComPtr<ISubPic> m_pStatic;
00131
00132 private:
00133 CSize m_cursize;
00134 CRect m_curvidrect;
00135 bool m_fDynamicWriteOnly;
00136
00137 virtual bool Alloc(bool fStatic, ISubPic** ppSubPic) = 0;
00138
00139 protected:
00140 bool m_fPow2Textures;
00141
00142 public:
00143 ISubPicAllocatorImpl(SIZE cursize, bool fDynamicWriteOnly, bool fPow2Textures);
00144
00145 DECLARE_IUNKNOWN;
00146 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00147
00148
00149
00150 STDMETHODIMP SetCurSize(SIZE cursize);
00151 STDMETHODIMP SetCurVidRect(RECT curvidrect);
00152 STDMETHODIMP GetStatic(ISubPic** ppSubPic);
00153 STDMETHODIMP AllocDynamic(ISubPic** ppSubPic);
00154 STDMETHODIMP_(bool) IsDynamicWriteOnly();
00155 STDMETHODIMP ChangeDevice(IUnknown* pDev);
00156 };
00157
00158
00159
00160
00161
00162 [uuid("D62B9A1A-879A-42db-AB04-88AA8F243CFD")]
00163 interface ISubPicProvider : public IUnknown
00164 {
00165 STDMETHOD (Lock) () PURE;
00166 STDMETHOD (Unlock) () PURE;
00167
00168 STDMETHOD_(POSITION, GetStartPosition) (REFERENCE_TIME rt, double fps) PURE;
00169 STDMETHOD_(POSITION, GetNext) (POSITION pos) PURE;
00170
00171 STDMETHOD_(REFERENCE_TIME, GetStart) (POSITION pos, double fps) PURE;
00172 STDMETHOD_(REFERENCE_TIME, GetStop) (POSITION pos, double fps) PURE;
00173
00174 STDMETHOD_(bool, IsAnimated) (POSITION pos) PURE;
00175
00176 STDMETHOD (Render) (SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox) PURE;
00177 };
00178
00179 class ISubPicProviderImpl : public CUnknown, public ISubPicProvider
00180 {
00181 protected:
00182 CCritSec* m_pLock;
00183
00184 public:
00185 ISubPicProviderImpl(CCritSec* pLock);
00186 virtual ~ISubPicProviderImpl();
00187
00188 DECLARE_IUNKNOWN;
00189 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00190
00191
00192
00193 STDMETHODIMP Lock();
00194 STDMETHODIMP Unlock();
00195
00196 STDMETHODIMP_(POSITION) GetStartPosition(REFERENCE_TIME rt, double fps) = 0;
00197 STDMETHODIMP_(POSITION) GetNext(POSITION pos) = 0;
00198
00199 STDMETHODIMP_(REFERENCE_TIME) GetStart(POSITION pos, double fps) = 0;
00200 STDMETHODIMP_(REFERENCE_TIME) GetStop(POSITION pos, double fps) = 0;
00201
00202 STDMETHODIMP Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox) = 0;
00203 };
00204
00205
00206
00207
00208
00209 [uuid("C8334466-CD1E-4ad1-9D2D-8EE8519BD180")]
00210 interface ISubPicQueue : public IUnknown
00211 {
00212 STDMETHOD (SetSubPicProvider) (ISubPicProvider* pSubPicProvider ) PURE;
00213 STDMETHOD (GetSubPicProvider) (ISubPicProvider** pSubPicProvider ) PURE;
00214
00215 STDMETHOD (SetFPS) (double fps ) PURE;
00216 STDMETHOD (SetTime) (REFERENCE_TIME rtNow ) PURE;
00217
00218 STDMETHOD (Invalidate) (REFERENCE_TIME rtInvalidate = -1) PURE;
00219 STDMETHOD_(bool, LookupSubPic) (REFERENCE_TIME rtNow , ISubPic** ppSubPic ) PURE;
00220
00221 STDMETHOD (GetStats) (int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop ) PURE;
00222 STDMETHOD (GetStats) (int nSubPic , REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop ) PURE;
00223 };
00224
00225 class ISubPicQueueImpl : public CUnknown, public ISubPicQueue
00226 {
00227 CCritSec m_csSubPicProvider;
00228 CComPtr<ISubPicProvider> m_pSubPicProvider;
00229
00230 protected:
00231 double m_fps;
00232 REFERENCE_TIME m_rtNow;
00233
00234 CComPtr<ISubPicAllocator> m_pAllocator;
00235
00236 HRESULT RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double fps);
00237
00238 public:
00239 ISubPicQueueImpl(ISubPicAllocator* pAllocator, HRESULT* phr);
00240 virtual ~ISubPicQueueImpl();
00241
00242 DECLARE_IUNKNOWN;
00243 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00244
00245
00246
00247 STDMETHODIMP SetSubPicProvider(ISubPicProvider* pSubPicProvider);
00248 STDMETHODIMP GetSubPicProvider(ISubPicProvider** pSubPicProvider);
00249
00250 STDMETHODIMP SetFPS(double fps);
00251 STDMETHODIMP SetTime(REFERENCE_TIME rtNow);
00252
00253
00254
00255
00256
00257
00258
00259 };
00260
00261 class CSubPicQueue : public ISubPicQueueImpl, private CInterfaceList<ISubPic>, private CAMThread
00262 {
00263 int m_nMaxSubPic;
00264
00265 CCritSec m_csQueueLock;
00266 REFERENCE_TIME UpdateQueue();
00267 void AppendQueue(ISubPic* pSubPic);
00268
00269 REFERENCE_TIME m_rtQueueStart, m_rtInvalidate;
00270
00271
00272
00273 bool m_fBreakBuffering;
00274 enum {EVENT_EXIT, EVENT_TIME, EVENT_COUNT};
00275 HANDLE m_ThreadEvents[EVENT_COUNT];
00276 DWORD ThreadProc();
00277
00278 public:
00279 CSubPicQueue(int nMaxSubPic, ISubPicAllocator* pAllocator, HRESULT* phr);
00280 virtual ~CSubPicQueue();
00281
00282
00283
00284 STDMETHODIMP SetFPS(double fps);
00285 STDMETHODIMP SetTime(REFERENCE_TIME rtNow);
00286
00287 STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1);
00288 STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, ISubPic** ppSubPic);
00289
00290 STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
00291 STDMETHODIMP GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
00292 };
00293
00294 class CSubPicQueueNoThread : public ISubPicQueueImpl
00295 {
00296 CCritSec m_csLock;
00297 CComPtr<ISubPic> m_pSubPic;
00298
00299 public:
00300 CSubPicQueueNoThread(ISubPicAllocator* pAllocator, HRESULT* phr);
00301 virtual ~CSubPicQueueNoThread();
00302
00303
00304
00305 STDMETHODIMP Invalidate(REFERENCE_TIME rtInvalidate = -1);
00306 STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, ISubPic** ppSubPic);
00307
00308 STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
00309 STDMETHODIMP GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
00310 };
00311
00312
00313
00314
00315
00316 [uuid("CF75B1F0-535C-4074-8869-B15F177F944E")]
00317 interface ISubPicAllocatorPresenter : public IUnknown
00318 {
00319 STDMETHOD (CreateRenderer) (IUnknown** ppRenderer) PURE;
00320
00321 STDMETHOD_(SIZE, GetVideoSize) (bool fCorrectAR = true) PURE;
00322 STDMETHOD_(void, SetPosition) (RECT w, RECT v) PURE;
00323 STDMETHOD_(bool, Paint) (bool fAll) PURE;
00324
00325 STDMETHOD_(void, SetTime) (REFERENCE_TIME rtNow) PURE;
00326 STDMETHOD_(double, GetFPS) () PURE;
00327
00328 STDMETHOD_(void, SetSubPicProvider) (ISubPicProvider* pSubPicProvider) PURE;
00329 STDMETHOD_(void, Invalidate) (REFERENCE_TIME rtInvalidate = -1) PURE;
00330
00331 STDMETHOD (GetDIB) (BYTE* lpDib, DWORD* size) PURE;
00332
00333 STDMETHOD (SetVideoAngle) (Vector v, bool fRepaint = true) PURE;
00334 STDMETHOD (SetPixelShader) (LPCSTR pSrcData, LPCSTR pTarget) PURE;
00335 };
00336
00337 class ISubPicAllocatorPresenterImpl
00338 : public CUnknown
00339 , public CCritSec
00340 , public ISubPicAllocatorPresenter
00341 {
00342 protected:
00343 HWND m_hWnd;
00344 CSize m_spMaxSize;
00345 int m_spMaxQueued;
00346
00347 CSize m_NativeVideoSize, m_AspectRatio;
00348 CRect m_VideoRect, m_WindowRect;
00349
00350 REFERENCE_TIME m_rtNow;
00351 double m_fps;
00352
00353 CComPtr<ISubPicAllocator> m_pAllocator;
00354 CComPtr<ISubPicQueue> m_pSubPicQueue;
00355
00356 void AlphaBltSubPic(CSize size, SubPicDesc* pTarget = NULL);
00357
00358 XForm m_xform;
00359 void Transform(CRect r, Vector v[4]);
00360
00361 public:
00362 ISubPicAllocatorPresenterImpl(HWND hWnd);
00363 virtual ~ISubPicAllocatorPresenterImpl();
00364
00365 DECLARE_IUNKNOWN;
00366 STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
00367
00368
00369
00370 STDMETHODIMP CreateRenderer(IUnknown** ppRenderer) = 0;
00371
00372 STDMETHODIMP_(SIZE) GetVideoSize(bool fCorrectAR = true);
00373 STDMETHODIMP_(void) SetPosition(RECT w, RECT v);
00374 STDMETHODIMP_(bool) Paint(bool fAll) = 0;
00375
00376 STDMETHODIMP_(void) SetTime(REFERENCE_TIME rtNow);
00377 STDMETHODIMP_(double) GetFPS();
00378
00379 STDMETHODIMP_(void) SetSubPicProvider(ISubPicProvider* pSubPicProvider);
00380 STDMETHODIMP_(void) Invalidate(REFERENCE_TIME rtInvalidate = -1);
00381
00382 STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size) {return E_NOTIMPL;}
00383
00384 STDMETHODIMP SetVideoAngle(Vector v, bool fRepaint = true);
00385 STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget) {return E_NOTIMPL;}
00386 };
00387
00388
00389
00390
00391
00392 [uuid("DE11E2FB-02D3-45e4-A174-6B7CE2783BDB")]
00393 interface ISubStream : public IPersist
00394 {
00395 STDMETHOD_(int, GetStreamCount) () PURE;
00396 STDMETHOD (GetStreamInfo) (int i, WCHAR** ppName, LCID* pLCID) PURE;
00397 STDMETHOD_(int, GetStream) () PURE;
00398 STDMETHOD (SetStream) (int iStream) PURE;
00399 STDMETHOD (Reload) () PURE;
00400
00401
00402
00403 };
00404