summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-11-25 16:44:14 (GMT)
committer jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-11-25 16:44:14 (GMT)
commit03f4a8b1cf5a826055feb4f08801dba63c8f71b4 (patch)
treed807c626b2a84d9546380e94b95e339490c29458
parentbc1cdd931b9641376c487458735bbb3d5d4a4dae (diff)
new Play and Stop xmlrpc channel methods,
small fixes, remote command cli application (in development) git-svn-id: svn://dyne.org/montevideo/ivysync@49 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r--Makefile6
-rw-r--r--cmdline.cpp18
-rw-r--r--decoder.cpp2
-rw-r--r--ivysync-remote.cpp127
-rw-r--r--xmlrpc.cpp38
-rw-r--r--xmlrpc.h31
6 files changed, 214 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 37a472e..fb5446c 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ LIBS = xmlrpc++/libxmlrpc++.a -lpthread -lssl `pkg-config --libs gtk+-2.0`
OBJ = decoder.o thread.o utils.o cmdline.o gui.o xmlrpc.o
-all: xmlrpc ivysync
+all: xmlrpc ivysync ivysync-remote
xmlrpc:
cd xmlrpc++ && $(MAKE)
@@ -28,6 +28,10 @@ xmlrpc:
ivysync: $(OBJ)
$(CPP) $(CPPFLAGS) -o ivysync $(OBJ) $(LIBS)
+ivysync-remote: ivysync-remote.o
+ $(CPP) -Ixmlrpc++ -Wall -ggdb -pg \
+ -o ivysync-remote ivysync-remote.o \
+ xmlrpc++/libxmlrpc++ -lssl
#make clean
clean:
diff --git a/cmdline.cpp b/cmdline.cpp
index fdc9f98..27a533e 100644
--- a/cmdline.cpp
+++ b/cmdline.cpp
@@ -59,14 +59,15 @@ IvySyncDaemon *daemonthread;
char *help =
"Usage: ivysync [-hsDgt] [ -d /dev/video16 [ -p playmode files ] ]\n"
" -h --help show this help\n"
-" -d --device activate a device (i.e. /dev/video16)\n"
+" -t --test dummy testrun: don't open devices\n"
+" -D --debug print verbose debugging messages\n"
" -s --scan scan for available devices\n"
-" -x --xmlrpc run XmlRpc daemon\n"
+" -d --device activate a device (i.e. /dev/video16)\n"
" -p --playmode playlist mode (play|cont|loop|rand)\n"
-" -g --gui start the graphical user interface\n"
-" -t --test dummy testrun: don't open devices\n";
+" -x --xmlrpc run XmlRpc daemon for remote control\n"
+" -g --gui start the graphical user interface\n";
-char *short_options = "-hd:sxp:gt";
+char *short_options = "-hd:sxp:gtD:";
const struct option long_options[] = {
{ "help", no_argument, NULL, 'h'},
{ "device", required_argument, NULL, 'd'},
@@ -75,6 +76,7 @@ const struct option long_options[] = {
{ "playmode", required_argument, NULL, 'p'},
{ "gui", no_argument, NULL, 'g'},
{ "test", no_argument, NULL, 't'},
+ { "debug", required_argument, NULL, 'D'},
{0, 0, 0, 0}
};
@@ -197,6 +199,10 @@ int cmdline(int argc, char **argv) {
case 't':
dummytest = true;
break;
+
+ case 'D':
+ set_debug( atoi(optarg) );
+ break;
case 1:
fd = fopen(optarg,"rb");
@@ -222,7 +228,7 @@ int main(int argc, char **argv) {
vector<Decoder*>::iterator dec_iter;
Decoder *dec;
- set_debug(3);
+ set_debug(1);
/* register quit signal handlers */
if (signal (SIGINT, quitproc) == SIG_ERR) {
diff --git a/decoder.cpp b/decoder.cpp
index eca9ea4..f39f332 100644
--- a/decoder.cpp
+++ b/decoder.cpp
@@ -426,6 +426,8 @@ int Decoder::load() {
now_epoch = time(NULL);
localtime_r( &now_epoch, &now );
snprintf(videodev,63,"video%u",device_num);
+ // use the default playlist
+ snprintf(ThePlaylist,511,"video%u",device_num);
// scan the directory for scheduled playlists starting with date
found = scandir(path, &filelist, playlist_selector, alphasort);
diff --git a/ivysync-remote.cpp b/ivysync-remote.cpp
new file mode 100644
index 0000000..40a17da
--- /dev/null
+++ b/ivysync-remote.cpp
@@ -0,0 +1,127 @@
+/* IvySync - Video SyncStarter
+ *
+ * (c) Copyright 2004-2005 Denis Roio aka jaromil <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 <cstdio>
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+#include <getopt.h>
+
+#include <XmlRpc.h>
+
+#include <utils.h>
+
+using namespace XmlRpc;
+
+
+char *help =
+"Usage: ivysync-remote [-s server:port] command [arguments]\n"
+" -h --help show this help\n"
+" -D --debug print verbos debugging messages\n"
+" -s --server server:port address to connect (default localhost:264)\n"
+" -i --inspect inspect methods available on host\n";
+
+char *short_options = "-hD:s:i";
+const struct option long_options[] = {
+ { "help", no_argument, NULL, 'h'},
+ { "debug", required_argument, NULL, 'D'},
+ { "server", required_argument, NULL, 's'},
+ { "inspect", no_argument, NULL, 'i'},
+ {0, 0, 0, 0}
+};
+
+
+bool introspect = false;
+char server[512];
+int port;
+
+
+int cmdline(int argc, char **argv) {
+
+ int res;
+ int c;
+
+ N("IvySync 0.3 / (c)2004-2005 Denis Rojo <jaromil@dyne.org>");
+
+ strcpy(server,"localhost");
+ port = 264;
+
+ do {
+ res = getopt_long(argc, argv, short_options, long_options, NULL);
+
+ switch(res) {
+
+ case 'h':
+ fprintf(stderr,"%s",help);
+ exit(1);
+ break;
+
+ case 'i':
+ introspect = true;
+ break;
+
+ case 's':
+ c = sscanf(optarg,"%s:%d",server,&port);
+ if(c != 2) {
+ E("error parsing server option: %s",optarg);
+ E("malformed syntax, please specify hostname:port");
+ exit(0);
+ }
+ break;
+
+ case 'D':
+ set_debug( atoi(optarg) );
+ break;
+
+ default: break;
+
+ }
+
+ } while(res > 0);
+
+ return res;
+}
+
+
+int main(int argc, char* argv[]) {
+
+ set_debug(1);
+
+ cmdline(argc, argv);
+
+ XmlRpcValue params;
+ XmlRpcValue result;
+ XmlRpc::setVerbosity(5);
+ XmlRpcClient c(server, port);
+
+ if(inspect) {
+ if( c.execute("system.listMethods", params, result) )
+ A("inspecting methods on %s:%i", server, port);
+ fprintf(stderr,"%s\n",result);
+ } else
+ E("error calling system.listMethods on %s:%i", server, port);
+ exit(1);
+ }
+
+ N("TODO");
+ exit(1);
+
+}
diff --git a/xmlrpc.cpp b/xmlrpc.cpp
index 422ac00..8274e0f 100644
--- a/xmlrpc.cpp
+++ b/xmlrpc.cpp
@@ -57,6 +57,15 @@ public: \
//RPCFUNC(Play,"Start playing a channel");
+Play::Play(XmlRpcServer* srv, vector<Decoder*> *decoders)
+ : XmlRpcServerMethod("Play", srv),
+ IvySyncPublicMethod(decoders)
+{ }
+
+Stop::Stop(XmlRpcServer* srv, vector<Decoder*> *decoders)
+ : XmlRpcServerMethod("Stop", srv),
+ IvySyncPublicMethod(decoders)
+{ }
GetPos::GetPos(XmlRpcServer* srv, vector<Decoder*> *decoders)
: XmlRpcServerMethod("GetPos", srv),
@@ -69,8 +78,35 @@ SetPos::SetPos(XmlRpcServer* srv, vector<Decoder*> *decoders)
{ }
-void GetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
+void Play::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ if( params.size() != 1) {
+ E("XMLRPC: Play called with invalid number of arguments (%u)",
+ params.size() );
+ return;
+ }
+
+ Decoder *dec = get_decoder( (int) params[0] -1 );
+ result = (double) dec->play();
+}
+
+
+
+void Stop::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ if( params.size() != 1) {
+ E("XMLRPC: Stop called with invalid number of arguments (%u)",
+ params.size() );
+ return;
+ }
+
+ Decoder *dec = get_decoder( (int) params[0] -1 );
+ result = (double) dec->stop();
+}
+
+
+
+
+void GetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
if( params.size() != 1) {
E("XMLRPC: GetPos called with invalid number of arguments (%u)",
params.size() );
diff --git a/xmlrpc.h b/xmlrpc.h
index 26f62f4..e3fd3a5 100644
--- a/xmlrpc.h
+++ b/xmlrpc.h
@@ -66,6 +66,37 @@ public:
//RPC(Stop,"Stop playing a channel");
//RPC(PlaylistAppend,"Append a file to a channel's playlist");
+
+class Play : public XmlRpcServerMethod, IvySyncPublicMethod {
+public:
+
+ Play(XmlRpcServer* srv, vector<Decoder*> *decoders);
+
+ ~Play() { };
+
+ void execute(XmlRpcValue &params, XmlRpcValue &result);
+
+ std::string help() {
+ return std::string("Start playing the channel"); }
+
+};
+
+
+class Stop : public XmlRpcServerMethod, IvySyncPublicMethod {
+public:
+
+ Stop(XmlRpcServer* srv, vector<Decoder*> *decoders);
+
+ ~Stop() { };
+
+ void execute(XmlRpcValue &params, XmlRpcValue &result);
+
+ std::string help() {
+ return std::string("Stop playing the channel"); }
+
+};
+
+
class GetPos : public XmlRpcServerMethod, IvySyncPublicMethod {
public: