Fraxinus  18.10
An IGT application
cxVideoServiceProxy.cpp
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 #include "cxVideoServiceProxy.h"
13 
14 #include <boost/bind.hpp>
15 #include <ctkPluginContext.h>
16 #include "cxNullDeleter.h"
17 
18 #include "cxStreamerService.h"
19 //#include "cxTypeConversions.h"
20 
21 namespace cx
22 {
23 
24 VideoServicePtr VideoServiceProxy::create(ctkPluginContext *pluginContext)
25 {
26  return VideoServicePtr(new VideoServiceProxy(pluginContext));
27 }
28 
29 VideoServiceProxy::VideoServiceProxy(ctkPluginContext *pluginContext) :
30  mPluginContext(pluginContext),
31  mVideoService(VideoService::getNullObject())
32 {
33  this->initServiceListener();
34 }
35 
36 void VideoServiceProxy::initServiceListener()
37 {
38  mVideoServiceListener.reset(new ServiceTrackerListener<VideoService>(
39  mPluginContext,
40  boost::bind(&VideoServiceProxy::onVideoServiceAdded, this, _1),
41  boost::function<void (VideoService*)>(),
42  boost::bind(&VideoServiceProxy::onVideoServiceRemoved, this, _1)
43  ));
44  mVideoServiceListener->open();
45 }
46 
47 void VideoServiceProxy::onVideoServiceAdded(VideoService* service)
48 {
49  mVideoService.reset(service, null_deleter());
50 
51  connect(service, &VideoService::connected, this, &VideoService::connected);
54  connect(service, &VideoService::fps, this, &VideoService::fps);
55 
57 }
58 
59 void VideoServiceProxy::onVideoServiceRemoved(VideoService *service)
60 {
61  disconnect(service, &VideoService::connected, this, &VideoService::connected);
64  disconnect(service, &VideoService::fps, this, &VideoService::fps);
65 
66  mVideoService = VideoService::getNullObject();
67 
68  emit connected(false);
70 }
71 
73 {
74  return mVideoService->isNull();
75 }
76 
78 {
79  return mVideoService->getStreamerService(uid);
80 }
81 
82 QList<StreamerServicePtr> VideoServiceProxy::getStreamerServices()
83 {
84  return mVideoService->getStreamerServices();
85 }
86 
88 {
89  mVideoService->setActiveVideoSource(uid);
90 }
91 
93 {
94  return mVideoService->getActiveVideoSource();
95 }
96 
97 std::vector<VideoSourcePtr> VideoServiceProxy::getVideoSources()
98 {
99  return mVideoService->getVideoSources();
100 }
101 
102 void VideoServiceProxy::setConnectionMethod(QString connectionMethod)
103 {
104  mVideoService->setConnectionMethod(connectionMethod);
105 }
106 
108 {
109  return mVideoService->getConnectionMethod();
110 }
111 
113 {
114  mVideoService->openConnection();
115 }
116 
118 {
119  mVideoService->closeConnection();
120 }
121 
123 {
124  return mVideoService->isConnected();
125 }
126 
128 {
129  mVideoService->setPlaybackMode(controller);
130 }
131 
132 std::vector<TimelineEvent> VideoServiceProxy::getPlaybackEvents()
133 {
134  return mVideoService->getPlaybackEvents();
135 }
136 
137 
138 
139 } //cx
boost::shared_ptr< class VideoService > VideoServicePtr
virtual VideoSourcePtr getActiveVideoSource()
void connected(bool on)
virtual QString getConnectionMethod()
virtual void setPlaybackMode(PlaybackTimePtr controller)
virtual std::vector< TimelineEvent > getPlaybackEvents()
static VideoServicePtr create(ctkPluginContext *pluginContext)
virtual std::vector< VideoSourcePtr > getVideoSources()
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
virtual StreamerServicePtr getStreamerService(QString uid)
void connectionMethodChanged()
boost::shared_ptr< class VideoSource > VideoSourcePtr
virtual QList< StreamerServicePtr > getStreamerServices()
static VideoServicePtr getNullObject()
Helper class for listening to services being added, modified and removed.
Provides access to all video sources in the system, and connection stuff for the sources.
virtual void setConnectionMethod(QString connectionMethod)
virtual void setActiveVideoSource(QString uid)
boost::shared_ptr< class StreamerService > StreamerServicePtr
virtual bool isConnected() const
void activeVideoSourceChanged()
VideoServiceProxy(ctkPluginContext *pluginContext)
Namespace for all CustusX production code.