summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-11-25 14:08:24 (GMT)
committer jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-11-25 14:08:24 (GMT)
commitbc1cdd931b9641376c487458735bbb3d5d4a4dae (patch)
tree9c8fa214565db24b11594ab0f12b214b0ece7aff
parent86d7f172e1766da6f8ded42203b3b964c5b3652d (diff)
ops! xmlrpc class was missing in last commit, here it is!
git-svn-id: svn://dyne.org/montevideo/ivysync@48 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r--Makefile2
-rw-r--r--xmlrpc.cpp95
-rw-r--r--xmlrpc.h99
3 files changed, 195 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 14c5aa9..37a472e 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ ivysync: $(OBJ)
#make clean
clean:
- rm -rf *.o *~ ivysync xmlrpc++/*.o xmlrpc++/*.a xmlrpc++/*~
+ rm -rf *.o *~ ivysync
install: ivysync
install ivysync /usr/local/bin
diff --git a/xmlrpc.cpp b/xmlrpc.cpp
new file mode 100644
index 0000000..422ac00
--- /dev/null
+++ b/xmlrpc.cpp
@@ -0,0 +1,95 @@
+/* IvySync - Video SyncStarter
+ *
+ * (c) Copyright 2004 - 2005 Denis Rojo <jaromil@dyne.org>
+ * Nederlands Instituut voor Mediakunst
+ *
+ * This source code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * Please refer to the GNU Public License for more details.
+ *
+ * You should have received a copy of the GNU Public License along with
+ * this source code; if not, write to:
+ * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#include <decoder.h>
+#include <xmlrpc.h>
+#include <utils.h>
+
+IvySyncDaemon::IvySyncDaemon(XmlRpcServer *srv)
+ : Thread() { xmlrpc = srv; }
+
+void IvySyncDaemon::run() {
+ running = true;
+ unlock();
+
+ D("thread %u launched",pthread_self());
+
+ // guess where this number comes from ? ;)
+ xmlrpc->bindAndListen(264);
+
+ // let's be introspective so we list our own methods
+ xmlrpc->enableIntrospection(true);
+
+ // work indefinitely (TODO: FIX this for proper quit)
+ xmlrpc->work(-1.0);
+}
+
+
+/* here we declare the public methods to be exposed via XmlRpc
+ each method is a class */
+#define RPCFUNC(name,Help) \
+class name : public XmlRpcServerMethod, IvySyncPublicMethod { \
+public: \
+ name (XmlRpcServer* srv, vector<Decoder*> *decoders); \
+ ~name() { }; \
+ void execute(XmlRpcValue &params, XmlRpcValue &result); \
+ std::string help() { \
+ return std::string(Help); } \
+}
+
+//RPCFUNC(Play,"Start playing a channel");
+
+
+GetPos::GetPos(XmlRpcServer* srv, vector<Decoder*> *decoders)
+ : XmlRpcServerMethod("GetPos", srv),
+ IvySyncPublicMethod(decoders)
+{ }
+
+SetPos::SetPos(XmlRpcServer* srv, vector<Decoder*> *decoders)
+ : XmlRpcServerMethod("SetPos", srv),
+ IvySyncPublicMethod(decoders)
+{ }
+
+
+void GetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
+
+ if( params.size() != 1) {
+ E("XMLRPC: GetPos called with invalid number of arguments (%u)",
+ params.size() );
+ return;
+ }
+
+ Decoder *dec = get_decoder( (int) params[0] -1 );
+ result = (double) dec->getpos();
+
+}
+
+void SetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ if( params.size() != 2) {
+ E("XMLRPC: SetPos called with invalid number of arguments (%u)",
+ params.size() );
+ return;
+ }
+
+ Decoder *dec = get_decoder( (int) params[0] -1 );
+ dec->setpos( (int) params[1] );
+}
+
diff --git a/xmlrpc.h b/xmlrpc.h
new file mode 100644
index 0000000..26f62f4
--- /dev/null
+++ b/xmlrpc.h
@@ -0,0 +1,99 @@
+/* IvySync - Video SyncStarter
+ *
+ * (c) Copyright 2004 - 2005 Denis Rojo <jaromil@dyne.org>
+ * Nederlands Instituut voor Mediakunst
+ *
+ * This source code is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This source code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * Please refer to the GNU Public License for more details.
+ *
+ * You should have received a copy of the GNU Public License along with
+ * this source code; if not, write to:
+ * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __XMLRPC_H__
+#define __XMLRPC_H__
+
+
+#include <XmlRpc.h>
+
+#include <iostream>
+#include <stdlib.h>
+
+#include <thread.h>
+
+using namespace XmlRpc;
+
+class IvySyncDaemon : public Thread {
+public:
+ IvySyncDaemon(XmlRpcServer *srv);
+ ~IvySyncDaemon() { };
+
+ void run();
+
+private:
+ XmlRpcServer *xmlrpc;
+};
+
+class IvySyncPublicMethod {
+public:
+
+ IvySyncPublicMethod(vector<Decoder*> *decs) {
+ decoders = decs;
+ }
+
+ ~IvySyncPublicMethod() { };
+
+ Decoder *get_decoder(int num) {
+ vector<Decoder*>::iterator dec_iter;
+ dec_iter = decoders->begin();
+ dec_iter += num;
+ return *dec_iter;
+ }
+
+ private:
+ vector<Decoder*> *decoders;
+
+};
+
+//RPC(Stop,"Stop playing a channel");
+//RPC(PlaylistAppend,"Append a file to a channel's playlist");
+
+class GetPos : public XmlRpcServerMethod, IvySyncPublicMethod {
+public:
+
+ GetPos(XmlRpcServer* srv, vector<Decoder*> *decoders);
+
+ ~GetPos() { };
+
+ void execute(XmlRpcValue &params, XmlRpcValue &result);
+
+ std::string help() {
+ return std::string("Return position of channel in percentage"); }
+
+};
+
+
+class SetPos : public XmlRpcServerMethod, IvySyncPublicMethod {
+ public:
+
+ SetPos(XmlRpcServer* srv, vector<Decoder*> *decoders);
+
+ ~SetPos() { };
+
+ void execute(XmlRpcValue &params, XmlRpcValue &result);
+
+ std::string help() {
+ return std::string("Skip channel to position in percentage"); }
+
+};
+
+
+#endif