diff options
-rw-r--r-- | command/demux.cpp | 36 | ||||
-rw-r--r-- | command/demux.h | 1 | ||||
-rw-r--r-- | command/markad-standalone.cpp | 85 | ||||
-rw-r--r-- | command/markad-standalone.h | 3 | ||||
-rw-r--r-- | command/pes2es.cpp | 14 | ||||
-rw-r--r-- | command/queue.h | 2 | ||||
-rw-r--r-- | command/ts2pkt.cpp | 3 | ||||
-rw-r--r-- | command/video.cpp | 2 | ||||
-rw-r--r-- | plugin/markad.cpp | 2 | ||||
-rw-r--r-- | plugin/po/de_DE.po | 5 | ||||
-rw-r--r-- | plugin/po/it_IT.po | 5 | ||||
-rw-r--r-- | plugin/setup.cpp | 4 | ||||
-rw-r--r-- | plugin/setup.h | 2 | ||||
-rw-r--r-- | plugin/status.cpp | 3 |
14 files changed, 85 insertions, 82 deletions
diff --git a/command/demux.cpp b/command/demux.cpp index 752b300..a5b4ed7 100644 --- a/command/demux.cpp +++ b/command/demux.cpp @@ -41,36 +41,6 @@ void cMarkAdDemux::Clear() skip=0; } -void cMarkAdDemux::GetVideoPTS(uchar *Data, int Count, unsigned int *Timestamp) -{ - if (!Data) return; - if (Count<=0) return; - if (!Timestamp) return; - struct PESHDR *peshdr=(struct PESHDR *) Data; - - if ((peshdr->Sync1!=0) && (peshdr->Sync2!=0) && (peshdr->Sync3!=1)) return; - if ((peshdr->StreamID & 0xF0)!=0xE0) return; - - struct PESHDROPT *peshdropt=(struct PESHDROPT *) &Data[sizeof(struct PESHDR)]; - if (peshdropt->MarkerBits!=0x2) return; - - if (peshdropt->PTSDTS<2) return; - - struct PESHDROPTPTS *peshdroptpts=(struct PESHDROPTPTS *) &Data[sizeof(struct PESHDR)+ - sizeof(struct PESHDROPT)]; - - if (peshdroptpts->Marker1 && peshdroptpts->Marker2 && - peshdroptpts->Marker3) -{ - unsigned int pts=0; - pts|=((peshdroptpts->PTS29_15_H<<7|peshdroptpts->PTS29_15_L)<<15); - pts|=(peshdroptpts->PTS14_0_H<<7|peshdroptpts->PTS14_0_L); - pts|=(peshdroptpts->PTS32_30<<30); - *Timestamp=pts; - } - return; -} - void cMarkAdDemux::ProcessVDR(MarkAdPid Pid, uchar *Data, int Count, MarkAdPacket *Pkt) { if (!Pkt) return; @@ -149,7 +119,6 @@ void cMarkAdDemux::ProcessTS(MarkAdPid Pid, uchar *Data, int Count, MarkAdPacket if ((Pid.Type==MARKAD_PIDTYPE_VIDEO_H262) || (Pid.Type==MARKAD_PIDTYPE_VIDEO_H264)) { - GetVideoPTS(pkt.Data,pkt.Length,&Pkt->Timestamp); if ((pkt.Data) && ((pkt.Data[3] & 0xF0)==0xE0) && (pkt.Data[4]!=0) && (pkt.Data[5]!=0)) { ts2pkt->InjectVideoPES(pkt.Data,pkt.Length); @@ -158,6 +127,7 @@ void cMarkAdDemux::ProcessTS(MarkAdPid Pid, uchar *Data, int Count, MarkAdPacket } Pkt->Data=pkt.Data; Pkt->Length=pkt.Length; + Pkt->Skipped=pkt.Skipped; } return; } @@ -207,6 +177,8 @@ int cMarkAdDemux::GetMinNeeded(MarkAdPid Pid, uchar *Data, int Count, bool *Offc } else { + queue->Clear(); + if (Offcnt) *Offcnt=true; return -1; // skip one byte (maybe we get another header!) } } @@ -223,6 +195,7 @@ int cMarkAdDemux::Process(MarkAdPid Pid, uchar *Data, int Count, MarkAdPacket *P { Pkt->Data=NULL; Pkt->Length=0; + Pkt->Skipped=0; Pkt->Offcnt=false; if (!min_needed) @@ -247,6 +220,7 @@ int cMarkAdDemux::Process(MarkAdPid Pid, uchar *Data, int Count, MarkAdPacket *P skip=-t_min_needed-Count; return Count; } + if (t_min_needed==-1) Pkt->Skipped++; return -t_min_needed; } min_needed=t_min_needed; diff --git a/command/demux.h b/command/demux.h index 489528b..9313912 100644 --- a/command/demux.h +++ b/command/demux.h @@ -32,7 +32,6 @@ private: int min_needed; int skip; - void GetVideoPTS(uchar *Data, int Count, unsigned int *Timestamp); int GetMinNeeded(MarkAdPid Pid, uchar *Data, int Count, bool *Offcnt); void ProcessTS(MarkAdPid Pid, uchar *Data, int Count, MarkAdPacket *pkt); void ProcessVDR(MarkAdPid Pid, uchar *Data, int Count, MarkAdPacket *pkt); diff --git a/command/markad-standalone.cpp b/command/markad-standalone.cpp index e361306..43ea333 100644 --- a/command/markad-standalone.cpp +++ b/command/markad-standalone.cpp @@ -33,6 +33,7 @@ extern int sys_ioprio_set(int which, int who, int ioprio); bool SYSLOG=false; +bool LOG2REC=false; cMarkAdStandalone *cmasta=NULL; int SysLogLevel=2; @@ -59,7 +60,7 @@ static inline int ioprio_set(int which, int who, int ioprio) void syslog_with_tid(int priority, const char *format, ...) { va_list ap; - if (SYSLOG) + if ((SYSLOG) && (!LOG2REC)) { char fmt[255]; snprintf(fmt, sizeof(fmt), "[%d] %s", getpid(), format); @@ -1334,6 +1335,10 @@ bool cMarkAdStandalone::ProcessFile(int Number) } } } + if (vpkt.Skipped) + { + errcnt+=vpkt.Skipped; + } tspkt+=len; tslen-=len; if (!vpkt.Offcnt) @@ -1589,6 +1594,17 @@ void cMarkAdStandalone::Process() if (macontext.Config->GenIndex) marks.RemoveGeneratedIndex(directory,isTS); } +bool cMarkAdStandalone::SetFileUID(char *File) +{ + if (!File) return false; + struct stat statbuf; + if (!stat(directory,&statbuf)) + { + if (chown(File,statbuf.st_uid, statbuf.st_gid)==-1) return false; + } + return true; +} + bool cMarkAdStandalone::SaveInfo() { if ((!setVideo43) && (!setVideo169) && (!setAudio20) && (!setAudio51) && (!setVideo43LB) && @@ -1772,21 +1788,7 @@ bool cMarkAdStandalone::SaveInfo() oldtimes.actime=statbuf_r.st_atime; oldtimes.modtime=statbuf_r.st_mtime; if (utime(src,&oldtimes)) {}; - } - } - - if ((getuid()==0 || geteuid()!=0) && (!err)) - { - // if we are root, set fileowner to owner of 001.vdr/00001.ts file - char *spath=NULL; - if (asprintf(&spath,"%s/%s",directory,isTS ? "00001.ts" : "001.vdr")!=-1) - { - struct stat statbuf; - if (!stat(spath,&statbuf)) - { - if (chown(src,statbuf.st_uid, statbuf.st_gid)) {}; - } - free(spath); + SetFileUID(src); } } @@ -2324,15 +2326,7 @@ bool cMarkAdStandalone::CreatePidfile() FILE *pidfile=fopen(buf,"w+"); - if (getuid()==0 || geteuid()!=0) - { - // if we are root, set fileowner to owner of directory - struct stat statbuf; - if (!stat(directory,&statbuf)) - { - if (chown(buf,statbuf.st_uid, statbuf.st_gid)) {}; - } - } + SetFileUID(buf); free(buf); if (!pidfile) return false; @@ -2390,6 +2384,8 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, const MarkAdConfig * noticeHEADER=false; noticeFILLER=false; + errcnt=0; + sleepcnt=0; waittime=iwaittime=0; duplicate=false; @@ -2604,6 +2600,11 @@ cMarkAdStandalone::~cMarkAdStandalone() { if ((!abort) && (!duplicate)) { + if (errcnt>20) + { + isyslog("skipped %i bytes in video stream",errcnt); + } + gettimeofday(&tv2,&tz); time_t sec; suseconds_t usec; @@ -2706,6 +2707,8 @@ int usage(int svdrpport) " [height] range from 20 to %3i, default %3i\n" "-O --OSD\n" " markad sends an OSD-Message for start and end\n" + "-R --log2rec\n" + " write logfiles into recording directory\n" "-T --threads=<number>\n" " number of threads used for decoding, max. 16\n" " (default is the number of cpus)\n" @@ -2866,6 +2869,7 @@ int main(int argc, char *argv[]) {"genindex",0, 0, 'G'}, {"extractlogo", 1, 0, 'L'}, {"OSD",0,0,'O' }, + {"log2rec",0,0,'R'}, {"savelogo", 0, 0, 'S'}, {"threads", 1, 0, 'T'}, {"version", 0, 0, 'V'}, @@ -2873,7 +2877,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0} }; - c = getopt_long (argc, argv, "abcd:i:jl:nop:r:s:vBCGL:OST:V", + c = getopt_long (argc, argv, "abcd:i:jl:nop:r:s:vBCGL:ORST:V", long_options, &option_index); if (c == -1) break; @@ -3050,6 +3054,11 @@ int main(int argc, char *argv[]) config.OSD=true; break; + case 'R': + // --log2rec + LOG2REC=true; + break; + case 'S': // --savelogo break; @@ -3208,18 +3217,15 @@ int main(int argc, char *argv[]) { char *err=strerror(errno); fprintf(stderr, "%s\n",err); - esyslog("fork ERROR: %s",err); return 2; } if (pid != 0) { - tsyslog("forked to pid %d",pid); return 0; // initial program immediately returns } } if ( bFork ) { - tsyslog("(forked) pid %d", getpid()); if (chdir("/")==-1) { perror("chdir"); @@ -3286,11 +3292,11 @@ int main(int argc, char *argv[]) { if (setpriority(PRIO_PROCESS,0,niceLevel)==-1) { - esyslog("failed to set nice to %d",niceLevel); + fprintf(stderr,"failed to set nice to %d",niceLevel); } if (ioprio_set(1,getpid(),ioprio | ioprio_class << 13)==-1) { - esyslog("failed to set ioprio to %i,%i",ioprio_class,ioprio); + fprintf(stderr,"failed to set ioprio to %i,%i",ioprio_class,ioprio); } } @@ -3308,6 +3314,12 @@ int main(int argc, char *argv[]) return -1; } + if (access(recDir,W_OK|R_OK)==-1) + { + fprintf(stderr,"cannot access %s\n",recDir); + return -1; + } + // ignore some signals signal(SIGHUP, SIG_IGN); @@ -3320,6 +3332,17 @@ int main(int argc, char *argv[]) signal(SIGTSTP, signal_handler); signal(SIGCONT, signal_handler); + if (LOG2REC) + { + char *fbuf; + if (asprintf(&fbuf,"%s/markad.log",recDir)!=-1) + { + if (freopen(fbuf,"w+",stdout)) {}; + if (chown(fbuf,statbuf.st_uid, statbuf.st_gid)) {}; + free(fbuf); + } + } + cmasta = new cMarkAdStandalone(recDir,&config); if (!cmasta) return -1; diff --git a/command/markad-standalone.h b/command/markad-standalone.h index 25d19bb..412530a 100644 --- a/command/markad-standalone.h +++ b/command/markad-standalone.h @@ -214,6 +214,8 @@ unsigned Descriptor_Length: int iStop; // posttimer as index value int iStopCheck; // check position for iStop + int errcnt; // Skipped bytes in stream + bool setAudio51; // set audio to 5.1 in info bool setAudio20; // set audio to 2.0 in info bool setVideo43; // set video to 4:3 in info @@ -255,6 +257,7 @@ unsigned Descriptor_Length: bool CheckTS(); bool LoadInfo(); bool SaveInfo(); + bool SetFileUID(char *File); bool RegenerateIndex(); bool ProcessFile2ndPass(clMark **Mark1, clMark **Mark2, int Number, off_t Offset, int Frame, int Frames); bool ProcessFile(int Number); diff --git a/command/pes2es.cpp b/command/pes2es.cpp index 4c74e5f..c78afd6 100644 --- a/command/pes2es.cpp +++ b/command/pes2es.cpp @@ -88,20 +88,6 @@ void cMarkAdPES2ES::Process(MarkAdPid Pid, uchar *PESData, int PESSize, MarkAdPa peshdropt->Length; buf=&PESData[bpos]; buflen=PESSize-bpos; - if (peshdropt->PTSDTS>1) - { - struct PESHDROPTPTS *peshdroptpts=(struct PESHDROPTPTS *) &PESData[sizeof(struct PESHDR)+ - sizeof(struct PESHDROPT)]; - - if (peshdroptpts->Marker1 && peshdroptpts->Marker2 && peshdroptpts->Marker3) - { - unsigned int pts=0; - pts|=((peshdroptpts->PTS29_15_H<<7|peshdroptpts->PTS29_15_L)<<15); - pts|=(peshdroptpts->PTS14_0_H<<7|peshdroptpts->PTS14_0_L); - pts|=(peshdroptpts->PTS32_30<<30); - ESPkt->Timestamp=pts; - } - } } else { diff --git a/command/queue.h b/command/queue.h index 855355b..4efd197 100644 --- a/command/queue.h +++ b/command/queue.h @@ -18,7 +18,7 @@ typedef struct MarkAdPacket { uchar *Data; int Length; - unsigned int Timestamp; + int Skipped; bool Offcnt; } MarkAdPacket; diff --git a/command/ts2pkt.cpp b/command/ts2pkt.cpp index 3fbfa75..c3bbd15 100644 --- a/command/ts2pkt.cpp +++ b/command/ts2pkt.cpp @@ -128,6 +128,7 @@ bool cMarkAdTS2Pkt::Process(MarkAdPid Pid, uchar *TSData, int TSSize, MarkAdPack { if (counter==(int) tshdr->Counter) { + Pkt->Skipped+=TS_SIZE; return true; // duplicate paket -> just ignore } // sequence error @@ -142,6 +143,7 @@ bool cMarkAdTS2Pkt::Process(MarkAdPid Pid, uchar *TSData, int TSSize, MarkAdPack } if (!sync) { + Pkt->Skipped+=TS_SIZE; return false; // not synced } @@ -195,6 +197,7 @@ bool cMarkAdTS2Pkt::Process(MarkAdPid Pid, uchar *TSData, int TSSize, MarkAdPack { if ((buf[0]!=0) && (buf[1]!=0)) { + Pkt->Skipped+=TS_SIZE; sync=false; if (buflen<7) return false; // add a pseudo padding stream diff --git a/command/video.cpp b/command/video.cpp index 8dc509c..6f683bf 100644 --- a/command/video.cpp +++ b/command/video.cpp @@ -714,7 +714,7 @@ MarkAdPos *cMarkAdOverlap::Process(int FrameNumber, int Frames, bool BeforeAd) { if ((lastframenumber>0) && (!similarMaxCnt)) { - similarCutOff=50000; + similarCutOff=60000; similarMaxCnt=4; } diff --git a/plugin/markad.cpp b/plugin/markad.cpp index daf1193..7e7437a 100644 --- a/plugin/markad.cpp +++ b/plugin/markad.cpp @@ -38,6 +38,7 @@ cPluginMarkAd::cPluginMarkAd(void) setup.HideMainMenuEntry=false; setup.SecondPass=true; setup.IOPrioClass=1; + setup.Log2Rec=false; } cPluginMarkAd::~cPluginMarkAd() @@ -188,6 +189,7 @@ bool cPluginMarkAd::SetupParse(const char *Name, const char *Value) else if (!strcasecmp(Name,"SecondPass")) setup.SecondPass=atoi(Value); else if (!strcasecmp(Name,"IOPrioClass")) setup.IOPrioClass=atoi(Value); else if (!strcasecmp(Name,"AC3Always")) setup.AC3Always=atoi(Value); + else if (!strcasecmp(Name,"Log2Rec")) setup.Log2Rec=atoi(Value); else return false; return true; } diff --git a/plugin/po/de_DE.po b/plugin/po/de_DE.po index 1441bc6..6ced106 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-10-10 15:33+0200\n" +"POT-Creation-Date: 2010-11-24 19:57+0100\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" @@ -96,6 +96,9 @@ msgstr "alte Marken sichern" msgid "verbose logging" msgstr "ausführliches Logging" +msgid "log to recording directory" +msgstr "Log ins Aufnahmeverzeichnis" + msgid "hide mainmenu entry" msgstr "Hauptmenüeintrag verstecken" diff --git a/plugin/po/it_IT.po b/plugin/po/it_IT.po index 8f60382..3c97af0 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-10-10 15:33+0200\n" +"POT-Creation-Date: 2010-11-24 19:57+0100\n" "PO-Revision-Date: 2010-08-09 20:05+0100\n" "Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n" "Language-Team: <vdr@linuxtv.org>\n" @@ -99,6 +99,9 @@ msgstr "Salva marcatori" msgid "verbose logging" msgstr "Log dettagliato" +msgid "log to recording directory" +msgstr "" + msgid "hide mainmenu entry" msgstr "" diff --git a/plugin/setup.cpp b/plugin/setup.cpp index 28af746..e87b7db 100644 --- a/plugin/setup.cpp +++ b/plugin/setup.cpp @@ -23,6 +23,7 @@ cSetupMarkAd::cSetupMarkAd(struct setup *Setup) hidemainmenuentry=setup->HideMainMenuEntry; secondpass=setup->SecondPass; ac3always=setup->AC3Always; + log2rec=setup->Log2Rec; processTexts[0]=tr("after"); processTexts[1]=tr("during"); @@ -53,6 +54,7 @@ void cSetupMarkAd::write(void) Add(new cMenuEditBoolItem(tr("OSD message"),&osdmsg)); Add(new cMenuEditBoolItem(tr("backup marks"),&backupmarks)); Add(new cMenuEditBoolItem(tr("verbose logging"),&verbose)); + Add(new cMenuEditBoolItem(tr("log to recording directory"),&log2rec)); Add(new cMenuEditBoolItem(tr("hide mainmenu entry"),&hidemainmenuentry)); Display(); @@ -95,6 +97,7 @@ void cSetupMarkAd::Store(void) SetupStore("HideMainMenuEntry",hidemainmenuentry); SetupStore("IOPrioClass",ioprioclass); SetupStore("AC3Always",ac3always); + SetupStore("Log2Rec",log2rec); setup->ProcessDuring=(bool) processduring; setup->whileRecording=(bool) whilerecording; @@ -108,4 +111,5 @@ void cSetupMarkAd::Store(void) setup->HideMainMenuEntry=(bool) hidemainmenuentry; setup->IOPrioClass=ioprioclass; setup->AC3Always=ac3always; + setup->Log2Rec=log2rec; } diff --git a/plugin/setup.h b/plugin/setup.h index 736ef8a..cd9cc0f 100644 --- a/plugin/setup.h +++ b/plugin/setup.h @@ -23,6 +23,7 @@ struct setup bool SecondPass; bool AC3Always; bool HideMainMenuEntry; + bool Log2Rec; }; class cSetupMarkAd : public cMenuSetupPage @@ -43,6 +44,7 @@ private: int secondpass; int hidemainmenuentry; int ac3always; + int log2rec; void write(void); protected: virtual void Store(void); diff --git a/plugin/status.cpp b/plugin/status.cpp index 6d62e0a..31ae31a 100644 --- a/plugin/status.cpp +++ b/plugin/status.cpp @@ -71,7 +71,7 @@ bool cStatusMarkAd::Start(const char *FileName, const char *Name, const bool Dir { if ((Direct) && (Get(FileName)!=-1)) return false; - cString cmd = cString::sprintf("\"%s\"/markad %s%s%s%s%s%s%s -r %i -l \"%s\" %s \"%s\"",bindir, + cString cmd = cString::sprintf("\"%s\"/markad %s%s%s%s%s%s%s%s -r %i -l \"%s\" %s \"%s\"",bindir, setup->Verbose ? " -v " : "", setup->BackupMarks ? " -B " : "", setup->GenIndex ? " -G " : "", @@ -79,6 +79,7 @@ bool cStatusMarkAd::Start(const char *FileName, const char *Name, const bool Dir setup->NoMargins ? " -i 4 " : "", setup->SecondPass ? "" : " --pass1only ", setup->AC3Always ? " -a " : "", + setup->Log2Rec ? " -R " : "", setup->IOPrioClass+1, logodir,Direct ? "-O after" : "--online=2 before", FileName); dsyslog("markad: executing %s",*cmd); |