summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile9
-rw-r--r--audio.cpp103
-rw-r--r--audio.h20
-rw-r--r--decoder.cpp35
-rw-r--r--decoder.h3
-rw-r--r--demux.cpp19
-rw-r--r--demux.h2
-rw-r--r--global.h7
-rw-r--r--markad-standalone.cpp87
-rw-r--r--markad-standalone.h3
-rw-r--r--pes2es.cpp4
-rw-r--r--pes2es.h2
-rw-r--r--queue.cpp7
-rw-r--r--queue.h3
-rw-r--r--recv.cpp393
-rw-r--r--recv.h95
-rw-r--r--status.cpp47
-rw-r--r--status.h4
-rw-r--r--ts2pkt.cpp17
-rw-r--r--ts2pkt.h3
-rw-r--r--vdr2pkt.cpp4
-rw-r--r--vdr2pkt.h2
-rw-r--r--video.cpp26
-rw-r--r--video.h8
24 files changed, 237 insertions, 666 deletions
diff --git a/Makefile b/Makefile
index 40e8961..4df7847 100644
--- a/Makefile
+++ b/Makefile
@@ -55,9 +55,8 @@ LIBS-CMD += $(shell $(PKG-CONFIG) --libs $(PKG-LIBS))
### The object files (add further files here):
-OBJS-CMD = markad-standalone.o decoder.o marks.o
-OBJS-COMMON = streaminfo.o video.o audio.o demux.o queue.o vdr2pkt.o ts2pkt.o pes2es.o
-OBJS = $(PLUGIN).o recv.o status.o $(OBJS-COMMON)
+OBJS-CMD = markad-standalone.o decoder.o marks.o streaminfo.o video.o audio.o demux.o queue.o vdr2pkt.o ts2pkt.o pes2es.o
+OBJS = $(PLUGIN).o status.o
### The main target:
@@ -109,8 +108,8 @@ libvdr-$(PLUGIN).so: $(OBJS)
$(CXX) $(CXXFLAGS) -shared $(OBJS) $(LIBS) -o $@
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
-$(PLUGIN): $(OBJS-COMMON) $(OBJS-CMD)
- $(CXX) $(CXXFLAGS) $(OBJS-COMMON) $(OBJS-CMD) $(LIBS-CMD) -o $@
+$(PLUGIN): $(OBJS-CMD)
+ $(CXX) $(CXXFLAGS) $(OBJS-CMD) $(LIBS-CMD) -o $@
dist: clean
@-rm -rf $(TMPDIR)/$(ARCHIVE)
diff --git a/audio.cpp b/audio.cpp
index ec5ae94..77729e7 100644
--- a/audio.cpp
+++ b/audio.cpp
@@ -8,13 +8,16 @@
#include "audio.h"
-cMarkAdAudio::cMarkAdAudio(int RecvNumber,MarkAdContext *maContext)
+cMarkAdAudio::cMarkAdAudio(MarkAdContext *maContext)
{
macontext=maContext;
- recvnumber=RecvNumber;
mark.Comment=NULL;
mark.Position=0;
channels=0;
+#if 0
+ lastiframe_gain=-ANALYZEFRAMES;
+#endif
+ lastiframe_silence=-1;
}
cMarkAdAudio::~cMarkAdAudio()
@@ -53,6 +56,78 @@ bool cMarkAdAudio::AddMark(int Position, const char *Comment)
return true;
}
+bool cMarkAdAudio::SilenceDetection()
+{
+ if (!macontext->Audio.Data.Valid) return false;
+ if (lastiframe_silence==lastiframe) return false; // we already detected silence for this frame
+
+ int samples=macontext->Audio.Data.SampleBufLen/
+ sizeof(*macontext->Audio.Data.SampleBuf)/
+ macontext->Audio.Info.Channels;
+
+ short left,right;
+ int lowvalcount=0;
+ for (int i=0; i<samples; i++)
+ {
+ left=macontext->Audio.Data.SampleBuf[0+(i*2)];
+ right=macontext->Audio.Data.SampleBuf[1+(i*2)];
+
+ if ((abs(left)+abs(right))<CUT_VAL)
+ {
+ lowvalcount++;
+ if (lowvalcount>MIN_LOWVALS)
+ {
+ lastiframe_silence=lastiframe;
+ return true;
+ }
+ }
+ else
+ {
+ lowvalcount=0;
+ }
+ }
+ return false;
+}
+
+#if 0
+bool cMarkAdAudio::AnalyzeGain()
+{
+ if (!macontext->Audio.Data.Valid) return false;
+
+ int samples=macontext->Audio.Data.SampleBufLen/
+ sizeof(*macontext->Audio.Data.SampleBuf)/
+ macontext->Audio.Info.Channels;
+
+ double left[samples];
+ double right[samples];
+
+ for (int i=0; i<samples; i++)
+ {
+ left[i]=macontext->Audio.Data.SampleBuf[0+(i*2)];
+ right[i]=macontext->Audio.Data.SampleBuf[1+(i*2)];
+ }
+
+ if ((lastiframe-lastiframe_gain)>ANALYZEFRAMES)
+ {
+ if (lastiframe_gain>0)
+ {
+ double dgain,gain = audiogain.GetGain();
+ dgain=gain-lastgain;
+ printf("%05i %+.2f db %+.2f db\n",lastiframe_gain,gain,lastgain);
+ lastgain=gain;
+ }
+ audiogain.Init(macontext->Audio.Info.SampleRate);
+ lastiframe_gain=lastiframe;
+ }
+ if (audiogain.AnalyzeSamples(left,right,samples,2)!=GAIN_ANALYSIS_OK)
+ {
+ lastiframe_gain=-ANALYZEFRAMES;
+ }
+
+ return true;
+}
+#endif
+
bool cMarkAdAudio::ChannelChange(int a, int b)
{
if ((a==0) || (b==0)) return false;
@@ -64,15 +139,33 @@ MarkAdMark *cMarkAdAudio::Process(int LastIFrame)
{
ResetMark();
if (!LastIFrame) return NULL;
+ lastiframe=LastIFrame;
+
+#if 0
+ AnalyzeGain();
+#endif
+ if (macontext->Audio.Options.AudioSilenceDetection)
+ {
+ if (SilenceDetection())
+ {
+ char *buf=NULL;
+ if (asprintf(&buf,"audio channel silence detecion (%i)",lastiframe)!=-1)
+ {
+ isyslog(buf);
+ AddMark(lastiframe,buf);
+ free(buf);
+ }
+ }
+ }
if (ChannelChange(macontext->Audio.Info.Channels,channels))
{
char *buf=NULL;
if (asprintf(&buf,"audio channel change from %i to %i (%i)", channels,
- macontext->Audio.Info.Channels,LastIFrame)!=-1)
+ macontext->Audio.Info.Channels,lastiframe)!=-1)
{
- isyslog("markad [%i]: %s",recvnumber, buf);
- AddMark(LastIFrame,buf);
+ isyslog(buf);
+ AddMark(lastiframe,buf);
free(buf);
}
}
diff --git a/audio.h b/audio.h
index 69d0666..babbeee 100644
--- a/audio.h
+++ b/audio.h
@@ -3,7 +3,6 @@
*
* See the README file for copyright information and how to reach the author.
*
- * $Id$
*/
#ifndef __audio_h_
@@ -13,22 +12,37 @@
#include <netinet/in.h> // for htonl
#include "global.h"
+#if 0
+#include "audio_gain_analysis.h"
+#endif
class cMarkAdAudio
{
private:
int lastiframe;
- int recvnumber;
MarkAdContext *macontext;
MarkAdMark mark;
void ResetMark();
bool AddMark(int Position, const char *Comment);
+#define CUT_VAL 10
+#define MIN_LOWVALS 3
+ bool SilenceDetection();
+ int lastiframe_silence;
+
+#if 0
+#define ANALYZEFRAMES 1
+ int lastiframe_gain;
+ double lastgain;
+ cMarkAdAudioGainAnalysis audiogain;
+ bool AnalyzeGain();
+#endif
+
int channels;
bool ChannelChange(int a, int b);
public:
- cMarkAdAudio(int RecvNumber,MarkAdContext *maContext);
+ cMarkAdAudio(MarkAdContext *maContext);
~cMarkAdAudio();
MarkAdMark *Process(int LastIFrame);
};
diff --git a/decoder.cpp b/decoder.cpp
index d2d8d18..6b11ae8 100644
--- a/decoder.cpp
+++ b/decoder.cpp
@@ -7,9 +7,8 @@
#include "decoder.h"
-cMarkAdDecoder::cMarkAdDecoder(int RecvNumber, bool useH264, bool useMP2, bool hasAC3)
+cMarkAdDecoder::cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3)
{
- recvnumber=RecvNumber;
avcodec_init();
avcodec_register_all();
@@ -27,7 +26,7 @@ cMarkAdDecoder::cMarkAdDecoder(int RecvNumber, bool useH264, bool useMP2, bool h
cpucount=CPU_COUNT(&cpumask);
}
- isyslog("markad [%i]: using libavcodec.so.%s with %i threads",recvnumber,
+ isyslog("using libavcodec.so.%s with %i threads",
AV_STRINGIFY(LIBAVCODEC_VERSION),cpucount);
if (useMP2)
@@ -42,19 +41,19 @@ cMarkAdDecoder::cMarkAdDecoder(int RecvNumber, bool useH264, bool useMP2, bool h
mp2_context->thread_count=cpucount;
if (avcodec_open(mp2_context, mp2_codec) < 0)
{
- esyslog("markad [%i]: could not open codec 0x%05x",recvnumber,mp2_codecid);
+ esyslog("could not open codec 0x%05x",mp2_codecid);
av_free(mp2_context);
mp2_context=NULL;
}
}
else
{
- esyslog("markad [%i]: could not allocate mp2 context",recvnumber);
+ esyslog("could not allocate mp2 context");
}
}
else
{
- esyslog("markad [%i]: codec 0x%05x not found",recvnumber,mp2_codecid);
+ esyslog("codec 0x%05x not found",mp2_codecid);
mp2_context=NULL;
}
}
@@ -75,19 +74,19 @@ cMarkAdDecoder::cMarkAdDecoder(int RecvNumber, bool useH264, bool useMP2, bool h
ac3_context->thread_count=cpucount;
if (avcodec_open(ac3_context, ac3_codec) < 0)
{
- esyslog("markad [%i]: could not open codec 0x%05x",recvnumber,ac3_codecid);
+ esyslog("could not open codec 0x%05x",ac3_codecid);
av_free(ac3_context);
ac3_context=NULL;
}
}
else
{
- esyslog("markad [%i]: could not allocate ac3 context",recvnumber);
+ esyslog("could not allocate ac3 context");
}
}
else
{
- esyslog("markad [%i]: codec 0x%05x not found",recvnumber,ac3_codecid);
+ esyslog("codec 0x%05x not found",ac3_codecid);
ac3_context=NULL;
}
}
@@ -162,24 +161,24 @@ cMarkAdDecoder::cMarkAdDecoder(int RecvNumber, bool useH264, bool useMP2, bool h
}
if (ret < 0)
{
- esyslog("markad [%i]: could not open codec 0x%05x",recvnumber,video_codecid);
+ esyslog("could not open codec 0x%05x",video_codecid);
av_free(video_context);
video_context=NULL;
}
else
{
- isyslog("markad [%i]: using codec %s",recvnumber,video_codec->long_name);
+ isyslog("using codec %s",video_codec->long_name);
if (video_context->hwaccel)
{
- isyslog("markad [%i]: using hwaccel %s",recvnumber,video_context->hwaccel->name);
+ isyslog("using hwaccel %s",video_context->hwaccel->name);
}
video_frame = avcodec_alloc_frame();
if (!video_frame)
{
- esyslog("markad [%i]: could not allocate frame",recvnumber);
+ esyslog("could not allocate frame");
avcodec_close(video_context);
av_free(video_context);
video_context=NULL;
@@ -188,12 +187,12 @@ cMarkAdDecoder::cMarkAdDecoder(int RecvNumber, bool useH264, bool useMP2, bool h
}
else
{
- esyslog("markad [%i]: could not allocate video context",recvnumber);
+ esyslog("could not allocate video context");
}
}
else
{
- esyslog("markad [%i]: codec 0x%05x not found",recvnumber,video_codecid);
+ esyslog("codec 0x%05x not found",video_codecid);
video_context=NULL;
}
@@ -258,7 +257,7 @@ bool cMarkAdDecoder::DecodeMP2(MarkAdContext *maContext, uchar *espkt, int eslen
#endif
if (len<0)
{
- esyslog("markad [%i]: error decoding mp2",recvnumber);
+ esyslog("error decoding mp2");
break;
}
if (audiobufsize>0)
@@ -312,7 +311,7 @@ bool cMarkAdDecoder::DecodeAC3(MarkAdContext *maContext, uchar *espkt, int eslen
#endif
if (len<0)
{
- esyslog("markad [%i]: error decoding ac3",recvnumber);
+ esyslog("error decoding ac3");
break;
}
if (audiobufsize>0)
@@ -403,7 +402,7 @@ bool cMarkAdDecoder::DecodeVideo(MarkAdContext *maContext,uchar *pkt, int plen)
#endif
if (len<0)
{
- esyslog("markad [%i]: error decoding video",recvnumber);
+ esyslog("error decoding video");
break;
}
else
diff --git a/decoder.h b/decoder.h
index 20734cc..1d75c7c 100644
--- a/decoder.h
+++ b/decoder.h
@@ -40,7 +40,6 @@ extern "C"
class cMarkAdDecoder
{
private:
- int recvnumber;
int16_t *audiobuf;
int audiobufsize;
@@ -60,7 +59,7 @@ public:
bool DecodeVideo(MarkAdContext *maContext, uchar *pkt, int plen);
bool DecodeMP2(MarkAdContext *maContext, uchar *espkt, int eslen);
bool DecodeAC3(MarkAdContext *maContext, uchar *espkt, int eslen);
- cMarkAdDecoder(int recvnumber, bool useH264, bool useMP2, bool hasAC3);
+ cMarkAdDecoder(bool useH264, bool useMP2, bool hasAC3);
~cMarkAdDecoder();
};
diff --git a/demux.cpp b/demux.cpp
index e0c89f7..711f620 100644
--- a/demux.cpp
+++ b/demux.cpp
@@ -7,16 +7,15 @@
#include "demux.h"
-cMarkAdDemux::cMarkAdDemux(int RecvNumber)
+cMarkAdDemux::cMarkAdDemux()
{
- recvnumber=RecvNumber;
ts2pkt=NULL;
vdr2pkt=NULL;
pes2audioes=NULL;
pes2videoes=NULL;
pause=false;
pause_retval=0;
- queue = new cMarkAdPaketQueue(RecvNumber,"Demux",376);
+ queue = new cMarkAdPaketQueue("Demux",376);
}
cMarkAdDemux::~cMarkAdDemux()
@@ -37,14 +36,14 @@ void cMarkAdDemux::ProcessVDR(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt
uchar *pkt;
int pktlen;
- if (!vdr2pkt) vdr2pkt= new cMarkAdVDR2Pkt(recvnumber);
+ if (!vdr2pkt) vdr2pkt= new cMarkAdVDR2Pkt();
if (!vdr2pkt) return;
vdr2pkt->Process(Pid,Data,Count,&pkt,&pktlen);
if ((Pid.Type==MARKAD_PIDTYPE_AUDIO_AC3) || (Pid.Type==MARKAD_PIDTYPE_AUDIO_MP2))
{
- if (!pes2audioes) pes2audioes=new cMarkAdPES2ES(recvnumber,"PES2ES audio");
+ if (!pes2audioes) pes2audioes=new cMarkAdPES2ES("PES2ES audio");
if (!pes2audioes) return;
pes2audioes->Process(Pid,pkt,pktlen,Pkt,PktLen);
}
@@ -55,11 +54,11 @@ void cMarkAdDemux::ProcessVDR(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt
{
if (Pid.Type==MARKAD_PIDTYPE_VIDEO_H264)
{
- pes2videoes=new cMarkAdPES2ES(recvnumber,"PES2H264ES video",393216);
+ pes2videoes=new cMarkAdPES2ES("PES2H264ES video",393216);
}
else
{
- pes2videoes=new cMarkAdPES2ES(recvnumber,"PES2ES video",65536);
+ pes2videoes=new cMarkAdPES2ES("PES2ES video",65536);
}
}
if (!pes2videoes) return;
@@ -82,11 +81,11 @@ void cMarkAdDemux::ProcessTS(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt,
{
if (Pid.Type==MARKAD_PIDTYPE_VIDEO_H264)
{
- ts2pkt=new cMarkAdTS2Pkt(recvnumber,"TS2H264",393216);
+ ts2pkt=new cMarkAdTS2Pkt("TS2H264",393216);
}
else
{
- ts2pkt=new cMarkAdTS2Pkt(recvnumber,"TS2PKT",262144);
+ ts2pkt=new cMarkAdTS2Pkt("TS2PKT",262144);
}
}
if (!ts2pkt) return;
@@ -95,7 +94,7 @@ void cMarkAdDemux::ProcessTS(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt,
if ((Pid.Type==MARKAD_PIDTYPE_AUDIO_AC3) || (Pid.Type==MARKAD_PIDTYPE_AUDIO_MP2))
{
- if (!pes2audioes) pes2audioes=new cMarkAdPES2ES(recvnumber,"PES2ES audio");
+ if (!pes2audioes) pes2audioes=new cMarkAdPES2ES("PES2ES audio");
if (!pes2audioes) return;
pes2audioes->Process(Pid,pkt,pktlen,Pkt,PktLen);
}
diff --git a/demux.h b/demux.h
index e712a83..e70b575 100644
--- a/demux.h
+++ b/demux.h
@@ -42,7 +42,7 @@ private:
void ProcessTS(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt, int *PktLen);
void ProcessVDR(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt, int *PktLen);
public:
- cMarkAdDemux(int RecvNumber);
+ cMarkAdDemux();
~cMarkAdDemux();
int Process(MarkAdPid Pid, uchar *Data, int Count, uchar **Pkt, int *PktLen);
};
diff --git a/global.h b/global.h
index 5b65605..bffbcaa 100644
--- a/global.h
+++ b/global.h
@@ -54,7 +54,7 @@ typedef struct MarkAdContext
int LogoExtraction;
int LogoWidth;
int LogoHeight;
- MarkAdAspectRatio AspectRatioHint;
+ bool ASD;
} StandAlone;
struct General
@@ -92,6 +92,11 @@ typedef struct MarkAdContext
struct Audio
{
+ struct Options
+ {
+ bool AudioSilenceDetection;
+ } Options;
+
struct Info
{
int Channels; // number of audio channels
diff --git a/markad-standalone.cpp b/markad-standalone.cpp
index 3d7849f..2521986 100644
--- a/markad-standalone.cpp
+++ b/markad-standalone.cpp
@@ -24,8 +24,10 @@ void syslog_with_tid(int priority, const char *format, ...)
}
else
{
+ char fmt[255];
+ snprintf(fmt, sizeof(fmt), "markad: [%d] %s", getpid(), format);
va_start(ap, format);
- vprintf(format,ap);
+ vprintf(fmt,ap);
va_end(ap);
printf("\n");
}
@@ -39,7 +41,7 @@ void cMarkAdStandalone::AddStartMark()
if (asprintf(&buf,"start of recording (0)")!=-1)
{
marks.Add(0,buf);
- isyslog("markad [%i]: %s",recvnumber,buf);
+ isyslog(buf);
free(buf);
}
}
@@ -135,14 +137,14 @@ void cMarkAdStandalone::CheckIndex()
if (maxframes<(framecnt+200))
{
// now we sleep and hopefully the index will grow
- dsyslog("markad [%i]: we are too fast, waiting %i secs",recvnumber,WAITTIME);
+ dsyslog("we are too fast, waiting %i secs",WAITTIME);
sleep(WAITTIME);
if (errno==EINTR) return;
sleepcnt++;
if (sleepcnt>=2)
{
- esyslog("markad [%i]: no new data after %i seconds, skipping wait!",
- recvnumber,sleepcnt*WAITTIME);
+ esyslog("no new data after %i seconds, skipping wait!",
+ sleepcnt*WAITTIME);
notenough=false; // something went wrong?
}
}
@@ -183,7 +185,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number)
if (abort) return false;
int dataread;
- dsyslog("markad [%i]: processing file %05i",recvnumber,Number);
+ dsyslog("processing file %05i",Number);
while ((dataread=read(f,data,datalen))>0)
{
@@ -215,7 +217,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number)
{
if (macontext.General.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264)
{
- isyslog("markad [%i]: HDTV %i%c",recvnumber,
+ isyslog("HDTV %i%c",
macontext.Video.Info.Height,macontext.Video.Info.Interlaced ? 'i' : 'p');
}
if (!marks.Load(Directory,macontext.Video.Info.FramesPerSecond,isTS))
@@ -276,7 +278,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number)
{
if ((!isTS) && (!noticeVDR_AC3))
{
- dsyslog("markad [%i]: found AC3",recvnumber);
+ dsyslog("found AC3");
if (mp2_demux)
{
delete mp2_demux;
@@ -317,7 +319,7 @@ bool cMarkAdStandalone::ProcessFile(const char *Directory, int Number)
{
if ((!isTS) && (!noticeVDR_MP2))
{
- dsyslog("markad [%i]: found MP2",recvnumber);
+ dsyslog("found MP2");
noticeVDR_MP2=true;
}
mark=audio->Process(lastiframe);
@@ -359,7 +361,7 @@ void cMarkAdStandalone::Process(const char *Directory)
}
if (abort)
{
- isyslog("markad [%i]: aborted",recvnumber);
+ isyslog("aborted");
}
else
{
@@ -373,7 +375,7 @@ void cMarkAdStandalone::Process(const char *Directory)
{
tempmark.Comment=buf;
AddMark(&tempmark);
- isyslog("markad [%i]: %s",recvnumber,buf);
+ isyslog(buf);
free(buf);
}
}
@@ -393,7 +395,7 @@ void cMarkAdStandalone::Process(const char *Directory)
{
if (bIndexError)
{
- esyslog("markad [%i]: index doesn't match marks%s",recvnumber,
+ esyslog("index doesn't match marks%s",
isTS ? ", please report this" : ", please run genindex");
}
}
@@ -403,7 +405,7 @@ void cMarkAdStandalone::Process(const char *Directory)
if (etime>0) ftime=framecnt/etime;
if (macontext.Video.Info.FramesPerSecond>0)
ptime=ftime/macontext.Video.Info.FramesPerSecond;
- isyslog("markad [%i]: elapsed time %.2fs, %i frames, %.1f fps, %.1f pps",recvnumber,
+ isyslog("elapsed time %.2fs, %i frames, %.1f fps, %.1f pps",
etime,framecnt,ftime,ptime);
}
@@ -459,7 +461,7 @@ bool cMarkAdStandalone::LoadInfo(const char *Directory)
{
// we dont have 4:3, so ignore AspectRatio-Changes
macontext.Video.Options.IgnoreAspectRatio=true;
- isyslog("markad [%i]: broadcasts aspectratio is not 4:3, disabling aspect ratio",recvnumber);
+ isyslog("broadcasts aspectratio is not 4:3, disabling aspect ratio");
}
}
@@ -471,13 +473,13 @@ bool cMarkAdStandalone::LoadInfo(const char *Directory)
if (strchr(descr,'2'))
{
macontext.General.DPid.Num=0;
- isyslog("markad [%i]: broadcast with DolbyDigital2.0, disabling AC3 decoding",recvnumber);
+ isyslog("broadcast with DolbyDigital2.0, disabling AC3 decoding");
}
// if we have DolbyDigital 5.1 disable video decoding
if (strchr(descr,'5'))
{
bDecodeVideo=false;
- isyslog("markad [%i]: broadcast with DolbyDigital5.1, disabling video decoding",recvnumber);
+ isyslog("broadcast with DolbyDigital5.1, disabling video decoding");
}
}
@@ -679,10 +681,9 @@ const char cMarkAdStandalone::frametypes[8]={'?','I','P','B','D','S','s','b'};
cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, int LogoExtraction,
int LogoWidth, int LogoHeight, bool DecodeVideo,
bool DecodeAudio, bool IgnoreVideoInfo, bool IgnoreAudioInfo,
- const char *LogoDir, const char *MarkFileName)
+ const char *LogoDir, const char *MarkFileName, bool ASD)
{
- recvnumber=255;
abort=false;
noticeVDR_MP2=false;
@@ -696,6 +697,7 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
macontext.StandAlone.LogoExtraction=LogoExtraction;
macontext.StandAlone.LogoWidth=LogoWidth;
macontext.StandAlone.LogoHeight=LogoHeight;
+ macontext.Audio.Options.AudioSilenceDetection=ASD;
bDecodeVideo=DecodeVideo;
bDecodeAudio=DecodeAudio;
@@ -715,23 +717,23 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
macontext.General.DPid.Type=MARKAD_PIDTYPE_AUDIO_AC3;
macontext.General.APid.Type=MARKAD_PIDTYPE_AUDIO_MP2;
- isyslog("markad [%i]: starting v%s",recvnumber,VERSION);
+ isyslog("starting v%s",VERSION);
if (!bDecodeAudio)
{
- isyslog("markad [%i]: audio decoding disabled by user",recvnumber);
+ isyslog("audio decoding disabled by user");
}
if (!bDecodeVideo)
{
- isyslog("markad [%i]: video decoding disabled by user",recvnumber);
+ isyslog("video decoding disabled by user");
}
if (bIgnoreAudioInfo)
{
- isyslog("markad [%i]: audio info usage disabled by user",recvnumber);
+ isyslog("audio info usage disabled by user");
}
if (bIgnoreVideoInfo)
{
- isyslog("markad [%i]: video info usage disabled by user",recvnumber);
+ isyslog("video info usage disabled by user");
}
if (!CheckTS(Directory))
@@ -749,7 +751,7 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
{
if (!CheckPATPMT(Directory))
{
- esyslog("markad [%i]: no PAT/PMT found -> nothing to process",recvnumber);
+ esyslog("no PAT/PMT found -> nothing to process");
abort=true;
}
macontext.General.APid.Num=0;
@@ -774,7 +776,7 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
if (!LoadInfo(Directory))
{
- if (bDecodeVideo) esyslog("markad [%i]: failed loading info - logo detection disabled",recvnumber);
+ if (bDecodeVideo) esyslog("failed loading info - logo detection disabled");
}
if (MarkFileName[0]) marks.SetFileName(MarkFileName);
@@ -783,16 +785,16 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
{
if (isTS)
{
- dsyslog("markad [%i]: using %s-video (0x%04x)",recvnumber,
+ dsyslog("using %s-video (0x%04x)",
macontext.General.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264 ? "H264": "H262",
macontext.General.VPid.Num);
}
else
{
- dsyslog("markad [%i]: using %s-video",
- recvnumber,macontext.General.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264 ? "H264": "H262");
+ dsyslog("using %s-video",
+ macontext.General.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264 ? "H264": "H262");
}
- video_demux = new cMarkAdDemux(recvnumber);
+ video_demux = new cMarkAdDemux();
}
else
{
@@ -802,8 +804,8 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
if (macontext.General.APid.Num)
{
if (macontext.General.APid.Num!=-1)
- dsyslog("markad [%i]: using MP2 (0x%04x)",recvnumber,macontext.General.APid.Num);
- mp2_demux = new cMarkAdDemux(recvnumber);
+ dsyslog("using MP2 (0x%04x)",macontext.General.APid.Num);
+ mp2_demux = new cMarkAdDemux();
}
else
{
@@ -813,8 +815,8 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
if (macontext.General.DPid.Num)
{
if (macontext.General.DPid.Num!=-1)
- dsyslog("markad [%i]: using AC3 (0x%04x)",recvnumber,macontext.General.DPid.Num);
- ac3_demux = new cMarkAdDemux(recvnumber);
+ dsyslog("using AC3 (0x%04x)",macontext.General.DPid.Num);
+ ac3_demux = new cMarkAdDemux();
}
else
{
@@ -823,10 +825,10 @@ cMarkAdStandalone::cMarkAdStandalone(const char *Directory, bool BackupMarks, in
if (!abort)
{
- decoder = new cMarkAdDecoder(recvnumber,macontext.General.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264,
+ decoder = new cMarkAdDecoder(macontext.General.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264,
macontext.General.APid.Num!=0,macontext.General.DPid.Num!=0);
- video = new cMarkAdVideo(recvnumber,&macontext);
- audio = new cMarkAdAudio(recvnumber,&macontext);
+ video = new cMarkAdVideo(&macontext);
+ audio = new cMarkAdAudio(&macontext);
streaminfo = new cMarkAdStreamInfo;
}
else
@@ -902,6 +904,8 @@ int usage()
" markad sends an OSD-Message for start and end\n"
"-V --version\n"
" print version-info and exit\n"
+ " --asd\n"
+ " enable audio silence detecion\n"
" --markfile=<markfilename>\n"
" set a different markfile-name\n"
"\ncmd: one of\n"
@@ -935,7 +939,9 @@ void signal_handler(int sig)
int main(int argc, char *argv[])
{
int c;
- bool bAfter=false,bBefore=false,bEdited=false,bFork=false,bNice=false,bImmediateCall=false;
+ bool bAfter=false,bBefore=false,bEdited=false;
+ bool bFork=false,bNice=false,bImmediateCall=false;
+ bool bASD=false;
int niceLevel = 19;
char *recDir=NULL;
char *tok,*str;
@@ -1188,6 +1194,7 @@ int main(int argc, char *argv[])
break;
case 6: // --asd
+ bASD=true;
break;
case 7: // --pass3only
@@ -1253,13 +1260,13 @@ int main(int argc, char *argv[])
}
if (pid != 0)
{
- isyslog("markad forked to pid %d",pid);
+ isyslog("forked to pid %d",pid);
return 0; // initial program immediately returns
}
}
if ( bFork )
{
- isyslog("markad (forked) pid: %d", getpid());
+ isyslog("(forked) pid %d", getpid());
if (chdir("/")==-1)
{
perror("chdir");
@@ -1354,7 +1361,7 @@ int main(int argc, char *argv[])
cmasta = new cMarkAdStandalone(recDir,bBackupMarks, logoExtraction, logoWidth, logoHeight,
bDecodeVideo,bDecodeAudio,bIgnoreVideoInfo,bIgnoreAudioInfo,
- logoDirectory,markFileName);
+ logoDirectory,markFileName,bASD);
if (!cmasta) return -1;
// ignore some signals
diff --git a/markad-standalone.h b/markad-standalone.h
index 7e5a079..9e1c9fb 100644
--- a/markad-standalone.h
+++ b/markad-standalone.h
@@ -152,7 +152,6 @@ unsigned Descriptor_Length:
cMarkAdStreamInfo *streaminfo;
MarkAdContext macontext;
- int recvnumber;
bool isTS;
int MaxFiles;
@@ -198,7 +197,7 @@ public:
cMarkAdStandalone(const char *Directory, bool BackupMarks, int LogoExtraction,
int LogoWidth, int LogoHeight, bool DecodeVideo,
bool DecodeAudio, bool IgnoreVideoInfo, bool IgnoreAudioInfo,
- const char *LogoDir, const char *MarkFileName);
+ const char *LogoDir, const char *MarkFileName, bool ASD);
~cMarkAdStandalone();
};
diff --git a/pes2es.cpp b/pes2es.cpp
index 8323794..f9bb1c7 100644
--- a/pes2es.cpp
+++ b/pes2es.cpp
@@ -7,9 +7,9 @@
#include "pes2es.h"
-cMarkAdPES2ES::cMarkAdPES2ES(int RecvNumber, const char *QueueName, int QueueSize)
+cMarkAdPES2ES::cMarkAdPES2ES(const char *QueueName, int QueueSize)
{
- queue = new cMarkAdPaketQueue(RecvNumber,QueueName,QueueSize);
+ queue = new cMarkAdPaketQueue(QueueName,QueueSize);
type=0;
}
diff --git a/pes2es.h b/pes2es.h
index 6509821..9a644c4 100644
--- a/pes2es.h
+++ b/pes2es.h
@@ -70,7 +70,7 @@ unsigned Length:
int type;
void Reset();
public:
- cMarkAdPES2ES(int RecvNumber, const char *QueueName="PES2ES", int QueueSize=32768);
+ cMarkAdPES2ES(const char *QueueName="PES2ES", int QueueSize=32768);
~cMarkAdPES2ES();
void Process(MarkAdPid Pid, uchar *PESData, int PESSize, uchar **ESData, int *ESSize);
};
diff --git a/queue.cpp b/queue.cpp
index 34394ee..cc7441f 100644
--- a/queue.cpp
+++ b/queue.cpp
@@ -7,9 +7,8 @@
#include "queue.h"
-cMarkAdPaketQueue::cMarkAdPaketQueue(int RecvNumber, const char *Name, int Size)
+cMarkAdPaketQueue::cMarkAdPaketQueue(const char *Name, int Size)
{
- recvnumber=RecvNumber;
inptr=0;
outptr=0;
memset(&pktinfo,0,sizeof(pktinfo));
@@ -66,7 +65,7 @@ bool cMarkAdPaketQueue::Put(uchar *Data, int Size)
if (((inptr+Size)>maxqueue) && (name))
{
- esyslog("markad [%i]: buffer %s full",recvnumber,name);
+ esyslog("buffer %s full",name);
inptr=outptr=0;
}
@@ -77,7 +76,7 @@ bool cMarkAdPaketQueue::Put(uchar *Data, int Size)
if ((npercent>90) && (name) && (npercent!=percent))
{
- dsyslog("markad [%i]: buffer %s usage: %3i%%",recvnumber,
+ dsyslog("buffer %s usage: %3i%%",
name,npercent);
percent=npercent;
}
diff --git a/queue.h b/queue.h
index 5bf783b..cc00ab0 100644
--- a/queue.h
+++ b/queue.h
@@ -104,7 +104,6 @@ unsigned Length:
private:
char *name;
- int recvnumber;
struct pktinfo
{
int pkthdr;
@@ -126,7 +125,7 @@ private:
int FindPktHeader(int Start, int *StreamSize,int *SyncSize, bool LongStartCode);
int FindAudioHeader(int Start, int *FrameSize, int *SyncSize, bool AC3);
public:
- cMarkAdPaketQueue(int RecvNumber, const char *Name, int Size=32768);
+ cMarkAdPaketQueue(const char *Name, int Size=32768);
~cMarkAdPaketQueue();
int Length()
{
diff --git a/recv.cpp b/recv.cpp
deleted file mode 100644
index 4dbbbd0..0000000
--- a/recv.cpp
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * recv.cpp: A plugin for the Video Disk Recorder
- *
- * See the README file for copyright information and how to reach the author.
- *
- */
-
-#include "recv.h"
-
-#if APIVERSNUM > 10711
-cMarkAdReceiver::cMarkAdReceiver(int RecvNumber, const char *Filename, cTimer *Timer)
- :
- cReceiver(NULL, -1),
- cThread("markad"),
- buffer(MEGATS(3)), running(false) // 3MB Buffer
-#else
-cMarkAdReceiver::cMarkAdReceiver(int RecvNumber, const char *Filename, cTimer *Timer)
- :
- cReceiver(Timer->Channel()->GetChannelID(), -1,
- Timer->Channel()->Vpid(),Timer->Channel()->Dpids()),
- cThread("markad"),
- buffer(MEGATS(3)), running(false) // 3MB Buffer
-#endif
-{
- if ((!Filename) || (!Timer)) return;
-
-#if APIVERSNUM > 10711
- AddPid(Timer->Channel()->Vpid());
- AddPid(Timer->Channel()->Dpid(0));
-#endif
-
- recvnumber=RecvNumber;
- filename=strdup(Filename);
-
- // 10 ms timeout on getting TS frames
- buffer.SetTimeouts(0, 10);
-
- memset(&macontext,0,sizeof(macontext));
- macontext.StandAlone.LogoExtraction=-1; // we are not standalone ;)
- macontext.General.VPid.Num=Timer->Channel()->Vpid();
-
-#if APIVERSNUM > 10700
- switch (Timer->Channel()->Vtype())
- {
- case 0x2:
- macontext.General.VPid.Type=MARKAD_PIDTYPE_VIDEO_H262;
- break;
- case 0x1b:
- macontext.General.VPid.Type=MARKAD_PIDTYPE_VIDEO_H264;
- break;
- default:
- macontext.General.VPid.Num=0;
- macontext.General.VPid.Type=0;
- break;
- }
-#else
-#if APIVERSNUM < 10700
- macontext.General.VPid.Type=MARKAD_PIDTYPE_VIDEO_H262;
-#else
-#error "VDR-1.7.0 is still unsupported"
-#error "in plugin version, please use"
-#error "standalone version: make markad"
-#endif
-#endif
-
- macontext.General.DPid.Num=Timer->Channel()->Dpid(0); // ... better solution?
- macontext.General.DPid.Type=MARKAD_PIDTYPE_AUDIO_AC3;
-
- if (macontext.General.VPid.Num)
- {
- dsyslog("markad [%i]: using %s-video",recvnumber,
- (macontext.General.VPid.Type==MARKAD_PIDTYPE_VIDEO_H264) ? "H264": "H262");
- video=new cMarkAdVideo(RecvNumber,&macontext);
- video_demux = new cMarkAdDemux(RecvNumber);
- }
- else
- {
- video=NULL;
- video_demux=NULL;
- }
-
- if (macontext.General.DPid.Num)
- {
- dsyslog("markad [%i]: using AC3",recvnumber);
- ac3_demux = new cMarkAdDemux(RecvNumber);
- }
- else
- {
- ac3_demux=NULL;
- }
-
- if ((macontext.General.APid.Num) || (macontext.General.DPid.Num))
- {
- audio=new cMarkAdAudio(RecvNumber,&macontext);
- }
- else
- {
- audio=NULL;
- }
-
- streaminfo=new cMarkAdStreamInfo;
-
- marks.Load(Filename);
-
- Index=NULL;
- lastiframe=0;
- framecnt=-1;
- marksfound=false;
-
- if (!marks.Count())
- {
- MarkAdMark tempmark;
- char *buf;
- tempmark.Position=0;
- if (asprintf(&buf,"start of recording (0)")!=-1)
- {
- tempmark.Comment=buf;
- AddMark(&tempmark,0);
- isyslog("markad [%i]: %s",recvnumber,buf);
- free(buf);
- }
- }
- else
- {
- marksfound=true;
- }
-}
-
-cMarkAdReceiver::~cMarkAdReceiver()
-{
- cReceiver::Detach();
- if (running)
- {
- running=false;
- buffer.Signal();
- Cancel(2);
- }
- buffer.Clear();
-
- if (lastiframe)
- {
- MarkAdMark tempmark;
- tempmark.Position=lastiframe;
- char *buf;
-
- if (asprintf(&buf,"stop of recording (%i)",lastiframe)!=-1)
- {
- tempmark.Comment=buf;
- AddMark(&tempmark,0);
- isyslog("markad [%i]: %s",recvnumber,buf);
- free(buf);
- }
- }
-
- if (Index) delete Index;
- if (video_demux) delete video_demux;
- if (ac3_demux) delete ac3_demux;
- if (streaminfo) delete streaminfo;
- if (video) delete video;
- if (audio) delete audio;
- if (filename) free(filename);
-}
-
-char *cMarkAdReceiver::strcatrealloc(char *dest, const char *src)
-{
- if (!src || !*src)
- return dest;
-
- size_t l = (dest ? strlen(dest) : 0) + strlen(src) + 1;
- if (dest)
- {
- dest = (char *)realloc(dest, l);
- strcat(dest, src);
- }
- else
- {
- dest = (char*)malloc(l);
- strcpy(dest, src);
- }
- return dest;
-}
-
-int cMarkAdReceiver::LastIFrame()
-{
- if (!Index)
- {
- if (!filename) return 0;
- Index = new cIndexFile(filename,false);
- if (!Index)
- {
- esyslog("markad [%i]: ERROR can't allocate index",recvnumber);
- return 0;
- }
- else if (!Index->Ok())
- {
- // index file is not ready till now, try it later
- delete Index;
- Index=NULL;
- return 0;
- }
- }
- int iframe=Index->GetNextIFrame(Index->Last(),false,NULL,NULL,NULL,true);
- if (iframe>0)
- {
- return iframe;
- }
- else
- {
- return 0;
- }
-}
-
-void cMarkAdReceiver::Activate(bool On)
-{
- if (On)
- {
- if (!running)
- {
- running=true;
- Start();
- }
- }
- else if (running)
- {
- running = false;
- buffer.Signal();
- Cancel(2);
- }
-}
-
-void cMarkAdReceiver::Receive(uchar *Data, int Length)
-{
- int len = Length;
-
- if (!buffer.Check(len))
- {
- // Buffer overrun
- esyslog("markad [%i]: buffer overrun (Check)",recvnumber);
- buffer.Signal();
- return;
- }
-
- cFrame *frame=new cFrame(Data, len);
- if (frame && !buffer.Put(frame))
- {
- // Buffer overrun
- esyslog("markad [%i]: buffer overrun (Put)",recvnumber);
- delete frame;
- buffer.Signal();
- }
-}
-
-void cMarkAdReceiver::AddMark(MarkAdMark *mark, int Priority)
-{
- if (!mark) return;
- if (!mark->Comment) return;
- if (mark->Position<0) return;
-
- cMark *newmark=marks.Add(mark->Position);
- if (newmark)
- {
- char *buf;
- if (asprintf(&buf,"P%i %s",Priority,mark->Comment)!=-1)
- {
- if (newmark->comment) free(newmark->comment);
- newmark->comment=buf;
- }
- }
- marks.Save();
-
- if (!marksfound)
- {
- cMark *prevmark=marks.GetPrev(mark->Position);
- if (!prevmark) return;
- if (!prevmark->comment) return;
- if (prevmark->position==0) return;
-#define MAXPOSDIFF (25*60*13) // = 13 min
- if (abs(mark->Position-prevmark->position)>MAXPOSDIFF)
- {
- cMark *firstmark=marks.Get(0);
- if (firstmark)
- {
- marks.Del(firstmark,true);
- marks.Save();
- marksfound=true;
- }
- }
- else
- {
- marksfound=true;
- }
- }
-}
-
-void cMarkAdReceiver::Action()
-{
- while (running)
- {
- cFrame *frame=buffer.Get();
- if (frame)
- {
- lastiframe=LastIFrame();
- MarkAdMark *mark;
-
- if ((video_demux) && (streaminfo) && (video))
- {
- cTimeMs t;
- uchar *pkt;
- int pktlen;
-
- uchar *tspkt = frame->Data();
- int tslen = frame->Count();
-
- while (tslen>0)
- {
- int len=video_demux->Process(macontext.General.VPid,tspkt,tslen,&pkt,&pktlen);
- if (len<0)
- {
- break;
- }
- else
- {
- if (pkt)
- {
- if (streaminfo->FindVideoInfos(&macontext,pkt,pktlen))
- {
- if (macontext.Video.Info.Pict_Type==MA_I_TYPE)
- {
- if (framecnt==-1)
- {
- framecnt=0;
- }
- else
- {
- mark=video->Process(lastiframe);
- AddMark(mark,3);
- }
- }
- if (framecnt!=-1) framecnt++;
- }
- }
- tspkt+=len;
- tslen-=len;
- }
- }
- if (t.Elapsed()>100)
- {
- isyslog("markad [%i]: 100ms exceeded -> %llums",
- recvnumber,(unsigned long long) t.Elapsed());
- }
- }
-
- if ((ac3_demux) && (streaminfo) && (audio))
- {
- uchar *pkt;
- int pktlen;
-
- uchar *tspkt = frame->Data();
- int tslen = frame->Count();
-
- while (tslen>0)
- {
- int len=ac3_demux->Process(macontext.General.DPid,tspkt,tslen,&pkt,&pktlen);
- if (len<0)
- {
- break;
- }
- else
- {
- if (pkt)
- {
- if (streaminfo->FindAC3AudioInfos(&macontext,pkt,pktlen))
- {
- mark=audio->Process(lastiframe);
- AddMark(mark,2);
- }
- }
- tspkt+=len;
- tslen-=len;
- }
- }
- }
-
- buffer.Drop(frame);
- }
- else
- buffer.Wait();
- }
- buffer.Clear();
- running=false;
-}
-
-
diff --git a/recv.h b/recv.h
deleted file mode 100644
index c068913..0000000
--- a/recv.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * recv.h: A plugin for the Video Disk Recorder
- *
- * See the README file for copyright information and how to reach the author.
- *
- */
-
-#ifndef __recv_h_
-#define __recv_h_
-
-#include <vdr/receiver.h>
-#include <vdr/filter.h>
-#include <vdr/thread.h>
-#include <vdr/ringbuffer.h>
-#include <vdr/recording.h>
-
-#include "demux.h"
-#include "streaminfo.h"
-#include "audio.h"
-#include "video.h"
-
-#if (APIVERSNUM >= 10700)
-#include <linux/dvb/frontend.h>
-#endif
-
-#define MEGATS(n) ((n)*1024*1880)
-
-class cMarkAdRingBuffer : public cRingBufferFrame
-{
-private:
- int pid;
-public:
- cMarkAdRingBuffer(int Size) : cRingBufferFrame(Size, true) {};
- ~cMarkAdRingBuffer()
- {
- Clear();
- }
- void Wait(void)
- {
- WaitForGet();
- }
- void Signal(void)
- {
- EnableGet();
- }
- bool Check(int Size)
- {
- return (Free() >= Size);
- }
-};
-
-class cMarkAdReceiver : public cReceiver, public cThread
-{
-private:
- int recvnumber;
- char *filename;
- int lastiframe;
- int framecnt;
- bool marksfound;
-
- char *strcatrealloc(char *dest, const char *src);
- cMarks marks;
- cIndexFile *Index;
-
- int LastIFrame();
- MarkAdContext macontext;
-
- cMarkAdStreamInfo *streaminfo;
- cMarkAdAudio *audio;
- cMarkAdVideo *video;
-
- cMarkAdDemux *video_demux;
- cMarkAdDemux *ac3_demux;
-
- void AddMark(MarkAdMark *mark, int Priority);
-protected:
- virtual void Activate(bool On);
- virtual void Receive(uchar *Data, int Length);
- void Action();
- cMarkAdRingBuffer buffer;
- bool running;
-public:
- cMarkAdReceiver(int RecvNumber, const char *Filename, cTimer *Timer);
- bool FoundMarks()
- {
- return marksfound;
- }
- const char *FileName()
- {
- return (const char *) filename;
- }
- virtual ~cMarkAdReceiver();
-};
-
-#endif
diff --git a/status.cpp b/status.cpp
index 1cc114f..b08fd94 100644
--- a/status.cpp
+++ b/status.cpp
@@ -7,39 +7,11 @@
#include "status.h"
-cStatusMarkAd::cStatusMarkAd()
-{
- memset(recv,0,sizeof(recv));
-}
-
-int cStatusMarkAd::GetFreeReceiver()
-{
- for (int i=0; i<(MAXDEVICES*MAXRECEIVERS); i++)
- {
- if (recv[i]==NULL) return i;
- }
- return -1;
-}
-
-int cStatusMarkAd::FindReceiver(const char *FileName)
-{
- for (int i=0; i<(MAXDEVICES*MAXRECEIVERS); i++)
- {
- if (recv[i])
- {
- if (!strcmp(recv[i]->FileName(),FileName)) return i;
- }
- }
- return -1;
-}
-
void cStatusMarkAd::Recording(const cDevice *Device, const char *Name, const char *FileName, bool On)
{
if (!Device) return; // just to be safe
if (!FileName) return; // we cannot operate without a filename
- int recvnumber;
-
if (On)
{
if (!Name) return; // we cannot operate without name ;)
@@ -57,26 +29,11 @@ void cStatusMarkAd::Recording(const cDevice *Device, const char *Name, const cha
if (!timer) return;
- recvnumber=GetFreeReceiver();
- if (recvnumber<0) return;
-
- recv[recvnumber] = new cMarkAdReceiver(recvnumber,FileName,timer);
- dsyslog("markad [%i]: start recording %s ",recvnumber,FileName);
- ((cDevice *) Device)->AttachReceiver(recv[recvnumber]);
+ // TODO: Start the standalone version ;)
}
else
{
- recvnumber=FindReceiver(FileName);
- if (recvnumber<0) return;
-
- dsyslog("markad [%i]: stop recording %s ",recvnumber,FileName);
- ((cDevice *) Device)->Detach(recv[recvnumber]);
- if (!recv[recvnumber]->FoundMarks())
- {
- // TODO: start standalone markad with logo detection
- }
- delete recv[recvnumber];
- recv[recvnumber]=NULL;
+ // TODO: Start second pass?
}
}
diff --git a/status.h b/status.h
index 6911bcf..786025c 100644
--- a/status.h
+++ b/status.h
@@ -8,15 +8,11 @@
#define __status_h_
#include <vdr/status.h>
-#include "recv.h"
// --- cStatusMarkAd
class cStatusMarkAd : public cStatus
{
private:
- cMarkAdReceiver *recv[MAXDEVICES*MAXRECEIVERS];
- int FindReceiver(const char *FileName);
- int GetFreeReceiver();
protected:
virtual void Recording(const cDevice *Device, const char *Name, const char *FileName, bool On);
public:
diff --git a/ts2pkt.cpp b/ts2pkt.cpp
index 198fda0..c32b87a 100644
--- a/ts2pkt.cpp
+++ b/ts2pkt.cpp
@@ -7,10 +7,9 @@
#include "ts2pkt.h"
-cMarkAdTS2Pkt::cMarkAdTS2Pkt(int RecvNumber, const char *QueueName, int QueueSize)
+cMarkAdTS2Pkt::cMarkAdTS2Pkt(const char *QueueName, int QueueSize)
{
- recvnumber=RecvNumber;
- queue=new cMarkAdPaketQueue(RecvNumber,QueueName,QueueSize);
+ queue=new cMarkAdPaketQueue(QueueName,QueueSize);
Reset();
}
@@ -25,22 +24,22 @@ void cMarkAdTS2Pkt::Reset(int ErrIndex)
switch (ErrIndex)
{
case MA_ERR_TSSIZE:
- dsyslog("markad [%i]: inbuf not 188 bytes",recvnumber);
+ dsyslog("inbuf not 188 bytes");
break;
case MA_ERR_NOSYNC:
- dsyslog("markad [%i]: found no sync",recvnumber);
+ dsyslog("found no sync");
break;
case MA_ERR_SEQ:
- dsyslog("markad [%i]: sequence error",recvnumber);
+ dsyslog("sequence error");
break;
case MA_ERR_AFC:
- dsyslog("markad [%i]: wrong AFC value",recvnumber);
+ dsyslog("wrong AFC value");
break;
case MA_ERR_TOBIG:
- dsyslog("markad [%i]: buflen > 188 bytes",recvnumber);
+ dsyslog("buflen > 188 bytes");
break;
case MA_ERR_NEG:
- dsyslog("markad [%i]: buflen negative",recvnumber);
+ dsyslog("buflen negative");
break;
}
counter=-1;
diff --git a/ts2pkt.h b/ts2pkt.h
index 70be956..52a7a77 100644
--- a/ts2pkt.h
+++ b/ts2pkt.h
@@ -101,7 +101,6 @@ unsigned Length:
};
#pragma pack()
- int recvnumber;
int counter;
bool sync;
@@ -116,7 +115,7 @@ unsigned Length:
#define MA_ERR_NEG 6
void Reset(int ErrIndex=MA_ERR_STARTUP);
public:
- cMarkAdTS2Pkt(int RecvNumber, const char *QueueName="TS2Pkt", int QueueSize=32768);
+ cMarkAdTS2Pkt(const char *QueueName="TS2Pkt", int QueueSize=32768);
~cMarkAdTS2Pkt();
void Process(MarkAdPid Pid,uchar *TSData, int TSSize, uchar **PktData, int *PktSize);
bool InjectVideoPES(uchar *PESData, int PESSize);
diff --git a/vdr2pkt.cpp b/vdr2pkt.cpp
index 85c26da..b7693bd 100644
--- a/vdr2pkt.cpp
+++ b/vdr2pkt.cpp
@@ -7,9 +7,9 @@
#include "vdr2pkt.h"
-cMarkAdVDR2Pkt::cMarkAdVDR2Pkt(int RecvNumber, const char *QueueName, int QueueSize)
+cMarkAdVDR2Pkt::cMarkAdVDR2Pkt(const char *QueueName, int QueueSize)
{
- queue = new cMarkAdPaketQueue(RecvNumber,QueueName,QueueSize);
+ queue = new cMarkAdPaketQueue(QueueName,QueueSize);
}
cMarkAdVDR2Pkt::~cMarkAdVDR2Pkt()
diff --git a/vdr2pkt.h b/vdr2pkt.h
index eb48c3c..532c9eb 100644
--- a/vdr2pkt.h
+++ b/vdr2pkt.h
@@ -20,7 +20,7 @@ class cMarkAdVDR2Pkt
private:
cMarkAdPaketQueue *queue;
public:
- cMarkAdVDR2Pkt(int RecvNumber, const char *QueueName="VDR2PKT", int QueueSize=32768);
+ cMarkAdVDR2Pkt(const char *QueueName="VDR2PKT", int QueueSize=32768);
~cMarkAdVDR2Pkt();
void Process(MarkAdPid Pid,uchar *VDRData, int VDRSize, uchar **PktData, int *PktSize);
};
diff --git a/video.cpp b/video.cpp
index af25320..295cd7f 100644
--- a/video.cpp
+++ b/video.cpp
@@ -7,10 +7,9 @@
#include "video.h"
-cMarkAdLogo::cMarkAdLogo(int RecvNumber, MarkAdContext *maContext)
+cMarkAdLogo::cMarkAdLogo(MarkAdContext *maContext)
{
macontext=maContext;
- recvnumber=RecvNumber;
// 3x3 GX Sobel mask
@@ -347,12 +346,12 @@ int cMarkAdLogo::Process(int LastIFrame, int *LogoIFrame)
switch (ret)
{
case -1:
- esyslog("markad [%i]: failed to open %s",recvnumber,buf);
+ esyslog("failed to open %s",buf);
break;
case -2:
- esyslog("markad [%i]: format error in %s",recvnumber,buf);
+ esyslog("format error in %s",buf);
break;
}
free(buf);
@@ -382,7 +381,7 @@ int cMarkAdLogo::Process(int LastIFrame, int *LogoIFrame)
return Detect(LastIFrame,LogoIFrame);
}
-cMarkAdBlackBordersHoriz::cMarkAdBlackBordersHoriz(int RecvNumber, MarkAdContext *maContext)
+cMarkAdBlackBordersHoriz::cMarkAdBlackBordersHoriz(MarkAdContext *maContext)
{
macontext=maContext;
@@ -486,18 +485,17 @@ int cMarkAdBlackBordersHoriz::Process(int LastIFrame, int *BorderIFrame)
}
-cMarkAdVideo::cMarkAdVideo(int RecvNumber,MarkAdContext *maContext)
+cMarkAdVideo::cMarkAdVideo(MarkAdContext *maContext)
{
macontext=maContext;
- recvnumber=RecvNumber;
aspectratio.Num=0;
aspectratio.Den=0;
mark.Comment=NULL;
mark.Position=0;
- hborder=new cMarkAdBlackBordersHoriz(RecvNumber,maContext);
- logo = new cMarkAdLogo(RecvNumber,maContext);
+ hborder=new cMarkAdBlackBordersHoriz(maContext);
+ logo = new cMarkAdLogo(maContext);
}
cMarkAdVideo::~cMarkAdVideo()
@@ -562,7 +560,7 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
{
if (asprintf(&buf,"detected logo start (%i)",logoiframe)!=-1)
{
- isyslog("markad [%i]: %s",recvnumber,buf);
+ isyslog(buf);
AddMark(logoiframe,buf);
free(buf);
}
@@ -571,7 +569,7 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
{
if (asprintf(&buf,"detected logo stop (%i)",logoiframe)!=-1)
{
- isyslog("markad [%i]: %s",recvnumber,buf);
+ isyslog(buf);
AddMark(logoiframe,buf);
free(buf);
}
@@ -587,7 +585,7 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
char *buf=NULL;
if (asprintf(&buf,"detected start of horiz. borders (%i)",borderiframe)!=-1)
{
- isyslog("markad [%i]: %s",recvnumber,buf);
+ isyslog(buf);
AddMark(borderiframe,buf);
free(buf);
}
@@ -598,7 +596,7 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
char *buf=NULL;
if (asprintf(&buf,"detected stop of horiz. borders (%i)",borderiframe)!=-1)
{
- isyslog("markad [%i]: %s",recvnumber,buf);
+ isyslog(buf);
AddMark(borderiframe,buf);
free(buf);
}
@@ -614,7 +612,7 @@ MarkAdMark *cMarkAdVideo::Process(int LastIFrame)
macontext->Video.Info.AspectRatio.Num,
macontext->Video.Info.AspectRatio.Den,LastIFrame)!=-1)
{
- isyslog("markad [%i]: %s",recvnumber, buf);
+ isyslog(buf);
AddMark(LastIFrame,buf);
free(buf);
}
diff --git a/video.h b/video.h
index 4dfa153..bb73b28 100644
--- a/video.h
+++ b/video.h
@@ -25,7 +25,6 @@
class cMarkAdLogo
{
private:
- int recvnumber;
enum
{
@@ -74,7 +73,7 @@ private:
int Load(char *file);
void Save(int lastiframe, uchar *picture);
public:
- cMarkAdLogo(int RecvNumber, MarkAdContext *maContext);
+ cMarkAdLogo(MarkAdContext *maContext);
~cMarkAdLogo();
int Process(int LastIFrame, int *LogoIFrame);
};
@@ -88,14 +87,13 @@ private:
void SaveFrame(int LastIFrame);
MarkAdContext *macontext;
public:
- cMarkAdBlackBordersHoriz(int RecvNumber, MarkAdContext *maContext);
+ cMarkAdBlackBordersHoriz(MarkAdContext *maContext);
int Process(int LastIFrame,int *BorderIFrame);
};
class cMarkAdVideo
{
private:
- int recvnumber;
MarkAdContext *macontext;
MarkAdMark mark;
@@ -109,7 +107,7 @@ private:
void SetTimerMarks(int LastIFrame);
public:
- cMarkAdVideo(int RecvNumber,MarkAdContext *maContext);
+ cMarkAdVideo(MarkAdContext *maContext);
~cMarkAdVideo();
MarkAdMark *Process(int LastIFrame);
};