Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxIGTLinkClientStreamer.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 CXIGTLINKCLIENTSTREAMER_H
12 #define CXIGTLINKCLIENTSTREAMER_H
13 
14 #include "cxStreamer.h"
15 #include "org_custusx_core_video_Export.h"
16 #include <QAbstractSocket>
17 #include "cxIGTLinkImageMessage.h"
20 
21 class QTcpSocket;
22 
23 namespace cx
24 {
25 
34 class org_custusx_core_video_EXPORT IGTLinkClientStreamer: public Streamer
35 {
36 Q_OBJECT
37 
38 public:
40  virtual ~IGTLinkClientStreamer();
41 
42  void setAddress(QString address, int port);
43 
44  virtual void startStreaming(SenderPtr sender);
45  virtual void stopStreaming();
46  virtual bool isStreaming();
47 
48 
49 private slots:
50  virtual void streamSlot() {}
51 private slots:
52  void readyReadSlot();
53 
54  void hostFoundSlot();
55  void connectedSlot();
56  void disconnectedSlot();
57  void errorSlot(QAbstractSocket::SocketError);
58 
59 private:
60  SenderPtr mSender;
61 
62  virtual QString hostDescription() const; // threadsafe
63  bool ReceiveImage(QTcpSocket* socket, igtl::MessageHeader::Pointer& header);
64  bool ReceiveSonixStatus(QTcpSocket* socket, igtl::MessageHeader::Pointer& header);
65  bool readOneMessage();
66  void addToQueue(IGTLinkUSStatusMessage::Pointer msg);
67  void addToQueue(igtl::ImageMessage::Pointer msg);
68  bool multipleTryConnectToHost();
69  bool tryConnectToHost();
70 
71  bool mHeadingReceived;
72  QString mAddress;
73  int mPort;
74  StreamedTimestampSynchronizer mStreamSynchronizer;
75  boost::shared_ptr<QTcpSocket> mSocket;
76  igtl::MessageHeader::Pointer mHeaderMsg;
77  IGTLinkUSStatusMessage::Pointer mUnsentUSStatusMessage;
78 
79 
80 };
81 typedef boost::shared_ptr<class IGTLinkClientStreamer> IGTLinkClientStreamerPtr;
82 
83 } // namespace cx
84 
85 #endif // CXIGTLINKCLIENTSTREAMER_H
boost::shared_ptr< class IGTLinkClientStreamer > IGTLinkClientStreamerPtr
boost::shared_ptr< Sender > SenderPtr
Definition: cxSender.h:64
Namespace for all CustusX production code.