summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmdline.cpp2
-rw-r--r--decoder.cpp9
-rw-r--r--decoder.h5
-rwxr-xr-xivysync-remote.py12
-rw-r--r--xmlrpc.cpp52
-rw-r--r--xmlrpc.h27
6 files changed, 104 insertions, 3 deletions
diff --git a/cmdline.cpp b/cmdline.cpp
index a8c5f10..c73ea80 100644
--- a/cmdline.cpp
+++ b/cmdline.cpp
@@ -319,6 +319,8 @@ int main(int argc, char **argv) {
new Pause (xmlrpc, &decoders);
new GetPos(xmlrpc, &decoders);
new SetPos(xmlrpc, &decoders);
+ new GetOffset(xmlrpc, &decoders);
+ new SetOffset(xmlrpc, &decoders);
new Open (xmlrpc, &decoders);
new Quit (xmlrpc, &decoders);
diff --git a/decoder.cpp b/decoder.cpp
index 78814a6..ae46d9d 100644
--- a/decoder.cpp
+++ b/decoder.cpp
@@ -448,7 +448,14 @@ void Decoder::setpos(int pos) {
D("Decoder::setpos(%u) : newfilepos = %lu",
pos, newfilepos);
}
-
+
+off64_t Decoder::getoffset() {
+ return filepos;
+}
+
+void Decoder::setoffset(off64_t pos) {
+ (pos < filesize) ? newfilepos = pos : newfilepos = filesize;
+}
bool Decoder::prepend(char *file) {
diff --git a/decoder.h b/decoder.h
index 8e1492a..dee8c59 100644
--- a/decoder.h
+++ b/decoder.h
@@ -86,9 +86,12 @@ class Decoder : public Thread, public Entry {
bool pause();
bool clear();
- int getpos();
+ int getpos();
void setpos(int pos);
+ off64_t getoffset();
+ void setoffset(off64_t pos);
+
/** state flags for use in the inner loop
the following booleans are changed by asynchronous calls
then behaviour is synched and executed in the main loop */
diff --git a/ivysync-remote.py b/ivysync-remote.py
index 5b04aeb..df0c2c6 100755
--- a/ivysync-remote.py
+++ b/ivysync-remote.py
@@ -53,7 +53,7 @@ class xmlrpc_connection:
if __name__ == '__main__':
- commands = ("Play", "Stop", "Open", "Pause", "Quit", "GetPos", "SetPos")
+ commands = ("Play", "Stop", "Open", "Pause", "Quit", "GetPos", "SetPos", "GetOffset", "SetOffset")
connection = xmlrpc_connection()
@@ -87,6 +87,12 @@ if __name__ == '__main__':
(res,) = connection.remote(cmd, (chan, pos))
answer = "Channel " + str(chan) + " is now at " + str(pos) + "%"
+ elif cmd == "SetOffset":
+ chan = int( sys.argv[2] )
+ pos = int( sys.argv[3] )
+
+ (res,) = connection.remote(cmd, (chan, pos))
+ answer = "Channel " + str(chan) + " is now at " + str(pos) + " byte offset"
elif cmd == "GetPos":
@@ -94,7 +100,11 @@ if __name__ == '__main__':
(res,) = connection.remote(cmd, (chan, 0))
answer = "Channel " + str(chan) + " is now at " + str(res) + "%"
+ elif cmd == "GetOffset":
+ chan = int( sys.argv[2] )
+ (res,) = connection.remote(cmd, (chan, 0))
+ answer = "Channel " + str(chan) + " is now at " + str(res) + " byte offset"
elif cmd == "Open":
diff --git a/xmlrpc.cpp b/xmlrpc.cpp
index 9946096..8386607 100644
--- a/xmlrpc.cpp
+++ b/xmlrpc.cpp
@@ -85,6 +85,16 @@ SetPos::SetPos(XmlRpcServer* srv, Linklist *decoders)
IvySyncPublicMethod(decoders)
{ }
+GetOffset::GetOffset(XmlRpcServer* srv, Linklist *decoders)
+ : XmlRpcServerMethod("GetOffset", srv),
+ IvySyncPublicMethod(decoders)
+{ }
+
+SetOffset::SetOffset(XmlRpcServer* srv, Linklist *decoders)
+ : XmlRpcServerMethod("SetOffset", srv),
+ IvySyncPublicMethod(decoders)
+{ }
+
Open::Open(XmlRpcServer* src, Linklist *decoders)
: XmlRpcServerMethod("Open", src),
IvySyncPublicMethod(decoders)
@@ -233,6 +243,28 @@ void GetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
}
+void GetOffset::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ int decnum;
+ int pos;
+
+ if( params.size() < 1) {
+ E("XMLRPC: GetOffset called with invalid number of arguments (%u)",
+ params.size() );
+ return;
+ }
+
+ decnum = (int) params[0];
+ Decoder *dec = (Decoder*) (*decoders)[decnum];
+ if(!dec) {
+ E("video decoder %i not present", decnum);
+ result = 0.0; return; }
+
+ pos = (int) dec->getoffset();
+ result = pos;
+ D("XMLRPC: GetOffset decoder %u returns %d", decnum, pos);
+}
+
+
void SetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
int decnum;
int pos;
@@ -254,3 +286,23 @@ void SetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
dec->setpos( pos );
}
+void SetOffset::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ int decnum;
+ double pos;
+
+ if( params.size() < 2) {
+ E("XMLRPC: SetOffset called with invalid number of arguments (%u)",
+ params.size() );
+ return;
+ }
+
+ decnum = (int) params[0];
+ Decoder *dec = (Decoder*) (*decoders)[decnum];
+ if(!dec) {
+ E("video decoder %i not present", decnum);
+ result = 0.0; return; }
+
+ pos = (int) params[1];
+ D("XMLRPC: SetOffset decoder %u to position %d", decnum, pos);
+ dec->setoffset( (off64_t) pos );
+}
diff --git a/xmlrpc.h b/xmlrpc.h
index c604e10..0dfab27 100644
--- a/xmlrpc.h
+++ b/xmlrpc.h
@@ -136,6 +136,18 @@ public:
};
+class GetOffset : public XmlRpcServerMethod, IvySyncPublicMethod {
+ public:
+
+ GetOffset(XmlRpcServer* srv, Linklist *decoders);
+
+ ~GetOffset() { };
+
+ void execute(XmlRpcValue &params, XmlRpcValue &result);
+
+ std::string help() {
+ return std::string("Return position of channel in byte offset"); }
+};
class SetPos : public XmlRpcServerMethod, IvySyncPublicMethod {
public:
@@ -151,6 +163,21 @@ class SetPos : public XmlRpcServerMethod, IvySyncPublicMethod {
};
+
+class SetOffset : public XmlRpcServerMethod, IvySyncPublicMethod {
+ public:
+
+ SetOffset(XmlRpcServer* srv, Linklist *decoders);
+
+ ~SetOffset() { };
+
+ void execute(XmlRpcValue &params, XmlRpcValue &result);
+
+ std::string help() {
+ return std::string("Skip channel to position in byte offset"); }
+
+};
+
class Open : public XmlRpcServerMethod, IvySyncPublicMethod {
public: