forked from xbmc/xbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for audio decoder addons
- Loading branch information
1 parent
0e239b4
commit b2db871
Showing
17 changed files
with
484 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.