summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-12-06 15:45:46 (GMT)
committer jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-12-06 15:45:46 (GMT)
commita36e5488f98b8df5b095ff2de57a5e920b2a53c1 (patch)
tree2a280028450de869051bfbd76f2f0d410a60f8f4
parent46526ee690ae3c0fe99bbceaf03b03d453f87e93 (diff)
more fixes to exclude SSL,
new video buffer size flag, fixed Stop and Play xmlrpc methods. git-svn-id: svn://dyne.org/montevideo/ivysync@53 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r--cmdline.cpp15
-rw-r--r--decoder.cpp30
-rw-r--r--decoder.h6
-rw-r--r--xmlrpc++/XmlRpcServerConnection.cpp6
-rw-r--r--xmlrpc.cpp42
5 files changed, 65 insertions, 34 deletions
diff --git a/cmdline.cpp b/cmdline.cpp
index 27a533e..9f71efe 100644
--- a/cmdline.cpp
+++ b/cmdline.cpp
@@ -43,6 +43,7 @@ bool syncstart = false;
bool graphical = false;
bool dummytest = false;
bool rpcdaemon = false;
+int videobuf = 64;
// our global vector holding all instantiated decoders
vector<Decoder*> decoders;
@@ -63,14 +64,16 @@ char *help =
" -D --debug print verbose debugging messages\n"
" -s --scan scan for available devices\n"
" -d --device activate a device (i.e. /dev/video16)\n"
+" -b --buffer size of video buffer in KB (default 64)\n"
" -p --playmode playlist mode (play|cont|loop|rand)\n"
" -x --xmlrpc run XmlRpc daemon for remote control\n"
" -g --gui start the graphical user interface\n";
-char *short_options = "-hd:sxp:gtD:";
+char *short_options = "-hd:sb:xp:gtD:";
const struct option long_options[] = {
{ "help", no_argument, NULL, 'h'},
{ "device", required_argument, NULL, 'd'},
+ { "buffer", required_argument, NULL, 'b'},
{ "scan", no_argument, NULL, 's'},
{ "xmlrpc", no_argument, NULL, 'x'},
{ "playmode", required_argument, NULL, 'p'},
@@ -203,7 +206,11 @@ int cmdline(int argc, char **argv) {
case 'D':
set_debug( atoi(optarg) );
break;
-
+
+ case 'b':
+ videobuf = atoi(optarg);
+ break;
+
case 1:
fd = fopen(optarg,"rb");
if(fd) {
@@ -279,6 +286,8 @@ int main(int argc, char **argv) {
if(rpcdaemon) {
xmlrpc = new XmlRpcServer();
// instantiate all classes
+ new Play (xmlrpc, &decoders);
+ new Stop (xmlrpc, &decoders);
new GetPos(xmlrpc, &decoders);
new SetPos(xmlrpc, &decoders);
@@ -299,7 +308,7 @@ int main(int argc, char **argv) {
++dec_iter) {
dec = *dec_iter;
- dec->syncstart = &syncstart;
+ dec->setup( &syncstart, videobuf );
dec->launch();
dec->play();
diff --git a/decoder.cpp b/decoder.cpp
index 3bf7669..681a58f 100644
--- a/decoder.cpp
+++ b/decoder.cpp
@@ -39,16 +39,13 @@ Decoder::Decoder()
playing = false;
dummy = false;
gui = false;
+ quit = true;
filesize = 0L;
filepos = 0L;
newfilepos = 0L;
-// memset(buffo,0,CHUNKSIZE+1024);
- buffo = (uint8_t*) calloc(CHUNKSIZE,1);
- if(!buffo)
- E("fatal error: can't allocate %uMb of memory for decoder",
- CHUNKSIZE/1024/1024);
+ buffo = NULL;
}
Decoder::~Decoder() {
@@ -87,6 +84,27 @@ bool Decoder::init(char *dev) {
return true;
}
+bool Decoder::setup(bool *sync, int bufsize) {
+
+ // save the syncstarter flag
+ syncstart = sync;
+
+ if(buffo) free(buffo);
+
+ buffo = (uint8_t*) calloc( bufsize+1, 1024); // +1 safety bound
+ if(!buffo) {
+ E("fatal error: can't allocate %uKB of memory for decoder", bufsize);
+ return(false);
+ }
+
+ buffo_size = bufsize*1024;
+
+ quit = false;
+
+ return(true);
+
+}
+
void Decoder::close() {
if(playing) stop();
quit = true;
@@ -218,7 +236,7 @@ void Decoder::run() {
if(quit) break;
///////////////////////////
- in = fread(buffo, 1, CHUNKSIZE, playlist_fd);
+ in = fread(buffo, 1, buffo_size, playlist_fd);
if( feof(playlist_fd) || in<1 ) { // EOF
D("end of file: %s",movie.c_str());
break;
diff --git a/decoder.h b/decoder.h
index 2b6e60f..714da85 100644
--- a/decoder.h
+++ b/decoder.h
@@ -40,9 +40,6 @@ using namespace __gnu_cxx;
#define LOOP 3
#define RAND 4
-// size of video chunks read in bytes
-#define CHUNKSIZE (1024*64)
-
class Playlist; // graphical interface
class Decoder : public Thread {
@@ -53,6 +50,8 @@ class Decoder : public Thread {
bool init(char *dev);
+ bool setup(bool *sync, int bufsize);
+
void close();
// playlist stuff
@@ -105,6 +104,7 @@ class Decoder : public Thread {
// uint8_t buffo[CHUNKSIZE+1024]; // + 1k bound
uint8_t *buffo;
+ int buffo_size;
};
diff --git a/xmlrpc++/XmlRpcServerConnection.cpp b/xmlrpc++/XmlRpcServerConnection.cpp
index 9ff3834..d428ff4 100644
--- a/xmlrpc++/XmlRpcServerConnection.cpp
+++ b/xmlrpc++/XmlRpcServerConnection.cpp
@@ -60,7 +60,7 @@ XmlRpcServerConnection::readHeader()
{
// Read available data
bool eof;
- if ( ! XmlRpcSocket::nbRead(this->getfd(), _header, &eof, _ssl_ssl)) {
+ if ( ! XmlRpcSocket::nbRead(this->getfd(), _header, &eof, NULL)) { // was _ssl_ssl
// Its only an error if we already have read some data
if (_header.length() > 0)
XmlRpcUtil::error("XmlRpcServerConnection::readHeader: error while reading header (%s).",XmlRpcSocket::getErrorMsg().c_str());
@@ -140,7 +140,7 @@ XmlRpcServerConnection::readRequest()
// If we dont have the entire request yet, read available data
if (int(_request.length()) < _contentLength) {
bool eof;
- if ( ! XmlRpcSocket::nbRead(this->getfd(), _request, &eof, _ssl_ssl)) {
+ if ( ! XmlRpcSocket::nbRead(this->getfd(), _request, &eof, NULL)) { // was _ssl_ssl
XmlRpcUtil::error("XmlRpcServerConnection::readRequest: read error (%s).",XmlRpcSocket::getErrorMsg().c_str());
return false;
}
@@ -179,7 +179,7 @@ XmlRpcServerConnection::writeResponse()
}
// Try to write the response
- if ( ! XmlRpcSocket::nbWrite(this->getfd(), _response, &_bytesWritten, _ssl_ssl)) {
+ if ( ! XmlRpcSocket::nbWrite(this->getfd(), _response, &_bytesWritten, NULL)) { // was _ssl_ssl
XmlRpcUtil::error("XmlRpcServerConnection::writeResponse: write error (%s).",XmlRpcSocket::getErrorMsg().c_str());
return false;
}
diff --git a/xmlrpc.cpp b/xmlrpc.cpp
index 1144b77..34fb7bb 100644
--- a/xmlrpc.cpp
+++ b/xmlrpc.cpp
@@ -49,20 +49,6 @@ void IvySyncDaemon::run() {
}
-/* 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");
-
Play::Play(XmlRpcServer* srv, vector<Decoder*> *decoders)
: XmlRpcServerMethod("Play", srv),
IvySyncPublicMethod(decoders)
@@ -86,26 +72,34 @@ SetPos::SetPos(XmlRpcServer* srv, vector<Decoder*> *decoders)
void Play::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ int decnum;
+
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 );
+ decnum = (int) params[0] -1;
+ Decoder *dec = get_decoder( decnum );
+ D("Play decoder %u", decnum );
result = (double) dec->play();
}
void Stop::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ int decnum;
+
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 );
+ decnum = (int) params[0] -1;
+ Decoder *dec = get_decoder( decnum );
+ D("Stop decoder %u", decnum);
result = (double) dec->stop();
}
@@ -113,25 +107,35 @@ void Stop::execute(XmlRpcValue &params, XmlRpcValue &result) {
void GetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ int decnum;
+ double pos;
+
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();
+ decnum = (int) params[0] -1;
+ Decoder *dec = get_decoder( decnum );
+ pos = (double) dec->getpos();
+ result = pos;
+ D("GetPos decoder %u returns %d", decnum, pos);
}
void SetPos::execute(XmlRpcValue &params, XmlRpcValue &result) {
+ int decnum;
+
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 );
+ decnum = (int) params[0] -1;
+ Decoder *dec = get_decoder( decnum );
+ D("SetPos decoder %u", decnum);
dec->setpos( (int) params[1] );
}