Fraxinus  16.5.0-fx-rc5
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //#include "cxStreamedTimestampSynchronizer.h"
48 
49 namespace cx
50 {
51 typedef boost::shared_ptr<class CyclicActionLogger> CyclicActionLoggerPtr;
52 typedef boost::shared_ptr<class Streamer> StreamerPtr;
53 typedef boost::shared_ptr<class StreamerService> StreamerServicePtr;
54 typedef boost::shared_ptr<class DirectlyLinkedSender> DirectlyLinkedSenderPtr;
55 typedef boost::shared_ptr<class ProbeDefinition> ProbeDefinitionPtr;
56 
64 typedef boost::shared_ptr<class ImageReceiverThread> ImageReceiverThreadPtr;
65 
77 class org_custusx_core_video_EXPORT ImageReceiverThread: public QObject
78 {
79 Q_OBJECT
80 public:
81  ImageReceiverThread(StreamerServicePtr streamerInterface, QObject* parent = NULL);
82  virtual ~ImageReceiverThread() {}
83  virtual ImagePtr getLastImageMessage(); // threadsafe, Threadsafe retrieval of last image message.
84  virtual ProbeDefinitionPtr getLastSonixStatusMessage(); // threadsafe,Threadsafe retrieval of last status message.
85  virtual QString hostDescription() const; // threadsafe
86 
87 public slots:
88  void initialize(); // not threadsafe, call via postevent
89  void shutdown(); // not threadsafe, call via postevent
90 
91 signals:
92  void imageReceived();
93  void sonixStatusReceived();
94  void fps(QString, double);
95  void finished(); // emitted when object has completed shutdown
96 
97 protected:
104  void addImageToQueue(ImagePtr imgMsg);
105  void addSonixStatusToQueue(ProbeDefinitionPtr msg);
106 
107 private slots:
108 
109  void addImageToQueueSlot();
110  void addSonixStatusToQueueSlot();
111 
112 private:
113  void reportFPS(QString streamUid);
114 // bool imageComesFromSonix(ImagePtr imgMsg);
115  bool attemptInitialize();
116 
117  std::map<QString, cx::CyclicActionLoggerPtr> mFPSTimer;
118  QMutex mImageMutex;
119  QMutex mSonixStatusMutex;
120  std::list<ImagePtr> mMutexedImageMessageQueue;
121  std::list<ProbeDefinitionPtr> mMutexedSonixStatusMessageQueue;
122 
123 // StreamedTimestampSynchronizer mStreamSynchronizer;
124 
125  StreamerServicePtr mStreamerInterface;
126  StreamerPtr mImageStreamer;
127  DirectlyLinkedSenderPtr mSender;
128 
129 };
130 
134 } //end namespace cx
135 
136 #endif /* CXImageReceiverThread_H_ */
boost::shared_ptr< class DirectlyLinkedSender > DirectlyLinkedSenderPtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
boost::shared_ptr< class CyclicActionLogger > CyclicActionLoggerPtr
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