NorMIT-nav  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 
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);
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
cx::VideoRecorderSaveThread
Definition: cxSavingVideoRecorder.h:48
cx::VideoRecorderSaveThread::mStop
bool mStop
Definition: cxSavingVideoRecorder.h:76
cx::VideoRecorderSaveThread::mCompressed
bool mCompressed
Definition: cxSavingVideoRecorder.h:79
cx::VideoRecorderSaveThread::mSaveFolder
QString mSaveFolder
Definition: cxSavingVideoRecorder.h:71
cx::VideoRecorderSaveThread::DataType::mTimestamp
TimeInfo mTimestamp
Definition: cxSavingVideoRecorder.h:67
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::VideoRecorderSaveThread::mPendingData
std::list< DataType > mPendingData
Definition: cxSavingVideoRecorder.h:74
cxForwardDeclarations.h
cx::VideoRecorderSaveThread::mCancel
bool mCancel
Definition: cxSavingVideoRecorder.h:77
cx::SavingVideoRecorder::getSaveFolder
QString getSaveFolder()
Definition: cxSavingVideoRecorder.h:118
vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxVideoConnectionWidget.h:30
cx::VideoRecorderSaveThread::DataType::mImage
vtkImageDataPtr mImage
Definition: cxSavingVideoRecorder.h:69
cx::SavingVideoRecorder
Recorder for a VideoSource.
Definition: cxSavingVideoRecorder.h:104
cx::FileManagerServicePtr
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
Definition: cxLogicManager.h:31
cx::SavingVideoRecorder::getSource
VideoSourcePtr getSource()
Definition: cxSavingVideoRecorder.h:124
cx::VideoSourcePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
Definition: cxForwardDeclarations.h:109
cxData.h
getImageData
const __global unsigned char * getImageData(int plane_id, __global const unsigned char *bscans_blocks[], int2 in_size)
cx::TimeInfo
Definition: cxData.h:43
vtkForwardDeclarations.h
cx::SavingVideoRecorderPtr
boost::shared_ptr< class SavingVideoRecorder > SavingVideoRecorderPtr
Definition: cxUSAcquisition.h:27
cx::VideoRecorderSaveThread::mTimestampsFile
QFile mTimestampsFile
Definition: cxSavingVideoRecorder.h:78
cx::VideoRecorderSaveThread::DataType
Definition: cxSavingVideoRecorder.h:65
cx::CachedImageDataContainerPtr
boost::shared_ptr< class CachedImageDataContainer > CachedImageDataContainerPtr
Definition: cxSavingVideoRecorder.h:27
cx::VideoRecorderSaveThread::mImageIndex
int mImageIndex
Definition: cxSavingVideoRecorder.h:73
cx::VideoRecorderSaveThread::mWriteColor
bool mWriteColor
Definition: cxSavingVideoRecorder.h:80
cx::VideoRecorderSaveThread::DataType::mImageFilename
QString mImageFilename
Definition: cxSavingVideoRecorder.h:68
cx::VideoRecorderSaveThread::mPrefix
QString mPrefix
Definition: cxSavingVideoRecorder.h:72
cx::VideoRecorderSaveThread::mMutex
QMutex mMutex
protects the mPendingData
Definition: cxSavingVideoRecorder.h:75