Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #ifndef CXSAVINGVIDEORECORDER_H
12 #define CXSAVINGVIDEORECORDER_H
13 
14 #include "cxResourceExport.h"
15 
16 #include <vector>
17 #include <QFile>
18 #include <QThread>
19 #include <QMutex>
20 
21 #include "vtkForwardDeclarations.h"
22 #include "cxForwardDeclarations.h"
23 #include "cxData.h"
24 
25 namespace cx
26 {
27 typedef boost::shared_ptr<class CachedImageDataContainer> CachedImageDataContainerPtr;
28 
48 class cxResource_EXPORT VideoRecorderSaveThread : public QThread
49 {
50  Q_OBJECT
51 public:
55  VideoRecorderSaveThread(QObject* parent, QString saveFolder, QString prefix, bool compressed, bool writeColor);
56  virtual ~VideoRecorderSaveThread();
60  QString addData(TimeInfo timestamp, vtkImageDataPtr data);
61  void stop();
62  void cancel();
63 
64 protected:
65  struct DataType
66  {
68  QString mImageFilename;
70  };
71  QString mSaveFolder;
72  QString mPrefix;
74  std::list<DataType> mPendingData;
75  QMutex mMutex;
76  bool mStop;
77  bool mCancel;
84  virtual void run();
85 
86  void writeQueue();
87  bool openTimestampsFile();
88  bool closeTimestampsFile();
89  void write(DataType data);
90  void writeTimeStampsFile(TimeInfo timeStamps);
91 };
92 
104 class cxResource_EXPORT SavingVideoRecorder : public QObject
105 {
106  Q_OBJECT
107 
108 public:
109  SavingVideoRecorder(VideoSourcePtr source, QString saveFolder, QString prefix, bool compressed, bool writeColor, FileManagerServicePtr filemanagerservice);
110  virtual ~SavingVideoRecorder();
111 
112  virtual void startRecord();
113  virtual void stopRecord();
114  void cancel();
115 
116  CachedImageDataContainerPtr getImageData();
117  std::vector<TimeInfo> getTimestamps();
118  QString getSaveFolder() { return mSaveFolder; }
119 
122  void completeSave();
123 
124  VideoSourcePtr getSource() { return mSource; }
125 
126 private slots:
127  void newFrameSlot();
128 private:
132  void deleteFolder(QString folder);
133  CachedImageDataContainerPtr mImages;
134  std::vector<TimeInfo> mTimestamps;
135  QString mSaveFolder;
136  QString mPrefix;
137  VideoSourcePtr mSource;
138  boost::shared_ptr<VideoRecorderSaveThread> mSaveThread;
139 
140 };
141 
142 typedef boost::shared_ptr<SavingVideoRecorder> SavingVideoRecorderPtr;
143 
144 
145 } // namespace cx
146 
147 
148 #endif // CXSAVINGVIDEORECORDER_H
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
__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
Namespace for all CustusX production code.