]> git.sesse.net Git - vlc/blob - modules/video_filter/atmo/AtmoPacketQueue.h
Fixed mix up between pitches in magnify filter.
[vlc] / modules / video_filter / atmo / AtmoPacketQueue.h
1 /*
2  * AtmoPacketQueue.h:  works as connection between the framegrabber (color-preprocessor)
3  * and the live output thread. It works as a FIFO for the colorpackets - helps also
4  * to synchronize between grabber and liveview threads.
5  * especially if the grabber has another framerate as the liveview (25fps)
6  *
7  * See the README.txt file for copyright information and how to reach the author(s).
8  *
9  * $Id$
10  */
11
12 #ifndef _AtmoPacketQueue_
13 #define _AtmoPacketQueue_
14
15 #include "AtmoDefs.h"
16 #include "AtmoThread.h"
17
18 #if defined(_ATMO_VLC_PLUGIN_)
19 #  include <vlc_common.h>
20 #  include <vlc_threads.h>
21 #else
22 # include "AtmoPacketQueueStatus.h"
23 #endif
24
25
26 struct ColorPacketItem {
27     pColorPacket packet;
28 #if defined(_ATMO_VLC_PLUGIN_)
29     mtime_t tickcount;
30 #else
31     DWORD tickcount;
32 #endif
33     ColorPacketItem *next;
34 };
35 typedef ColorPacketItem* pColorPacketItem;
36
37
38
39 class CAtmoPacketQueue
40 {
41 public:
42 #if defined(_ATMO_VLC_PLUGIN_)
43     CAtmoPacketQueue();
44 #else
45     CAtmoPacketQueue(CAtmoPacketQueueStatus *statusMonitor);
46 #endif
47     ~CAtmoPacketQueue(void);
48
49 protected:
50     int m_waitcounter;
51     int m_skipcounter;
52     int m_framecounter;
53     int m_nullpackets;
54     DWORD m_avgWait;
55     DWORD m_avgDelay;
56
57 #if !defined(_ATMO_VLC_PLUGIN_)
58     CAtmoPacketQueueStatus *m_StatusMonitor;
59 #endif
60
61 private:
62     volatile pColorPacketItem m_first;
63     volatile pColorPacketItem m_last;
64
65 #if defined(_ATMO_VLC_PLUGIN_)
66     vlc_cond_t   m_PacketArrivedCond;
67     vlc_mutex_t  m_PacketArrivedLock;
68     volatile ATMO_BOOL m_PacketArrived;
69     vlc_mutex_t  m_Lock;
70 #else
71     CRITICAL_SECTION m_lock;
72     HANDLE m_hPacketArrivedEvent;
73 #endif
74
75 private:
76     void Lock();
77     void Unlock();
78     void SignalEvent();
79     void UnSignalEvent();
80
81 private:
82     pColorPacket GetNextPacket();
83     pColorPacketItem GetNextPacketContainer();
84
85 public:
86     void AddPacket(pColorPacket newPacket);
87
88     // timecode = GetTickCount() - framedelay;
89 #if defined(_ATMO_VLC_PLUGIN_)
90     void ShowQueueStatus(atmo_thread_t *p_this);
91     pColorPacket GetNextPacket(mtime_t timecode, ATMO_BOOL withWait, atmo_thread_t *p_this, mtime_t &packet_time );
92 #else
93     pColorPacket GetNextPacket(DWORD timecode, ATMO_BOOL withWait, DWORD &packet_time );
94 #endif
95
96     void ClearQueue();
97
98     ATMO_BOOL WaitForNextPacket(DWORD timeout);
99
100 };
101
102 #endif