Fraxinus  16.5.0-fx-rc3
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxSavingVideoRecorder.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 #ifndef CXSAVINGVIDEORECORDER_H
33 #define CXSAVINGVIDEORECORDER_H
34 
35 #include "cxResourceExport.h"
36 
37 #include <vector>
38 #include <QFile>
39 #include <QThread>
40 #include <QMutex>
41 
42 #include "vtkForwardDeclarations.h"
43 #include "cxForwardDeclarations.h"
44 #include "cxData.h"
45 
46 namespace cx
47 {
48 typedef boost::shared_ptr<class CachedImageDataContainer> CachedImageDataContainerPtr;
49 
69 class cxResource_EXPORT VideoRecorderSaveThread : public QThread
70 {
71  Q_OBJECT
72 public:
76  VideoRecorderSaveThread(QObject* parent, QString saveFolder, QString prefix, bool compressed, bool writeColor);
77  virtual ~VideoRecorderSaveThread();
81  QString addData(TimeInfo timestamp, vtkImageDataPtr data);
82  void stop();
83  void cancel();
84 
85 protected:
86  struct DataType
87  {
89  QString mImageFilename;
91  };
92  QString mSaveFolder;
93  QString mPrefix;
95  std::list<DataType> mPendingData;
96  QMutex mMutex;
97  bool mStop;
98  bool mCancel;
105  virtual void run();
106 
107  void writeQueue();
108  bool openTimestampsFile();
109  bool closeTimestampsFile();
110  void write(DataType data);
111  void writeTimeStampsFile(TimeInfo timeStamps);
112 };
113 
125 class cxResource_EXPORT SavingVideoRecorder : public QObject
126 {
127  Q_OBJECT
128 
129 public:
130  SavingVideoRecorder(VideoSourcePtr source, QString saveFolder, QString prefix, bool compressed, bool writeColor);
131  virtual ~SavingVideoRecorder();
132 
133  virtual void startRecord();
134  virtual void stopRecord();
135  void cancel();
136 
138  std::vector<TimeInfo> getTimestamps();
139  QString getSaveFolder() { return mSaveFolder; }
140 
143  void completeSave();
144 
145  VideoSourcePtr getSource() { return mSource; }
146 
147 private slots:
148  void newFrameSlot();
149 private:
153  void deleteFolder(QString folder);
155  std::vector<TimeInfo> mTimestamps;
156  QString mSaveFolder;
157  QString mPrefix;
158  VideoSourcePtr mSource;
159  boost::shared_ptr<VideoRecorderSaveThread> mSaveThread;
160 
161 };
162 
163 typedef boost::shared_ptr<SavingVideoRecorder> SavingVideoRecorderPtr;
164 
165 
166 } // namespace cx
167 
168 
169 #endif // CXSAVINGVIDEORECORDER_H
__global const unsigned char * getImageData(int plane_id, __global const unsigned char *bscans_blocks[], int2 in_size)
boost::shared_ptr< class SavingVideoRecorder > SavingVideoRecorderPtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
std::list< DataType > mPendingData
Recorder for a VideoSource.
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
boost::shared_ptr< class CachedImageDataContainer > CachedImageDataContainerPtr
QMutex mMutex
protects the mPendingData