]> git.sesse.net Git - casparcg/blob - modules/flash/interop/TimerHelper.h
Try to use a unique pdwCookie when Advising an ITimerSink in flash producer. This...
[casparcg] / modules / flash / interop / TimerHelper.h
1 /*
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
3 *
4 *  This file is part of CasparCG.
5 *
6 *    CasparCG 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 3 of the License, or
9 *    (at your option) any later version.
10 *
11 *    CasparCG 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 CasparCG.  If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20  
21 #ifndef _TIMER_HELPER_H__
22 #define _TIMER_HELPER_H__
23
24 #include "FlashAxContainer.h"
25
26 namespace caspar {
27 namespace flash {
28
29         class TimerHelper
30         {
31                 TimerHelper(const TimerHelper&);
32                 const TimerHelper& operator=(const TimerHelper&);
33
34         public:
35                 TimerHelper()
36                 {}
37                 TimerHelper(DWORD id, DWORD first, DWORD interv, ITimerSink* pTS)
38                         : ID(id)
39                         , firstTime(first)
40                         , interval(interv)
41                         , currentTime(first)
42                         , pTimerSink(pTS)
43                 {
44                 }
45
46                 ~TimerHelper()
47                 {
48                 }
49                 void Setup(DWORD id, DWORD first, DWORD interv, ITimerSink* pTS)
50                 {
51                         ID = id;
52                         firstTime = first;
53                         interval = interv;
54                         currentTime = first;
55                         pTimerSink = pTS;
56                 }
57
58                 DWORD Invoke()
59                 {
60                         if(pTimerSink != 0)
61                         {
62                                 VARIANT value;
63                                 value.vt = VT_UI4;
64                                 value.ulVal = currentTime;
65
66                                 pTimerSink->OnTimer(value);
67                                 currentTime += interval;
68                         }
69                         return currentTime;
70                 }
71
72                 DWORD ID;
73                 DWORD firstTime;
74                 DWORD interval;
75                 DWORD currentTime;
76                 ATL::CComPtr<ITimerSink> pTimerSink;
77         };
78
79 }       //namespace flash
80 }       //namespace caspar
81
82 #endif  //_TIMER_HELPER_H__