35 #include <ctkPluginContext.h>
36 #include "boost/bind.hpp"
71 mActiveVideoSource = mEmptyVideoSource;
80 this->initServiceListener();
94 mVideoConnection.reset();
99 return mStreamerServiceListener->getService(service);
104 return mStreamerServiceListener->getServices();
112 void VideoImplService::autoSelectActiveVideoSource()
114 VideoSourcePtr suggestion = this->getGuessForActiveVideoSource(mActiveVideoSource);
120 mActiveVideoSource = mEmptyVideoSource;
123 for (
unsigned i=0; i<sources.size(); ++i)
124 if (sources[i]->getUid()==uid)
125 mActiveVideoSource = sources[i];
129 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
131 ProbePtr probe = iter->second->getProbe();
134 if (!probe->getAvailableVideoSources().count(uid))
136 probe->setActiveStream(uid);
145 if (mUSAcquisitionVideoPlayback->isActive())
146 return mUSAcquisitionVideoPlayback->getVideoSource();
149 ToolPtr tool = mBackend->getToolManager()->getFirstProbe();
150 if (tool && tool->getProbe() && tool->getProbe()->getRTSource())
155 if (tool->getProbe()->getAvailableVideoSources().count(old->getUid()))
159 return tool->getProbe()->getRTSource();
167 if (std::count(allSources.begin(), allSources.end(), old))
170 if (!allSources.empty())
171 return allSources.front();
174 return mEmptyVideoSource;
179 return mActiveVideoSource;
184 mUSAcquisitionVideoPlayback->setTime(controller);
185 this->autoSelectActiveVideoSource();
187 VideoSourcePtr playbackSource = mUSAcquisitionVideoPlayback->getVideoSource();
189 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
191 ProbePtr probe = iter->second->getProbe();
194 if (mUSAcquisitionVideoPlayback->isActive())
195 probe->setRTSource(playbackSource);
197 probe->removeRTSource(playbackSource);
199 if (mUSAcquisitionVideoPlayback->isActive())
202 this->autoSelectActiveVideoSource();
204 mUSAcquisitionVideoPlayback->setRoot(mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/");
209 std::vector<VideoSourcePtr> retval = mVideoConnection->getVideoSources();
210 if (mUSAcquisitionVideoPlayback->isActive())
211 retval.push_back(mUSAcquisitionVideoPlayback->getVideoSource());
215 void VideoImplService::fpsSlot(QString source,
int val)
217 if (source==mActiveVideoSource->getUid())
223 if (mVideoConnection->isConnected())
229 reportError(QString(
"Found no streamer for method [%1]").arg(mConnectionMethod));
233 mVideoConnection->runDirectLinkClient(service);
238 mVideoConnection->disconnectServer();
243 return mVideoConnection->isConnected();
248 return mConnectionMethod;
253 if (mConnectionMethod == connectionMethod)
256 if(connectionMethod.isEmpty())
258 reportWarning(
"Trying to set connection method to empty string");
262 mConnectionMethod = connectionMethod;
268 return mUSAcquisitionVideoPlayback->getEvents();
271 void VideoImplService::initServiceListener()
275 boost::bind(&VideoImplService::onStreamerServiceAdded,
this, _1),
277 boost::bind(&VideoImplService::onStreamerServiceRemoved,
this, _1)
279 mStreamerServiceListener->open();
283 void VideoImplService::onStreamerServiceAdded(StreamerService* service)
285 if (mConnectionMethod.isEmpty())
286 mConnectionMethod = service->getName();
291 void VideoImplService::onStreamerServiceRemoved(StreamerService *service)
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
virtual QString getConnectionMethod()
void reportError(QString msg)
virtual void setPlaybackMode(PlaybackTimePtr controller)
virtual VideoSourcePtr getActiveVideoSource()
void StreamerServiceRemoved(StreamerService *service)
boost::shared_ptr< class TrackingService > TrackingServicePtr
virtual ~VideoImplService()
VideoImplService(ctkPluginContext *context)
virtual std::vector< TimelineEvent > getPlaybackEvents()
void videoSourcesChanged()
void StreamerServiceAdded(StreamerService *service)
virtual bool isConnected() const
Handler for playback of US image data from a US recording session.
boost::shared_ptr< class VideoServiceBackend > VideoServiceBackendPtr
static TrackingServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< Probe > ProbePtr
static PatientModelServicePtr create(ctkPluginContext *pluginContext)
void activeToolChanged(const QString &uId)
void reportWarning(QString msg)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class VideoSource > VideoSourcePtr
virtual void setConnectionMethod(QString connectionMethod)
virtual std::vector< VideoSourcePtr > getVideoSources()
VideoSource controlled by a vtkImageData.
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
Helper class for listening to services being added, modified and removed.
std::map< QString, ToolPtr > ToolMap
static VideoServiceBackendPtr create(PatientModelServicePtr dataManager, TrackingServicePtr trackingService, SpaceProviderPtr spaceProvider, ctkPluginContext *context)
Represent one video grabber connection.
virtual StreamerService * getStreamerService(QString service)
Abstract class. Interface to Streamers.
virtual void setActiveVideoSource(QString uid)
virtual void closeConnection()
virtual void openConnection()
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
void activeVideoSourceChanged()
virtual QList< StreamerService * > getStreamerServices()
void fps(QString source, int fps)
boost::shared_ptr< class Tool > ToolPtr