41 #include "QApplication"
52 std::vector<PropertyPtr> retval;
63 bool defaultValue =
true;
65 bool defaultValue =
false;
70 "Run streamer in a separate process",
72 retval->setAdvanced(
false);
73 retval->setGroup(
"Connection");
79 QString defaultValue = this->getOpenIGTLinkServer().join(
" ");
81 "Name of server executable, used only if Run Local Server is set.",
84 retval->setAdvanced(
false);
85 retval->setGroup(
"Connection");
93 QStringList LocalServerStreamerArguments::checkGrabberServerExist(QString path, QString filename)
96 path = QDir::cleanPath(path);
97 if (QDir(path).exists(filename))
100 if (retval.isEmpty())
102 QString bundledPath = QString(
"%1/%2.app/Contents/MacOS").arg(path).arg(filename);
103 if (QDir(bundledPath).exists(filename))
111 QStringList LocalServerStreamerArguments::getOpenIGTLinkServer()
113 QString filename =
"OpenIGTLinkServer";
115 filename =
"OpenIGTLinkServer.exe";
118 return this->getGrabberServer(filename);
121 QStringList LocalServerStreamerArguments::getGrabberServer(QString filename)
127 result = this->checkGrabberServerExist(qApp->applicationDirPath(), filename);
128 if (!result.isEmpty())
133 if (!result.isEmpty())
155 QStringList cmdlineArguments;
156 for (StringMap::iterator i=args.begin(); i!=args.end(); ++i)
157 cmdlineArguments << i->first << i->second;
160 boost::shared_ptr<LocalServerStreamer> streamer;
167 mServerName(serverName),
168 mServerArguments(serverArguments)
170 mLocalVideoServerProcess.reset(
new ProcessWrapper(QString(
"Local Video Server: %1").arg(mServerName)));
173 int defaultport = 18333;
174 igtLinkStreamer->setAddress(
"Localhost", defaultport);
175 mBase = igtLinkStreamer;
185 mLocalVideoServerProcess->launchWithRelativePath(mServerName, mServerArguments.split(
" "));
187 this->waitForServerStart();
188 if (!this->localVideoServerIsRunning())
194 return mBase->startStreaming(sender);
197 void LocalServerStreamer::waitForServerStart()
202 qApp->processEvents();
203 if (this->localVideoServerIsRunning())
207 waitTime -= interval;
213 mBase->stopStreaming();
215 if (mLocalVideoServerProcess->getProcess())
216 mLocalVideoServerProcess->getProcess()->close();
221 return "LocalServer";
224 bool LocalServerStreamer::localVideoServerIsRunning()
226 if (!mLocalVideoServerProcess->getProcess())
228 return this->mLocalVideoServerProcess->getProcess()->state() == QProcess::Running;
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
void reportError(QString msg)
virtual void stopStreaming()
static StreamerPtr createStreamerIfEnabled(QDomElement root, StringMap args)
LocalServerStreamer(QString serverName, QString serverArguments)
StringPropertyBasePtr getLocalServerNameOption(QDomElement root)
BoolPropertyBasePtr getRunLocalServerOption(QDomElement root)
virtual bool startStreaming(SenderPtr sender)
boost::shared_ptr< class StringProperty > StringPropertyPtr
std::map< QString, QString > StringMap
void reportWarning(QString msg)
boost::shared_ptr< class BoolPropertyBase > BoolPropertyBasePtr
virtual QString getType()
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
virtual ~LocalServerStreamer()
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
boost::shared_ptr< Sender > SenderPtr
static QString getBundlePath()
return the folder where the bundle or executable are located.
boost::shared_ptr< class Streamer > StreamerPtr
std::vector< PropertyPtr > getSettings(QDomElement root)
boost::shared_ptr< class StringPropertyBase > StringPropertyBasePtr