svvitch
digital signage player
D:/vs_workspace/switch_sf/src/svvitch/MainScene.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <Poco/StreamCopier.h>
00004 #include <d3d9.h>
00005 #include <d3dx9.h>
00006 #define DIRECTINPUT_VERSION 0x0800
00007 #include <dinput.h>
00008 #include <Poco/ActiveMethod.h>
00009 #include <Poco/ActiveResult.h>
00010 #include <Poco/FileStream.h>
00011 #include <Poco/Logger.h>
00012 #include <Poco/Mutex.h>
00013 #include <Poco/Thread.h>
00014 #include <Poco/Runnable.h>
00015 #include <map>
00016 #include <string>
00017 #include <vector>
00018 #include <queue>
00019 
00020 #include "Common.h"
00021 
00022 #include "Container.h"
00023 #include "Renderer.h"
00024 #include "Scene.h"
00025 #include "Transition.h"
00026 #include "Workspace.h"
00027 
00028 using std::string;
00029 using std::vector;
00030 using std::queue;
00031 using std::map;
00032 
00033 using Poco::ActiveMethod;
00034 using Poco::ActiveResult;
00035 
00036 
00040 struct PlayParameters
00041 {
00042     string playlistID;
00043     int i;
00044     string action;
00045     string transition;
00046 };
00047 
00051 struct RemovableMediaArgs {
00052     const string& driveLetter;
00053 };
00054 
00055 
00059 class DelayedRelease {
00060 private:
00061     Poco::Timestamp t;
00062     ContainerPtr c;
00063 
00064     DelayedRelease& copy(const DelayedRelease& dr) {
00065         t = dr.t;
00066         c = dr.c;
00067         return *this;
00068     }
00069 
00070 public:
00071     DelayedRelease(ContainerPtr _c) {
00072         Poco::DateTime now;
00073         t = now.timestamp();
00074         c = _c;
00075     }
00076 
00077     virtual ‾DelayedRelease() {
00078     }
00079 
00080     DelayedRelease& operator=(const DelayedRelease& dr) {
00081         return copy(dr);
00082     }
00083 
00084     const Poco::Timestamp& timestamp() {
00085         return t;
00086     }
00087 
00088     const ContainerPtr& container() {
00089         return c;
00090     }
00091 };
00092 
00093 
00098 class MainScene: public Scene
00099 {
00100 private:
00101     Poco::FastMutex _lock;
00102     Poco::FastMutex _workspaceLock;
00103     Poco::FastMutex _delayedUpdateLock;
00104 
00105     WorkspacePtr _workspace;
00106     WorkspacePtr _updatedWorkspace;
00107 
00108     DWORD _frame;
00109     bool _startup;
00110     bool _autoStart;
00111     int _brightness;
00112 
00113     vector<ContainerPtr> _contents;
00114     int _currentContent;
00115     bool _preparing;
00116 
00118     PlayParameters _playCurrent;
00119 
00121     LPDIRECT3DTEXTURE9 _description;
00123     LPDIRECT3DTEXTURE9 _playlistName;
00125     LPDIRECT3DTEXTURE9 _currentName;
00126 
00127     vector<PlayParameters> _nextStack;
00128     int _nextStackTime;
00129 
00131     PlayParameters _playNext;
00132 
00134     LPDIRECT3DTEXTURE9 _nextPlaylistName;
00136     LPDIRECT3DTEXTURE9 _nextName;
00137 
00138     vector<PlayParameters> _prepareStack;
00139     int _prepareStackTime;
00140 
00142     PlayParameters _playPrepared;
00143 
00145     ContainerPtr _prepared;
00146 
00148     LPDIRECT3DTEXTURE9 _preparedPlaylistName;
00150     LPDIRECT3DTEXTURE9 _preparedName;
00151 
00153     int _playCount;
00154     bool _doPrepareNext;
00155     bool _preparingNext;
00157     bool _doSwitchNext;
00159     bool _doSwitchPrepared;
00161     TransitionPtr _transition;
00162 
00164     string _nowTime;
00166     int _timeSecond;
00167 
00168     bool _initializing;
00169     bool _running;
00170 
00171     string _castLogDate;
00172     Poco::FileOutputStream* _castLog;
00173 
00175     map<string, File> _stock;
00176 
00178     LPDIRECT3DTEXTURE9 _removableIcon;
00179     float _removableIconAlpha;
00180     string _addRemovable;
00181     float _removableAlpha;
00182     float _removableCover;
00183     unsigned long _copySize;
00184     unsigned long _currentCopySize;
00185     int _copyProgress;
00186     int _currentCopyProgress;
00187     int _copyRemoteFiles;
00188     string _copyingRemote;
00189     bool _delayedCopy;
00190     vector<File> _delayUpdateFiles;
00191 
00192     vector<DelayedRelease> _delayReleases;
00193     queue<string> _deletes;
00194 
00196     map<string, ContainerPtr> _stanbyMedias;
00197     string _interruptted;
00198     ContainerPtr _interrupttedContent;
00199 
00201     DWORD _messageFrame;
00202     queue<string> _messages;
00203 
00204 
00206     void execDelayedRelease();
00207 
00209     void pushDelayedRelease(ContainerPtr c);
00210 
00212     void preparedStanbyMedia();
00213 
00215     void preparedFont(WorkspacePtr workspace);
00216 
00217     void run();
00218 
00220     bool prepareContent(const PlayParameters& args);
00221 
00223     bool prepareNextContent(const PlayParameters& args);
00224 
00226     bool preparePlaylist(ContainerPtr container, const string& playlistID, const int i, const bool round = false);
00227 
00228     bool prepareMedia(ContainerPtr container, MediaItemPtr media, const string& templatedText);
00229 
00230     void addRemovableMedia(const string& driveLetter);
00231 
00232     int copyFiles(const string& src, const string& dst);
00233 
00235     void copyRemote(const string& remote);
00236 
00237     bool copyRemoteFile(const string& remote, const string& path, Path& out, bool equalityCheck = false);
00238 
00239     void setRemoteStatus(const string& remote, const string& name, const string& value);
00240 
00242 /*  bool copyRemoteDir(const string& remote, const string& root);
00243 */
00245     ActiveMethod<bool, PlayParameters, MainScene> activePrepareNextContent;
00246 
00247 
00248 public:
00249     MainScene(Renderer& renderer);
00250 
00251     virtual ‾MainScene();
00252 
00254     bool initialize();
00255 
00257     Workspace& getWorkspace();
00258 
00259     void notifyKey(const int keycode, const bool shift, const bool ctrl);
00260 
00262     bool stackPrepareContent(string& playlistID, int i = 0);
00263 
00265     const void setDescription(const string& description);
00266 
00268     const string getPlaylistText(const string& playlistID);
00269 
00271     bool setPlaylistText(const string& playlistID, const string& text);
00272 
00274     void setBrightness(int i);
00275 
00277     void setAction(string& action);
00278 
00280     void setTransition(string& transition);
00281 
00283     ActiveMethod<bool, PlayParameters, MainScene> activePrepareContent;
00284 
00289     bool switchContent();
00290 
00292     ActiveMethod<bool, void, MainScene> activeSwitchContent;
00293 
00294     bool addStock(const string& path, File file, bool copy = false);
00295 
00296     void clearStock();
00297 
00298     bool flushStock();
00299 
00301     void addDelayedUpdateFile(File& file);
00302 
00304     void removeDelayedUpdateFile(File& file);
00305 
00307     void updateDelayedFiles();
00308 
00310     bool updateWorkspace();
00311 
00313     ActiveMethod<void, string, MainScene> activeCopyRemote;
00314 
00316     ActiveMethod<void, string, MainScene> activeAddRemovableMedia;
00317 
00319     virtual void process();
00320 
00325     virtual void draw1();
00326 
00331     virtual void draw2();
00332 
00334     void drawConsole(string text);
00335 };
00336 
00337 typedef MainScene* MainScenePtr;
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines