aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Morten Kvarving <cptspiff@gmail.com>2013-11-15 20:55:40 +0100
committerJonathan Marshall <jmarshall@xbmc.org>2014-07-10 19:15:22 +1200
commit0ccd9106373a7df135c4ef5ac2b025d62be9b4be (patch)
tree7d38c027022490f3c6e8e73411c0d2bd99f45113
parent858ef8cd37c27197fe9002d60b1ecd8c714f6bff (diff)
[audioencoders] move vorbis, lame, flac and wav audio encoders to add-ons
-rw-r--r--addons/audioencoder.xbmc.builtin.aac/addon.xml19
-rw-r--r--addons/audioencoder.xbmc.builtin.aac/resources/language/English/strings.po17
-rw-r--r--addons/audioencoder.xbmc.builtin.aac/resources/settings.xml3
-rw-r--r--addons/audioencoder.xbmc.builtin.wma/addon.xml19
-rw-r--r--addons/audioencoder.xbmc.builtin.wma/resources/language/English/strings.po17
-rw-r--r--addons/audioencoder.xbmc.builtin.wma/resources/settings.xml3
-rw-r--r--configure.in56
-rwxr-xr-xlanguage/English/strings.po11
-rw-r--r--system/settings/settings.xml64
-rw-r--r--xbmc/Application.cpp6
-rw-r--r--xbmc/Autorun.cpp14
-rw-r--r--xbmc/Autorun.h1
-rw-r--r--xbmc/DllPaths_generated.h.in2
-rw-r--r--xbmc/DllPaths_generated_android.h.in2
-rw-r--r--xbmc/DllPaths_win32.h2
-rw-r--r--xbmc/addons/Addon.cpp2
-rw-r--r--xbmc/addons/AddonManager.cpp13
-rw-r--r--xbmc/addons/AudioEncoder.cpp90
-rw-r--r--xbmc/addons/AudioEncoder.h51
-rw-r--r--xbmc/addons/IAddon.h1
-rw-r--r--xbmc/addons/Makefile1
-rw-r--r--xbmc/addons/addon-bindings.mk2
-rw-r--r--xbmc/addons/include/xbmc_audioenc_dll.h61
-rw-r--r--xbmc/addons/include/xbmc_audioenc_types.h113
-rw-r--r--xbmc/cdrip/CDDARipJob.cpp57
-rw-r--r--xbmc/cdrip/CDDARipper.cpp22
-rw-r--r--xbmc/cdrip/CDDARipper.h2
-rw-r--r--xbmc/cdrip/DllFlacEnc.h95
-rw-r--r--xbmc/cdrip/DllLameenc.h103
-rw-r--r--xbmc/cdrip/DllOgg.h59
-rw-r--r--xbmc/cdrip/DllVorbis.h89
-rw-r--r--xbmc/cdrip/DllVorbisEnc.h47
-rw-r--r--xbmc/cdrip/Encoder.cpp64
-rw-r--r--xbmc/cdrip/Encoder.h77
-rw-r--r--xbmc/cdrip/EncoderFFmpeg.cpp74
-rw-r--r--xbmc/cdrip/EncoderFFmpeg.h15
-rw-r--r--xbmc/cdrip/EncoderFlac.cpp187
-rw-r--r--xbmc/cdrip/EncoderFlac.h47
-rw-r--r--xbmc/cdrip/EncoderLame.cpp167
-rw-r--r--xbmc/cdrip/EncoderLame.h47
-rw-r--r--xbmc/cdrip/EncoderVorbis.cpp233
-rw-r--r--xbmc/cdrip/EncoderVorbis.h56
-rw-r--r--xbmc/cdrip/EncoderWav.cpp94
-rw-r--r--xbmc/cdrip/EncoderWav.h60
-rw-r--r--xbmc/cdrip/IEncoder.h56
-rw-r--r--xbmc/cdrip/Makefile.in9
-rw-r--r--xbmc/settings/Settings.cpp2
47 files changed, 650 insertions, 1582 deletions
diff --git a/addons/audioencoder.xbmc.builtin.aac/addon.xml b/addons/audioencoder.xbmc.builtin.aac/addon.xml
new file mode 100644
index 0000000000..eb484a95c6
--- /dev/null
+++ b/addons/audioencoder.xbmc.builtin.aac/addon.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<addon
+ id="audioencoder.xbmc.builtin.aac"
+ version="1.0.0"
+ name="AAC encoder"
+ provider-name="spiff">
+ <requires>
+ <import addon="xbmc.audioencoder" version="1.0.0"/>
+ </requires>
+ <extension
+ point="xbmc.audioencoder"
+ extension=".m4a"
+ library_linux="dummy.so"/>
+ <extension point="xbmc.addon.metadata">
+ <summary lang="en">AAC Audio Encoder</summary>
+ <description lang="en">AAC Audio Encoder</description>
+ <platform>all</platform>
+ </extension>
+</addon>
diff --git a/addons/audioencoder.xbmc.builtin.aac/resources/language/English/strings.po b/addons/audioencoder.xbmc.builtin.aac/resources/language/English/strings.po
new file mode 100644
index 0000000000..7ac3a3aa12
--- /dev/null
+++ b/addons/audioencoder.xbmc.builtin.aac/resources/language/English/strings.po
@@ -0,0 +1,17 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: XBMC Main Translation Project (Frodo)\n"
+"Report-Msgid-Bugs-To: http://trac.xbmc.org/\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: XBMC Translation Team\n"
+"Language-Team: English (http://www.transifex.com/projects/p/XBMC-Main-Frodo/language/en/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: en\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+msgctxt "#30000"
+msgid "Bitrate"
+msgstr ""
diff --git a/addons/audioencoder.xbmc.builtin.aac/resources/settings.xml b/addons/audioencoder.xbmc.builtin.aac/resources/settings.xml
new file mode 100644
index 0000000000..1eb80e6d42
--- /dev/null
+++ b/addons/audioencoder.xbmc.builtin.aac/resources/settings.xml
@@ -0,0 +1,3 @@
+<settings>
+ <setting id="bitrate" label="30000" type="enum" values="128|160|192|224|256|288|320" default="2"/>
+</settings>
diff --git a/addons/audioencoder.xbmc.builtin.wma/addon.xml b/addons/audioencoder.xbmc.builtin.wma/addon.xml
new file mode 100644
index 0000000000..6b02df3a4e
--- /dev/null
+++ b/addons/audioencoder.xbmc.builtin.wma/addon.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<addon
+ id="audioencoder.xbmc.builtin.wma"
+ version="1.0.0"
+ name="WMA encoder"
+ provider-name="spiff">
+ <requires>
+ <import addon="xbmc.audioencoder" version="1.0.0"/>
+ </requires>
+ <extension
+ point="xbmc.audioencoder"
+ extension=".wma"
+ library_linux="dummy.so"/>
+ <extension point="xbmc.addon.metadata">
+ <summary lang="en">WMA Audio Encoder</summary>
+ <description lang="en">WMA Audio Encoder</description>
+ <platform>all</platform>
+ </extension>
+</addon>
diff --git a/addons/audioencoder.xbmc.builtin.wma/resources/language/English/strings.po b/addons/audioencoder.xbmc.builtin.wma/resources/language/English/strings.po
new file mode 100644
index 0000000000..7ac3a3aa12
--- /dev/null
+++ b/addons/audioencoder.xbmc.builtin.wma/resources/language/English/strings.po
@@ -0,0 +1,17 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: XBMC Main Translation Project (Frodo)\n"
+"Report-Msgid-Bugs-To: http://trac.xbmc.org/\n"
+"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: XBMC Translation Team\n"
+"Language-Team: English (http://www.transifex.com/projects/p/XBMC-Main-Frodo/language/en/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Language: en\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+msgctxt "#30000"
+msgid "Bitrate"
+msgstr ""
diff --git a/addons/audioencoder.xbmc.builtin.wma/resources/settings.xml b/addons/audioencoder.xbmc.builtin.wma/resources/settings.xml
new file mode 100644
index 0000000000..1eb80e6d42
--- /dev/null
+++ b/addons/audioencoder.xbmc.builtin.wma/resources/settings.xml
@@ -0,0 +1,3 @@
+<settings>
+ <setting id="bitrate" label="30000" type="enum" values="128|160|192|224|256|288|320" default="2"/>
+</settings>
diff --git a/configure.in b/configure.in
index efd0574eb9..83687bb2cf 100644
--- a/configure.in
+++ b/configure.in
@@ -504,18 +504,6 @@ AC_ARG_ENABLE([libcec],
[use_libcec=$enableval],
[use_libcec=auto])
-AC_ARG_ENABLE([libmp3lame],
- [AS_HELP_STRING([--enable-libmp3lame],
- [enable lame mp3 encoder support (default is auto)])],
- [use_libmp3lame=$enableval],
- [use_libmp3lame=auto])
-
-AC_ARG_ENABLE([libvorbisenc],
- [AS_HELP_STRING([--enable-libvorbisenc],
- [enable vorbis encoder support (default is auto)])],
- [use_libvorbisenc=$enableval],
- [use_libvorbisenc=auto])
-
AC_ARG_ENABLE([libcap],
[AS_HELP_STRING([--enable-libcap],
[enable libcap support (default is auto)])],
@@ -1229,37 +1217,6 @@ XB_FIND_SONAME([MODPLUG], [modplug])
XB_FIND_SONAME([ASS], [ass])
XB_FIND_SONAME([MPEG2], [mpeg2])
-# Audio encoders
-if test "x$use_libmp3lame" != "xno"; then
- XB_FIND_SONAME([LAMEENC], [mp3lame], [use_libmp3lame])
- if test "x$use_libmp3lame" != "xno"; then
- AC_CHECK_HEADER([lame/lame.h],, AC_MSG_ERROR($missing_headers))
- fi
-fi
-AS_CASE([x$use_libmp3lame],
- [xno],[
- AC_SUBST([HAVE_LIBMP3LAME], 0)
- ],
- [
- AC_DEFINE([HAVE_LIBMP3LAME], 1, [System has libmp3lame library])
- AC_SUBST([HAVE_LIBMP3LAME], 1)
- ]
-)
-if test "x$use_libvorbisenc" != "xno"; then
- XB_FIND_SONAME([VORBISENC], [vorbisenc], [use_libvorbisenc])
- if test "x$use_libvorbisenc" != "xno"; then
- AC_CHECK_HEADER([vorbis/vorbisenc.h],, AC_MSG_ERROR($missing_headers))
- fi
-fi
-AS_CASE([x$use_libvorbisenc],
- [xno],[
- AC_SUBST([HAVE_LIBVORBISENC], 0)
- ],[
- AC_DEFINE([HAVE_LIBVORBISENC], 1, [System has libvorbisenc library])
- AC_SUBST([HAVE_LIBVORBISENC], 1)
- ]
-)
-
# WebServer
if test "$use_webserver" = "yes"; then
AC_CHECK_LIB([microhttpd], [main],, AC_MSG_ERROR($missing_library))
@@ -2459,18 +2416,6 @@ else
final_message="$final_message\n libcec support:\tNo"
fi
-if test "x$use_libmp3lame" != "xno"; then
- final_message="$final_message\n libmp3lame support:\tYes"
-else
- final_message="$final_message\n libmp3lame support:\tNo"
-fi
-
-if test "x$use_libvorbisenc" != "xno"; then
- final_message="$final_message\n libvorbisenc support:\tYes"
-else
- final_message="$final_message\n libvorbisenc support:\tNo"
-fi
-
if test "x$use_libcap" != "xno"; then
final_message="$final_message\n libcap support:\tYes"
else
@@ -2651,7 +2596,6 @@ AC_SUBST(LIBFLAC_BASENAME)
AC_SUBST(LIBVORBISFILE_BASENAME)
AC_SUBST(LIBMODPLUG_BASENAME)
AC_SUBST(LIBOGG_BASENAME)
-AC_SUBST(LIBVORBISENC_BASENAME)
AC_SUBST(LIBVORBIS_BASENAME)
AC_SUBST(LIBASS_BASENAME)
AC_SUBST(LIBMEPG2_BASENAME)
diff --git a/language/English/strings.po b/language/English/strings.po
index 17e8cb961a..9a002223b0 100755
--- a/language/English/strings.po
+++ b/language/English/strings.po
@@ -823,7 +823,11 @@ msgctxt "#199"
msgid "Web interface"
msgstr ""
-#empty strings from id 200 to 201
+msgctxt "#200"
+msgid "Audio encoders"
+msgstr ""
+
+#empty string with id 201
#: xbmc/playlists/SmartPlaylist.cpp
msgctxt "#202"
@@ -15778,3 +15782,8 @@ msgstr ""
msgctxt "#37024"
msgid "Select this if the audio out connection only supports multichannel audio as Dolby Digital 5.1, this allows multichannel audio such as AAC5.1 or FLAC5.1 to be listened to in 5.1 surround sound. Note - Not recommended on Pi as this requires a lot of CPU."
msgstr ""
+
+#: system/settings/settings.xml
+msgctxt "#37025"
+msgid "Configure audio encoder settings such as quality and compression level"
+msgstr ""
diff --git a/system/settings/settings.xml b/system/settings/settings.xml
index 472256c4c5..ba258ed089 100644
--- a/system/settings/settings.xml
+++ b/system/settings/settings.xml
@@ -1747,68 +1747,22 @@
<heading>16016</heading>
</control>
</setting>
- <setting id="audiocds.encoder" type="integer" label="621" help="36287">
- <level>2</level>
- <default>3</default> <!-- CDDARIP_ENCODER_FLAC -->
- <constraints>
- <options>audiocdencoders</options>
- </constraints>
- <control type="spinner" format="string" />
- </setting>
- <setting id="audiocds.quality" type="integer" parent="audiocds.encoder" label="622" help="36288">
- <level>2</level>
- <default>0</default> <!-- CDDARIP_QUALITY_CBR -->
+ <setting id="audiocds.encoder" type="addon" label="621" help="36287">
+ <level>0</level>
+ <default>audioencoder.xbmc.builtin.wav</default>
<constraints>
- <options>
- <option label="604">0</option> <!-- CDDARIP_QUALITY_CBR -->
- <option label="601">1</option> <!-- CDDARIP_QUALITY_MEDIUM -->
- <option label="602">2</option> <!-- CDDARIP_QUALITY_STANDARD -->
- <option label="603">3</option> <!-- CDDARIP_QUALITY_EXTREME -->
- </options>
+ <addontype>xbmc.audioencoder</addontype>
</constraints>
- <dependencies>
- <dependency type="enable">
- <and>
- <condition setting="audiocds.encoder" operator="!is">2</condition> <!-- CDDARIP_ENCODER_WAV -->
- <condition setting="audiocds.encoder" operator="!is">3</condition> <!-- CDDARIP_ENCODER_FLAC -->
- </and>
- </dependency>
- </dependencies>
- <control type="spinner" format="string" />
+ <control type="button" format="addon" />
</setting>
- <setting id="audiocds.bitrate" type="integer" parent="audiocds.encoder" label="623" help="36289">
- <level>2</level>
- <default>192</default>
- <constraints>
- <minimum>128</minimum>
- <step>32</step>
- <maximum>320</maximum>
- </constraints>
+ <setting id="audiocds.settings" parent="audiocds.encoder" type="action" label="21417" help="37025">
+ <level>1</level>
<dependencies>
<dependency type="enable">
- <and>
- <condition setting="audiocds.encoder" operator="!is">2</condition> <!-- CDDARIP_ENCODER_WAV -->
- <condition setting="audiocds.encoder" operator="!is">3</condition> <!-- CDDARIP_ENCODER_FLAC -->
- <condition setting="audiocds.quality" operator="is">0</condition> <!-- CDDARIP_QUALITY_CBR -->
- </and>
+ <condition on="property" name="AddonHasSettings" setting="audiocds.encoder" />
</dependency>
</dependencies>
- <control type="spinner" format="string">
- <formatlabel>14048</formatlabel>
- </control>
- </setting>
- <setting id="audiocds.compressionlevel" type="integer" parent="audiocds.encoder" label="665" help="36290">
- <level>2</level>
- <default>5</default>
- <constraints>
- <minimum>0</minimum>
- <step>1</step>
- <maximum>8</maximum>
- </constraints>
- <dependencies>
- <dependency type="enable" setting="audiocds.encoder">3</dependency> <!-- CDDARIP_ENCODER_FLAC -->
- </dependencies>
- <control type="spinner" format="integer" />
+ <control type="button" format="action" />
</setting>
<setting id="audiocds.ejectonrip" type="boolean" label="14099" help="36291">
<level>1</level>
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index c9690fcd94..1499ca496d 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -1715,6 +1715,12 @@ void CApplication::OnSettingAction(const CSetting *setting)
if (CAddonMgr::Get().GetAddon(CSettings::Get().GetString("screensaver.mode"), addon, ADDON_SCREENSAVER))
CGUIDialogAddonSettings::ShowAndGetInput(addon);
}
+ else if (settingId == "audiocds.settings")
+ {
+ AddonPtr addon;
+ if (CAddonMgr::Get().GetAddon(CSettings::Get().GetString("audiocds.encoder"), addon, ADDON_AUDIOENCODER))
+ CGUIDialogAddonSettings::ShowAndGetInput(addon);
+ }
else if (settingId == "videoscreen.guicalibration")
g_windowManager.ActivateWindow(WINDOW_SCREEN_CALIBRATION);
else if (settingId == "videoscreen.testpattern")
diff --git a/xbmc/Autorun.cpp b/xbmc/Autorun.cpp
index ddf13ecf78..6c64e4593b 100644
--- a/xbmc/Autorun.cpp
+++ b/xbmc/Autorun.cpp
@@ -516,18 +516,4 @@ void CAutorun::SettingOptionAudioCdActionsFiller(const CSetting *setting, std::v
#endif
}
-void CAutorun::SettingOptionAudioCdEncodersFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current, void *data)
-{
-#ifdef HAVE_LIBMP3LAME
- list.push_back(make_pair(g_localizeStrings.Get(34000), CDDARIP_ENCODER_LAME));
-#endif
-#ifdef HAVE_LIBVORBISENC
- list.push_back(make_pair(g_localizeStrings.Get(34001), CDDARIP_ENCODER_VORBIS));
-#endif
- list.push_back(make_pair(g_localizeStrings.Get(34002), CDDARIP_ENCODER_WAV));
- list.push_back(make_pair(g_localizeStrings.Get(34005), CDDARIP_ENCODER_FLAC));
- list.push_back(make_pair(g_localizeStrings.Get(34006), CDDARIP_ENCODER_FFMPEG_M4A));
- list.push_back(make_pair(g_localizeStrings.Get(34007), CDDARIP_ENCODER_FFMPEG_WMA));
-}
-
#endif
diff --git a/xbmc/Autorun.h b/xbmc/Autorun.h
index 04c10c87f2..04b1787a07 100644
--- a/xbmc/Autorun.h
+++ b/xbmc/Autorun.h
@@ -65,7 +65,6 @@ public:
static void ExecuteAutorun(const CStdString& path = "", bool bypassSettings = false, bool ignoreplaying = false, bool startFromBeginning = false);
static void SettingOptionAudioCdActionsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current, void *data);
- static void SettingOptionAudioCdEncodersFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current, void *data);
protected:
static bool RunDisc(XFILE::IDirectory* pDir, const CStdString& strDrive, int& nAddedToPlaylist, bool bRoot, bool bypassSettings, bool startFromBeginning);
diff --git a/xbmc/DllPaths_generated.h.in b/xbmc/DllPaths_generated.h.in
index baebb4dbad..74bd5d1820 100644
--- a/xbmc/DllPaths_generated.h.in
+++ b/xbmc/DllPaths_generated.h.in
@@ -70,9 +70,7 @@
#define DLL_PATH_LIBMPEG2 "@MPEG2_SONAME@"
/* cdrip */
-#define DLL_PATH_LAME_ENC "@LAMEENC_SONAME@"
#define DLL_PATH_OGG "@OGG_SONAME@"
-#define DLL_PATH_VORBIS_ENC "@VORBISENC_SONAME@"
#define DLL_PATH_VORBIS "@VORBIS_SONAME@"
/* broadcom crystalhd */
diff --git a/xbmc/DllPaths_generated_android.h.in b/xbmc/DllPaths_generated_android.h.in
index b0d83b4f38..56c09b7a9a 100644
--- a/xbmc/DllPaths_generated_android.h.in
+++ b/xbmc/DllPaths_generated_android.h.in
@@ -74,9 +74,7 @@
#define DLL_PATH_LIBSTAGEFRIGHTICS "libXBMCvcodec_stagefrightICS-@ARCH@.so"
/* cdrip */
-#define DLL_PATH_LAME_ENC "@LAMEENC_SONAME@"
#define DLL_PATH_OGG "@OGG_SONAME@"
-#define DLL_PATH_VORBIS_ENC "@VORBISENC_SONAME@"
#define DLL_PATH_VORBIS "@VORBIS_SONAME@"
/* libbluray */
diff --git a/xbmc/DllPaths_win32.h b/xbmc/DllPaths_win32.h
index 7f302a05e4..4cf3cd1122 100644
--- a/xbmc/DllPaths_win32.h
+++ b/xbmc/DllPaths_win32.h
@@ -64,9 +64,7 @@
#define DLL_PATH_LIBSWRESAMPLE "special://xbmcbin/system/players/dvdplayer/swresample-0.dll"
/* cdrip */
-#define DLL_PATH_LAME_ENC "special://xbmcbin/system/cdrip/lame_enc.dll"
#define DLL_PATH_OGG "special://xbmcbin/system/cdrip/ogg.dll"
-#define DLL_PATH_VORBIS_ENC "special://xbmcbin/system/cdrip/vorbisenc.dll"
#define DLL_PATH_VORBIS "special://xbmcbin/system/cdrip/vorbis.dll"
/* libbluray */
diff --git a/xbmc/addons/Addon.cpp b/xbmc/addons/Addon.cpp
index ccfd99c694..38b7b7129a 100644
--- a/xbmc/addons/Addon.cpp
+++ b/xbmc/addons/Addon.cpp
@@ -87,6 +87,7 @@ static const TypeMapping types[] =
{"xbmc.addon.audio", ADDON_AUDIO, 1038, "DefaultAddonMusic.png" },
{"xbmc.addon.image", ADDON_IMAGE, 1039, "DefaultAddonPicture.png" },
{"xbmc.addon.executable", ADDON_EXECUTABLE, 1043, "DefaultAddonProgram.png" },
+ {"xbmc.audioencoder", ADDON_AUDIOENCODER, 200, "DefaultAddonAudioEncoder.png" },
{"xbmc.service", ADDON_SERVICE, 24018, "DefaultAddonService.png" }};
const CStdString TranslateType(const ADDON::TYPE &type, bool pretty/*=false*/)
@@ -392,6 +393,7 @@ void CAddon::BuildLibName(const cp_extension_t *extension)
case ADDON_PLUGIN:
case ADDON_SERVICE:
case ADDON_REPOSITORY:
+ case ADDON_AUDIOENCODER:
{
CStdString temp = CAddonMgr::Get().GetExtValue(extension->configuration, "@library");
m_strLibName = temp;
diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp
index 9b63e51663..34b170c0a0 100644
--- a/xbmc/addons/AddonManager.cpp
+++ b/xbmc/addons/AddonManager.cpp
@@ -19,6 +19,7 @@
*/
#include "AddonManager.h"
#include "Addon.h"
+#include "AudioEncoder.h"
#include "DllLibCPluff.h"
#include "utils/StringUtils.h"
#include "utils/JobManager.h"
@@ -114,6 +115,7 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
case ADDON_VIZ:
case ADDON_SCREENSAVER:
case ADDON_PVRDLL:
+ case ADDON_AUDIOENCODER:
{ // begin temporary platform handling for Dlls
// ideally platforms issues will be handled by C-Pluff
// this is not an attempt at a solution
@@ -128,7 +130,12 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
if (URIUtils::HasExtension(library, ".py"))
return AddonPtr(new CScreenSaver(props));
}
-#if defined(TARGET_ANDROID)
+ if (type == ADDON_AUDIOENCODER && 0 == strncmp(props->plugin->identifier,
+ "audioencoder.xbmc.builtin.", 26))
+ { // built in audio encoder
+ return AddonPtr(new CAudioEncoder(props));
+ }
+#if defined(TARGET_ANDROID)
if ((value = GetExtValue(props->plugin->extensions->configuration, "@library_android")) && value.empty())
break;
#elif defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
@@ -156,6 +163,8 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
return AddonPtr(new CPVRClient(props));
#endif
}
+ else if (type == ADDON_AUDIOENCODER)
+ return AddonPtr(new CAudioEncoder(props));
else
return AddonPtr(new CScreenSaver(props));
}
@@ -663,6 +672,8 @@ AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
return AddonPtr(new CAddonLibrary(addonProps));
case ADDON_PVRDLL:
return AddonPtr(new CPVRClient(addonProps));
+ case ADDON_AUDIOENCODER:
+ return AddonPtr(new CAudioEncoder(addonProps));
case ADDON_REPOSITORY:
return AddonPtr(new CRepository(addonProps));
default:
diff --git a/xbmc/addons/AudioEncoder.cpp b/xbmc/addons/AudioEncoder.cpp
new file mode 100644
index 0000000000..2737bba036
--- /dev/null
+++ b/xbmc/addons/AudioEncoder.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2013 Arne Morten Kvarving
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#include "AudioEncoder.h"
+
+namespace ADDON
+{
+
+CAudioEncoder::CAudioEncoder(const cp_extension_t* ext)
+ : AudioEncoderDll(ext),
+ extension(CAddonMgr::Get().GetExtValue(ext->configuration, "@extension")),
+ m_context(NULL)
+{
+}
+
+AddonPtr CAudioEncoder::Clone() const
+{
+ // Copy constructor is generated by compiler and calls parent copy constructor
+ return AddonPtr(new CAudioEncoder(*this));
+}
+
+bool CAudioEncoder::Init(audioenc_callbacks &callbacks)
+{
+ if (!Initialized())
+ return false;
+
+ // create encoder instance
+ m_context = m_pStruct->Create(&callbacks);
+ if (!m_context)
+ return false;
+
+ return m_pStruct->Start(m_context,
+ m_iInChannels,
+ m_iInSampleRate,
+ m_iInBitsPerSample,
+ m_strTitle.c_str(),
+ m_strArtist.c_str(),
+ m_strAlbumArtist.c_str(),
+ m_strAlbum.c_str(),
+ m_strYear.c_str(),
+ m_strTrack.c_str(),
+ m_strGenre.c_str(),
+ m_strComment.c_str(),
+ m_iTrackLength);
+}
+
+int CAudioEncoder::Encode(int nNumBytesRead, uint8_t* pbtStream)
+{
+ if (!Initialized() || !m_context)
+ return 0;
+
+ return m_pStruct->Encode(m_context, nNumBytesRead, pbtStream);
+}
+
+bool CAudioEncoder::Close()
+{
+ if (!Initialized() || !m_context)
+ return false;
+
+ if (!m_pStruct->Finish(m_context))
+ return false;
+
+ m_pStruct->Free(m_context);
+ m_context = NULL;
+
+ return true;
+}
+
+void CAudioEncoder::Destroy()
+{
+ AudioEncoderDll::Destroy();
+}
+
+} /*namespace ADDON*/
+
diff --git a/xbmc/addons/AudioEncoder.h b/xbmc/addons/AudioEncoder.h
new file mode 100644
index 0000000000..3900333f81
--- /dev/null
+++ b/xbmc/addons/AudioEncoder.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 Arne Morten Kvarving
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+
+#include "AddonDll.h"
+#include "include/xbmc_audioenc_types.h"
+#include "cdrip/IEncoder.h"
+
+typedef DllAddon<AudioEncoder, AUDIOENC_PROPS> DllAudioEncoder;
+namespace ADDON
+{
+ typedef CAddonDll<DllAudioEncoder,
+ AudioEncoder, AUDIOENC_PROPS> AudioEncoderDll;
+
+ class CAudioEncoder : public AudioEncoderDll, public IEncoder
+ {
+ public:
+ CAudioEncoder(const AddonProps &props) : AudioEncoderDll(props) {};
+ CAudioEncoder(const cp_extension_t *ext);
+ virtual ~CAudioEncoder() {}
+ virtual AddonPtr Clone() const;
+
+ // Things that MUST be supplied by the child classes
+ bool Init(audioenc_callbacks &callbacks);
+ int Encode(int nNumBytesRead, uint8_t* pbtStream);
+ bool Close();
+ void Destroy();
+
+ const std::string extension;
+
+ private:
+ void *m_context; ///< audio encoder context
+ };
+
+} /*namespace ADDON*/
diff --git a/xbmc/addons/IAddon.h b/xbmc/addons/IAddon.h
index 41bbe134d2..fde7c885b3 100644
--- a/xbmc/addons/IAddon.h
+++ b/xbmc/addons/IAddon.h
@@ -50,6 +50,7 @@ namespace ADDON
ADDON_REPOSITORY,
ADDON_WEB_INTERFACE,
ADDON_SERVICE,
+ ADDON_AUDIOENCODER,
ADDON_VIDEO, // virtual addon types
ADDON_AUDIO,
ADDON_IMAGE,
diff --git a/xbmc/addons/Makefile b/xbmc/addons/Makefile
index 5222da2e18..33c445637a 100644
--- a/xbmc/addons/Makefile
+++ b/xbmc/addons/Makefile
@@ -9,6 +9,7 @@ SRCS=Addon.cpp \
AddonManager.cpp \
AddonStatusHandler.cpp \
AddonVersion.cpp \
+ AudioEncoder.cpp \
GUIDialogAddonInfo.cpp \
GUIDialogAddonSettings.cpp \
GUIViewStateAddonBrowser.cpp \
diff --git a/xbmc/addons/addon-bindings.mk b/xbmc/addons/addon-bindings.mk
index 9a83a903eb..50d75bcadf 100644
--- a/xbmc/addons/addon-bindings.mk
+++ b/xbmc/addons/addon-bindings.mk
@@ -1,6 +1,8 @@
BINDINGS =xbmc/addons/include/xbmc_addon_cpp_dll.h
BINDINGS+=xbmc/addons/include/xbmc_addon_dll.h
BINDINGS+=xbmc/addons/include/xbmc_addon_types.h
+BINDINGS+=xbmc/addons/include/xbmc_audioenc_dll.h
+BINDINGS+=xbmc/addons/include/xbmc_audioenc_types.h
BINDINGS+=xbmc/addons/include/xbmc_codec_types.h
BINDINGS+=xbmc/addons/include/xbmc_epg_types.h
BINDINGS+=xbmc/addons/include/xbmc_pvr_dll.h
diff --git a/xbmc/addons/include/xbmc_audioenc_dll.h b/xbmc/addons/include/xbmc_audioenc_dll.h
new file mode 100644
index 0000000000..01e8d1202f
--- /dev/null
+++ b/xbmc/addons/include/xbmc_audioenc_dll.h
@@ -0,0 +1,61 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __XBMC_AUDIOENC_H__
+#define __XBMC_AUDIOENC_H__
+
+#include <stdint.h>
+#include "xbmc_addon_dll.h"
+#include "xbmc_audioenc_types.h"
+
+extern "C"
+{
+ //! \copydoc AudioEncoder::Create
+ void* Create(audioenc_callbacks *callbacks);
+
+ //! \copydoc AudioEncoder::Start
+ bool Start(void* context, int iInChannels, int iInRate, int iInBits,
+ const char* title, const char* artist,
+ const char* albumartist, const char* album,
+ const char* year, const char* track,
+ const char* genre, const char* comment, int iTrackLength);
+
+ //! \copydoc AudioEncoder::Encode
+ int Encode(void* context, int nNumBytesRead, uint8_t* pbtStream);
+
+ //! \copydoc AudioEncoder::Finish
+ bool Finish(void* context);
+
+ //! \copydoc AudioEncoder::Free
+ void Free(void* context);
+
+ // function to export the above structure to XBMC
+ void __declspec(dllexport) get_addon(struct AudioEncoder* pScr)
+ {
+ pScr->Create = Create;
+ pScr->Start = Start;
+ pScr->Encode = Encode;
+ pScr->Finish = Finish;
+ pScr->Free = Free;
+ };
+};
+
+#endif
diff --git a/xbmc/addons/include/xbmc_audioenc_types.h b/xbmc/addons/include/xbmc_audioenc_types.h
new file mode 100644
index 0000000000..aa527dbde6
--- /dev/null
+++ b/xbmc/addons/include/xbmc_audioenc_types.h
@@ -0,0 +1,113 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2013 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef __AUDIOENC_TYPES_H__
+#define __AUDIOENC_TYPES_H__
+
+#ifdef TARGET_WINDOWS
+#include <windows.h>
+#else
+#ifndef __cdecl
+#define __cdecl
+#endif
+#ifndef __declspec
+#define __declspec(X)
+#endif
+#endif
+
+#include <stdint.h>
+
+extern "C"
+{
+ struct AUDIOENC_INFO
+ {
+ int dummy;
+ };
+
+ struct AUDIOENC_PROPS
+ {
+ int dummy;
+ };
+
+ typedef int (*audioenc_write_callback)(void* opaque, uint8_t* data, int len);
+ typedef int64_t (*audioenc_seek_callback)(void* opaque, int64_t pos, int whence);
+
+ typedef struct
+ {
+ void* opaque;
+ audioenc_write_callback write;
+ audioenc_seek_callback seek;
+ } audioenc_callbacks;
+
+ struct AudioEncoder
+ {
+ /*! \brief Create encoder context
+ \param callbacks Pointer to audioenc_callbacks structure.
+ \return opaque pointer to encoder context, to be passed to other methods.
+ \sa IEncoder::Init
+ */
+ void (*(__cdecl *Create) (audioenc_callbacks* callbacks));
+
+ /*! \brief Start encoder
+ \param context Encoder context from Create.
+ \param iInChannels Number of channels
+ \param iInRate Sample rate of input data
+ \param iInBits Bits per sample in input data
+ \param title The title of the song
+ \param artist The artist of the song
+ \param albumartist The albumartist of the song
+ \param year The year of the song
+ \param track The track number of the song
+ \param genre The genre of the song
+ \param comment A comment to attach to the song
+ \param iTrackLength Total track length in seconds
+ \sa IEncoder::Init
+ */
+ bool (__cdecl* Start) (void* context, int iInChannels, int iInRate, int iInBits,
+ const char* title, const char* artist,
+ const char* albumartist, const char* album,
+ const char* year, const char* track,
+ const char* genre, const char* comment,
+ int iTrackLength);
+
+ /*! \brief Encode a chunk of audio
+ \param context Encoder context from Create.
+ \param nNumBytesRead Number of bytes in input buffer
+ \param pbtStream the input buffer
+ \return Number of bytes consumed
+ \sa IEncoder::Encode
+ */
+ int (__cdecl* Encode) (void* context, int nNumBytesRead, uint8_t* pbtStream);
+
+ /*! \brief Finalize encoding
+ \param context Encoder context from Create.
+ \return True on success, false on failure.
+ */
+ bool (__cdecl* Finish) (void* context);
+
+ /*! \brief Free encoder context
+ \param context Encoder context to free.
+ */
+ void (__cdecl* Free)(void* context);
+ };
+}
+
+#endif
diff --git a/xbmc/cdrip/CDDARipJob.cpp b/xbmc/cdrip/CDDARipJob.cpp
index 3abd4833a6..045a73b314 100644
--- a/xbmc/cdrip/CDDARipJob.cpp
+++ b/xbmc/cdrip/CDDARipJob.cpp
@@ -19,16 +19,8 @@
*/
#include "CDDARipJob.h"
-#include "system.h"
-#ifdef HAVE_LIBMP3LAME
-#include "EncoderLame.h"
-#endif
-#ifdef HAVE_LIBVORBISENC
-#include "EncoderVorbis.h"
-#endif
-#include "EncoderWav.h"
+#include "Encoder.h"
#include "EncoderFFmpeg.h"
-#include "EncoderFlac.h"
#include "FileItem.h"
#include "utils/log.h"
#include "Util.h"
@@ -37,10 +29,14 @@
#include "filesystem/SpecialProtocol.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
+#include "settings/Settings.h"
#include "settings/AdvancedSettings.h"
#include "utils/StringUtils.h"
#include "storage/MediaManager.h"
+#include "addons/AddonManager.h"
+#include "addons/AudioEncoder.h"
+using namespace ADDON;
using namespace MUSIC_INFO;
using namespace XFILE;
@@ -113,7 +109,7 @@ bool CCDDARipJob::DoWork()
}
// close encoder ripper
- encoder->Close();
+ encoder->CloseEncode();
delete encoder;
reader.Close();
@@ -182,32 +178,25 @@ int CCDDARipJob::RipChunk(CFile& reader, CEncoder* encoder, int& percent)
CEncoder* CCDDARipJob::SetupEncoder(CFile& reader)
{
- CEncoder* encoder;
- switch (m_encoder)
+ CEncoder* encoder = NULL;
+ if (CSettings::Get().GetString("audiocds.encoder") == "audioencoder.xbmc.builtin.aac" ||
+ CSettings::Get().GetString("audiocds.encoder") == "audioencoder.xbmc.builtin.wma")
{
-#ifdef HAVE_LIBVORBISENC
- case CDDARIP_ENCODER_VORBIS:
- encoder = new CEncoderVorbis();
- break;
-#endif
-#ifdef HAVE_LIBMP3LAME
- case CDDARIP_ENCODER_LAME:
- encoder = new CEncoderLame();
- break;
-#endif
- case CDDARIP_ENCODER_FLAC:
- encoder = new CEncoderFlac();
- break;
- case CDDARIP_ENCODER_FFMPEG_M4A:
- case CDDARIP_ENCODER_FFMPEG_WMA:
- encoder = new CEncoderFFmpeg();
- break;
- case CDDARIP_ENCODER_WAV:
- default:
- encoder = new CEncoderWav();
- break;
+ boost::shared_ptr<IEncoder> enc(new CEncoderFFmpeg());
+ encoder = new CEncoder(enc);
+ }
+ else
+ {
+ AddonPtr addon;
+ CAddonMgr::Get().GetAddon(CSettings::Get().GetString("audiocds.encoder"), addon);
+ if (addon)
+ {
+ boost::shared_ptr<CAudioEncoder> aud = boost::static_pointer_cast<CAudioEncoder>(addon);
+ aud->Create();
+ boost::shared_ptr<IEncoder> enc = boost::static_pointer_cast<IEncoder>(aud);
+ encoder = new CEncoder(enc);
+ }
}
-
if (!encoder)
return NULL;
diff --git a/xbmc/cdrip/CDDARipper.cpp b/xbmc/cdrip/CDDARipper.cpp
index 4e7b88d9f1..b837cfee89 100644
--- a/xbmc/cdrip/CDDARipper.cpp
+++ b/xbmc/cdrip/CDDARipper.cpp
@@ -47,8 +47,11 @@
#include "settings/MediaSourceSettings.h"
#include "Application.h"
#include "music/MusicDatabase.h"
+#include "addons/AddonManager.h"
+#include "addons/AudioEncoder.h"
using namespace std;
+using namespace ADDON;
using namespace XFILE;
using namespace MUSIC_INFO;
@@ -150,16 +153,6 @@ bool CCDDARipper::RipCD()
return true;
}
-const char* CCDDARipper::GetExtension(int iEncoder)
-{
- if (iEncoder == CDDARIP_ENCODER_WAV) return ".wav";
- if (iEncoder == CDDARIP_ENCODER_VORBIS) return ".ogg";
- if (iEncoder == CDDARIP_ENCODER_FLAC) return ".flac";
- if (iEncoder == CDDARIP_ENCODER_FFMPEG_M4A) return ".m4a";
- if (iEncoder == CDDARIP_ENCODER_FFMPEG_WMA) return ".wma";
- return ".mp3";
-}
-
bool CCDDARipper::CreateAlbumDir(const MUSIC_INFO::CMusicInfoTag& infoTag, CStdString& strDirectory, int& legalType)
{
CSettingPath *recordingpathSetting = (CSettingPath*)CSettings::Get().GetSetting("audiocds.recordingpath");
@@ -299,7 +292,14 @@ CStdString CCDDARipper::GetTrackName(CFileItem *item)
CStdString track = destItem.GetLabel();
if (track.empty())
track = StringUtils::Format("%s%02i", "Track-", trackNumber);
- track += GetExtension(CSettings::Get().GetInt("audiocds.encoder"));
+
+ AddonPtr addon;
+ CAddonMgr::Get().GetAddon(CSettings::Get().GetString("audiocds.encoder"), addon);
+ if (addon)
+ {
+ boost::shared_ptr<CAudioEncoder> enc = boost::static_pointer_cast<CAudioEncoder>(addon);
+ track += enc->extension;
+ }
return track;
}
diff --git a/xbmc/cdrip/CDDARipper.h b/xbmc/cdrip/CDDARipper.h
index 113594eea4..488ef7ef2f 100644
--- a/xbmc/cdrip/CDDARipper.h
+++ b/xbmc/cdrip/CDDARipper.h
@@ -21,7 +21,7 @@
*
*/
-#include "Encoder.h"
+#include "utils/StdString.h"
#include "utils/JobManager.h"
class CFileItem;
diff --git a/xbmc/cdrip/DllFlacEnc.h b/xbmc/cdrip/DllFlacEnc.h
deleted file mode 100644
index 779e740830..0000000000
--- a/xbmc/cdrip/DllFlacEnc.h
+++ /dev/null
@@ -1,95 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#if (defined HAVE_CONFIG_H) && (!defined WIN32)
- #include "config.h"
-#endif
-
-#include <FLAC/stream_encoder.h>
-#include <FLAC/metadata.h>
-
-#include "DynamicDll.h"
-
-class DllFlacEncInterface
-{
-public:
- virtual FLAC__StreamEncoder *FLAC__stream_encoder_new()=0;
- virtual FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value)=0;
- virtual FLAC__bool FLAC__stream_encoder_set_compression_level(FLAC__StreamEncoder *encoder, unsigned value)=0;
- virtual FLAC__bool FLAC__stream_encoder_set_channels(FLAC__StreamEncoder *encoder, unsigned value)=0;
- virtual FLAC__bool FLAC__stream_encoder_set_bits_per_sample(FLAC__StreamEncoder *encoder, unsigned value)=0;
- virtual FLAC__bool FLAC__stream_encoder_set_sample_rate(FLAC__StreamEncoder *encoder, unsigned value)=0;
- virtual FLAC__bool FLAC__stream_encoder_set_total_samples_estimate(FLAC__StreamEncoder *encoder, FLAC__uint64 value)=0;
- virtual FLAC__bool FLAC__stream_encoder_set_metadata(FLAC__StreamEncoder *encoder, FLAC__StreamMetadata **metadata, unsigned num_blocks)=0;
- virtual FLAC__StreamEncoderInitStatus FLAC__stream_encoder_init_stream(FLAC__StreamEncoder *encoder, FLAC__StreamEncoderWriteCallback write_callback, FLAC__StreamEncoderSeekCallback seek_callback, FLAC__StreamEncoderTellCallback tell_callback, FLAC__StreamEncoderMetadataCallback metadata_callback, void *client_data)=0;
- virtual FLAC__bool FLAC__stream_encoder_process_interleaved(FLAC__StreamEncoder *encoder, const FLAC__int32 buffer[], unsigned samples)=0;
- virtual FLAC__StreamEncoderState FLAC__stream_encoder_get_state(FLAC__StreamEncoder *encoder)=0;
- virtual FLAC__bool FLAC__stream_encoder_finish(FLAC__StreamEncoder *encoder)=0;
- virtual void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder)=0;
- virtual FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type)=0;
- virtual FLAC__bool FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *field_name, const char *field_value)=0;
- virtual FLAC__bool FLAC__metadata_object_vorbiscomment_append_comment(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy)=0;
- virtual void FLAC__metadata_object_delete(FLAC__StreamMetadata *object)=0;
- virtual ~DllFlacEncInterface() {}
-};
-
-class DllFlacEnc : public DllDynamic, DllFlacEncInterface
-{
- DECLARE_DLL_WRAPPER(DllFlacEnc, DLL_PATH_FLAC_CODEC)
- DEFINE_METHOD0(FLAC__StreamEncoder*, FLAC__stream_encoder_new)
- DEFINE_METHOD2(FLAC__bool, FLAC__stream_encoder_set_verify, (FLAC__StreamEncoder *p1, FLAC__bool p2))
- DEFINE_METHOD2(FLAC__bool, FLAC__stream_encoder_set_compression_level, (FLAC__StreamEncoder *p1, unsigned p2))
- DEFINE_METHOD2(FLAC__bool, FLAC__stream_encoder_set_channels, (FLAC__StreamEncoder *p1, unsigned p2))
- DEFINE_METHOD2(FLAC__bool, FLAC__stream_encoder_set_bits_per_sample, (FLAC__StreamEncoder *p1, unsigned p2))
- DEFINE_METHOD2(FLAC__bool, FLAC__stream_encoder_set_sample_rate, (FLAC__StreamEncoder *p1, unsigned p2))
- DEFINE_METHOD2(FLAC__bool, FLAC__stream_encoder_set_total_samples_estimate, (FLAC__StreamEncoder *p1, FLAC__uint64 p2))
- DEFINE_METHOD3(FLAC__bool, FLAC__stream_encoder_set_metadata, (FLAC__StreamEncoder *p1, FLAC__StreamMetadata **p2, unsigned p3))
- DEFINE_METHOD6(FLAC__StreamEncoderInitStatus, FLAC__stream_encoder_init_stream, (FLAC__StreamEncoder *p1, FLAC__StreamEncoderWriteCallback p2, FLAC__StreamEncoderSeekCallback p3, FLAC__StreamEncoderTellCallback p4, FLAC__StreamEncoderMetadataCallback p5, void *p6))
- DEFINE_METHOD3(FLAC__bool, FLAC__stream_encoder_process_interleaved, (FLAC__StreamEncoder *p1, const FLAC__int32 p2[], unsigned p3))
- DEFINE_METHOD1(FLAC__StreamEncoderState, FLAC__stream_encoder_get_state, (FLAC__StreamEncoder *p1))
- DEFINE_METHOD1(FLAC__bool, FLAC__stream_encoder_finish, (FLAC__StreamEncoder *p1))
- DEFINE_METHOD1(void, FLAC__stream_encoder_delete, (FLAC__StreamEncoder *p1))
- DEFINE_METHOD1(FLAC__StreamMetadata *, FLAC__metadata_object_new, (FLAC__MetadataType p1))
- DEFINE_METHOD3(FLAC__bool, FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair, (FLAC__StreamMetadata_VorbisComment_Entry *p1, const char *p2, const char *p3))
- DEFINE_METHOD3(FLAC__bool, FLAC__metadata_object_vorbiscomment_append_comment, (FLAC__StreamMetadata *p1, FLAC__StreamMetadata_VorbisComment_Entry p2, FLAC__bool p3))
- DEFINE_METHOD1(void, FLAC__metadata_object_delete, (FLAC__StreamMetadata *p1))
-
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(FLAC__stream_encoder_new)
- RESOLVE_METHOD(FLAC__stream_encoder_set_verify)
- RESOLVE_METHOD(FLAC__stream_encoder_set_compression_level)
- RESOLVE_METHOD(FLAC__stream_encoder_set_channels)
- RESOLVE_METHOD(FLAC__stream_encoder_set_bits_per_sample)
- RESOLVE_METHOD(FLAC__stream_encoder_set_sample_rate)
- RESOLVE_METHOD(FLAC__stream_encoder_set_total_samples_estimate)
- RESOLVE_METHOD(FLAC__stream_encoder_set_metadata)
- RESOLVE_METHOD(FLAC__stream_encoder_init_stream)
- RESOLVE_METHOD(FLAC__stream_encoder_process_interleaved)
- RESOLVE_METHOD(FLAC__stream_encoder_get_state)
- RESOLVE_METHOD(FLAC__stream_encoder_finish)
- RESOLVE_METHOD(FLAC__stream_encoder_delete)
- RESOLVE_METHOD(FLAC__metadata_object_new)
- RESOLVE_METHOD(FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair)
- RESOLVE_METHOD(FLAC__metadata_object_vorbiscomment_append_comment)
- RESOLVE_METHOD(FLAC__metadata_object_delete)
- END_METHOD_RESOLVE()
-};
diff --git a/xbmc/cdrip/DllLameenc.h b/xbmc/cdrip/DllLameenc.h
deleted file mode 100644
index d9c322bf28..0000000000
--- a/xbmc/cdrip/DllLameenc.h
+++ /dev/null
@@ -1,103 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "DynamicDll.h"
-#include "lame/lame.h"
-
-class DllLameEncInterface
-{
-public:
- virtual void id3tag_init(lame_global_flags* gfp)=0;
- virtual void id3tag_add_v2(lame_global_flags* gfp)=0;
- virtual int id3tag_set_genre(lame_global_flags* gfp, const char* genre)=0;
- virtual void id3tag_set_title(lame_global_flags* gfp, const char* title)=0;
- virtual void id3tag_set_artist(lame_global_flags* gfp, const char* artist)=0;
- virtual void id3tag_set_album(lame_global_flags* gfp, const char* album)=0;
- virtual void id3tag_set_year(lame_global_flags* gfp, const char* year)=0;
- virtual void id3tag_set_comment(lame_global_flags* gfp, const char* comment)=0;
- virtual void id3tag_set_track(lame_global_flags* gfp, const char* track)=0;
- virtual int id3tag_set_textinfo_latin1(lame_global_flags* gfp, const char* field, const char* text)=0;
- virtual int id3tag_set_textinfo_utf16(lame_global_flags* gfp, const char* field, const unsigned short* text)=0;
- virtual int id3tag_set_textinfo_ucs2(lame_global_flags* gfp, const char* field, const unsigned short* text)=0;
- virtual lame_global_flags* lame_init()=0;
- virtual int lame_init_params(lame_global_flags *gfp)=0;
- virtual int lame_set_in_samplerate(lame_global_flags *gfp, int arg)=0;
- virtual int lame_set_brate(lame_global_flags *gfp, int arg)=0;
- virtual int lame_set_preset(lame_global_flags *gfp, int arg)=0;
- virtual int lame_set_asm_optimizations(lame_global_flags* gfp, int arg1, int arg2)=0;
- virtual int lame_encode_buffer_interleaved(lame_global_flags* gfp, short int pcm[], int num_samples, unsigned char* mp3buf, int mp3buf_size)=0;
- virtual int lame_close(lame_global_flags* gfp)=0;
- virtual void lame_mp3_tags_fid(lame_global_flags* gfp, FILE* fid)=0;
- virtual int lame_encode_flush(lame_global_flags* gfp, unsigned char* mp3buf, int size)=0;
- virtual ~DllLameEncInterface() {}
-};
-
-class DllLameEnc : public DllDynamic, DllLameEncInterface
-{
- DECLARE_DLL_WRAPPER(DllLameEnc, DLL_PATH_LAME_ENC)
- DEFINE_METHOD1(void, id3tag_init, (lame_global_flags* p1));
- DEFINE_METHOD1(void, id3tag_add_v2, (lame_global_flags* p1));
- DEFINE_METHOD2(int, id3tag_set_genre, (lame_global_flags* p1, const char* p2))
- DEFINE_METHOD2(void, id3tag_set_title, (lame_global_flags* p1, const char* p2))
- DEFINE_METHOD2(void, id3tag_set_artist, (lame_global_flags* p1, const char* p2))
- DEFINE_METHOD2(void, id3tag_set_album, (lame_global_flags* p1, const char* p2))
- DEFINE_METHOD2(void, id3tag_set_year, (lame_global_flags* p1, const char* p2))
- DEFINE_METHOD2(void, id3tag_set_comment, (lame_global_flags* p1, const char* p2))
- DEFINE_METHOD2(void, id3tag_set_track, (lame_global_flags* p1, const char* p2))
- DEFINE_METHOD3(int, id3tag_set_textinfo_latin1, (lame_global_flags* p1, const char* p2, const char* p3))
- DEFINE_METHOD3(int, id3tag_set_textinfo_utf16, (lame_global_flags* p1, const char* p2, const unsigned short *p3))
- DEFINE_METHOD3(int, id3tag_set_textinfo_ucs2, (lame_global_flags* p1, const char* p2, const unsigned short *p3))
- DEFINE_METHOD0(lame_global_flags*, lame_init)
- DEFINE_METHOD1(int, lame_init_params, (lame_global_flags *p1))
- DEFINE_METHOD2(int, lame_set_in_samplerate, (lame_global_flags *p1, int p2))
- DEFINE_METHOD2(int, lame_set_brate, (lame_global_flags *p1, int p2))
- DEFINE_METHOD2(int, lame_set_preset, (lame_global_flags *p1, int p2))
- DEFINE_METHOD3(int, lame_set_asm_optimizations, (lame_global_flags* p1, int p2, int p3))
- DEFINE_METHOD5(int, lame_encode_buffer_interleaved, (lame_global_flags* p1, short int p2[], int p3, unsigned char* p4, int p5))
- DEFINE_METHOD1(int, lame_close, (lame_global_flags* p1))
- DEFINE_METHOD2(void, lame_mp3_tags_fid, (lame_global_flags* p1, FILE* p2))
- DEFINE_METHOD3(int, lame_encode_flush, (lame_global_flags* p1, unsigned char* p2, int p3))
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(id3tag_init)
- RESOLVE_METHOD(id3tag_add_v2)
- RESOLVE_METHOD(id3tag_set_genre)
- RESOLVE_METHOD(id3tag_set_title)
- RESOLVE_METHOD(id3tag_set_artist)
- RESOLVE_METHOD(id3tag_set_album)
- RESOLVE_METHOD(id3tag_set_year)
- RESOLVE_METHOD(id3tag_set_comment)
- RESOLVE_METHOD(id3tag_set_track)
- RESOLVE_METHOD(id3tag_set_textinfo_latin1)
- RESOLVE_METHOD(id3tag_set_textinfo_utf16)
- RESOLVE_METHOD(id3tag_set_textinfo_ucs2)
- RESOLVE_METHOD(lame_init)
- RESOLVE_METHOD(lame_init_params)
- RESOLVE_METHOD(lame_set_in_samplerate)
- RESOLVE_METHOD(lame_set_brate)
- RESOLVE_METHOD(lame_set_preset)
- RESOLVE_METHOD(lame_set_asm_optimizations)
- RESOLVE_METHOD(lame_encode_buffer_interleaved)
- RESOLVE_METHOD(lame_close)
- RESOLVE_METHOD(lame_mp3_tags_fid)
- RESOLVE_METHOD(lame_encode_flush)
- END_METHOD_RESOLVE()
-};
diff --git a/xbmc/cdrip/DllOgg.h b/xbmc/cdrip/DllOgg.h
deleted file mode 100644
index 2fe4495e9c..0000000000
--- a/xbmc/cdrip/DllOgg.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
- #include "config.h"
-#endif
-#include <ogg/ogg.h>
-#include "utils/log.h"
-#include "DynamicDll.h"
-
-class DllOggInterface
-{
-public:
- virtual int ogg_page_eos(ogg_page *og)=0;
- virtual int ogg_stream_init(ogg_stream_state *os, int serialno)=0;
- virtual int ogg_stream_clear(ogg_stream_state *os)=0;
- virtual int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og)=0;
- virtual int ogg_stream_flush(ogg_stream_state *os, ogg_page *og)=0;
- virtual int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op)=0;
- virtual ~DllOggInterface() {}
-};
-
-class DllOgg : public DllDynamic, DllOggInterface
-{
- DECLARE_DLL_WRAPPER(DllOgg, DLL_PATH_OGG)
- DEFINE_METHOD1(int, ogg_page_eos, (ogg_page *p1))
- DEFINE_METHOD2(int, ogg_stream_init, (ogg_stream_state *p1, int p2))
- DEFINE_METHOD1(int, ogg_stream_clear, (ogg_stream_state *p1))
- DEFINE_METHOD2(int, ogg_stream_pageout, (ogg_stream_state *p1, ogg_page *p2))
- DEFINE_METHOD2(int, ogg_stream_flush, (ogg_stream_state *p1, ogg_page *p2))
- DEFINE_METHOD2(int, ogg_stream_packetin, (ogg_stream_state *p1, ogg_packet *p2))
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(ogg_page_eos)
- RESOLVE_METHOD(ogg_stream_init)
- RESOLVE_METHOD(ogg_stream_clear)
- RESOLVE_METHOD(ogg_stream_pageout)
- RESOLVE_METHOD(ogg_stream_flush)
- RESOLVE_METHOD(ogg_stream_packetin)
- END_METHOD_RESOLVE()
-};
diff --git a/xbmc/cdrip/DllVorbis.h b/xbmc/cdrip/DllVorbis.h
deleted file mode 100644
index f1af1b8f62..0000000000
--- a/xbmc/cdrip/DllVorbis.h
+++ /dev/null
@@ -1,89 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
- #include "config.h"
-#endif
-#include <vorbis/vorbisenc.h>
-#include "utils/log.h"
-#include "DynamicDll.h"
-
-class DllVorbisInterface
-{
-public:
- virtual void vorbis_info_init(vorbis_info *vi)=0;
- virtual int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op)=0;
- virtual int vorbis_bitrate_addblock(vorbis_block *vb)=0;
- virtual int vorbis_analysis_init(vorbis_dsp_state *v, vorbis_info *vi)=0;
- virtual int vorbis_analysis(vorbis_block *vb, ogg_packet *op)=0;
- virtual int vorbis_analysis_blockout(vorbis_dsp_state *v, vorbis_block *vb)=0;
- virtual int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals)=0;
- virtual float** vorbis_analysis_buffer(vorbis_dsp_state *v, int vals)=0;
- virtual int vorbis_analysis_headerout(vorbis_dsp_state *v, vorbis_comment *vc, ogg_packet *op, ogg_packet *op_comm, ogg_packet *op_code)=0;
- virtual int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb)=0;
- virtual int vorbis_block_clear(vorbis_block *vb)=0;
- virtual void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents)=0;
- virtual void vorbis_comment_init(vorbis_comment *vc)=0;
- virtual void vorbis_info_clear(vorbis_info *vi)=0;
- virtual void vorbis_comment_clear(vorbis_comment *vc)=0;
- virtual void vorbis_dsp_clear(vorbis_dsp_state *v)=0;
- virtual ~DllVorbisInterface() {}
-};
-
-class DllVorbis : public DllDynamic, DllVorbisInterface
-{
- DECLARE_DLL_WRAPPER(DllVorbis, DLL_PATH_VORBIS)
- DEFINE_METHOD1(void, vorbis_info_init, (vorbis_info *p1))
- DEFINE_METHOD2(int, vorbis_bitrate_flushpacket, (vorbis_dsp_state *p1, ogg_packet *p2))
- DEFINE_METHOD1(int, vorbis_bitrate_addblock, (vorbis_block *p1))
- DEFINE_METHOD2(int, vorbis_analysis_init, (vorbis_dsp_state *p1, vorbis_info *p2))
- DEFINE_METHOD2(int, vorbis_analysis, (vorbis_block *p1, ogg_packet *p2))
- DEFINE_METHOD2(int, vorbis_analysis_blockout, (vorbis_dsp_state *p1, vorbis_block *p2))
- DEFINE_METHOD2(int, vorbis_analysis_wrote, (vorbis_dsp_state *p1, int p2))
- DEFINE_METHOD2(float**, vorbis_analysis_buffer, (vorbis_dsp_state *p1, int p2))
- DEFINE_METHOD5(int, vorbis_analysis_headerout, (vorbis_dsp_state *p1, vorbis_comment *p2, ogg_packet *p3, ogg_packet *p4, ogg_packet *p5))
- DEFINE_METHOD2(int, vorbis_block_init, (vorbis_dsp_state *p1, vorbis_block *p2))
- DEFINE_METHOD1(int, vorbis_block_clear, (vorbis_block *p1))
- DEFINE_METHOD3(void, vorbis_comment_add_tag, (vorbis_comment *p1, char *p2, char *p3))
- DEFINE_METHOD1(void, vorbis_comment_init, (vorbis_comment *p1))
- DEFINE_METHOD1(void, vorbis_info_clear, (vorbis_info *p1))
- DEFINE_METHOD1(void, vorbis_comment_clear, (vorbis_comment *p1))
- DEFINE_METHOD1(void, vorbis_dsp_clear, (vorbis_dsp_state *p1))
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(vorbis_info_init)
- RESOLVE_METHOD(vorbis_bitrate_flushpacket)
- RESOLVE_METHOD(vorbis_bitrate_addblock)
- RESOLVE_METHOD(vorbis_analysis_init)
- RESOLVE_METHOD(vorbis_analysis)
- RESOLVE_METHOD(vorbis_analysis_blockout)
- RESOLVE_METHOD(vorbis_analysis_wrote)
- RESOLVE_METHOD(vorbis_analysis_buffer)
- RESOLVE_METHOD(vorbis_analysis_headerout)
- RESOLVE_METHOD(vorbis_block_init)
- RESOLVE_METHOD(vorbis_block_clear)
- RESOLVE_METHOD(vorbis_comment_add_tag)
- RESOLVE_METHOD(vorbis_comment_init)
- RESOLVE_METHOD(vorbis_info_clear)
- RESOLVE_METHOD(vorbis_comment_clear)
- RESOLVE_METHOD(vorbis_dsp_clear)
- END_METHOD_RESOLVE()
-};
diff --git a/xbmc/cdrip/DllVorbisEnc.h b/xbmc/cdrip/DllVorbisEnc.h
deleted file mode 100644
index b483167a48..0000000000
--- a/xbmc/cdrip/DllVorbisEnc.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#pragma once
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
- #include "config.h"
-#endif
-#include <vorbis/vorbisenc.h>
-#include "utils/log.h"
-#include "DynamicDll.h"
-
-class DllVorbisEncInterface
-{
-public:
- virtual int vorbis_encode_init(vorbis_info *vi, long channels, long rate, long max_bitrate, long nominal_bitrate, long min_bitrate)=0;
- virtual int vorbis_encode_init_vbr(vorbis_info *vi, long channels, long rate, float base_quality)=0;
- virtual ~DllVorbisEncInterface() {}
-};
-
-class DllVorbisEnc : public DllDynamic, DllVorbisEncInterface
-{
- DECLARE_DLL_WRAPPER(DllVorbisEnc, DLL_PATH_VORBIS_ENC)
- DEFINE_METHOD6(int, vorbis_encode_init, (vorbis_info *p1, long p2, long p3, long p4, long p5, long p6))
- DEFINE_METHOD4(int, vorbis_encode_init_vbr, (vorbis_info *p1, long p2, long p3, float p4))
- BEGIN_METHOD_RESOLVE()
- RESOLVE_METHOD(vorbis_encode_init)
- RESOLVE_METHOD(vorbis_encode_init_vbr)
- END_METHOD_RESOLVE()
-};
diff --git a/xbmc/cdrip/Encoder.cpp b/xbmc/cdrip/Encoder.cpp
index fa0f7fabb1..dfb389aca0 100644
--- a/xbmc/cdrip/Encoder.cpp
+++ b/xbmc/cdrip/Encoder.cpp
@@ -22,13 +22,11 @@
#include "filesystem/File.h"
#include "utils/log.h"
-CEncoder::CEncoder()
+CEncoder::CEncoder(boost::shared_ptr<IEncoder> encoder)
{
m_file = NULL;
m_dwWriteBufferPointer = 0;
- m_iInChannels = 0;
- m_iInSampleRate = 0;
- m_iInBitsPerSample = 0;
+ m_impl = encoder;
}
CEncoder::~CEncoder()
@@ -36,23 +34,48 @@ CEncoder::~CEncoder()
FileClose();
}
+int CEncoder::WriteCallback(void *opaque, uint8_t *data, int size)
+{
+ if (opaque)
+ {
+ CEncoder *encoder = static_cast<CEncoder *>(opaque);
+ return encoder->WriteStream(data, size);
+ }
+ return -1;
+}
+
+int64_t CEncoder::SeekCallback(void *opaque, int64_t position, int whence)
+{
+ if (opaque)
+ {
+ CEncoder *encoder = static_cast<CEncoder *>(opaque);
+ return encoder->FileSeek(position, whence);
+ }
+ return -1;
+}
+
bool CEncoder::Init(const char* strFile, int iInChannels, int iInRate, int iInBits)
{
if (strFile == NULL) return false;
m_dwWriteBufferPointer = 0;
- m_strFile = strFile;
+ m_impl->m_strFile = strFile;
- m_iInChannels = iInChannels;
- m_iInSampleRate = iInRate;
- m_iInBitsPerSample = iInBits;
+ m_impl->m_iInChannels = iInChannels;
+ m_impl->m_iInSampleRate = iInRate;
+ m_impl->m_iInBitsPerSample = iInBits;
if (!FileCreate(strFile))
{
CLog::Log(LOGERROR, "Error: Cannot open file: %s", strFile);
return false;
}
- return true;
+
+ audioenc_callbacks callbacks;
+ callbacks.opaque = this;
+ callbacks.write = WriteCallback;
+ callbacks.seek = SeekCallback;
+ return m_impl->Init(callbacks);
}
bool CEncoder::FileCreate(const char* filename)
@@ -151,3 +174,26 @@ int CEncoder::FlushStream()
return iResult;
}
+
+int CEncoder::Encode(int nNumBytesRead, uint8_t* pbtStream)
+{
+ int iBytes = m_impl->Encode(nNumBytesRead, pbtStream);
+
+ if (iBytes < 0)
+ {
+ CLog::Log(LOGERROR, "Internal encoder error: %i", iBytes);
+ return 0;
+ }
+ return 1;
+}
+
+bool CEncoder::CloseEncode()
+{
+ if (!m_impl->Close())
+ return false;
+
+ FlushStream();
+ FileClose();
+
+ return true;
+}
diff --git a/xbmc/cdrip/Encoder.h b/xbmc/cdrip/Encoder.h
index 7d34c8e960..38d80654df 100644
--- a/xbmc/cdrip/Encoder.h
+++ b/xbmc/cdrip/Encoder.h
@@ -21,83 +21,48 @@
*
*/
-#include "utils/StdString.h"
-
-#define ENC_ARTIST 11
-#define ENC_TITLE 12
-#define ENC_ALBUM 13
-#define ENC_YEAR 14
-#define ENC_COMMENT 15
-#define ENC_TRACK 16
-#define ENC_GENRE 17
+#include <string>
+#include <boost/shared_ptr.hpp>
+#include "IEncoder.h"
#define WRITEBUFFER_SIZE 131072 // 128k buffer
-enum CDDARipEncoder
-{
- CDDARIP_ENCODER_LAME = 0,
- CDDARIP_ENCODER_VORBIS,
- CDDARIP_ENCODER_WAV,
- CDDARIP_ENCODER_FLAC,
- CDDARIP_ENCODER_FFMPEG_M4A,
- CDDARIP_ENCODER_FFMPEG_WMA
-};
-
-enum CDDARipQuality
-{
- CDDARIP_QUALITY_CBR = 0,
- CDDARIP_QUALITY_MEDIUM,
- CDDARIP_QUALITY_STANDARD,
- CDDARIP_QUALITY_EXTREME
-};
-
namespace XFILE { class CFile; }
class CEncoder
{
public:
- CEncoder();
+ CEncoder(boost::shared_ptr<IEncoder> encoder);
virtual ~CEncoder();
- virtual bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits) = 0;
- virtual int Encode(int nNumBytesRead, uint8_t* pbtStream) = 0;
- virtual bool Close() = 0;
-
- void SetComment(const CStdString& str) { m_strComment = str; }
- void SetArtist(const CStdString& str) { m_strArtist = str; }
- void SetTitle(const CStdString& str) { m_strTitle = str; }
- void SetAlbum(const CStdString& str) { m_strAlbum = str; }
- void SetAlbumArtist(const CStdString& str) { m_strAlbumArtist = str; }
- void SetGenre(const CStdString& str) { m_strGenre = str; }
- void SetTrack(const CStdString& str) { m_strTrack = str; }
- void SetTrackLength(int length) { m_iTrackLength = length; }
- void SetYear(const CStdString& str) { m_strYear = str; }
+ virtual bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits);
+ virtual int Encode(int nNumBytesRead, uint8_t* pbtStream);
+ virtual bool CloseEncode();
+
+ void SetComment(const std::string& str) { m_impl->m_strComment = str; }
+ void SetArtist(const std::string& str) { m_impl->m_strArtist = str; }
+ void SetTitle(const std::string& str) { m_impl->m_strTitle = str; }
+ void SetAlbum(const std::string& str) { m_impl->m_strAlbum = str; }
+ void SetAlbumArtist(const std::string& str) { m_impl->m_strAlbumArtist = str; }
+ void SetGenre(const std::string& str) { m_impl->m_strGenre = str; }
+ void SetTrack(const std::string& str) { m_impl->m_strTrack = str; }
+ void SetTrackLength(int length) { m_impl->m_iTrackLength = length; }
+ void SetYear(const std::string& str) { m_impl->m_strYear = str; }
-protected:
bool FileCreate(const char* filename);
bool FileClose();
int FileWrite(const void *pBuffer, uint32_t iBytes);
int64_t FileSeek(int64_t iFilePosition, int iWhence = SEEK_SET);
+protected:
int WriteStream(const void *pBuffer, uint32_t iBytes);
int FlushStream();
- // tag info
- CStdString m_strComment;
- CStdString m_strArtist;
- CStdString m_strAlbumArtist;
- CStdString m_strTitle;
- CStdString m_strAlbum;
- CStdString m_strGenre;
- CStdString m_strTrack;
- CStdString m_strYear;
- int m_iTrackLength;
+ static int WriteCallback(void *opaque, uint8_t *data, int size);
+ static int64_t SeekCallback(void *opaque, int64_t offset, int whence);
- CStdString m_strFile;
+ boost::shared_ptr<IEncoder> m_impl;
XFILE::CFile *m_file;
- int m_iInChannels;
- int m_iInSampleRate;
- int m_iInBitsPerSample;
uint8_t m_btWriteBuffer[WRITEBUFFER_SIZE]; // 128k buffer for writing to disc
uint32_t m_dwWriteBufferPointer;
diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp
index c58115380a..f827f8a3a0 100644
--- a/xbmc/cdrip/EncoderFFmpeg.cpp
+++ b/xbmc/cdrip/EncoderFFmpeg.cpp
@@ -35,12 +35,15 @@
#include "utils/log.h"
#include "settings/Settings.h"
#include "utils/URIUtils.h"
+#include "addons/AddonManager.h"
/* AV_PKT_FLAG_KEY was named PKT_FLAG_KEY in older versions of libavcodec */
#ifndef AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY PKT_FLAG_KEY
#endif
+using namespace ADDON;
+
CEncoderFFmpeg::CEncoderFFmpeg():
m_Format (NULL),
m_CodecCtx (NULL),
@@ -54,11 +57,17 @@ CEncoderFFmpeg::CEncoderFFmpeg():
m_ResampledFrame(NULL),
m_NeedConversion(false)
{
+ memset(&m_callbacks, 0, sizeof(m_callbacks));
}
-bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int iInBits)
+bool CEncoderFFmpeg::Init(audioenc_callbacks &callbacks)
{
- CStdString filename = URIUtils::GetFileName(strFile);
+ if (!callbacks.opaque || !callbacks.write || !callbacks.seek)
+ return false;
+
+ m_callbacks = callbacks;
+
+ CStdString filename = URIUtils::GetFileName(m_strFile);
if(avformat_alloc_output_context2(&m_Format,NULL,NULL,filename.c_str()))
{
CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Unable to guess the output format for the file %s", filename.c_str());
@@ -82,7 +91,12 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
return false;
}
- m_Format->bit_rate = CSettings::Get().GetInt("audiocds.bitrate") * 1000;
+ AddonPtr addon;
+ CAddonMgr::Get().GetAddon(CSettings::Get().GetString("audiocds.encoder"), addon);
+ if (addon)
+ {
+ m_Format->bit_rate = (128+32*strtol(addon->GetSetting("bitrate").c_str(), NULL, 10))*1000;
+ }
/* add a stream to it */
m_Stream = avformat_new_stream(m_Format, codec);
@@ -99,11 +113,11 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
m_CodecCtx->codec_id = codec->id;
m_CodecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
m_CodecCtx->bit_rate = m_Format->bit_rate;
- m_CodecCtx->sample_rate = iInRate;
- m_CodecCtx->channels = iInChannels;
- m_CodecCtx->channel_layout = av_get_default_channel_layout(iInChannels);
+ m_CodecCtx->sample_rate = m_iInSampleRate;
+ m_CodecCtx->channels = m_iInChannels;
+ m_CodecCtx->channel_layout = av_get_default_channel_layout(m_iInChannels);
m_CodecCtx->time_base.num = 1;
- m_CodecCtx->time_base.den = iInRate;
+ m_CodecCtx->time_base.den = m_iInSampleRate;
/* Allow experimental encoders (like FFmpeg builtin AAC encoder) */
m_CodecCtx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
@@ -113,7 +127,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
m_Format->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
- switch(iInBits)
+ switch(m_iInBitsPerSample)
{
case 8: m_InFormat = AV_SAMPLE_FMT_U8 ; break;
case 16: m_InFormat = AV_SAMPLE_FMT_S16; break;
@@ -141,7 +155,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
/* calculate how many bytes we need per frame */
m_NeededFrames = m_CodecCtx->frame_size;
- m_NeededBytes = av_samples_get_buffer_size(NULL, iInChannels, m_NeededFrames, m_InFormat, 0);
+ m_NeededBytes = av_samples_get_buffer_size(NULL, m_iInChannels, m_NeededFrames, m_InFormat, 0);
m_Buffer = (uint8_t*)av_malloc(m_NeededBytes);
m_BufferSize = 0;
@@ -161,7 +175,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
m_BufferFrame->format = m_InFormat;
m_BufferFrame->channel_layout = m_CodecCtx->channel_layout;
- avcodec_fill_audio_frame(m_BufferFrame, iInChannels, m_InFormat, m_Buffer, m_NeededBytes, 0);
+ avcodec_fill_audio_frame(m_BufferFrame, m_iInChannels, m_InFormat, m_Buffer, m_NeededBytes, 0);
if(m_NeedConversion)
{
@@ -180,7 +194,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
return false;
}
- m_ResampledBufferSize = av_samples_get_buffer_size(NULL, iInChannels, m_NeededFrames, m_OutFormat, 0);
+ m_ResampledBufferSize = av_samples_get_buffer_size(NULL, m_iInChannels, m_NeededFrames, m_OutFormat, 0);
m_ResampledBuffer = (uint8_t*)av_malloc(m_ResampledBufferSize);
m_ResampledFrame = av_frame_alloc();
if(!m_ResampledBuffer || !m_ResampledFrame)
@@ -199,22 +213,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
m_ResampledFrame->nb_samples = m_NeededFrames;
m_ResampledFrame->format = m_OutFormat;
m_ResampledFrame->channel_layout = m_CodecCtx->channel_layout;
- avcodec_fill_audio_frame(m_ResampledFrame, iInChannels, m_OutFormat, m_ResampledBuffer, m_ResampledBufferSize, 0);
- }
-
- /* set input stream information and open the file */
- if (!CEncoder::Init(strFile, iInChannels, iInRate, iInBits))
- {
- CLog::Log(LOGERROR, "CEncoderFFmpeg::Init - Failed to call CEncoder::Init");
- if (m_ResampledFrame ) av_frame_free(&m_ResampledFrame);
- if (m_ResampledBuffer) av_freep(&m_ResampledBuffer);
- if (m_SwrCtx) swr_free(&m_SwrCtx);
- av_frame_free(&m_BufferFrame);
- av_freep(&m_Buffer);
- av_freep(&m_Stream);
- av_freep(&m_Format->pb);
- av_freep(&m_Format);
- return false;
+ avcodec_fill_audio_frame(m_ResampledFrame, m_iInChannels, m_OutFormat, m_ResampledBuffer, m_ResampledBufferSize, 0);
}
/* set the tags */
@@ -245,7 +244,7 @@ bool CEncoderFFmpeg::Init(const char* strFile, int iInChannels, int iInRate, int
return true;
}
-void CEncoderFFmpeg::SetTag(const CStdString tag, const CStdString value)
+void CEncoderFFmpeg::SetTag(const std::string &tag, const std::string &value)
{
av_dict_set(&m_Format->metadata, tag.c_str(), value.c_str(), 0);
}
@@ -253,7 +252,7 @@ void CEncoderFFmpeg::SetTag(const CStdString tag, const CStdString value)
int CEncoderFFmpeg::avio_write_callback(void *opaque, uint8_t *buf, int buf_size)
{
CEncoderFFmpeg *enc = (CEncoderFFmpeg*)opaque;
- if(enc->FileWrite(buf, buf_size) != buf_size)
+ if(enc->m_callbacks.write(enc->m_callbacks.opaque, buf, buf_size) != buf_size)
{
CLog::Log(LOGERROR, "Error writing FFmpeg buffer to file");
return -1;
@@ -264,10 +263,10 @@ int CEncoderFFmpeg::avio_write_callback(void *opaque, uint8_t *buf, int buf_size
int64_t CEncoderFFmpeg::avio_seek_callback(void *opaque, int64_t offset, int whence)
{
CEncoderFFmpeg *enc = (CEncoderFFmpeg*)opaque;
- return enc->FileSeek(offset, whence);
+ return enc->m_callbacks.seek(enc->m_callbacks.opaque, offset, whence);
}
-int CEncoderFFmpeg::Encode(int nNumBytesRead, BYTE* pbtStream)
+int CEncoderFFmpeg::Encode(int nNumBytesRead, uint8_t* pbtStream)
{
while(nNumBytesRead > 0)
{
@@ -281,7 +280,10 @@ int CEncoderFFmpeg::Encode(int nNumBytesRead, BYTE* pbtStream)
/* only write full packets */
if (m_BufferSize == m_NeededBytes)
- if (!WriteFrame()) return 0;
+ {
+ if (!WriteFrame())
+ return 0;
+ }
}
return 1;
@@ -334,9 +336,11 @@ bool CEncoderFFmpeg::WriteFrame()
bool CEncoderFFmpeg::Close()
{
- if (m_Format) {
+ if (m_Format)
+ {
/* if there is anything still in the buffer */
- if (m_BufferSize > 0) {
+ if (m_BufferSize > 0)
+ {
/* zero the unused space so we dont encode random junk */
memset(&m_Buffer[m_BufferSize], 0, m_NeededBytes - m_BufferSize);
/* write any remaining data */
@@ -356,8 +360,6 @@ bool CEncoderFFmpeg::Close()
/* write the trailer */
av_write_trailer(m_Format);
- FlushStream();
- FileClose();
/* cleanup */
avcodec_close(m_CodecCtx);
diff --git a/xbmc/cdrip/EncoderFFmpeg.h b/xbmc/cdrip/EncoderFFmpeg.h
index 7155796d1b..3cf2d753e7 100644
--- a/xbmc/cdrip/EncoderFFmpeg.h
+++ b/xbmc/cdrip/EncoderFFmpeg.h
@@ -21,7 +21,7 @@
*
*/
-#include "Encoder.h"
+#include "IEncoder.h"
extern "C" {
#include "libavformat/avformat.h"
@@ -30,16 +30,15 @@ extern "C" {
#include "libswresample/swresample.h"
}
-class CEncoderFFmpeg : public CEncoder
+class CEncoderFFmpeg : public IEncoder
{
public:
CEncoderFFmpeg();
virtual ~CEncoderFFmpeg() {}
- bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits);
- int Encode(int nNumBytesRead, uint8_t* pbtStream);
- bool Close();
- void AddTag(int key, const char* value);
+ bool Init(audioenc_callbacks &callbacks);
+ int Encode(int nNumBytesRead, uint8_t *pbtStream);
+ bool Close();
private:
AVFormatContext *m_Format;
@@ -58,7 +57,7 @@ private:
unsigned char m_BCBuffer[4096];
static int avio_write_callback(void *opaque, uint8_t *buf, int buf_size);
static int64_t avio_seek_callback(void *opaque, int64_t offset, int whence);
- void SetTag(const CStdString tag, const CStdString value);
+ void SetTag(const std::string &tag, const std::string &value);
unsigned int m_NeededFrames;
@@ -71,6 +70,8 @@ private:
AVFrame *m_ResampledFrame;
bool m_NeedConversion;
+ audioenc_callbacks m_callbacks;
+
bool WriteFrame();
};
diff --git a/xbmc/cdrip/EncoderFlac.cpp b/xbmc/cdrip/EncoderFlac.cpp
deleted file mode 100644
index a41e4fcc18..0000000000
--- a/xbmc/cdrip/EncoderFlac.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "EncoderFlac.h"
-#include "utils/log.h"
-#include "filesystem/File.h"
-#include "settings/Settings.h"
-
-CEncoderFlac::CEncoderFlac() : m_encoder(0), m_samplesBuf(new FLAC__int32[SAMPLES_BUF_SIZE])
-{
- m_metadata[0] = 0;
- m_metadata[1] = 0;
-}
-
-CEncoderFlac::~CEncoderFlac()
-{
- delete [] m_samplesBuf;
-}
-
-bool CEncoderFlac::Init(const char* strFile, int iInChannels, int iInRate, int iInBits)
-{
- // we only accept 2 / 44100 / 16 atm
- if (iInChannels != 2 || iInRate != 44100 || iInBits != 16)
- return false;
-
- // set input stream information and open the file
- if (!CEncoder::Init(strFile, iInChannels, iInRate, iInBits))
- return false;
-
- // load the flac dll
- if (!m_dll.Load())
- return false;
-
- // allocate libFLAC encoder
- m_encoder = m_dll.FLAC__stream_encoder_new();
- if (!m_encoder)
- {
- CLog::Log(LOGERROR, "Error: FLAC__stream_encoder_new() failed");
- return false;
- }
-
- FLAC__bool ok = 1;
-
- ok &= m_dll.FLAC__stream_encoder_set_verify(m_encoder, true);
- ok &= m_dll.FLAC__stream_encoder_set_channels(m_encoder, 2);
- ok &= m_dll.FLAC__stream_encoder_set_bits_per_sample(m_encoder, 16);
- ok &= m_dll.FLAC__stream_encoder_set_sample_rate(m_encoder, 44100);
- ok &= m_dll.FLAC__stream_encoder_set_total_samples_estimate(m_encoder, m_iTrackLength / 4);
- ok &= m_dll.FLAC__stream_encoder_set_compression_level(m_encoder, CSettings::Get().GetInt("audiocds.compressionlevel"));
-
- // now add some metadata
- FLAC__StreamMetadata_VorbisComment_Entry entry;
- if (ok)
- {
- if (
- (m_metadata[0] = m_dll.FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT)) == NULL ||
- (m_metadata[1] = m_dll.FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING)) == NULL ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "ARTIST", m_strArtist.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "ALBUM", m_strAlbum.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "ALBUMARTIST", m_strAlbumArtist.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "TITLE", m_strTitle.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "GENRE", m_strGenre.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "TRACKNUMBER", m_strTrack.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "DATE", m_strYear.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair(&entry, "COMMENT", m_strComment.c_str()) ||
- !m_dll.FLAC__metadata_object_vorbiscomment_append_comment(m_metadata[0], entry, false)
- )
- {
- CLog::Log(LOGERROR, "ERROR: FLAC out of memory or tag error\n");
- ok = false;
- }
- else
- {
- m_metadata[1]->length = 4096;
- ok = m_dll.FLAC__stream_encoder_set_metadata(m_encoder, m_metadata, 2);
- }
- }
-
- // initialize encoder in stream mode
- if (ok)
- {
- FLAC__StreamEncoderInitStatus init_status;
- init_status = m_dll.FLAC__stream_encoder_init_stream(m_encoder, write_callback, NULL, NULL, NULL, this);
- if (init_status != FLAC__STREAM_ENCODER_INIT_STATUS_OK)
- {
- CLog::Log(LOGERROR, "FLAC encoder initializing error");
- ok = false;
- }
- }
-
- if (!ok)
- {
- CLog::Log(LOGERROR, "Error: FLAC intialization failed");
- return false;
- }
-
- return true;
-}
-
-int CEncoderFlac::Encode(int nNumBytesRead, BYTE* pbtStream)
-{
- int nLeftSamples = nNumBytesRead / 2; // each sample takes 2 bytes (16 bits per sample)
- while (nLeftSamples > 0)
- {
- int nSamples = nLeftSamples > SAMPLES_BUF_SIZE ? SAMPLES_BUF_SIZE : nLeftSamples;
-
- // convert the packed little-endian 16-bit PCM samples into an interleaved FLAC__int32 buffer for libFLAC
- for (int i = 0; i < nSamples; i++)
- { // inefficient but simple and works on big- or little-endian machines.
- m_samplesBuf[i] = (FLAC__int32)(((FLAC__int16)(FLAC__int8)pbtStream[2*i+1] << 8) | (FLAC__int16)pbtStream[2*i]);
- }
-
- // feed samples to encoder
- if (!m_dll.FLAC__stream_encoder_process_interleaved(m_encoder, m_samplesBuf, nSamples / 2))
- {
- CLog::Log(LOGERROR, "FLAC__stream_encoder_process_interleaved error");
- return 0;
- }
-
- nLeftSamples -= nSamples;
- pbtStream += nSamples * 2; // skip processed samples
- }
-
- return 1;
-}
-
-bool CEncoderFlac::Close()
-{
- FLAC__bool ok = 0;
-
- if (m_encoder)
- {
- // finish encoding
- ok = m_dll.FLAC__stream_encoder_finish(m_encoder);
- if (!ok)
- CLog::Log(LOGERROR, "FLAC encoder finish error");
-
- // now that encoding is finished, the metadata can be freed
- if (m_metadata[0])
- m_dll.FLAC__metadata_object_delete(m_metadata[0]);
- if (m_metadata[1])
- m_dll.FLAC__metadata_object_delete(m_metadata[1]);
-
- // delete encoder
- m_dll.FLAC__stream_encoder_delete(m_encoder);
- }
-
- FlushStream();
- FileClose();
-
- // unload the flac dll
- m_dll.Unload();
-
- return ok ? true : false;
-}
-
-FLAC__StreamEncoderWriteStatus CEncoderFlac::write_callback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data)
-{
- CEncoderFlac *pThis = (CEncoderFlac *)client_data;
- if (pThis->FileWrite(buffer, bytes) != (int)bytes)
- return FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
- return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
-}
diff --git a/xbmc/cdrip/EncoderFlac.h b/xbmc/cdrip/EncoderFlac.h
deleted file mode 100644
index 1a6baa55a2..0000000000
--- a/xbmc/cdrip/EncoderFlac.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef _ENCODERFLAC_H
-#define _ENCODERFLAC_H
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "Encoder.h"
-#include "DllFlacEnc.h"
-
-class CEncoderFlac : public CEncoder
-{
-public:
- CEncoderFlac();
- virtual ~CEncoderFlac();
- bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits);
- int Encode(int nNumBytesRead, uint8_t* pbtStream);
- bool Close();
-
-private:
- DllFlacEnc m_dll;
- FLAC__StreamEncoder *m_encoder;
- FLAC__StreamMetadata *m_metadata[2];
-
- static const int SAMPLES_BUF_SIZE = 1024 * 2;
- FLAC__int32 *m_samplesBuf;
-
- static FLAC__StreamEncoderWriteStatus write_callback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
-};
-
-#endif // _ENCODERFLAC_H
diff --git a/xbmc/cdrip/EncoderLame.cpp b/xbmc/cdrip/EncoderLame.cpp
deleted file mode 100644
index 9aa4358650..0000000000
--- a/xbmc/cdrip/EncoderLame.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "EncoderLame.h"
-#include "settings/Settings.h"
-#include "utils/log.h"
-
-#ifdef TARGET_WINDOWS
-extern "C" FILE *fopen_utf8(const char *_Filename, const char *_Mode);
-#else
-#define fopen_utf8 fopen
-#endif
-
-CEncoderLame::CEncoderLame()
-{
- memset(m_inPath, 0, 1024 + 1);
- memset(m_outPath, 0, 1024 + 1);
-}
-
-bool CEncoderLame::Init(const char* strFile, int iInChannels, int iInRate, int iInBits)
-{
- // we only accept 2 / 44100 / 16 atm
- if (iInChannels != 2 || iInRate != 44100 || iInBits != 16) return false;
-
- // set input stream information and open the file
- if (!CEncoder::Init(strFile, iInChannels, iInRate, iInBits)) return false;
-
- // load the lame dll
- if (!m_dll.Load())
- return false;
-
- m_pGlobalFlags = m_dll.lame_init();
- if (!m_pGlobalFlags)
- {
- CLog::Log(LOGERROR, "Error: lame_init() failed");
- return false;
- }
-
- // setup parmaters, see lame.h for possibilities
- if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR)
- {
- int bitrate = CSettings::Get().GetInt("audiocds.bitrate");
- // use cbr and specified bitrate from settings
- CLog::Log(LOGDEBUG, "Lame setting CBR bitrate %d", bitrate);
- m_dll.lame_set_brate(m_pGlobalFlags, bitrate);
- }
- else
- {
- // use presets (VBR)
- int preset;
- switch (CSettings::Get().GetInt("audiocds.quality"))
- {
- case CDDARIP_QUALITY_MEDIUM:
- preset = MEDIUM;
- break;
- case CDDARIP_QUALITY_STANDARD:
- preset = STANDARD;
- break;
- case CDDARIP_QUALITY_EXTREME:
- preset = EXTREME;
- break;
- default:
- preset = STANDARD;
- }
- CLog::Log(LOGDEBUG, "Lame setting preset %d", preset);
- m_dll.lame_set_preset(m_pGlobalFlags, preset);
- }
-
- m_dll.lame_set_asm_optimizations(m_pGlobalFlags, MMX, 1);
- m_dll.lame_set_asm_optimizations(m_pGlobalFlags, SSE, 1);
- m_dll.lame_set_in_samplerate(m_pGlobalFlags, 44100);
-
- // Setup the ID3 tagger
- m_dll.id3tag_init(m_pGlobalFlags);
- m_dll.id3tag_add_v2(m_pGlobalFlags);
- m_dll.id3tag_set_title(m_pGlobalFlags, m_strTitle.c_str());
- m_dll.id3tag_set_artist(m_pGlobalFlags, m_strArtist.c_str());
- m_dll.id3tag_set_textinfo_latin1(m_pGlobalFlags, "TPE2", m_strAlbumArtist.c_str());
- m_dll.id3tag_set_album(m_pGlobalFlags, m_strAlbum.c_str());
- m_dll.id3tag_set_year(m_pGlobalFlags, m_strYear.c_str());
- m_dll.id3tag_set_track(m_pGlobalFlags, m_strTrack.c_str());
- int test = m_dll.id3tag_set_genre(m_pGlobalFlags, m_strGenre.c_str());
- if(test==-1)
- m_dll.id3tag_set_genre(m_pGlobalFlags,"Other");
-
- // Now that all the options are set, lame needs to analyze them and
- // set some more internal options and check for problems
- if (m_dll.lame_init_params(m_pGlobalFlags) < 0)
- {
- CLog::Log(LOGERROR, "Error: Cannot init Lame params");
- return false;
- }
-
- return true;
-}
-
-int CEncoderLame::Encode(int nNumBytesRead, BYTE* pbtStream)
-{
- int iBytes = m_dll.lame_encode_buffer_interleaved(m_pGlobalFlags, (short*)pbtStream, nNumBytesRead / 4, m_buffer, sizeof(m_buffer));
-
- if (iBytes < 0)
- {
- CLog::Log(LOGERROR, "Internal Lame error: %i", iBytes);
- return 0;
- }
-
- if (WriteStream(m_buffer, iBytes) != iBytes)
- {
- CLog::Log(LOGERROR, "Error writing Lame buffer to file");
- return 0;
- }
-
- return 1;
-}
-
-bool CEncoderLame::Close()
-{
- // may return one more mp3 frames
- int iBytes = m_dll.lame_encode_flush(m_pGlobalFlags, m_buffer, sizeof(m_buffer));
-
- if (iBytes < 0)
- {
- CLog::Log(LOGERROR, "Internal Lame error: %i", iBytes);
- return false;
- }
-
- WriteStream(m_buffer, iBytes);
- FlushStream();
- FileClose();
-
- // open again, but now the old way, lame only accepts FILE pointers
- FILE* file = fopen_utf8(m_strFile.c_str(), "rb+");
- if (!file)
- {
- CLog::Log(LOGERROR, "Error: Cannot open file for writing tags: %s", m_strFile.c_str());
- return false;
- }
-
- m_dll.lame_mp3_tags_fid(m_pGlobalFlags, file); /* add VBR tags to mp3 file */
- fclose(file);
-
- m_dll.lame_close(m_pGlobalFlags);
-
- // unload the lame dll
- m_dll.Unload();
-
-
-
- return true;
-}
diff --git a/xbmc/cdrip/EncoderLame.h b/xbmc/cdrip/EncoderLame.h
deleted file mode 100644
index d6cd7d5781..0000000000
--- a/xbmc/cdrip/EncoderLame.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef _ENCODERLAME_H
-#define _ENCODERLAME_H
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "Encoder.h"
-#include "DllLameenc.h"
-
-class CEncoderLame : public CEncoder
-{
-public:
- CEncoderLame();
- virtual ~CEncoderLame() {}
- bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits);
- int Encode(int nNumBytesRead, BYTE* pbtStream);
- bool Close();
- void AddTag(int key, const char* value);
-
-protected:
- lame_global_flags* m_pGlobalFlags;
-
- unsigned char m_buffer[48160]; // mp3buf_size in bytes = 1.25*(chunk size / 4) + 7200
- char m_inPath[1024 + 1];
- char m_outPath[1024 + 1];
-
- DllLameEnc m_dll;
-};
-
-#endif // _ENCODERLAME_H
diff --git a/xbmc/cdrip/EncoderVorbis.cpp b/xbmc/cdrip/EncoderVorbis.cpp
deleted file mode 100644
index 3d85040eae..0000000000
--- a/xbmc/cdrip/EncoderVorbis.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "EncoderVorbis.h"
-#include "settings/Settings.h"
-#include "utils/log.h"
-
-CEncoderVorbis::CEncoderVorbis()
-{
- m_pBuffer = NULL;
-}
-
-bool CEncoderVorbis::Init(const char* strFile, int iInChannels, int iInRate, int iInBits)
-{
- // we only accept 2 / 44100 / 16 atm
- if (iInChannels != 2 || iInRate != 44100 || iInBits != 16) return false;
-
- // set input stream information and open the file
- if (!CEncoder::Init(strFile, iInChannels, iInRate, iInBits)) return false;
-
- float fQuality = 0.5f;
- if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_MEDIUM) fQuality = 0.4f;
- if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_STANDARD) fQuality = 0.5f;
- if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_EXTREME) fQuality = 0.7f;
-
- if (!m_VorbisEncDll.Load() || !m_OggDll.Load() || !m_VorbisDll.Load())
- {
- // failed loading the dll's, unload it all
- CLog::Log(LOGERROR, "CEncoderVorbis::Init() Error while loading ogg.dll and or vorbis.dll");
- return false;
- }
-
- m_VorbisDll.vorbis_info_init(&m_sVorbisInfo);
- if (CSettings::Get().GetInt("audiocds.quality") == CDDARIP_QUALITY_CBR)
- {
- // not realy cbr, but abr in this case
- int iBitRate = CSettings::Get().GetInt("audiocds.bitrate") * 1000;
- m_VorbisEncDll.vorbis_encode_init(&m_sVorbisInfo, m_iInChannels, m_iInSampleRate, -1, iBitRate, -1);
- }
- else
- {
- if (m_VorbisEncDll.vorbis_encode_init_vbr(&m_sVorbisInfo, m_iInChannels, m_iInSampleRate, fQuality)) return false;
- }
-
- /* add a comment */
- m_VorbisDll.vorbis_comment_init(&m_sVorbisComment);
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"comment", (char*)m_strComment.c_str());
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"artist", (char*)m_strArtist.c_str());
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"title", (char*)m_strTitle.c_str());
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"album", (char*)m_strAlbum.c_str());
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"albumartist", (char*)m_strAlbumArtist.c_str());
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"genre", (char*)m_strGenre.c_str());
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"tracknumber", (char*)m_strTrack.c_str());
- m_VorbisDll.vorbis_comment_add_tag(&m_sVorbisComment, (char*)"date", (char*)m_strYear.c_str());
-
- /* set up the analysis state and auxiliary encoding storage */
- m_VorbisDll.vorbis_analysis_init(&m_sVorbisDspState, &m_sVorbisInfo);
-
- m_VorbisDll.vorbis_block_init(&m_sVorbisDspState, &m_sVorbisBlock);
-
- /* set up our packet->stream encoder */
- /* pick a random serial number; that way we can more likely build
- chained streams just by concatenation */
- srand(time(NULL));
- m_OggDll.ogg_stream_init(&m_sOggStreamState, rand());
-
- {
- ogg_packet header;
- ogg_packet header_comm;
- ogg_packet header_code;
-
- m_VorbisDll.vorbis_analysis_headerout(&m_sVorbisDspState, &m_sVorbisComment,
- &header, &header_comm, &header_code);
-
- m_OggDll.ogg_stream_packetin(&m_sOggStreamState, &header);
- m_OggDll.ogg_stream_packetin(&m_sOggStreamState, &header_comm);
- m_OggDll.ogg_stream_packetin(&m_sOggStreamState, &header_code);
-
- /* This ensures the actual
- * audio data will start on a new page, as per spec
- */
- while (1)
- {
- int result = m_OggDll.ogg_stream_flush(&m_sOggStreamState, &m_sOggPage);
- if (result == 0)break;
- FileWrite(m_sOggPage.header, m_sOggPage.header_len);
- FileWrite(m_sOggPage.body, m_sOggPage.body_len);
- }
- }
- m_pBuffer = new BYTE[4096];
-
- return true;
-}
-
-int CEncoderVorbis::Encode(int nNumBytesRead, BYTE* pbtStream)
-{
- int eos = 0;
-
- /* data to encode */
- LONG nBlocks = (int)(nNumBytesRead / 4096);
- LONG nBytesleft = nNumBytesRead - nBlocks * 4096;
- LONG block = 4096;
-
- for (int a = 0; a <= nBlocks; a++)
- {
- if (a == nBlocks)
- {
- // no more blocks of 4096 bytes to write, just write the last bytes
- block = nBytesleft;
- }
-
- /* expose the buffer to submit data */
- float **buffer = m_VorbisDll.vorbis_analysis_buffer(&m_sVorbisDspState, 1024);
-
- /* uninterleave samples */
- memcpy(m_pBuffer, pbtStream, block);
- pbtStream += 4096;
- LONG iSamples = block / (2 * 2);
- signed char* buf = (signed char*) m_pBuffer;
- for (int i = 0; i < iSamples; i++)
- {
- int j = i << 2; // j = i * 4
- buffer[0][i] = (((long)buf[j + 1] << 8) | (0x00ff & (int)buf[j])) / 32768.0f;
- buffer[1][i] = (((long)buf[j + 3] << 8) | (0x00ff & (int)buf[j + 2])) / 32768.0f;
- }
-
- /* tell the library how much we actually submitted */
- m_VorbisDll.vorbis_analysis_wrote(&m_sVorbisDspState, iSamples);
-
- /* vorbis does some data preanalysis, then divvies up blocks for
- more involved (potentially parallel) processing. Get a single
- block for encoding now */
- while (m_VorbisDll.vorbis_analysis_blockout(&m_sVorbisDspState, &m_sVorbisBlock) == 1)
- {
- /* analysis, assume we want to use bitrate management */
- m_VorbisDll.vorbis_analysis(&m_sVorbisBlock, NULL);
- m_VorbisDll.vorbis_bitrate_addblock(&m_sVorbisBlock);
-
- while (m_VorbisDll.vorbis_bitrate_flushpacket(&m_sVorbisDspState, &m_sOggPacket))
- {
- /* weld the packet into the bitstream */
- m_OggDll.ogg_stream_packetin(&m_sOggStreamState, &m_sOggPacket);
-
- /* write out pages (if any) */
- while (!eos)
- {
- int result = m_OggDll.ogg_stream_pageout(&m_sOggStreamState, &m_sOggPage);
- if (result == 0)break;
- WriteStream(m_sOggPage.header, m_sOggPage.header_len);
- WriteStream(m_sOggPage.body, m_sOggPage.body_len);
-
- /* this could be set above, but for illustrative purposes, I do
- it here (to show that vorbis does know where the stream ends) */
- if (m_OggDll.ogg_page_eos(&m_sOggPage)) eos = 1;
- }
- }
- }
- }
-
- return 1;
-}
-
-bool CEncoderVorbis::Close()
-{
- int eos = 0;
- // tell vorbis we are encoding the end of the stream
- m_VorbisDll.vorbis_analysis_wrote(&m_sVorbisDspState, 0);
- while (m_VorbisDll.vorbis_analysis_blockout(&m_sVorbisDspState, &m_sVorbisBlock) == 1)
- {
- /* analysis, assume we want to use bitrate management */
- m_VorbisDll.vorbis_analysis(&m_sVorbisBlock, NULL);
- m_VorbisDll.vorbis_bitrate_addblock(&m_sVorbisBlock);
-
- while (m_VorbisDll.vorbis_bitrate_flushpacket(&m_sVorbisDspState, &m_sOggPacket))
- {
- /* weld the packet into the bitstream */
- m_OggDll.ogg_stream_packetin(&m_sOggStreamState, &m_sOggPacket);
-
- /* write out pages (if any) */
- while (!eos)
- {
- int result = m_OggDll.ogg_stream_pageout(&m_sOggStreamState, &m_sOggPage);
- if (result == 0)break;
- WriteStream(m_sOggPage.header, m_sOggPage.header_len);
- WriteStream(m_sOggPage.body, m_sOggPage.body_len);
-
- /* this could be set above, but for illustrative purposes, I do
- it here (to show that vorbis does know where the stream ends) */
- if (m_OggDll.ogg_page_eos(&m_sOggPage)) eos = 1;
- }
- }
- }
-
- /* clean up and exit. vorbis_info_clear() must be called last */
- m_OggDll.ogg_stream_clear(&m_sOggStreamState);
- m_VorbisDll.vorbis_block_clear(&m_sVorbisBlock);
- m_VorbisDll.vorbis_dsp_clear(&m_sVorbisDspState);
- m_VorbisDll.vorbis_comment_clear(&m_sVorbisComment);
- m_VorbisDll.vorbis_info_clear(&m_sVorbisInfo);
-
- /* ogg_page and ogg_packet structs always point to storage in
- libvorbis. They're never freed or manipulated directly */
- FlushStream();
- FileClose();
-
- delete []m_pBuffer;
- m_pBuffer = NULL;
-
- m_VorbisEncDll.Unload();
-
- m_OggDll.Unload();
-
- m_VorbisDll.Unload();
-
- return true;
-}
diff --git a/xbmc/cdrip/EncoderVorbis.h b/xbmc/cdrip/EncoderVorbis.h
deleted file mode 100644
index a2bc86571a..0000000000
--- a/xbmc/cdrip/EncoderVorbis.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef _ENCODERVORBIS_H
-#define _ENCODERVORBIS_H
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "Encoder.h"
-#include "DllOgg.h"
-#include "DllVorbis.h"
-#include "DllVorbisEnc.h"
-
-class CEncoderVorbis : public CEncoder
-{
-public:
- CEncoderVorbis();
- virtual ~CEncoderVorbis() {};
- bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits);
- int Encode(int nNumBytesRead, BYTE* pbtStream);
- bool Close();
- void AddTag(int key, const char* value);
-
-protected:
- vorbis_info m_sVorbisInfo; /* struct that stores all the static vorbis bitstream settings */
- vorbis_dsp_state m_sVorbisDspState; /* central working state for the packet->PCM decoder */
- vorbis_block m_sVorbisBlock; /* local working space for packet->PCM decode */
- vorbis_comment m_sVorbisComment;
-
- ogg_stream_state m_sOggStreamState; /* take physical pages, weld into a logical stream of packets */
- ogg_page m_sOggPage; /* one Ogg bitstream page. Vorbis packets are inside */
- ogg_packet m_sOggPacket; /* one raw packet of data for decode */
-
- BYTE* m_pBuffer;
-
- DllOgg m_OggDll;
- DllVorbis m_VorbisDll;
- DllVorbisEnc m_VorbisEncDll;
-};
-
-#endif // _ENCODERVORBIS_H
diff --git a/xbmc/cdrip/EncoderWav.cpp b/xbmc/cdrip/EncoderWav.cpp
deleted file mode 100644
index 4202305a88..0000000000
--- a/xbmc/cdrip/EncoderWav.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "EncoderWav.h"
-#include "filesystem/File.h"
-#include "utils/log.h"
-
-CEncoderWav::CEncoderWav()
-{
- m_iBytesWritten = 0;
-}
-
-bool CEncoderWav::Init(const char* strFile, int iInChannels, int iInRate, int iInBits)
-{
- m_iBytesWritten = 0;
-
- // we only accept 2 / 44100 / 16 atm
- if (iInChannels != 2 || iInRate != 44100 || iInBits != 16) return false;
-
- // set input stream information and open the file
- if (!CEncoder::Init(strFile, iInChannels, iInRate, iInBits)) return false;
-
- // write dummy header file
- WAVHDR dummyheader;
- memset(&dummyheader, 0, sizeof(dummyheader));
- FileWrite(&dummyheader, sizeof(dummyheader));
-
- return true;
-}
-
-int CEncoderWav::Encode(int nNumBytesRead, BYTE* pbtStream)
-{
- // write stream to file (no conversion needed at this time)
- if (FileWrite(pbtStream, nNumBytesRead) == -1)
- {
- CLog::Log(LOGERROR, "Error writing buffer to file");
- return 0;
- }
-
- m_iBytesWritten += nNumBytesRead;
- return 1;
-}
-
-bool CEncoderWav::Close()
-{
- WriteWavHeader();
- FileClose();
- return true;
-}
-
-bool CEncoderWav::WriteWavHeader()
-{
- WAVHDR wav;
- int bps = 1;
-
- if (!m_file) return false;
-
- memcpy(wav.riff, "RIFF", 4);
- wav.len = m_iBytesWritten + 44 - 8;
- memcpy(wav.cWavFmt, "WAVEfmt ", 8);
- wav.dwHdrLen = 16;
- wav.wFormat = WAVE_FORMAT_PCM;
- wav.wNumChannels = m_iInChannels;
- wav.dwSampleRate = m_iInSampleRate;
- wav.wBitsPerSample = m_iInBitsPerSample;
- if (wav.wBitsPerSample == 16) bps = 2;
- wav.dwBytesPerSec = m_iInBitsPerSample * m_iInChannels * bps;
- wav.wBlockAlign = 4;
- memcpy(wav.cData, "data", 4);
- wav.dwDataLen = m_iBytesWritten;
-
- // write header to beginning of stream
- m_file->Seek(0, FILE_BEGIN);
- FileWrite(&wav, sizeof(wav));
-
- return true;
-}
diff --git a/xbmc/cdrip/EncoderWav.h b/xbmc/cdrip/EncoderWav.h
deleted file mode 100644
index b0cd5c816d..0000000000
--- a/xbmc/cdrip/EncoderWav.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef _ENCODERWAV_H
-#define _ENCODERWAV_H
-
-/*
- * Copyright (C) 2005-2013 Team XBMC
- * http://xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "Encoder.h"
-#include <stdio.h>
-
-typedef struct
-{
- uint8_t riff[4]; /* must be "RIFF" */
- uint32_t len; /* #bytes + 44 - 8 */
- uint8_t cWavFmt[8]; /* must be "WAVEfmt " */
- uint32_t dwHdrLen;
- uint16_t wFormat;
- uint16_t wNumChannels;
- uint32_t dwSampleRate;
- uint32_t dwBytesPerSec;
- uint16_t wBlockAlign;
- uint16_t wBitsPerSample;
- uint8_t cData[4]; /* must be "data" */
- uint32_t dwDataLen; /* #bytes */
-}
-WAVHDR, *PWAVHDR, *LPWAVHDR;
-
-class CEncoderWav : public CEncoder
-{
-public:
- CEncoderWav();
- virtual ~CEncoderWav() {}
- bool Init(const char* strFile, int iInChannels, int iInRate, int iInBits);
- int Encode(int nNumBytesRead, uint8_t* pbtStream);
- bool Close();
- void AddTag(int key, const char* value);
-
-private:
- bool WriteWavHeader();
-
- int m_iBytesWritten;
-};
-
-#endif // _ENCODERWAV_H
diff --git a/xbmc/cdrip/IEncoder.h b/xbmc/cdrip/IEncoder.h
new file mode 100644
index 0000000000..3b708f608a
--- /dev/null
+++ b/xbmc/cdrip/IEncoder.h
@@ -0,0 +1,56 @@
+#pragma once
+/*
+ * Copyright (C) 2014 Team XBMC
+ * http://xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <string>
+#include <stdint.h>
+#include "addons/include/xbmc_audioenc_types.h"
+
+class IEncoder
+{
+public:
+ IEncoder() :
+ m_iTrackLength(0),
+ m_iInChannels(0),
+ m_iInSampleRate(0),
+ m_iInBitsPerSample(0)
+ {
+ }
+ virtual ~IEncoder() {}
+ virtual bool Init(audioenc_callbacks &callbacks) = 0;
+ virtual int Encode(int nNumBytesRead, uint8_t* pbtStream) = 0;
+ virtual bool Close() = 0;
+
+ // tag info
+ std::string m_strComment;
+ std::string m_strArtist;
+ std::string m_strAlbumArtist;
+ std::string m_strTitle;
+ std::string m_strAlbum;
+ std::string m_strGenre;
+ std::string m_strTrack;
+ std::string m_strYear;
+ std::string m_strFile;
+ int m_iTrackLength;
+ int m_iInChannels;
+ int m_iInSampleRate;
+ int m_iInBitsPerSample;
+};
+
diff --git a/xbmc/cdrip/Makefile.in b/xbmc/cdrip/Makefile.in
index 19eb8c4c34..e763cdef9d 100644
--- a/xbmc/cdrip/Makefile.in
+++ b/xbmc/cdrip/Makefile.in
@@ -2,15 +2,6 @@ SRCS = CDDARipJob.cpp
SRCS += CDDARipper.cpp
SRCS += Encoder.cpp
SRCS += EncoderFFmpeg.cpp
-SRCS += EncoderFlac.cpp
-SRCS += EncoderWav.cpp
-
-ifeq (@HAVE_LIBMP3LAME@,1)
-SRCS += EncoderLame.cpp
-endif
-ifeq (@HAVE_LIBVORBISENC@,1)
-SRCS += EncoderVorbis.cpp
-endif
LIB=cdrip.a
diff --git a/xbmc/settings/Settings.cpp b/xbmc/settings/Settings.cpp
index 69f0518314..a2a3222795 100644
--- a/xbmc/settings/Settings.cpp
+++ b/xbmc/settings/Settings.cpp
@@ -568,7 +568,6 @@ void CSettings::InitializeOptionFillers()
// register setting option fillers
#ifdef HAS_DVD_DRIVE
m_settingsManager->RegisterSettingOptionsFiller("audiocdactions", MEDIA_DETECT::CAutorun::SettingOptionAudioCdActionsFiller);
- m_settingsManager->RegisterSettingOptionsFiller("audiocdencoders", MEDIA_DETECT::CAutorun::SettingOptionAudioCdEncodersFiller);
#endif
m_settingsManager->RegisterSettingOptionsFiller("aequalitylevels", CAEFactory::SettingOptionsAudioQualityLevelsFiller);
m_settingsManager->RegisterSettingOptionsFiller("audiodevices", CAEFactory::SettingOptionsAudioDevicesFiller);
@@ -717,6 +716,7 @@ void CSettings::InitializeISettingCallbacks()
settingSet.insert("screensaver.mode");
settingSet.insert("screensaver.preview");
settingSet.insert("screensaver.settings");
+ settingSet.insert("audiocds.settings");
settingSet.insert("videoscreen.guicalibration");
settingSet.insert("videoscreen.testpattern");
settingSet.insert("videoplayer.useamcodec");