Fraxinus  22.09
An IGT application
cxImageStreamerSonix.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 
12 #ifndef CXIMAGESTREAMERSONIX_H_
13 #define CXIMAGESTREAMERSONIX_H_
14 
15 #ifdef CX_WIN32
16 
17 #include "cxGrabberExport.h"
18 
19 #include "boost/shared_ptr.hpp"
20 #include <QTcpSocket>
21 #include <QStringList>
22 #include <QMetaType>
23 #include <QMutex>
24 #include <vtkSmartPointer.h>
25 #include "cxImageSenderFactory.h"
26 
27 #include "cxIGTLinkImageMessage.h"
29 #include "vtkSonixVideoSource.h"
30 #include "SonixHelper.h"
31 #include "cxStreamer.h"
32 
33 class QTimer;
34 typedef vtkSmartPointer<class vtkSonixVideoSource> vtkSonixVideoSourcePtr;
35 
36 namespace cx
37 {
38 
50 class cxGrabber_EXPORT ImageStreamerSonix : public CommandLineStreamer
51 {
52  Q_OBJECT
53 
54 public:
55  ImageStreamerSonix();
56  ~ImageStreamerSonix();
57 
58  virtual void initialize(StringMap arguments);
59  virtual bool startStreaming(SenderPtr sender);
60  virtual void stopStreaming();
61 
62  virtual QString getType();
63  virtual QStringList getArgumentDescription();
64 
65 public slots:
66  void sendOpenIGTLinkImageSlot(int sendNumberOfMessages);
67  void sendOpenIGTLinkStatusSlot(int sendNumberOfMessages);
68 
69 signals:
70  void imageOnQueue(int);
71  void queueInfo(int size, int dropped);
72  void statusOnQueue(int);
73 
74 protected:
75  void initializeSonixGrabber();
76 
77 private slots:
78  void receiveFrameSlot(Frame& frame);
79  void initializeSonixSlot();
80 
81 private:
82  IGTLinkImageMessage::Pointer convertFrame(Frame& frame);
83  IGTLinkUSStatusMessage::Pointer getFrameStatus(Frame& frame);
84 
85  void addImageToQueue(IGTLinkImageMessage::Pointer msg);
86  IGTLinkImageMessage::Pointer getLastImageMessageFromQueue();
87 
88  void addStatusMessageToQueue(IGTLinkUSStatusMessage::Pointer msg);
89  IGTLinkUSStatusMessage::Pointer getLastStatusMessageFromQueue();
90 
91  std::string createDeviceName();
92 
93  QMutex mImageMutex;
94  int mMaxqueueInfo;
95  std::list<IGTLinkImageMessage::Pointer> mMutexedImageMessageQueue;
96  int mDroppedImages;
97 
98  QMutex mStatusMutex;
99  std::list<IGTLinkUSStatusMessage::Pointer> mMutexedStatusMessageQueue;
100 
101  bool mEmitStatusMessage;
102  double mLastFrameTimestamp;
103  double mCurrentFrameTimestamp;
104 
105  vtkSonixVideoSourcePtr mSonixGrabber;
106  SonixHelper* mSonixHelper;
107 
108 };
109 
110 }//namespace cx
111 
112 //Declaration of a frame metatype needed to be able to send frame as a signal.
113 //typedef cx::Frame Frame;
114 //Q_DECLARE_METATYPE(Frame)
115 
116 #endif // CX_WIN32
117 
118 #endif /* CXIMAGESTREAMERSONIX_H_ */
Support Qt support for vtkSonixVideoSource.
Definition: SonixHelper.h:36
std::map< QString, QString > StringMap
boost::shared_ptr< Sender > SenderPtr
Definition: cxSender.h:64
Namespace for all CustusX production code.