35 #include <ctkPluginContext.h>
36 #include "boost/bind.hpp"
71 mActiveVideoSource = mEmptyVideoSource;
80 this->initServiceListener();
85 mVideoConnection.reset();
90 return mStreamerServiceListener->getService(service);
95 return mStreamerServiceListener->getServices();
103 void VideoImplService::autoSelectActiveVideoSource()
105 VideoSourcePtr suggestion = this->getGuessForActiveVideoSource(mActiveVideoSource);
111 mActiveVideoSource = mEmptyVideoSource;
114 for (
unsigned i=0; i<sources.size(); ++i)
115 if (sources[i]->getUid()==uid)
116 mActiveVideoSource = sources[i];
120 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
122 ProbePtr probe = iter->second->getProbe();
125 if (!probe->getAvailableVideoSources().count(uid))
127 probe->setActiveStream(uid);
136 if (mUSAcquisitionVideoPlayback->isActive())
137 return mUSAcquisitionVideoPlayback->getVideoSource();
140 ToolPtr tool = mBackend->getToolManager()->getFirstProbe();
141 if (tool && tool->getProbe() && tool->getProbe()->getRTSource())
146 if (tool->getProbe()->getAvailableVideoSources().count(old->getUid()))
150 return tool->getProbe()->getRTSource();
158 if (std::count(allSources.begin(), allSources.end(), old))
161 if (!allSources.empty())
162 return allSources.front();
165 return mEmptyVideoSource;
170 return mActiveVideoSource;
175 mUSAcquisitionVideoPlayback->setTime(controller);
176 this->autoSelectActiveVideoSource();
178 VideoSourcePtr playbackSource = mUSAcquisitionVideoPlayback->getVideoSource();
180 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
182 ProbePtr probe = iter->second->getProbe();
185 if (mUSAcquisitionVideoPlayback->isActive())
186 probe->setRTSource(playbackSource);
188 probe->removeRTSource(playbackSource);
190 if (mUSAcquisitionVideoPlayback->isActive())
193 this->autoSelectActiveVideoSource();
195 mUSAcquisitionVideoPlayback->setRoot(mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/");
200 std::vector<VideoSourcePtr> retval = mVideoConnection->getVideoSources();
201 if (mUSAcquisitionVideoPlayback->isActive())
202 retval.push_back(mUSAcquisitionVideoPlayback->getVideoSource());
206 void VideoImplService::fpsSlot(QString source,
int val)
208 if (source==mActiveVideoSource->getUid())
214 if (mVideoConnection->isConnected())
220 reportError(QString(
"Found no streamer for method [%1]").arg(mConnectionMethod));
224 mVideoConnection->runDirectLinkClient(service);
229 mVideoConnection->disconnectServer();
234 return mVideoConnection->isConnected();
239 return mConnectionMethod;
244 if (mConnectionMethod == connectionMethod)
247 if(connectionMethod.isEmpty())
249 reportWarning(
"Trying to set connection method to empty string");
253 mConnectionMethod = connectionMethod;
259 return mUSAcquisitionVideoPlayback->getEvents();
262 void VideoImplService::initServiceListener()
266 boost::bind(&VideoImplService::onStreamerServiceAdded,
this, _1),
268 boost::bind(&VideoImplService::onStreamerServiceRemoved,
this, _1)
270 mStreamerServiceListener->open();
274 void VideoImplService::onStreamerServiceAdded(StreamerService* service)
276 if (mConnectionMethod.isEmpty())
277 mConnectionMethod = service->getName();
282 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