Skip to content

Commit

Permalink
add support for audio decoder addons
Browse files Browse the repository at this point in the history
  • Loading branch information
notspiff authored and FernetMenta committed Mar 3, 2015
1 parent 0e239b4 commit b2db871
Show file tree
Hide file tree
Showing 17 changed files with 484 additions and 8 deletions.
10 changes: 10 additions & 0 deletions Kodi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@
395C2A1F1A9F96A700EBC7AD /* ContextItemAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395C2A1D1A9F96A700EBC7AD /* ContextItemAddon.cpp */; };
395C2A201A9F96A700EBC7AD /* ContextItemAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395C2A1D1A9F96A700EBC7AD /* ContextItemAddon.cpp */; };
395C2A211A9F96A700EBC7AD /* ContextItemAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395C2A1D1A9F96A700EBC7AD /* ContextItemAddon.cpp */; };
395C2A241AA4C32100EBC7AD /* AudioDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395C2A221AA4C32100EBC7AD /* AudioDecoder.cpp */; };
395C2A251AA4C32100EBC7AD /* AudioDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395C2A221AA4C32100EBC7AD /* AudioDecoder.cpp */; };
395C2A261AA4C32100EBC7AD /* AudioDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395C2A221AA4C32100EBC7AD /* AudioDecoder.cpp */; };
395F6DDD1A8133360088CC74 /* GUIDialogSimpleMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395F6DDB1A8133360088CC74 /* GUIDialogSimpleMenu.cpp */; };
395F6DDE1A8133360088CC74 /* GUIDialogSimpleMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395F6DDB1A8133360088CC74 /* GUIDialogSimpleMenu.cpp */; };
395F6DDF1A8133360088CC74 /* GUIDialogSimpleMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 395F6DDB1A8133360088CC74 /* GUIDialogSimpleMenu.cpp */; };
Expand Down Expand Up @@ -3696,6 +3699,8 @@
395C2A031A9CD25100EBC7AD /* ContextItemAddonInvoker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ContextItemAddonInvoker.h; path = python/ContextItemAddonInvoker.h; sourceTree = "<group>"; };
395C2A1D1A9F96A700EBC7AD /* ContextItemAddon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContextItemAddon.cpp; sourceTree = "<group>"; };
395C2A1E1A9F96A700EBC7AD /* ContextItemAddon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextItemAddon.h; sourceTree = "<group>"; };
395C2A221AA4C32100EBC7AD /* AudioDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AudioDecoder.cpp; sourceTree = "<group>"; };
395C2A231AA4C32100EBC7AD /* AudioDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioDecoder.h; sourceTree = "<group>"; };
395F6DDB1A8133360088CC74 /* GUIDialogSimpleMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogSimpleMenu.cpp; sourceTree = "<group>"; };
395F6DDC1A8133360088CC74 /* GUIDialogSimpleMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogSimpleMenu.h; sourceTree = "<group>"; };
395F6DE01A81FACF0088CC74 /* HTTPImageTransformationHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPImageTransformationHandler.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6113,6 +6118,8 @@
F52BFFD9115D5574004B1D66 /* AddonStatusHandler.h */,
18B700DF13A6A5750009C1AF /* AddonVersion.cpp */,
18B700E013A6A5750009C1AF /* AddonVersion.h */,
395C2A221AA4C32100EBC7AD /* AudioDecoder.cpp */,
395C2A231AA4C32100EBC7AD /* AudioDecoder.h */,
7CF34D9D1930264A00D543C5 /* AudioEncoder.cpp */,
7CF34D9E1930264A00D543C5 /* AudioEncoder.h */,
395C2A1D1A9F96A700EBC7AD /* ContextItemAddon.cpp */,
Expand Down Expand Up @@ -10838,6 +10845,7 @@
7C779E3A104A57E500F444C4 /* RenderSystem.cpp in Sources */,
7C779E3B104A57E500F444C4 /* RenderSystemGL.cpp in Sources */,
7C779E3C104A57E500F444C4 /* WinEventsSDL.cpp in Sources */,
395C2A241AA4C32100EBC7AD /* AudioDecoder.cpp in Sources */,
7C779E3D104A57E500F444C4 /* WinSystem.cpp in Sources */,
7C779E3E104A57E500F444C4 /* WinSystemOSX.mm in Sources */,
7C779E3F104A57E500F444C4 /* WinSystemOSXGL.mm in Sources */,
Expand Down Expand Up @@ -11547,6 +11555,7 @@
DFF0F12817528350002DA3A4 /* Repository.cpp in Sources */,
DFF0F12917528350002DA3A4 /* Scraper.cpp in Sources */,
DFF0F12A17528350002DA3A4 /* ScreenSaver.cpp in Sources */,
395C2A261AA4C32100EBC7AD /* AudioDecoder.cpp in Sources */,
DFF0F12B17528350002DA3A4 /* Service.cpp in Sources */,
DFF0F12C17528350002DA3A4 /* Skin.cpp in Sources */,
DFF0F12D17528350002DA3A4 /* Visualisation.cpp in Sources */,
Expand Down Expand Up @@ -12990,6 +12999,7 @@
E4991309174E5DAD00741B6D /* GUIRadioButtonControl.cpp in Sources */,
E499130A174E5DAD00741B6D /* GUIRenderingControl.cpp in Sources */,
E499130B174E5DAD00741B6D /* GUIResizeControl.cpp in Sources */,
395C2A251AA4C32100EBC7AD /* AudioDecoder.cpp in Sources */,
E499130C174E5DAD00741B6D /* GUIRSSControl.cpp in Sources */,
E499130D174E5DAD00741B6D /* GUIScrollBarControl.cpp in Sources */,
E499130E174E5DAD00741B6D /* GUISelectButtonControl.cpp in Sources */,
Expand Down
7 changes: 7 additions & 0 deletions addons/kodi.audiodecoder/addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="kodi.audiodecoder" version="1.0.0" provider-name="Team-Kodi">
<backwards-compatibility abi="1.0.0"/>
<requires>
<import addon="xbmc.core" version="0.1.0"/>
</requires>
</addon>
5 changes: 4 additions & 1 deletion language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,10 @@ msgctxt "#200"
msgid "Audio encoders"
msgstr ""

#empty string with id 201
#: xbmc/filesystem/AddonsDirectory.cpp
msgctxt "#201"
msgid "Audio decoders"
msgstr ""

#: xbmc/playlists/SmartPlaylist.cpp
msgctxt "#202"
Expand Down
1 change: 1 addition & 0 deletions project/VS2010Express/XBMC.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
<ClCompile Include="..\..\xbmc\addons\AddonInstaller.cpp" />
<ClCompile Include="..\..\xbmc\addons\AddonVersion.cpp" />
<ClCompile Include="..\..\xbmc\addons\ContextItemAddon.cpp" />
<ClCompile Include="..\..\xbmc\addons\AudioDecoder.cpp" />
<ClCompile Include="..\..\xbmc\addons\GUIDialogAddonInfo.cpp" />
<ClCompile Include="..\..\xbmc\addons\GUIDialogAddonSettings.cpp" />
<ClCompile Include="..\..\xbmc\addons\GUIViewStateAddonBrowser.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions project/VS2010Express/XBMC.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -3177,6 +3177,9 @@
<ClCompile Include="..\..\xbmc\network\httprequesthandler\HTTPPythonHandler.cpp">
<Filter>network\httprequesthandler</Filter>
</ClCompile>
<ClCompile Include="..\..\xbmc\addons\AudioDecoder.cpp">
<Filter>addons</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\win32\pch.h">
Expand Down
2 changes: 2 additions & 0 deletions xbmc/addons/Addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static const TypeMapping types[] =
{"xbmc.addon.image", ADDON_IMAGE, 1039, "DefaultAddonPicture.png" },
{"xbmc.addon.executable", ADDON_EXECUTABLE, 1043, "DefaultAddonProgram.png" },
{"xbmc.audioencoder", ADDON_AUDIOENCODER, 200, "DefaultAddonAudioEncoder.png" },
{"kodi.audiodecoder", ADDON_AUDIODECODER, 201, "DefaultAddonAudioDecoder.png" },
{"xbmc.service", ADDON_SERVICE, 24018, "DefaultAddonService.png" }};

const std::string TranslateType(const ADDON::TYPE &type, bool pretty/*=false*/)
Expand Down Expand Up @@ -397,6 +398,7 @@ void CAddon::BuildLibName(const cp_extension_t *extension)
case ADDON_REPOSITORY:
case ADDON_AUDIOENCODER:
case ADDON_CONTEXT_ITEM:
case ADDON_AUDIODECODER:
{
std::string temp = CAddonMgr::Get().GetExtValue(extension->configuration, "@library");
m_strLibName = temp;
Expand Down
6 changes: 6 additions & 0 deletions xbmc/addons/AddonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "AddonManager.h"
#include "Addon.h"
#include "AudioEncoder.h"
#include "AudioDecoder.h"
#include "DllLibCPluff.h"
#include "utils/StringUtils.h"
#include "utils/JobManager.h"
Expand Down Expand Up @@ -117,6 +118,7 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
case ADDON_SCREENSAVER:
case ADDON_PVRDLL:
case ADDON_AUDIOENCODER:
case ADDON_AUDIODECODER:
{ // begin temporary platform handling for Dlls
// ideally platforms issues will be handled by C-Pluff
// this is not an attempt at a solution
Expand Down Expand Up @@ -163,6 +165,8 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
}
else if (type == ADDON_AUDIOENCODER)
return AddonPtr(new CAudioEncoder(props));
else if (type == ADDON_AUDIODECODER)
return AddonPtr(new CAudioDecoder(props));
else
return AddonPtr(new CScreenSaver(props));
}
Expand Down Expand Up @@ -757,6 +761,8 @@ AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
return AddonPtr(new PVR::CPVRClient(addonProps));
case ADDON_AUDIOENCODER:
return AddonPtr(new CAudioEncoder(addonProps));
case ADDON_AUDIODECODER:
return AddonPtr(new CAudioDecoder(addonProps));
case ADDON_REPOSITORY:
return AddonPtr(new CRepository(addonProps));
case ADDON_CONTEXT_ITEM:
Expand Down
135 changes: 135 additions & 0 deletions xbmc/addons/AudioDecoder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* 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 "AudioDecoder.h"
#include "music/tags/MusicInfoTag.h"
#include "music/tags/TagLoaderTagLib.h"

namespace ADDON
{

CAudioDecoder::CAudioDecoder(const cp_extension_t* ext)
: AudioDecoderDll(ext),
m_extension(CAddonMgr::Get().GetExtValue(ext->configuration, "@extension")),
m_mimetype(CAddonMgr::Get().GetExtValue(ext->configuration, "@mimetype")),
m_context(NULL),
m_tags(CAddonMgr::Get().GetExtValue(ext->configuration, "@tags") == "true"),
m_tracks(CAddonMgr::Get().GetExtValue(ext->configuration, "@tracks") == "true"),
m_channel(NULL)
{
m_CodecName = CAddonMgr::Get().GetExtValue(ext->configuration, "@name");
m_strExt = CAddonMgr::Get().GetExtValue(ext->configuration, "@name")+"stream";
}

AddonPtr CAudioDecoder::Clone() const
{
// Copy constructor is generated by compiler and calls parent copy constructor
return AddonPtr(new CAudioDecoder(*this));
}

bool CAudioDecoder::Init(const std::string& strFile, unsigned int filecache)
{
if (!Initialized())
return false;

// for replaygain
CTagLoaderTagLib tag;
tag.Load(strFile, XFILE::CMusicFileDirectory::m_tag, NULL);

m_context = m_pStruct->Init(strFile.c_str(), filecache,
&m_Channels, &m_SampleRate,
&m_BitsPerSample, &m_TotalTime,
&m_Bitrate, &m_DataFormat, &m_channel);

return (m_context != NULL);
}

int CAudioDecoder::ReadPCM(uint8_t* buffer, int size, int* actualsize)
{
if (!Initialized())
return 0;

return m_pStruct->ReadPCM(m_context, buffer, size, actualsize);
}

int64_t CAudioDecoder::Seek(int64_t time)
{
if (!Initialized())
return 0;

return m_pStruct->Seek(m_context, time);
}

void CAudioDecoder::DeInit()
{
if (!Initialized())
return;

m_pStruct->DeInit(m_context);
}

bool CAudioDecoder::Load(const std::string& fileName,
MUSIC_INFO::CMusicInfoTag& tag,
MUSIC_INFO::EmbeddedArt* art)
{
if (!Initialized())
return false;

char title[256];
char artist[256];
int length;
if (m_pStruct->ReadTag(fileName.c_str(), title, artist, &length))
{
tag.SetTitle(title);
tag.SetArtist(artist);
tag.SetDuration(length);
return true;
}

return false;
}

int CAudioDecoder::GetTrackCount(const std::string& strPath)
{
if (!Initialized())
return 0;

int result = m_pStruct->TrackCount(strPath.c_str());

if (result > 1 && !Load(strPath, XFILE::CMusicFileDirectory::m_tag, NULL))
return 0;

XFILE::CMusicFileDirectory::m_tag.SetLoaded(true);
return result;
}

CAEChannelInfo CAudioDecoder::GetChannelInfo()
{
if (m_channel)
return CAEChannelInfo(m_channel);

return ICodec::GetChannelInfo();
}

void CAudioDecoder::Destroy()
{
AudioDecoderDll::Destroy();
}

} /*namespace ADDON*/

76 changes: 76 additions & 0 deletions xbmc/addons/AudioDecoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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/kodi_audiodec_types.h"
#include "cores/paplayer/ICodec.h"
#include "music/tags/ImusicInfoTagLoader.h"
#include "filesystem/MusicFileDirectory.h"

namespace MUSIC_INFO
{
class CMusicInfoTag;
class EmbeddedArt;
}

typedef DllAddon<AudioDecoder, AUDIODEC_PROPS> DllAudioDecoder;
namespace ADDON
{
typedef CAddonDll<DllAudioDecoder,
AudioDecoder, AUDIODEC_PROPS> AudioDecoderDll;

class CAudioDecoder : public AudioDecoderDll,
public ICodec,
public MUSIC_INFO::IMusicInfoTagLoader,
public XFILE::CMusicFileDirectory
{
public:
CAudioDecoder(const AddonProps &props) : AudioDecoderDll(props) {};
CAudioDecoder(const cp_extension_t *ext);
virtual ~CAudioDecoder() {}
virtual AddonPtr Clone() const;

// Things that MUST be supplied by the child classes
bool Init(const std::string& strFile, unsigned int filecache);
int ReadPCM(uint8_t* buffer, int size, int* actualsize);
int64_t Seek(int64_t time);
bool CanInit() { return true; }
void DeInit();
void Destroy();
bool Load(const std::string& strFileName,
MUSIC_INFO::CMusicInfoTag& tag,
MUSIC_INFO::EmbeddedArt *art = NULL);
int GetTrackCount(const std::string& strPath);
virtual CAEChannelInfo GetChannelInfo();

const std::string& GetExtensions() const { return m_extension; }
const std::string& GetMimetypes() const { return m_mimetype; }
bool HasTags() const { return m_tags; }
bool HasTracks() const { return m_tracks; }
protected:
std::string m_extension;
std::string m_mimetype;
void* m_context;
bool m_tags;
bool m_tracks;
const AEChannel* m_channel;
};

} /*namespace ADDON*/
1 change: 1 addition & 0 deletions xbmc/addons/IAddon.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace ADDON
ADDON_SERVICE,
ADDON_AUDIOENCODER,
ADDON_CONTEXT_ITEM,
ADDON_AUDIODECODER,
ADDON_VIDEO, // virtual addon types
ADDON_AUDIO,
ADDON_IMAGE,
Expand Down
1 change: 1 addition & 0 deletions xbmc/addons/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SRCS=Addon.cpp \
AddonVersion.cpp \
AudioEncoder.cpp \
ContextItemAddon.cpp \
AudioDecoder.cpp \
GUIDialogAddonInfo.cpp \
GUIDialogAddonSettings.cpp \
GUIViewStateAddonBrowser.cpp \
Expand Down
4 changes: 3 additions & 1 deletion xbmc/addons/addon-bindings.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ 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/kodi_audiodec_dll.h
BINDINGS+=xbmc/addons/include/kodi_audiodec_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
Expand All @@ -17,4 +19,4 @@ BINDINGS+=addons/library.xbmc.gui/libXBMC_gui.h
BINDINGS+=addons/library.xbmc.pvr/libXBMC_pvr.h
BINDINGS+=addons/library.xbmc.codec/libXBMC_codec.h
BINDINGS+=xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxPacket.h

BINDINGS+=xbmc/cores/AudioEngine/Utils/AEChannelData.h
Loading

0 comments on commit b2db871

Please sign in to comment.