Fraxinus  17.12-rc2
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) 2008-2014, SINTEF Department of Medical Technology
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 
11 1. Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13 
14 2. Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17 
18 3. Neither the name of the copyright holder nor the names of its contributors
19  may be used to endorse or promote products derived from this software
20  without specific prior written permission.
21 
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 =========================================================================*/
33 
34 
35 #ifndef CXImageReceiverThread_H_
36 #define CXImageReceiverThread_H_
37 
38 #include "org_custusx_core_video_Export.h"
39 
40 
41 #include <vector>
42 #include "boost/shared_ptr.hpp"
43 #include <QThread>
44 #include <QMutex>
45 #include <QDateTime>
46 #include "cxForwardDeclarations.h"
47 
48 namespace cx
49 {
50 typedef boost::shared_ptr<class Streamer> StreamerPtr;
51 typedef boost::shared_ptr<class StreamerService> StreamerServicePtr;
52 typedef boost::shared_ptr<class DirectlyLinkedSender> DirectlyLinkedSenderPtr;
53 typedef boost::shared_ptr<class ProbeDefinition> ProbeDefinitionPtr;
54 
62 typedef boost::shared_ptr<class ImageReceiverThread> ImageReceiverThreadPtr;
63 
75 class org_custusx_core_video_EXPORT ImageReceiverThread: public QObject
76 {
77 Q_OBJECT
78 public:
79  ImageReceiverThread(StreamerServicePtr streamerInterface, QObject* parent = NULL);
80  virtual ~ImageReceiverThread() {}
81  virtual ImagePtr getLastImageMessage(); // threadsafe, Threadsafe retrieval of last image message.
82  virtual ProbeDefinitionPtr getLastSonixStatusMessage(); // threadsafe,Threadsafe retrieval of last status message.
83  virtual QString hostDescription() const; // threadsafe
84 
85 public slots:
86  void initialize(); // not threadsafe, call via postevent
87  void shutdown(); // not threadsafe, call via postevent
88 
89 signals:
90  void imageReceived();
91  void sonixStatusReceived();
92  void fps(QString, double);
93  void finished(); // emitted when object has completed shutdown
94 
95 protected:
102  void addImageToQueue(ImagePtr imgMsg);
103  void addSonixStatusToQueue(ProbeDefinitionPtr msg);
104 
105 private slots:
106 
107  void addImageToQueueSlot();
108  void addSonixStatusToQueueSlot();
109 
110 private:
111  void reportFPS(QString streamUid);
112 // bool imageComesFromSonix(ImagePtr imgMsg);
113  bool attemptInitialize();
114 
115  std::map<QString, cx::CyclicActionLoggerPtr> mFPSTimer;
116  QMutex mImageMutex;
117  QMutex mSonixStatusMutex;
118  std::list<ImagePtr> mMutexedImageMessageQueue;
119  std::list<ProbeDefinitionPtr> mMutexedSonixStatusMessageQueue;
120 
121 // StreamedTimestampSynchronizer mStreamSynchronizer;
122 
123  StreamerServicePtr mStreamerInterface;
124  StreamerPtr mImageStreamer;
125  DirectlyLinkedSenderPtr mSender;
126 
127 };
128 
132 } //end namespace cx
133 
134 #endif /* CXImageReceiverThread_H_ */
boost::shared_ptr< class DirectlyLinkedSender > DirectlyLinkedSenderPtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
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.