35 #include <ctkPluginContext.h>
36 #include "boost/bind.hpp"
75 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)){
156 report(
"No active streams");
159 probe->setActiveStream(uid);
168 if(old && old->getUid().contains(
"playback"))
171 QStringList nameFilters;
172 nameFilters <<
"TissueAngio.fts" <<
"TissueFlow.fts" <<
"ScanConverted.fts";
176 if (uSAcquisitionVideoPlayback->isActive() && nameFilters.contains(uSAcquisitionVideoPlayback->getType()) )
177 return uSAcquisitionVideoPlayback->getVideoSource();
183 if (uSAcquisitionVideoPlayback->isActive())
184 return uSAcquisitionVideoPlayback->getVideoSource();
188 ToolPtr tool = mBackend->tracking()->getFirstProbe();
189 if (tool && tool->getProbe() && tool->getProbe()->getRTSource())
194 if (tool->getProbe()->getAvailableVideoSources().count(old->getUid()))
198 return tool->getProbe()->getRTSource();
205 if (std::count(allSources.begin(), allSources.end(), old))
209 if (!allSources.empty())
210 return allSources.front();
213 return mEmptyVideoSource;
218 return mActiveVideoSource;
224 QStringList res =
getAbsolutePathToFiles( mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/",QStringList(
"*.fts"),
true);
226 foreach (
const QString &acq, res)
228 types.insert(acq.split(
"_").back());
231 foreach(
const QString type, types.toList() ){
234 mUSAcquisitionVideoPlaybacks.push_back(tempUSAcquisitionVideoPlayback );
237 mUSAcquisitionVideoPlaybacks.back()->setTime(controller);
239 VideoSourcePtr playbackSource = mUSAcquisitionVideoPlaybacks.back()->getVideoSource();
241 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
243 ProbePtr probe = iter->second->getProbe();
246 if (mUSAcquisitionVideoPlaybacks.back()->isActive())
247 probe->setRTSource(playbackSource);
249 probe->removeRTSource(playbackSource);
251 mUSAcquisitionVideoPlaybacks.back()->setRoot(mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/");
253 this->autoSelectActiveVideoSource();
258 std::vector<VideoSourcePtr> retval = mVideoConnection->getVideoSources();
261 if (uSAcquisitionVideoPlayback->isActive())
262 retval.push_back(uSAcquisitionVideoPlayback->getVideoSource());
267 void VideoImplService::fpsSlot(QString source,
int val)
269 if (source==mActiveVideoSource->getUid())
275 if (mVideoConnection->isConnected())
282 reportError(QString(
"Found no streamer for method [%1]").arg(mConnectionMethod));
286 mVideoConnection->runDirectLinkClient(service);
291 mVideoConnection->disconnectServer();
296 return mVideoConnection->isConnected();
301 return mConnectionMethod;
306 if (mConnectionMethod == connectionMethod)
309 if(connectionMethod.isEmpty())
311 reportWarning(
"Trying to set connection method to empty string");
315 mConnectionMethod = connectionMethod;
321 std::vector<TimelineEvent> retval;
324 std::vector<TimelineEvent> events = uSAcquisitionVideoPlayback->getEvents();
325 retval.reserve(retval.size() + events.size());
326 retval.insert( retval.end(), events.begin(), events.end() );
332 void VideoImplService::initServiceListener()
336 boost::bind(&VideoImplService::onStreamerServiceAdded,
this, _1),
338 boost::bind(&VideoImplService::onStreamerServiceRemoved,
this, _1)
340 mStreamerServiceListener->open();
344 void VideoImplService::onStreamerServiceAdded(StreamerService* service)
346 if (mConnectionMethod.isEmpty())
347 mConnectionMethod = service->getType();
352 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< class PlaybackTime > PlaybackTimePtr
boost::shared_ptr< Probe > ProbePtr
static PatientModelServicePtr create(ctkPluginContext *pluginContext)
void activeToolChanged(const QString &uId)
void reportWarning(QString msg)
boost::shared_ptr< USAcquisitionVideoPlayback > USAcquisitionVideoPlaybackPtr
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
QStringList getAbsolutePathToFiles(QString path, QStringList nameFilters, bool includeSubDirs)
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()
void activeVideoSourceChanged()
void fps(QString source, int fps)
Null implementation of the StreamerService.
boost::shared_ptr< class Tool > ToolPtr