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)
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
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)
static VideoServiceBackendPtr create(PatientModelServicePtr dataManager, TrackingServicePtr trackingService, SpaceProviderPtr spaceProvider, FileManagerServicePtr filemanager, ctkPluginContext *context)
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)
static FileManagerServicePtr create(ctkPluginContext *context)
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)
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