2 * $Id: SubPicQueueImpl.h 2786 2010-12-17 16:42:55Z XhmikosR $
5 * (C) 2006-2010 see AUTHORS
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Make; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 * http://www.gnu.org/copyleft/gpl.html
27 #include "ISimpleSubPic.h"
30 class CSubPicQueueImpl
: public CUnknown
, public ISubPicQueue
, public ISimpleSubPicProvider
32 CAtlList
<int> m_prefered_colortype
;
34 CCritSec m_csSubPicProvider
;
35 CComPtr
<ISubPicProviderEx
> m_pSubPicProviderEx
;
39 REFERENCE_TIME m_rtNow
;
40 REFERENCE_TIME m_rtNowLast
;
42 CComPtr
<ISubPicExAllocator
> m_pAllocator
;
44 HRESULT
RenderTo(ISubPicEx
* pSubPic
, REFERENCE_TIME rtStart
, REFERENCE_TIME rtStop
, double fps
, BOOL bIsAnimated
);
46 HRESULT
SetSubPicProviderEx(ISubPicProviderEx
* pSubPicProviderEx
);
47 HRESULT
GetSubPicProviderEx(ISubPicProviderEx
** pSubPicProviderEx
);
49 CSubPicQueueImpl(ISubPicExAllocator
* pAllocator
, HRESULT
* phr
, const int *prefered_colortype
=NULL
, int prefered_colortype_num
=0);
50 virtual ~CSubPicQueueImpl();
53 STDMETHODIMP
NonDelegatingQueryInterface(REFIID riid
, void** ppv
);
57 STDMETHODIMP
SetSubPicProvider(ISubPicProvider
* pSubPicProvider
);
58 STDMETHODIMP
GetSubPicProvider(ISubPicProvider
** pSubPicProvider
);
60 STDMETHODIMP
SetFPS(double fps
);
61 STDMETHODIMP
SetTime(REFERENCE_TIME rtNow
);
63 // ISimpleSubPicProvider
65 STDMETHODIMP
SetSubPicProvider(IUnknown
* subpic_provider
);
66 STDMETHODIMP
GetSubPicProvider(IUnknown
** subpic_provider
);
68 STDMETHODIMP
Invalidate(REFERENCE_TIME rtInvalidate
= -1) = 0;
70 STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow, ISubPic** ppSubPic) = 0;
72 STDMETHODIMP GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
73 STDMETHODIMP GetStats(int nSubPics, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop) = 0;
77 class CSubPicQueue
: public CSubPicQueueImpl
, private CAMThread
82 CInterfaceList
<ISubPic
> m_Queue
;
84 CCritSec m_csQueueLock
; // for protecting CInterfaceList<ISubPic>
87 POSITION m_subPos
;//use to pass to the SubPic provider to produce the next SubPic
89 REFERENCE_TIME
UpdateQueue();
90 void AppendQueue(ISubPic
* pSubPic
);
93 REFERENCE_TIME m_rtQueueMin
;
94 REFERENCE_TIME m_rtQueueMax
;
95 REFERENCE_TIME m_rtQueueStart
, m_rtInvalidate
;
99 bool m_fBreakBuffering
;
100 enum {EVENT_EXIT
, EVENT_TIME
, EVENT_COUNT
}; // IMPORTANT: _EXIT must come before _TIME if we want to exit fast from the destructor
101 HANDLE m_ThreadEvents
[EVENT_COUNT
];
102 enum {QueueEvents_NOTEMPTY
, QueueEvents_NOTFULL
, QueueEvents_COUNT
};
103 HANDLE m_QueueEvents
[QueueEvents_COUNT
];
107 CSubPicQueue(int nMaxSubPic
, BOOL bDisableAnim
, ISubPicExAllocator
* pAllocator
, HRESULT
* phr
);
108 virtual ~CSubPicQueue();
112 STDMETHODIMP
SetFPS(double fps
);
113 STDMETHODIMP
SetTime(REFERENCE_TIME rtNow
);
115 STDMETHODIMP
Invalidate(REFERENCE_TIME rtInvalidate
= -1);
116 STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow
, ISubPic
** ppSubPic
);
118 STDMETHODIMP
GetStats(int& nSubPics
, REFERENCE_TIME
& rtNow
, REFERENCE_TIME
& rtStart
, REFERENCE_TIME
& rtStop
);
119 STDMETHODIMP
GetStats(int nSubPic
, REFERENCE_TIME
& rtStart
, REFERENCE_TIME
& rtStop
);
121 // ISimpleSubPicProvider
122 STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME now
/*[in]*/, ISimpleSubPic
** output_subpic
/*[out]*/);
125 class CSubPicQueueNoThread
: public CSubPicQueueImpl
128 CComPtr
<ISubPicEx
> m_pSubPic
;
130 CAtlList
<int> m_prefered_colortype
;
132 bool LookupSubPicEx(REFERENCE_TIME rtNow
, ISubPicEx
** ppSubPic
);
134 CSubPicQueueNoThread(ISubPicExAllocator
* pAllocator
, HRESULT
* phr
, const int *prefered_colortype
=NULL
, int prefered_colortype_num
=0);
135 virtual ~CSubPicQueueNoThread();
138 STDMETHODIMP
Invalidate(REFERENCE_TIME rtInvalidate
= -1);
139 STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME rtNow
, ISubPic
** ppSubPic
);
141 STDMETHODIMP
GetStats(int& nSubPics
, REFERENCE_TIME
& rtNow
, REFERENCE_TIME
& rtStart
, REFERENCE_TIME
& rtStop
);
142 STDMETHODIMP
GetStats(int nSubPic
, REFERENCE_TIME
& rtStart
, REFERENCE_TIME
& rtStop
);
144 // ISimpleSubPicProvider
145 STDMETHODIMP_(bool) LookupSubPic(REFERENCE_TIME now
/*[in]*/, ISimpleSubPic
** output_subpic
/*[out]*/);