Fraxinus  2023.01.05-dev+develop.0da12
An IGT application
cxVideoConnection.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 CXOPENIGTLINKRTSOURCE_H_
12 #define CXOPENIGTLINKRTSOURCE_H_
13 
14 #include "org_custusx_core_video_Export.h"
15 
16 #include <vector>
17 #include <map>
18 #include <boost/array.hpp>
19 #include "cxForwardDeclarations.h"
20 
21 typedef vtkSmartPointer<class vtkImageImport> vtkImageImportPtr;
22 typedef vtkSmartPointer<class vtkImageAlgorithm> vtkImageAlgorithmPtr;
23 typedef boost::shared_ptr<QThread> QThreadPtr;
24 
25 namespace cx
26 {
33 typedef boost::shared_ptr<class ProbeDefinition> ProbeDefinitionPtr;
34 typedef boost::shared_ptr<class StreamerService> StreamerServicePtr;
35 typedef boost::shared_ptr<class ImageReceiverThread> ImageReceiverThreadPtr;
36 typedef boost::shared_ptr<class BasicVideoSource> BasicVideoSourcePtr;
37 typedef boost::shared_ptr<class VideoServiceBackend> VideoServiceBackendPtr;
38 
54 class org_custusx_core_video_EXPORT VideoConnection : public QObject
55 {
56  Q_OBJECT
57 
58 public:
59  explicit VideoConnection(VideoServiceBackendPtr backend);
60  virtual ~VideoConnection();
61  virtual bool isConnected() const;
62  void disconnectServer();
63  void runDirectLinkClient(StreamerServicePtr service);
64  std::vector<VideoSourcePtr> getVideoSources();
65 
66 signals:
67  bool connected(bool);
68  void fps(QString source, int fps);
69  void videoSourcesChanged();
70 
71 private slots:
72  void onConnected();
73  void onDisconnected();
74  void imageReceivedSlot();
75  void statusReceivedSlot();
76  void fpsSlot(QString, double fps);
77  void connectVideoToProbe();
78  void useUnusedProbeDefinitionSlot();
79 
80 private:
81  void waitForClientFinished();
82  StreamerServicePtr getStreamerInterface();
83  void updateImage(ImagePtr message); // called by receiving thread when new data arrives.
84  void stopClient();
85  void resetProbe();
86  void updateStatus(ProbeDefinitionPtr message);
87  void startAllSources();
88  void stopAllSources();
89  void removeSourceFromProbe(ToolPtr tool);
90 
91  QPointer<ImageReceiverThread> mClient;
92  QPointer<QThread> mThread;
93 
94  double mFPS;
95  std::vector<ProbeDefinitionPtr> mUnusedProbeDefinitionVector;
96  std::vector<BasicVideoSourcePtr> mSources;
97  VideoServiceBackendPtr mBackend;
98  StreamerServicePtr mStreamerInterface;
99 };
100 typedef boost::shared_ptr<VideoConnection> VideoConnectionPtr;
101 
105 } // namespace cx
106 
107 #endif /* CXOPENIGTLINKRTSOURCE_H_ */
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
boost::shared_ptr< VideoConnection > VideoConnectionPtr
boost::shared_ptr< class VideoServiceBackend > VideoServiceBackendPtr
vtkSmartPointer< class vtkImageAlgorithm > vtkImageAlgorithmPtr
boost::shared_ptr< QThread > QThreadPtr
vtkSmartPointer< class vtkImageImport > vtkImageImportPtr
Represent one video grabber connection.
boost::shared_ptr< class StreamerService > StreamerServicePtr
boost::shared_ptr< class ImageReceiverThread > ImageReceiverThreadPtr
boost::shared_ptr< class BasicVideoSource > BasicVideoSourcePtr
boost::shared_ptr< class ProbeDefinition > ProbeDefinitionPtr
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr