svvitch
digital signage player
|
00001 #pragma once 00002 00003 #include <Poco/Mutex.h> 00004 #include <Poco/Thread.h> 00005 #include <Poco/Runnable.h> 00006 00007 #include "Content.h" 00008 #include "ControlSite.h" 00009 00010 00011 using std::queue; 00012 00017 class Rect 00018 { 00019 private: 00020 Rect& copy(const Rect& rect) { 00021 if (this == &rect) return *this; 00022 x = rect.x; 00023 y = rect.y; 00024 w = rect.w; 00025 h = rect.h; 00026 return *this; 00027 } 00028 00029 public: 00030 int x; 00031 int y; 00032 int w; 00033 int h; 00034 00035 Rect(int x_, int y_, int w_, int h_): x(x_), y(y_), w(w_), h(h_) { 00036 } 00037 00038 Rect(const Rect& rect) { 00039 copy(rect); 00040 } 00041 00042 Rect& operator=(const Rect& rect) { 00043 return copy(rect); 00044 } 00045 }; 00046 00047 00052 class ComContent: public Content, Poco::Runnable { 00053 private: 00054 protected: 00055 Poco::FastMutex _lock; 00056 queue<Rect> _invalidateRects; 00057 00058 IOleObject* _ole; 00059 ControlSite* _controlSite; 00060 Poco::Thread _thread; 00061 Poco::Runnable* _worker; 00062 00063 LPDIRECT3DTEXTURE9 _texture; 00064 LPDIRECT3DSURFACE9 _surface; 00065 00066 int _phase; 00067 DWORD _background; 00068 PerformanceTimer _playTimer; 00069 DWORD _readTime; 00070 int _readCount; 00071 float _avgTime; 00072 00073 00074 ComContent(Renderer& renderer, int splitType, float x = 0, float y = 0, float w = 0, float h = 0); 00075 00076 virtual ‾ComContent(); 00077 00078 virtual void createComComponents() = 0; 00079 00080 virtual void releaseComComponents() = 0; 00081 00082 bool hasInvalidateRect(); 00083 00084 Rect popInvalidateRect(); 00085 00086 00087 public: 00088 void invalidateRect(int x, int y, int w, int h); 00089 00091 virtual bool open(const MediaItemPtr media, const int offset = 0); 00092 00094 void play(); 00095 00097 void stop(); 00098 00099 bool useFastStop(); 00100 00102 const bool playing() const; 00103 00104 const bool finished(); 00105 00107 void close(); 00108 00109 void process(const DWORD& frame); 00110 00111 virtual void run() = 0; 00112 00113 void draw(const DWORD& frame); 00114 }; 00115 00116 typedef ComContent* ComContentPtr;