14 #include <ctkPluginContext.h>
15 #include "boost/bind.hpp"
56 mActiveVideoSource = mEmptyVideoSource;
64 this->initServiceListener();
78 mVideoConnection.reset();
86 if (service->getType()==uid)
96 QList<StreamerServicePtr> retval;
97 QList<StreamerService *> services = mStreamerServiceListener->getServices();
114 void VideoImplService::autoSelectActiveVideoSource()
116 VideoSourcePtr suggestion = this->getGuessForActiveVideoSource(mActiveVideoSource);
122 mActiveVideoSource = mEmptyVideoSource;
125 for (
unsigned i=0; i<sources.size(); ++i)
126 if (sources[i]->getUid()==uid)
127 mActiveVideoSource = sources[i];
131 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
133 ProbePtr probe = iter->second->getProbe();
136 if (!probe->getAvailableVideoSources().count(uid)){
137 report(
"No active streams");
140 probe->setActiveStream(uid);
149 if(old && old->getUid().contains(
"playback"))
152 QStringList nameFilters;
153 nameFilters <<
"TissueAngio.fts" <<
"TissueFlow.fts" <<
"ScanConverted.fts";
157 if (uSAcquisitionVideoPlayback->isActive() && nameFilters.contains(uSAcquisitionVideoPlayback->getType()) )
158 return uSAcquisitionVideoPlayback->getVideoSource();
164 if (uSAcquisitionVideoPlayback->isActive())
165 return uSAcquisitionVideoPlayback->getVideoSource();
169 ToolPtr tool = mBackend->tracking()->getFirstProbe();
170 if (tool && tool->getProbe() && tool->getProbe()->getRTSource())
175 if (tool->getProbe()->getAvailableVideoSources().count(old->getUid()))
179 return tool->getProbe()->getRTSource();
186 if (std::count(allSources.begin(), allSources.end(), old))
190 if (!allSources.empty())
191 return allSources.front();
194 return mEmptyVideoSource;
199 return mActiveVideoSource;
205 QStringList res =
getAbsolutePathToFiles( mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/",QStringList(
"*.fts"),
true);
207 foreach (
const QString &acq, res)
209 types.insert(acq.split(
"_").back());
212 foreach(
const QString type, types.toList() ){
215 mUSAcquisitionVideoPlaybacks.push_back(tempUSAcquisitionVideoPlayback );
218 mUSAcquisitionVideoPlaybacks.back()->setTime(controller);
220 VideoSourcePtr playbackSource = mUSAcquisitionVideoPlaybacks.back()->getVideoSource();
222 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
224 ProbePtr probe = iter->second->getProbe();
227 if (mUSAcquisitionVideoPlaybacks.back()->isActive())
228 probe->setRTSource(playbackSource);
230 probe->removeRTSource(playbackSource);
232 mUSAcquisitionVideoPlaybacks.back()->setRoot(mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/");
234 this->autoSelectActiveVideoSource();
239 std::vector<VideoSourcePtr> retval = mVideoConnection->getVideoSources();
242 if (uSAcquisitionVideoPlayback->isActive())
243 retval.push_back(uSAcquisitionVideoPlayback->getVideoSource());
248 void VideoImplService::fpsSlot(QString source,
int val)
250 if (source==mActiveVideoSource->getUid())
256 if (mVideoConnection->isConnected())
263 reportError(QString(
"Found no streamer for method [%1]").arg(mConnectionMethod));
267 mVideoConnection->runDirectLinkClient(service);
272 mVideoConnection->disconnectServer();
277 return mVideoConnection->isConnected();
282 return mConnectionMethod;
287 if (mConnectionMethod == connectionMethod)
290 if(connectionMethod.isEmpty())
292 reportWarning(
"Trying to set connection method to empty string");
296 mConnectionMethod = connectionMethod;
302 std::vector<TimelineEvent> retval;
305 std::vector<TimelineEvent> events = uSAcquisitionVideoPlayback->getEvents();
306 retval.reserve(retval.size() + events.size());
307 retval.insert( retval.end(), events.begin(), events.end() );
313 void VideoImplService::initServiceListener()
317 boost::bind(&VideoImplService::onStreamerServiceAdded,
this, _1),
319 boost::bind(&VideoImplService::onStreamerServiceRemoved,
this, _1)
321 mStreamerServiceListener->open();
325 void VideoImplService::onStreamerServiceAdded(StreamerService* service)
327 if (mConnectionMethod.isEmpty())
328 mConnectionMethod = service->getType();
333 void VideoImplService::onStreamerServiceRemoved(StreamerService *service)