summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoerg Bornkessel <hd_brummy@gentoo.org>2014-04-26 23:29:18 +0200
committerJoerg Bornkessel <hd_brummy@gentoo.org>2014-04-26 23:29:18 +0200
commitd859d0cee8fb99763e223f781bd5172e09a7f511 (patch)
treec4b069117ebbc208a5136fa64ceea0fe0fe228e8
parenta237b9e8bb92f75d71964c7f45084319a9f63f36 (diff)
downloadvdr-plugin-audiorecorder-d859d0cee8fb99763e223f781bd5172e09a7f511.tar.gz
vdr-plugin-audiorecorder-d859d0cee8fb99763e223f781bd5172e09a7f511.tar.bz2
ffmpeg libav-9 compile fixes
-rw-r--r--Makefile.obsolete136
-rw-r--r--audioreceiver.c19
-rw-r--r--audioreceiver.h26
-rw-r--r--audiorecorder.c8
-rw-r--r--audiorecorder.h4
-rw-r--r--convert.c14
-rw-r--r--convert.h9
7 files changed, 47 insertions, 169 deletions
diff --git a/Makefile.obsolete b/Makefile.obsolete
deleted file mode 100644
index 16c6eac..0000000
--- a/Makefile.obsolete
+++ /dev/null
@@ -1,136 +0,0 @@
-#
-# Makefile for a Video Disk Recorder plugin
-#
-# $Id$
-
-# The official name of this plugin.
-# This name will be used in the '-P...' option of VDR to load the plugin.
-# By default the main source file also carries this name.
-#
-PLUGIN = audiorecorder
-
-### The version number of this plugin (taken from the main source file):
-
-VERSION = $(shell grep 'const char \*cPluginAudiorecorder::VERSION *=' $(PLUGIN).c | awk '{ print $$5 }' | sed -e 's/[";]//g')
-
-### The C++ compiler and options:
-
-CXX ?= g++
-CXXFLAGS ?= -fPIC -g -O2 -Wall -Woverloaded-virtual
-
-### The directory environment:
-
-VDRDIR = ../../..
-LIBDIR = ../../lib
-TMPDIR = /tmp
-
-FFMDIR = /usr/include
-
-### Allow user defined options to overwrite defaults:
-
--include $(VDRDIR)/Make.config
-
-### The version number of VDR's plugin API (taken from VDR's "config.h"):
-
-APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h)
-
-### The name of the distribution archive:
-
-ARCHIVE = $(PLUGIN)-$(VERSION)
-PACKAGE = vdr-$(ARCHIVE)
-
-### Includes, Libs and Defines (add further entries here):
-
-INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include $(shell taglib-config --cflags)
-
-LIBS = $(shell taglib-config --libs)
-
-DEFINES += -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DTIXML_USE_STL
-
-ifdef AUDIORECORDER_DEVEL
- DEFINES += -DAUDIORECORDER_DEVEL
-endif
-
-# ffmpeg
-AVCODEC_INC = $(shell pkg-config libavcodec --cflags | sed -e 's/ //g')
-ifeq ($(strip $(AVCODEC_INC)),)
- INCLUDES += -I$(FFMDIR) -I$(FFMDIR)/libavcodec
-else
- INCLUDES += $(AVCODEC_INC)
-endif
-AVCODEC_LIBS = $(shell pkg-config libavcodec --libs)
-ifeq ($(strip $(AVCODEC_LIBS)),)
- LIBS += -lavcodec
-else
- LIBS += $(AVCODEC_LIBS)
-endif
-
-### The object files (add further files here):
-
-OBJS = $(PLUGIN).o mainmenu.o browse.o browse-item.o column.o dispatcher.o audioreceiver.o postdata.o trackinfo.o postproc.o rds.o convert.o cache.o xml-cache.o xml-base.o setup.o mpa-frame.o tinyxml/tinyxml.o tinyxml/tinyxmlerror.o tinyxml/tinyxmlparser.o audiorecorder_i18n.o
-
-### Implicit rules:
-
-%.o: %.c
- $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) -o $@ $<
-
-# Dependencies:
-
-MAKEDEP = $(CXX) -MM -MG
-DEPFILE = .dependencies
-$(DEPFILE): Makefile
- @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
-
--include $(DEPFILE)
-
-### Internationalization (I18N):
-
-PODIR = po
-LOCALEDIR = $(VDRDIR)/locale
-I18Npo = $(wildcard $(PODIR)/*.po)
-I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file))))
-I18Ndirs = $(notdir $(foreach file, $(I18Npo), $(basename $(file))))
-I18Npot = $(PODIR)/$(PLUGIN).pot
-I18Nvdrmo = vdr-$(PLUGIN).mo
-ifeq ($(strip $(APIVERSION)),1.5.7)
- I18Nvdrmo = $(PLUGIN).mo
-endif
-
-%.mo: %.po
- msgfmt -c -o $@ $<
-
-$(I18Npot): $(OBJS:%.o=%.c)
- xgettext -C -cTRANSLATORS --no-wrap -F -k -ktr -ktrNOOP --msgid-bugs-address='<cwieninger@gmx.de>' -o $@ $(OBJS:%.o=%.c)
-
-$(I18Npo): $(I18Npot)
- msgmerge -U --no-wrap -F --backup=none -q $@ $<
-
-i18n: $(I18Nmo)
- @mkdir -p $(LOCALEDIR)
- for i in $(I18Ndirs); do\
- mkdir -p $(LOCALEDIR)/$$i/LC_MESSAGES;\
- cp $(PODIR)/$$i.mo $(LOCALEDIR)/$$i/LC_MESSAGES/$(I18Nvdrmo);\
- done
-
-generate-i18n: i18n-template.h $(I18Npot) $(I18Npo) buildutil/pot2i18n.pl
- buildutil/pot2i18n.pl $(I18Npot) i18n-template.h > i18n-generated.h
-
-### Targets:
-
-all: libvdr-$(PLUGIN).so i18n
-
-libvdr-$(PLUGIN).so: $(OBJS)
- $(CXX) $(CXXFLAGS) -shared $(OBJS) $(LIBS) -o $@
- @cp $@ $(LIBDIR)/$@.$(APIVERSION)
-
-dist: clean
- @-rm -rf $(TMPDIR)/$(ARCHIVE)
- @mkdir $(TMPDIR)/$(ARCHIVE)
- @cp -a * $(TMPDIR)/$(ARCHIVE)
- @tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE)
- @-rm -rf $(TMPDIR)/$(ARCHIVE)
- @echo Distribution package created as $(PACKAGE).tgz
-
-clean:
- @-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
- @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~
diff --git a/audioreceiver.c b/audioreceiver.c
index 43c8723..82f45f0 100644
--- a/audioreceiver.c
+++ b/audioreceiver.c
@@ -9,16 +9,19 @@
/* --- cAudioReceiver ------------------------------------------------------- */
-cAudioReceiver::cAudioReceiver(const cChannel *_channel)
-:cReceiver(_channel->GetChannelID(), -2, _channel->Apid(0)), cThread()
+cAudioReceiver::cAudioReceiver(const cChannel* _channel)
+:cReceiver(_channel, -2), cThread("audiorecorder-receiver")
{
+ SetPids(NULL);
+ AddPid(_channel->Apid(0));
+
channel = _channel;
active = false;
pes_sync = false;
- device_number = -1;
- recstat = recWait;
+ device_number = -1;
+ recstat = recWait;
buffer = NULL;
rds = NULL;
@@ -32,7 +35,7 @@ cAudioReceiver::cAudioReceiver(const cChannel *_channel)
cAudioReceiver::~cAudioReceiver(void)
{
- Activate(false);
+ Activate(false);
DELETE(buffer);
DELETE(rds);
@@ -146,7 +149,7 @@ void cAudioReceiver::Action(void)
}
- pes_sync = false;
+ pes_sync = false;
device_number = -1;
recstat = recWait;
@@ -165,8 +168,8 @@ bool cAudioReceiver::is_attached(int attached_device_number)
return false;
if (attached_device_number != device_number &&
- attached_device_number != -1)
- return false;
+ attached_device_number != -1)
+ return false;
return true;
}
diff --git a/audioreceiver.h b/audioreceiver.h
index 33a6776..9639b5f 100644
--- a/audioreceiver.h
+++ b/audioreceiver.h
@@ -23,39 +23,39 @@ class cAudioReceiver : public cReceiver, cThread {
private:
bool active;
int device_number;
-
+
std::ofstream outfile;
-
+
cRingBufferLinear *buffer;
const cChannel *channel;
-
+
cPostData *postdata;
cRds *rds;
-
+
eRecStat recstat;
mpeg_audio_frame mpa_frame;
bool pes_sync;
-
+
void set_recstat_rds(void);
void control_track(void);
protected:
virtual void Receive(uchar *data, int length);
-
+
virtual void Action(void);
virtual void Activate(bool on);
public:
- cAudioReceiver(const cChannel *_channel);
+ cAudioReceiver(const cChannel* _channel);
~cAudioReceiver();
-
+
void set_device_number(int _device_number) { device_number =
_device_number; }
int get_device_number(void) { return device_number; }
bool is_attached(int attached_device_number);
- /*
- * returns true if the receiver is attached to the given device.
- * if attached_device_number == -1, true is returned if the
- * receiver is attached to a device
- */
+ /*
+ * returns true if the receiver is attached to the given device.
+ * if attached_device_number == -1, true is returned if the
+ * receiver is attached to a device
+ */
bool is_recording(void);
const cChannel *get_channel(void) { return channel; }
};
diff --git a/audiorecorder.c b/audiorecorder.c
index d9a1609..58284ec 100644
--- a/audiorecorder.c
+++ b/audiorecorder.c
@@ -20,8 +20,12 @@
#include <iostream>
+#if defined(APIVERSNUM) && APIVERSNUM < 20000
+#error "VDR-2.0.0 API version or greater is required!"
+#endif
+
extern "C" {
- #include <avcodec.h>
+#include <libavcodec/avcodec.h>
}
// extern cChannels Channels;
@@ -174,7 +178,9 @@ bool cPluginAudiorecorder::Initialize(void)
bool cPluginAudiorecorder::Start(void)
{
/* initialize libavcodec */
+#if LIBAVCODEC_VERSION_MAJOR < 54
avcodec_init();
+#endif
avcodec_register_all();
probe_audio_codecs();
diff --git a/audiorecorder.h b/audiorecorder.h
index 3ec9c3c..64c57a1 100644
--- a/audiorecorder.h
+++ b/audiorecorder.h
@@ -15,7 +15,7 @@
class cPluginAudiorecorder : public cPlugin {
private:
- cDispatcher *dispatcher;
+ cDispatcher *dispatcher;
cPostproc *postproc;
static const char *DESCRIPTION;
@@ -43,7 +43,7 @@ public:
virtual void Housekeeping(void);
virtual const char *MainMenuEntry(void);
virtual cOsdObject *MainMenuAction(void);
- virtual cString Active(void);
+ virtual cString Active(void);
virtual cMenuSetupPage *SetupMenu(void);
virtual bool SetupParse(const char *name, const char *value);
virtual bool Service(const char *id, void *data = NULL);
diff --git a/convert.c b/convert.c
index 237f4c1..89b49be 100644
--- a/convert.c
+++ b/convert.c
@@ -51,8 +51,8 @@ void cConvert::init_decoder(void)
return;
}
- decoder_ctx = avcodec_alloc_context();
- decoder_open = avcodec_open(decoder_ctx, decoder_codec);
+ decoder_ctx = avcodec_alloc_context3(NULL);
+ decoder_open = avcodec_open2(decoder_ctx, decoder_codec, 0);
if (decoder_open < 0) {
dsyslog("[audiorecorder]: could not open codec mp2 (%s, "
@@ -77,7 +77,7 @@ void cConvert::init_encoder(const char *codec, int bit_rate, int sample_rate,
return;
}
- encoder_ctx = avcodec_alloc_context();
+ encoder_ctx = avcodec_alloc_context3(NULL);
encoder_ctx->bit_rate = bit_rate;
encoder_ctx->sample_rate = sample_rate;
@@ -111,9 +111,13 @@ void cConvert::decode_mpa_frame(mpeg_audio_frame *mpa_frame)
avcodec_decode_audio(decoder_ctx, (short *)decoder_buf.data,
&decoder_buf.length, mpa_frame->data, mpa_frame->length);
#else
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
+ avpkt.data = mpa_frame->data;
+ avpkt.size = mpa_frame->length;
decoder_buf.length = AVCODEC_MAX_AUDIO_FRAME_SIZE;
- avcodec_decode_audio2(decoder_ctx, (short *)decoder_buf.data,
- &decoder_buf.length, mpa_frame->data, mpa_frame->length);
+ int len = avcodec_decode_audio3(decoder_ctx, (short *)decoder_buf.data,
+ &decoder_buf.length, &avpkt);
#endif
}
diff --git a/convert.h b/convert.h
index 04fcc4b..1d84596 100644
--- a/convert.h
+++ b/convert.h
@@ -10,7 +10,8 @@
#include "a-tools.h"
extern "C" {
-#include <avcodec.h>
+#include <libavcodec/avcodec.h>
+#include <libavutil/mem.h>
}
@@ -19,9 +20,9 @@ private:
AVCodec *decoder_codec, *encoder_codec;
AVCodecContext *decoder_ctx, *encoder_ctx;
int decoder_open, encoder_open;
-
+
abuffer decoder_buf, encoder_buf, mpa_frame_buf;
-
+
void init_decoder(void);
void decode_mpa_frame(mpeg_audio_frame *mpa_frame);
void init_encoder(const char *codec, int bit_rate, int sample_rate,
@@ -29,7 +30,7 @@ private:
public:
cConvert(const cPostData &postdata);
~cConvert();
-
+
abuffer *reencode_mpa_frame(mpeg_audio_frame *mpa_frame,
float volume = 1);
};