14 #include <ctkPluginContext.h> 15 #include "boost/bind.hpp" 54 mActiveVideoSource = mEmptyVideoSource;
62 this->initServiceListener();
76 mVideoConnection.reset();
84 if (service->getType()==uid)
94 QList<StreamerServicePtr> retval;
95 QList<StreamerService *> services = 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)){
135 report(
"No active streams");
138 probe->setActiveStream(uid);
147 if(old && old->getUid().contains(
"playback"))
150 QStringList nameFilters;
151 nameFilters <<
"TissueAngio.fts" <<
"TissueFlow.fts" <<
"ScanConverted.fts";
155 if (uSAcquisitionVideoPlayback->isActive() && nameFilters.contains(uSAcquisitionVideoPlayback->getType()) )
156 return uSAcquisitionVideoPlayback->getVideoSource();
162 if (uSAcquisitionVideoPlayback->isActive())
163 return uSAcquisitionVideoPlayback->getVideoSource();
167 ToolPtr tool = mBackend->tracking()->getFirstProbe();
168 if (tool && tool->getProbe() && tool->getProbe()->getRTSource())
173 if (tool->getProbe()->getAvailableVideoSources().count(old->getUid()))
177 return tool->getProbe()->getRTSource();
184 if (std::count(allSources.begin(), allSources.end(), old))
188 if (!allSources.empty())
189 return allSources.front();
192 return mEmptyVideoSource;
197 return mActiveVideoSource;
203 QStringList res =
getAbsolutePathToFiles( mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/",QStringList(
"*.fts"),
true);
205 foreach (
const QString &acq, res)
207 types.insert(acq.split(
"_").back());
210 foreach(
const QString type, types.toList() ){
213 mUSAcquisitionVideoPlaybacks.push_back(tempUSAcquisitionVideoPlayback );
216 mUSAcquisitionVideoPlaybacks.back()->setTime(controller);
218 VideoSourcePtr playbackSource = mUSAcquisitionVideoPlaybacks.back()->getVideoSource();
220 for (TrackingService::ToolMap::iterator iter=tools.begin(); iter!=tools.end(); ++iter)
222 ProbePtr probe = iter->second->getProbe();
225 if (mUSAcquisitionVideoPlaybacks.back()->isActive())
226 probe->setRTSource(playbackSource);
228 probe->removeRTSource(playbackSource);
230 mUSAcquisitionVideoPlaybacks.back()->setRoot(mBackend->getDataManager()->getActivePatientFolder() +
"/US_Acq/");
232 this->autoSelectActiveVideoSource();
237 std::vector<VideoSourcePtr> retval = mVideoConnection->getVideoSources();
240 if (uSAcquisitionVideoPlayback->isActive())
241 retval.push_back(uSAcquisitionVideoPlayback->getVideoSource());
246 void VideoImplService::fpsSlot(QString source,
int val)
248 if (source==mActiveVideoSource->getUid())
254 if (mVideoConnection->isConnected())
261 reportError(QString(
"Found no streamer for method [%1]").arg(mConnectionMethod));
265 mVideoConnection->runDirectLinkClient(service);
270 mVideoConnection->disconnectServer();
275 return mVideoConnection->isConnected();
280 return mConnectionMethod;
285 if (mConnectionMethod == connectionMethod)
288 if(connectionMethod.isEmpty())
290 reportWarning(
"Trying to set connection method to empty string");
294 mConnectionMethod = connectionMethod;
300 std::vector<TimelineEvent> retval;
303 std::vector<TimelineEvent> events = uSAcquisitionVideoPlayback->getEvents();
304 retval.reserve(retval.size() + events.size());
305 retval.insert( retval.end(), events.begin(), events.end() );
311 void VideoImplService::initServiceListener()
315 boost::bind(&VideoImplService::onStreamerServiceAdded,
this, _1),
317 boost::bind(&VideoImplService::onStreamerServiceRemoved,
this, _1)
319 mStreamerServiceListener->open();
323 void VideoImplService::onStreamerServiceAdded(
StreamerService* service)
325 if (mConnectionMethod.isEmpty())
326 mConnectionMethod = service->
getType();
331 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()
virtual QString getType() const =0
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 connectionMethodChanged()
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.
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.
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr