From 943ebc634a0033eac934a55e425e7e88b590d3c5 Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sat, 1 Sep 2012 12:04:31 +0200 Subject: [PATCH] Switch back to system libav and add audio options --- GNUmakefile | 8 +- audiovpe.cc | 263 +++++++++++++++++++++++++++++++++++++++ audiovpe.h | 19 +++ raspi-patches/readme.txt | 7 ++ 4 files changed, 293 insertions(+), 4 deletions(-) mode change 100755 => 100644 audiovpe.cc diff --git a/GNUmakefile b/GNUmakefile index 6964c7d..c7812ee 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -56,12 +56,12 @@ endif ifeq ($(vomp_platform),raspberry) $(info Raspberry pi flags) LDFLAGS = -Wall -LIBS = -L/opt/vc/lib -lpthread -lrt -lEGL -lGLESv2 -lopenmaxil -lbcm_host +LIBS = -L/opt/vc/lib -lpthread -lrt -lEGL -lGLESv2 -lopenmaxil -lbcm_host -lavformat -lavcodec -lavutil -OBJECTS += main.o threadp.o osdopengl.o surfaceopengl.o ledraspberry.o mtdraspberry.o videovpeogl.o audiovpe.o wjpegsimple.o remotelinux.o glshader.o glosdshader.o glyuv400shader.o glyuv444shader.o glmocoshader.o +OBJECTS += main.o threadp.o osdopengl.o surfaceopengl.o ledraspberry.o mtdraspberry.o videovpeogl.o audiovpe.o wjpegsimple.o remotelinux.o glshader.o glosdshader.o glyuv400shader.o glyuv444shader.o glmocoshader.o LIBS+= -ljpeg -CROSSLIBS = ../libav/libavformat/libavformat.a ../libav/libavcodec/libavcodec.a ../libav/libavutil/libavutil.a -INCLUDES = -DVOMP_PLATTFORM_RASPBERRY -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I../libav +CROSSLIBS = +INCLUDES = -DVOMP_PLATTFORM_RASPBERRY -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads CXXFLAGS_DEV += -D__STDC_CONSTANT_MACROS CXXFLAGS_REL += -D__STDC_CONSTANT_MACROS diff --git a/audiovpe.cc b/audiovpe.cc old mode 100755 new mode 100644 index f1dd4be..93f2942 --- a/audiovpe.cc +++ b/audiovpe.cc @@ -21,6 +21,8 @@ #include "audiovpe.h" #include "videovpeogl.h" #include "log.h" +#include "vdr.h" +#include "woptionpane.h" AudioVPE::AudioVPE() { @@ -31,6 +33,15 @@ AudioVPE::AudioVPE() volume = 20; muted = 0; lastAType = MPTYPE_MPEG_AUDIO; + + canpass_ac3=false; + canpass_mp2=false; + canpass_mp3=false; + canpass_pcm_mch=false; + + prefered_ac3=0; //0 stereo PCM, 1 passthrough 2 Multichannel PCM + prefered_mp2=0; + prefered_mp3=0; } AudioVPE::~AudioVPE() @@ -80,6 +91,258 @@ int AudioVPE::shutdown() return 1; } +bool AudioVPE::loadOptionsfromServer(VDR* vdr) +{ + char *name=vdr->configLoad("AudioOMX","AC3DecodingMode"); + + if (name != NULL) { + if (STRCASECMP(name, "PCM") == 0) { + prefered_ac3 = 0; + } else if (STRCASECMP(name, "Passthrough") == 0) { + prefered_ac3 = 1; + } else if (STRCASECMP(name, "PCMMultichannel") == 0) { + prefered_ac3 = 2; + } + } + + name = vdr->configLoad("AudioOMX", "Mp2DecodingMode"); + + if (name != NULL) { + if (STRCASECMP(name, "PCM") == 0) { + prefered_mp2 = 0; + } else if (STRCASECMP(name, "Passthrough") == 0) { + prefered_mp2 = 1; + } else if (STRCASECMP(name, "PCMMultichannel") == 0) { + prefered_mp2 = 2; + } + } + + name = vdr->configLoad("AudioOMX", "Mp3DecodingMode"); + + if (name != NULL) { + if (STRCASECMP(name, "PCM") == 0) { + prefered_mp3 = 0; + } else if (STRCASECMP(name, "Passthrough") == 0) { + prefered_mp3 = 1; + } else if (STRCASECMP(name, "PCMMultichannel") == 0) { + prefered_mp3 = 2; + } + } + + name = vdr->configLoad("AudioOMX", "AudioOutput"); + + if (name != NULL) { + if (STRCASECMP(name, "analog") == 0) { + hdmi = false; + } else if (STRCASECMP(name, "HDMI") == 0) { + hdmi = true; + } + } + + + return true; + +} + +bool AudioVPE::handleOptionChanges(Option* option) +{ + if (Audio::handleOptionChanges(option)) + return true; + switch (option->id) { + case 4: { + if (STRCASECMP(option->options[option->userSetChoice], "analog") == 0) { + hdmi = false; + } else if (STRCASECMP(option->options[option->userSetChoice], "HDMI") + == 0) { + hdmi = true; + } + return true; + } + break; + case 1: { + if (STRCASECMP(option->options[option->userSetChoice], "PCM") == 0) { + prefered_ac3 = 0; + } else if (STRCASECMP(option->options[option->userSetChoice], + "Passthrough") == 0) { + prefered_ac3 = 1; + } else if (STRCASECMP(option->options[option->userSetChoice], + "PCMMultichannel") == 0) { + prefered_ac3 = 2; + } + } + break; + case 2: { + if (STRCASECMP(option->options[option->userSetChoice], "PCM") == 0) { + prefered_mp2 = 0; + } else if (STRCASECMP(option->options[option->userSetChoice], + "Passthrough") == 0) { + prefered_mp2 = 1; + } else if (STRCASECMP(option->options[option->userSetChoice], + "PCMMultichannel") == 0) { + prefered_mp2 = 2; + } + } + break; + case 3: { + if (STRCASECMP(option->options[option->userSetChoice], "PCM") == 0) { + prefered_mp3 = 0; + } else if (STRCASECMP(option->options[option->userSetChoice], + "Passthrough") == 0) { + prefered_mp3 = 1; + } else if (STRCASECMP(option->options[option->userSetChoice], + "PCMMultichannel") == 0) { + prefered_mp3 = 2; + } + } + break; + }; + return false; + +} + +bool AudioVPE::saveOptionstoServer() +{ + + switch (prefered_ac3) { + case 0: + VDR::getInstance()->configSave("AudioOMX", "AC3DecodingMode", "PCM"); + break; + case 1: + VDR::getInstance()->configSave("AudioOMX", "AC3DecodingMode", + "Passthrough"); + break; + case 2: + VDR::getInstance()->configSave("AudioOMX", "AC3DecodingMode", + "PCMMultichannel"); + break; + }; + + switch (prefered_mp2) { + case 0: + VDR::getInstance()->configSave("AudioOMX", "Mp2DecodingMode", "PCM"); + break; + case 1: + VDR::getInstance()->configSave("AudioOMX", "Mp2DecodingMode", + "Passthrough"); + break; + case 2: + VDR::getInstance()->configSave("AudioOMX", "Mp2DecodingMode", + "PCMMultichannel"); + break; + }; + + switch (prefered_mp3) { + case 0: + VDR::getInstance()->configSave("AudioOMX", "Mp3DecodingMode", "PCM"); + break; + case 1: + VDR::getInstance()->configSave("AudioOMX", "Mp3DecodingMode", + "Passthrough"); + break; + case 2: + VDR::getInstance()->configSave("AudioOMX", "Mp3DecodingMode", + "PCMMultichannel"); + break; + }; + + if (hdmi) + VDR::getInstance()->configSave("AudioOMX", "AudioOutput", "analog"); + else + VDR::getInstance()->configSave("AudioOMX", "AudioOutput", "HDMI"); + + + return true; +} + +/*Option(UINT id, const char* displayText, const char* configSection, const char* configKey, UINT optionType, + UINT numChoices, UINT defaultChoice, UINT startInt, + const char * const * options, const char * const * optionkeys = NULL, AbstractOption* handler=NULL);*/ + +bool AudioVPE::addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane) +{ + if (!Audio::addOptionsToPanes(panenumber,options,pane)) return false; + + + Option* option; + if (panenumber == 2) + { + + static const char* audioopts[]={"analog","HDMI"}; + option = new Option(4,tr("Audio Output"), "AudioOMX","AudioOutput",Option::TYPE_TEXT,2,0,0,audioopts,NULL,false,this); + options->push_back(option); + pane->addOptionLine(option); + + + char **ac3opts=new char *[3]; + int i=0; + ac3opts[i]=new char[strlen("PCM")+1]; + strcpy(ac3opts[i],"PCM"); + i++; + if (canpass_ac3) { + ac3opts[i]=new char[strlen("Passthrough")+1]; + strcpy(ac3opts[i],"PassThrough"); + i++; + } + if (canpass_pcm_mch) { + ac3opts[i]=new char[strlen("PCMMultichannel")+1]; + strcpy(ac3opts[i],"PCMMultichannel"); + i++; + } + option = new Option(1 ,tr("AC3 HDMI Mode"), "AudioOMX", "AC3DecodingMode", Option::TYPE_TEXT, i, 0, 0, ac3opts,NULL,true, this); + options->push_back(option); + pane->addOptionLine(option); + + char **mp2opts = new char *[3]; + i = 0; + mp2opts[i] = new char[strlen("PCM") + 1]; + strcpy(mp2opts[i], "PCM"); + i++; + if (canpass_mp2) { + mp2opts[i] = new char[strlen("Passthrough") + 1]; + strcpy(mp2opts[i], "PassThrough"); + i++; + } + if (canpass_pcm_mch) { + mp2opts[i] = new char[strlen("PCMMultichannel") + 1]; + strcpy(mp2opts[i], "PCMMultichannel"); + i++; + } + option = new Option(2, tr("Mp2 HDMI Mode"), "AudioOMX", + "Mp2DecodingMode", Option::TYPE_TEXT, i, 0, 0, + mp2opts, NULL, true, this); + options->push_back(option); + pane->addOptionLine(option); + + char **mp3opts = new char *[3]; + i = 0; + mp3opts[i] = new char[strlen("PCM") + 1]; + strcpy(mp3opts[i], "PCM"); + i++; + if (canpass_mp3) { + mp3opts[i] = new char[strlen("Passthrough") + 1]; + strcpy(mp3opts[i], "PassThrough"); + i++; + } + if (canpass_pcm_mch) { + mp3opts[i] = new char[strlen("PCMMultichannel") + 1]; + strcpy(mp3opts[i], "PCMMultichannel"); + i++; + } + option = new Option(3, tr("Mp3 HDMI Mode"), "AudioOMX", + "Mp2DecodingMode", Option::TYPE_TEXT, i, 0, 0, mp3opts, + NULL, true, this); + options->push_back(option); + pane->addOptionLine(option); + + + } + + return true; +} + + + + int AudioVPE::setStreamType(UCHAR type) { if (!initted) return 0; diff --git a/audiovpe.h b/audiovpe.h index b9be7ac..1d52f23 100644 --- a/audiovpe.h +++ b/audiovpe.h @@ -66,6 +66,12 @@ class AudioVPE : public Audio int getCurrentPacketNum(){return currentpacketnum;}; UCHAR getLastAType() {return lastAType;} + bool loadOptionsfromServer(VDR* vdr); + bool saveOptionstoServer(); + bool addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane); + bool handleOptionChanges(Option* option); + + #ifdef DEV int test(); #endif @@ -79,6 +85,19 @@ class AudioVPE : public Audio MediaPacket packet; UINT packetpos; + + bool hdmi; // use hdmi as audio output + bool passthrough; // use audio passthrough for the current audio type + + bool canpass_ac3; + bool canpass_mp2; + bool canpass_mp3; + bool canpass_pcm_mch; + + + int prefered_ac3; //0 stereo PCM, 1 passthrough 2 Multichannel PCM + int prefered_mp2; + int prefered_mp3; }; #endif diff --git a/raspi-patches/readme.txt b/raspi-patches/readme.txt index d6671a8..7c3b2a5 100644 --- a/raspi-patches/readme.txt +++ b/raspi-patches/readme.txt @@ -1,3 +1,10 @@ +Since now mpeg2 licenses are available, + a custom libav is not necessary anymore for transcoding. + I leave the patch here, if some one wants to pick up the idea again. + + Marten + +== Not necessary anymore == vompclient on Raspberry PI needs its own patched libav. Please use the skript fetch_libav.sh to download the libav from and to apply our custom libav patches and to run the configure command. -- 2.39.5