CustusX  18.04-rc1
An IGT application
cxImageReceiverThread.h
Go to the documentation of this file.
1 
2 /*=========================================================================
3 This file is part of CustusX, an Image Guided Therapy Application.
4 
5 Copyright (c) SINTEF Department of Medical Technology.
6 All rights reserved.
7 
8 CustusX is released under a BSD 3-Clause license.
9 
10 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
11 =========================================================================*/
12 
13 
14 #ifndef CXImageReceiverThread_H_
15 #define CXImageReceiverThread_H_
16 
17 #include "org_custusx_core_video_Export.h"
18 
19 
20 #include <vector>
21 #include "boost/shared_ptr.hpp"
22 #include <QThread>
23 #include <QMutex>
24 #include <QDateTime>
25 #include "cxForwardDeclarations.h"
26 
27 namespace cx
28 {
29 typedef boost::shared_ptr<class Streamer> StreamerPtr;
30 typedef boost::shared_ptr<class StreamerService> StreamerServicePtr;
31 typedef boost::shared_ptr<class DirectlyLinkedSender> DirectlyLinkedSenderPtr;
32 typedef boost::shared_ptr<class ProbeDefinition> ProbeDefinitionPtr;
33 
41 typedef boost::shared_ptr<class ImageReceiverThread> ImageReceiverThreadPtr;
42 
54 class org_custusx_core_video_EXPORT ImageReceiverThread: public QObject
55 {
56 Q_OBJECT
57 public:
58  ImageReceiverThread(StreamerServicePtr streamerInterface, QObject* parent = NULL);
59  virtual ~ImageReceiverThread() {}
60  virtual ImagePtr getLastImageMessage(); // threadsafe, Threadsafe retrieval of last image message.
61  virtual ProbeDefinitionPtr getLastSonixStatusMessage(); // threadsafe,Threadsafe retrieval of last status message.
62  virtual QString hostDescription() const; // threadsafe
63 
64 public slots:
65  void initialize(); // not threadsafe, call via postevent
66  void shutdown(); // not threadsafe, call via postevent
67 
68 signals:
69  void imageReceived();
70  void sonixStatusReceived();
71  void fps(QString, double);
72  void finished(); // emitted when object has completed shutdown
73 
74 protected:
81  void addImageToQueue(ImagePtr imgMsg);
82  void addSonixStatusToQueue(ProbeDefinitionPtr msg);
83 
84 private slots:
85 
86  void addImageToQueueSlot();
87  void addSonixStatusToQueueSlot();
88 
89 private:
90  void reportFPS(QString streamUid);
91 // bool imageComesFromSonix(ImagePtr imgMsg);
92  bool attemptInitialize();
93 
94  std::map<QString, cx::CyclicActionLoggerPtr> mFPSTimer;
95  QMutex mImageMutex;
96  QMutex mSonixStatusMutex;
97  std::list<ImagePtr> mMutexedImageMessageQueue;
98  std::list<ProbeDefinitionPtr> mMutexedSonixStatusMessageQueue;
99 
100 // StreamedTimestampSynchronizer mStreamSynchronizer;
101 
102  StreamerServicePtr mStreamerInterface;
103  StreamerPtr mImageStreamer;
104  DirectlyLinkedSenderPtr mSender;
105 
106 };
107 
111 } //end namespace cx
112 
113 #endif /* CXImageReceiverThread_H_ */
boost::shared_ptr< class DirectlyLinkedSender > DirectlyLinkedSenderPtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
Base class for receiving images from a video stream.
boost::shared_ptr< class StreamerService > StreamerServicePtr
boost::shared_ptr< class ImageReceiverThread > ImageReceiverThreadPtr
boost::shared_ptr< class ProbeDefinition > ProbeDefinitionPtr
boost::shared_ptr< class Streamer > StreamerPtr
Namespace for all CustusX production code.