diff options
-rw-r--r-- | command/markad-standalone.cpp | 11 | ||||
-rw-r--r-- | plugin/Makefile | 2 | ||||
-rw-r--r-- | plugin/markad.cpp | 99 | ||||
-rw-r--r-- | plugin/markad.h | 2 | ||||
-rw-r--r-- | plugin/menu.cpp | 12 | ||||
-rw-r--r-- | plugin/po/de_DE.po | 19 | ||||
-rw-r--r-- | plugin/po/it_IT.po | 15 | ||||
-rw-r--r-- | plugin/setup.cpp | 24 | ||||
-rw-r--r-- | plugin/setup.h | 10 | ||||
-rw-r--r-- | plugin/status.cpp | 111 | ||||
-rw-r--r-- | plugin/status.h | 5 |
11 files changed, 247 insertions, 63 deletions
diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp index 0f13456..ce1ffd9 100644 --- a/command/markad-standalone.cpp +++ b/command/markad-standalone.cpp @@ -644,11 +644,8 @@ bool cMarkAdStandalone::LoadInfo(const char *Directory) FILE *f; f=fopen(buf,"r"); - if (!f) - { - free(buf); - return false; - } + free(buf); + if (!f) return false; char *line=NULL; size_t length; @@ -742,7 +739,6 @@ bool cMarkAdStandalone::LoadInfo(const char *Directory) if (line) free(line); fclose(f); - free(buf); if (!macontext.Info.ChannelID) { return false; @@ -1368,7 +1364,7 @@ int main(int argc, char *argv[]) bool bDecodeAudio=true; bool bIgnoreAudioInfo=false; bool bIgnoreVideoInfo=false; - int online=1; + int online=0; strcpy(logoDirectory,"/var/lib/markad"); @@ -1655,6 +1651,7 @@ int main(int argc, char *argv[]) } else if (strcmp(argv[optind], "before" ) == 0 ) { + if (!online) online=1; bBefore = bFork = bNice = SYSLOG = true; } else if (strcmp(argv[optind], "edited" ) == 0 ) diff --git a/plugin/Makefile b/plugin/Makefile index 82cf02c..9a2ffde 100644 --- a/plugin/Makefile +++ b/plugin/Makefile @@ -17,7 +17,7 @@ VERSION = $(shell grep 'static const char \*VERSION *=' ../version.h | awk '{ pr ### The C++ compiler and options: CXX ?= g++ -CXXFLAGS ?= -fPIC -g -O2 -pedantic -Wall -Wextra -Woverloaded-virtual -Wno-parentheses +CXXFLAGS ?= -fPIC -g -O2 -Wall -Wextra -Woverloaded-virtual -Wno-parentheses ### The directory environment: diff --git a/plugin/markad.cpp b/plugin/markad.cpp index 68d5eed..5fc04bb 100644 --- a/plugin/markad.cpp +++ b/plugin/markad.cpp @@ -20,7 +20,10 @@ cPluginMarkAd::cPluginMarkAd(void) setup.ProcessDuring=true; setup.whileRecording=true; - setup.whilePlaying=true; + setup.whileReplaying=true; + setup.OSDMessage=false; + setup.BackupMarks=false; + setup.Verbose=false; } cPluginMarkAd::~cPluginMarkAd() @@ -150,7 +153,10 @@ bool cPluginMarkAd::SetupParse(const char *Name, const char *Value) // Parse setup parameters and store their values. if (!strcasecmp(Name,"Execution")) setup.ProcessDuring=atoi(Value); else if (!strcasecmp(Name,"whileRecording")) setup.whileRecording=atoi(Value); - else if (!strcasecmp(Name,"whilePlaying")) setup.whilePlaying=atoi(Value); + else if (!strcasecmp(Name,"whileReplaying")) setup.whileReplaying=atoi(Value); + else if (!strcasecmp(Name,"OSDMessage")) setup.OSDMessage=atoi(Value); + else if (!strcasecmp(Name,"BackupMarks")) setup.BackupMarks=atoi(Value); + else if (!strcasecmp(Name,"Verbose")) setup.Verbose=atoi(Value); else return false; return true; } @@ -163,16 +169,93 @@ bool cPluginMarkAd::Service(const char *UNUSED(Id), void *UNUSED(Data)) const char **cPluginMarkAd::SVDRPHelpPages(void) { - // Return help text for SVDRP commands this plugin implements - return NULL; + // Return help text for SVDRP + static const char *HelpPage[] = + { + "MARK <filename>\n" + " Start markad for the recording with the given filename.", + NULL + }; + return HelpPage; } -cString cPluginMarkAd::SVDRPCommand(const char *UNUSED(Command), const char *UNUSED(Option), - int &UNUSED(ReplyCode)) +bool cPluginMarkAd::ReadTitle(const char *Directory) { - // Process SVDRP commands this plugin implements - return NULL; + memset(&title,0,sizeof(title)); + char *buf; +#if VDRVERSNUM > 10700 + if (asprintf(&buf,"%s/info",Directory)==-1) return false; +#else + if (asprintf(&buf,"%s/info.vdr",Directory)==-1) return false; +#endif + + FILE *f; + f=fopen(buf,"r"); + free(buf); + if (!f) + { +#if VDRVERSNUM > 10700 + if (asprintf(&buf,"%s/info.vdr",Directory)==-1) return false; +#else + if (asprintf(&buf,"%s/info",Directory)==-1) return false; +#endif + f=fopen(buf,"r"); + free(buf); + if (!f) return false; + } + + char *line=NULL; + size_t length; + while (getline(&line,&length,f)!=-1) + { + if (line[0]=='T') + { + int result=sscanf(line,"%*c %79c",title); + if ((result==0) || (result==EOF)) + { + title[0]=0; + } + else + { + char *lf=strchr(title,10); + if (lf) *lf=0; + char *cr=strchr(title,13); + if (cr) *cr=0; + } + } + } + if (line) free(line); + + fclose(f); + return (title[0]!=0); } +cString cPluginMarkAd::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) +{ + // Process SVDRP command + if (!strcasecmp(Command,"MARK")) + { + if (Option) + { + char *Title=NULL; + if (ReadTitle(Option)) Title=(char *) &title; + if (statusMonitor->Start(Option,Title,true)) + { + return cString::sprintf("Started markad for %s",Option); + } + else + { + ReplyCode=451; + return cString::sprintf("Failed to start markad for %s",Option); + } + } + else + { + ReplyCode=501; + return cString::sprintf("Missing filename"); + } + } + return NULL; +} VDRPLUGINCREATOR(cPluginMarkAd) // Don't touch this! diff --git a/plugin/markad.h b/plugin/markad.h index fa52d68..b7fe929 100644 --- a/plugin/markad.h +++ b/plugin/markad.h @@ -31,6 +31,8 @@ private: char *bindir; char *logodir; struct setup setup; + char title[80]; + bool ReadTitle(const char *Directory); public: cPluginMarkAd(void); virtual ~cPluginMarkAd(); diff --git a/plugin/menu.cpp b/plugin/menu.cpp index 75fa300..2d7c9a7 100644 --- a/plugin/menu.cpp +++ b/plugin/menu.cpp @@ -36,7 +36,7 @@ cOsdMarkAd::cOsdMarkAd(struct recs *Entry) } char *buf=NULL; - if (asprintf(&buf,"%s\t %s",entry->Name,status)!=-1) + if (asprintf(&buf,"%s\t %s",entry->Name ? entry->Name : entry->FileName,status)!=-1) { SetText(buf,true); free(buf); @@ -44,7 +44,7 @@ cOsdMarkAd::cOsdMarkAd(struct recs *Entry) else { // fallback - SetText(entry->Name,true); + SetText(entry->Name ? entry->Name : entry->FileName,true); } } @@ -93,14 +93,14 @@ bool cMenuMarkAd::write() do { status->GetNextActive(&Entry); - if ((Entry) && (Entry->Name)) + if (Entry) { if (!header) { header=true; Add(new cOsdItem(tr("Recording\t Status"),osUnknown,false)); } - Add(new cOsdMarkAd(Entry),first); + Add(new cOsdMarkAd(Entry)); first=false; } } @@ -154,10 +154,11 @@ eOSState cMenuMarkAd::ProcessKey(eKeys Key) if ((osd) && (osd->Selectable())) { struct recs *entry=osd->GetEntry(); - if ((entry) && (entry->Pid)) + if ((entry) && (entry->Pid) && (entry->Status!='T')) { dsyslog("sending TSTP to %i",entry->Pid); kill(entry->Pid,SIGTSTP); + entry->ChangedbyUser=true; SetHelp(NULL,tr("Continue")); } } @@ -172,6 +173,7 @@ eOSState cMenuMarkAd::ProcessKey(eKeys Key) { dsyslog("sending CONT to %i",entry->Pid); kill(entry->Pid,SIGCONT); + entry->ChangedbyUser=true; SetHelp(tr("Pause"),NULL); } } diff --git a/plugin/po/de_DE.po b/plugin/po/de_DE.po index 847f107..aceb4bd 100644 --- a/plugin/po/de_DE.po +++ b/plugin/po/de_DE.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2010-04-08 11:24+0200\n" +"POT-Creation-Date: 2010-04-10 13:35+0200\n" "PO-Revision-Date: 2009-08-27 14:18+0200\n" "Last-Translator: Jochen Dolze <vdr@dolze.de>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -57,11 +57,20 @@ msgstr "während" msgid "execution" msgstr "Ausführung" -msgid "while recording" -msgstr "während einer Aufnahme" +msgid " during another recording" +msgstr " während einer anderen Aufnahme" -msgid "while playing" -msgstr "während einer Wiedergabe" +msgid " while replaying" +msgstr " während einer Wiedergabe" + +msgid "OSD message" +msgstr "OSD Meldung" + +msgid "backup marks" +msgstr "alte Marken sichern" + +msgid "verbose logging" +msgstr "ausführliches Logging" msgid "Mark advertisements" msgstr "Markiere Werbung" diff --git a/plugin/po/it_IT.po b/plugin/po/it_IT.po index e75b2bc..047603f 100644 --- a/plugin/po/it_IT.po +++ b/plugin/po/it_IT.po @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: vdr\n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2010-04-08 11:24+0200\n" +"POT-Creation-Date: 2010-04-10 13:35+0200\n" "PO-Revision-Date: 2009-11-14 18:06+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -60,10 +60,19 @@ msgstr "" msgid "execution" msgstr "" -msgid "while recording" +msgid " during another recording" msgstr "" -msgid "while playing" +msgid " while replaying" +msgstr "" + +msgid "OSD message" +msgstr "" + +msgid "backup marks" +msgstr "" + +msgid "verbose logging" msgstr "" msgid "Mark advertisements" diff --git a/plugin/setup.cpp b/plugin/setup.cpp index 3b51a1f..157291a 100644 --- a/plugin/setup.cpp +++ b/plugin/setup.cpp @@ -11,9 +11,12 @@ cSetupMarkAd::cSetupMarkAd(struct setup *Setup) { setup=Setup; - processduring=(int) setup->ProcessDuring; + processduring=setup->ProcessDuring; whilerecording=setup->whileRecording; - whileplaying=setup->whilePlaying; + whilereplaying=setup->whileReplaying; + osdmsg=setup->OSDMessage; + backupmarks=setup->BackupMarks; + verbose=setup->Verbose; processTexts[0]=tr("after"); processTexts[1]=tr("during"); @@ -28,9 +31,12 @@ void cSetupMarkAd::write(void) Add(new cMenuEditStraItem(tr("execution"),&processduring,2,processTexts)); if (!processduring) { - Add(new cMenuEditBoolItem(tr("while recording"),&whilerecording)); - Add(new cMenuEditBoolItem(tr("while playing"),&whileplaying)); + Add(new cMenuEditBoolItem(tr(" during another recording"),&whilerecording)); + Add(new cMenuEditBoolItem(tr(" while replaying"),&whilereplaying)); } + Add(new cMenuEditBoolItem(tr("OSD message"),&osdmsg)); + Add(new cMenuEditBoolItem(tr("backup marks"),&backupmarks)); + Add(new cMenuEditBoolItem(tr("verbose logging"),&verbose)); Display(); } @@ -61,9 +67,15 @@ void cSetupMarkAd::Store(void) { SetupStore("Execution",processduring); SetupStore("whileRecording",whilerecording); - SetupStore("whilePlaying",whileplaying); + SetupStore("whileReplaying",whilereplaying); + SetupStore("BackupMarks",backupmarks); + SetupStore("OSDMessage",osdmsg); + SetupStore("Verbose",verbose); setup->ProcessDuring=(bool) processduring; setup->whileRecording=(bool) whilerecording; - setup->whilePlaying=(bool) whileplaying; + setup->whileReplaying=(bool) whilereplaying; + setup->OSDMessage=(bool) osdmsg; + setup->BackupMarks=(bool) backupmarks; + setup->Verbose=(bool) verbose; } diff --git a/plugin/setup.h b/plugin/setup.h index 5421457..c13c769 100644 --- a/plugin/setup.h +++ b/plugin/setup.h @@ -14,7 +14,10 @@ struct setup { bool ProcessDuring; bool whileRecording; - bool whilePlaying; + bool whileReplaying; + bool OSDMessage; + bool BackupMarks; + bool Verbose; }; class cSetupMarkAd : public cMenuSetupPage @@ -24,7 +27,10 @@ private: struct setup *setup; int processduring; int whilerecording; - int whileplaying; + int whilereplaying; + int osdmsg; + int backupmarks; + int verbose; void write(void); protected: virtual void Store(void); diff --git a/plugin/status.cpp b/plugin/status.cpp index fe074ac..be32133 100644 --- a/plugin/status.cpp +++ b/plugin/status.cpp @@ -20,7 +20,7 @@ cStatusMarkAd::~cStatusMarkAd() { for (int i=0; i<(MAXDEVICES*MAXRECEIVERS); i++) { - Remove(i); + Remove(i,true); } } @@ -54,7 +54,7 @@ bool cStatusMarkAd::Replaying() void cStatusMarkAd::Replaying(const cControl *UNUSED(Control), const char *UNUSED(Name), const char *UNUSED(FileName), bool On) { - if (setup->whilePlaying) return; + if (setup->whileReplaying) return; if (On) { Pause(NULL); @@ -65,25 +65,24 @@ void cStatusMarkAd::Replaying(const cControl *UNUSED(Control), const char *UNUSE } } -void cStatusMarkAd::Recording(const cDevice *UNUSED(Device), const char *Name, - const char *FileName, bool On) +bool cStatusMarkAd::Start(const char *FileName, const char *Name, bool Direct) { - if (!FileName) return; // we cannot operate without a filename - if (!bindir) return; // we cannot operate without bindir - if (!logodir) return; // we dont want to operate without logodir + if ((Direct) && (Get(FileName)!=-1)) return false; - if (On) + cString cmd = cString::sprintf("\"%s\"/markad %s %s %s -l \"%s\" %s \"%s\"",bindir, + setup->Verbose ? "-v" : "", setup->BackupMarks ? "-B" : "", + setup->OSDMessage ? "-O" : "", + logodir,Direct ? "after" : "--online=2 before", FileName); + dsyslog("executing %s",*cmd); + if (SystemExec(cmd)!=-1) { - // Start markad with recording - cString cmd = cString::sprintf("\"%s\"/markad --online=2 -l \"%s\" before \"%s\"",bindir, - logodir,FileName); - if (SystemExec(cmd)!=-1) + usleep(200000); + int pos=Add(FileName,Name); + if (getPid(pos) && getStatus(pos)) { - usleep(200000); - int pos=Add(FileName,Name); - if (getPid(pos) && getStatus(pos)) + if (!setup->ProcessDuring) { - if (!setup->ProcessDuring) + if (!Direct) { if (!setup->whileRecording) { @@ -94,16 +93,43 @@ void cStatusMarkAd::Recording(const cDevice *UNUSED(Device), const char *Name, Pause(FileName); } } + else + { + if (!setup->whileRecording && Recording()) + { + Pause(FileName); + } + if (!setup->whileReplaying && Replaying()) + { + Pause(FileName); + } + } } + return true; } } + return false; +} + +void cStatusMarkAd::Recording(const cDevice *UNUSED(Device), const char *Name, + const char *FileName, bool On) +{ + if (!FileName) return; // we cannot operate without a filename + if (!bindir) return; // we cannot operate without bindir + if (!logodir) return; // we dont want to operate without logodir + + if (On) + { + // Start markad with recording + Start(FileName,Name); + } else { if (!setup->ProcessDuring) { if (!setup->whileRecording) { - if (!setup->whilePlaying) + if (!setup->whileReplaying) { if (!Recording() && !Replaying()) Continue(NULL); } @@ -209,11 +235,19 @@ bool cStatusMarkAd::MarkAdRunning() return (tmpRecs!=NULL); } -void cStatusMarkAd::Remove(int Position) +int cStatusMarkAd::Get(const char *FileName) +{ + for (int i=0; i<(MAXDEVICES*MAXRECEIVERS); i++) + { + if ((recs[i].FileName) && (!strcmp(recs[i].FileName,FileName))) return i; + } + return -1; +} + +void cStatusMarkAd::Remove(int Position, bool Kill) { if (recs[Position].FileName) { - dsyslog("markad: removing %s at position %i",recs[Position].FileName,Position); free(recs[Position].FileName); recs[Position].FileName=NULL; } @@ -222,6 +256,25 @@ void cStatusMarkAd::Remove(int Position) free(recs[Position].Name); recs[Position].Name=NULL; } + + if ((Kill) && (recs[Position].Pid)) + { + if (getStatus(Position)) + { + if ((recs[Position].Status=='R') || (recs[Position].Status=='S')) + { + kill(recs[Position].Pid,SIGTERM); + } + else + { + kill(recs[Position].Pid,SIGKILL); + } + } + else + { + kill(recs[Position].Pid,SIGKILL); + } + } recs[Position].Status=0; recs[Position].Pid=0; } @@ -232,9 +285,15 @@ int cStatusMarkAd::Add(const char *FileName, const char *Name) { if (!recs[i].FileName) { - dsyslog("markad: adding %s at position %i",FileName,i); recs[i].FileName=strdup(FileName); - recs[i].Name=strdup(Name); + if (Name) + { + recs[i].Name=strdup(Name); + } + else + { + Name=NULL; + } recs[i].Status=0; recs[i].Pid=0; return i; @@ -249,14 +308,15 @@ void cStatusMarkAd::Pause(const char *FileName) { if (FileName) { - if ((recs[i].FileName) && (!strcmp(recs[i].FileName,FileName)) && (recs[i].Pid)) + if ((recs[i].FileName) && (!strcmp(recs[i].FileName,FileName)) && + (recs[i].Pid) && (!recs[i].ChangedbyUser)) { kill(recs[i].Pid,SIGTSTP); } } else { - if (recs[i].Pid) + if ((recs[i].Pid) && (!recs[i].ChangedbyUser)) { kill(recs[i].Pid,SIGTSTP); } @@ -270,14 +330,15 @@ void cStatusMarkAd::Continue(const char *FileName) { if (FileName) { - if ((recs[i].FileName) && (!strcmp(recs[i].FileName,FileName)) && (recs[i].Pid)) + if ((recs[i].FileName) && (!strcmp(recs[i].FileName,FileName)) && + (recs[i].Pid) && (!recs[i].ChangedbyUser) ) { kill(recs[i].Pid,SIGCONT); } } else { - if (recs[i].Pid) + if ((recs[i].Pid) && (!recs[i].ChangedbyUser)) { kill(recs[i].Pid,SIGCONT); } diff --git a/plugin/status.h b/plugin/status.h index 83dd23f..238de3b 100644 --- a/plugin/status.h +++ b/plugin/status.h @@ -19,6 +19,7 @@ struct recs char *FileName; pid_t Pid; char Status; + bool ChangedbyUser; }; // --- cStatusMarkAd @@ -37,8 +38,9 @@ private: bool getStatus(int Position); int Recording(); bool Replaying(); + int Get(const char *FileName); int Add(const char *FileName, const char *Name); - void Remove(int Position); + void Remove(int Position, bool Kill=false); void Pause(const char *FileName); void Continue(const char *FileName); protected: @@ -53,6 +55,7 @@ public: actpos=0; } bool GetNextActive(struct recs **RecEntry); + bool Start(const char *FileName, const char *Name, bool Direct=false); }; #endif |