00001 /* 00002 * AtmoPacketQueue.h: works as connection between the framegrabber (color-preprocessor) 00003 * and the live output thread. It works as a FIFO for the colorpackets - helps also 00004 * to synchronize between grabber and liveview threads. 00005 * especially if the grabber has another framerate as the liveview (25fps) 00006 * 00007 * See the README.txt file for copyright information and how to reach the author(s). 00008 * 00009 * $Id: 31ad98dc405af3990f0933ec292cd7fb418e6d81 $ 00010 */ 00011 00012 #ifndef _AtmoPacketQueue_ 00013 #define _AtmoPacketQueue_ 00014 00015 #include "AtmoDefs.h" 00016 #include "AtmoThread.h" 00017 00018 #if defined(_ATMO_VLC_PLUGIN_) 00019 # include <vlc_common.h> 00020 # include <vlc_threads.h> 00021 #else 00022 # include "AtmoPacketQueueStatus.h" 00023 #endif 00024 00025 00026 struct ColorPacketItem { 00027 pColorPacket packet; 00028 #if defined(_ATMO_VLC_PLUGIN_) 00029 mtime_t tickcount; 00030 #else 00031 DWORD tickcount; 00032 #endif 00033 ColorPacketItem *next; 00034 }; 00035 typedef ColorPacketItem* pColorPacketItem; 00036 00037 00038 00039 class CAtmoPacketQueue 00040 { 00041 public: 00042 #if defined(_ATMO_VLC_PLUGIN_) 00043 CAtmoPacketQueue(); 00044 #else 00045 CAtmoPacketQueue(CAtmoPacketQueueStatus *statusMonitor); 00046 #endif 00047 ~CAtmoPacketQueue(void); 00048 00049 protected: 00050 int m_waitcounter; 00051 int m_skipcounter; 00052 int m_framecounter; 00053 int m_nullpackets; 00054 DWORD m_avgWait; 00055 DWORD m_avgDelay; 00056 00057 #if !defined(_ATMO_VLC_PLUGIN_) 00058 CAtmoPacketQueueStatus *m_StatusMonitor; 00059 #endif 00060 00061 private: 00062 volatile pColorPacketItem m_first; 00063 volatile pColorPacketItem m_last; 00064 00065 #if defined(_ATMO_VLC_PLUGIN_) 00066 vlc_cond_t m_PacketArrivedCond; 00067 vlc_mutex_t m_PacketArrivedLock; 00068 volatile ATMO_BOOL m_PacketArrived; 00069 vlc_mutex_t m_Lock; 00070 #else 00071 CRITICAL_SECTION m_lock; 00072 HANDLE m_hPacketArrivedEvent; 00073 #endif 00074 00075 private: 00076 void Lock(); 00077 void Unlock(); 00078 void SignalEvent(); 00079 void UnSignalEvent(); 00080 00081 private: 00082 pColorPacket GetNextPacket(); 00083 pColorPacketItem GetNextPacketContainer(); 00084 00085 public: 00086 void AddPacket(pColorPacket newPacket); 00087 00088 // timecode = GetTickCount() - framedelay; 00089 #if defined(_ATMO_VLC_PLUGIN_) 00090 void ShowQueueStatus(atmo_thread_t *p_this); 00091 pColorPacket GetNextPacket(mtime_t timecode, ATMO_BOOL withWait, atmo_thread_t *p_this, mtime_t &packet_time ); 00092 #else 00093 pColorPacket GetNextPacket(DWORD timecode, ATMO_BOOL withWait, DWORD &packet_time ); 00094 #endif 00095 00096 void ClearQueue(); 00097 00098 ATMO_BOOL WaitForNextPacket(DWORD timeout); 00099 00100 }; 00101 00102 #endif
1.5.6