35 #include <ctkPluginContext.h>
36 #include "boost/bind.hpp"
74 mActiveVideoSource = mEmptyVideoSource;
83 this->initServiceListener();
97 mVideoConnection.reset();
105 if (service->getType()==uid)
115 QList<StreamerServicePtr> retval;
116 QList<StreamerService *> services = mStreamerServiceListener->getServices();
133 void VideoImplService::autoSelectActiveVideoSource()
135 VideoSourcePtr suggestion = this->getGuessForActiveVideoSource(mActiveVideoSource);
141 mActiveVideoSource = mEmptyVideoSource;
144 for (
unsigned i=0; i<sources.size(); ++i)
145 if (sources[i]->getUid()==uid)
146 mActiveVideoSource = sources[i];
150 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
152 ProbePtr probe = iter->second->getProbe();
155 if (!probe->getAvailableVideoSources().count(uid))
157 probe->setActiveStream(uid);
166 if (mUSAcquisitionVideoPlayback->isActive())
167 return mUSAcquisitionVideoPlayback->getVideoSource();
170 ToolPtr tool = mBackend->getToolManager()->getFirstProbe();
171 if (tool && tool->getProbe() && tool->getProbe()->getRTSource())
176 if (tool->getProbe()->getAvailableVideoSources().count(old->getUid()))
180 return tool->getProbe()->getRTSource();
188 if (std::count(allSources.begin(), allSources.end(), old))
191 if (!allSources.empty())
192 return allSources.front();
195 return mEmptyVideoSource;
200 return mActiveVideoSource;
205 mUSAcquisitionVideoPlayback->setTime(controller);
206 this->autoSelectActiveVideoSource();
208 VideoSourcePtr playbackSource = mUSAcquisitionVideoPlayback->getVideoSource();
210 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
212 ProbePtr probe = iter->second->getProbe();
215 if (mUSAcquisitionVideoPlayback->isActive())
216 probe->setRTSource(playbackSource);
218 probe->removeRTSource(playbackSource);
220 if (mUSAcquisitionVideoPlayback->isActive())
223 this->autoSelectActiveVideoSource();
225 mUSAcquisitionVideoPlayback->setRoot(mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/");
230 std::vector<VideoSourcePtr> retval = mVideoConnection->getVideoSources();
231 if (mUSAcquisitionVideoPlayback->isActive())
232 retval.push_back(mUSAcquisitionVideoPlayback->getVideoSource());
236 void VideoImplService::fpsSlot(QString source,
int val)
238 if (source==mActiveVideoSource->getUid())
244 if (mVideoConnection->isConnected())
251 reportError(QString(
"Found no streamer for method [%1]").arg(mConnectionMethod));
255 mVideoConnection->runDirectLinkClient(service);
260 mVideoConnection->disconnectServer();
265 return mVideoConnection->isConnected();
270 return mConnectionMethod;
275 if (mConnectionMethod == connectionMethod)
278 if(connectionMethod.isEmpty())
280 reportWarning(
"Trying to set connection method to empty string");
284 mConnectionMethod = connectionMethod;
290 return mUSAcquisitionVideoPlayback->getEvents();
293 void VideoImplService::initServiceListener()
297 boost::bind(&VideoImplService::onStreamerServiceAdded,
this, _1),
299 boost::bind(&VideoImplService::onStreamerServiceRemoved,
this, _1)
301 mStreamerServiceListener->open();
305 void VideoImplService::onStreamerServiceAdded(StreamerService* service)
307 if (mConnectionMethod.isEmpty())
308 mConnectionMethod = service->getType();
313 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
Proxy for StreamerServices.
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 QString getName()=0
virtual StreamerServicePtr getStreamerService(QString uid)
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.
boost::shared_ptr< class StreamerService > StreamerServicePtr
Abstract class. Interface to Streamers.
virtual void setActiveVideoSource(QString uid)
virtual void closeConnection()
virtual void openConnection()
virtual QList< StreamerServicePtr > getStreamerServices()
boost::shared_ptr< class PlaybackTime > PlaybackTimePtr
void activeVideoSourceChanged()
void fps(QString source, int fps)
Null implementation of the StreamerService.
boost::shared_ptr< class Tool > ToolPtr