diff options
| author | manuel <manuel@mausz.at> | 2015-03-03 16:53:59 +0100 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2015-03-03 16:53:59 +0100 |
| commit | ffca21f2743a7b367fa212799c6e2fea6190dd5d (patch) | |
| tree | 0608ea3a29cf644ec9ab204e2b4bb9bfaae1c381 /xbmc/addons/AudioEncoder.cpp | |
| download | kodi-pvr-build-ffca21f2743a7b367fa212799c6e2fea6190dd5d.tar.gz kodi-pvr-build-ffca21f2743a7b367fa212799c6e2fea6190dd5d.tar.bz2 kodi-pvr-build-ffca21f2743a7b367fa212799c6e2fea6190dd5d.zip | |
initial commit for kodi master
Diffstat (limited to 'xbmc/addons/AudioEncoder.cpp')
| -rw-r--r-- | xbmc/addons/AudioEncoder.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/xbmc/addons/AudioEncoder.cpp b/xbmc/addons/AudioEncoder.cpp new file mode 100644 index 0000000..2737bba --- /dev/null +++ b/xbmc/addons/AudioEncoder.cpp | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2013 Arne Morten Kvarving | ||
| 3 | * | ||
| 4 | * This Program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 7 | * any later version. | ||
| 8 | * | ||
| 9 | * This Program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with XBMC; see the file COPYING. If not, see | ||
| 16 | * <http://www.gnu.org/licenses/>. | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | #include "AudioEncoder.h" | ||
| 20 | |||
| 21 | namespace ADDON | ||
| 22 | { | ||
| 23 | |||
| 24 | CAudioEncoder::CAudioEncoder(const cp_extension_t* ext) | ||
| 25 | : AudioEncoderDll(ext), | ||
| 26 | extension(CAddonMgr::Get().GetExtValue(ext->configuration, "@extension")), | ||
| 27 | m_context(NULL) | ||
| 28 | { | ||
| 29 | } | ||
| 30 | |||
| 31 | AddonPtr CAudioEncoder::Clone() const | ||
| 32 | { | ||
| 33 | // Copy constructor is generated by compiler and calls parent copy constructor | ||
| 34 | return AddonPtr(new CAudioEncoder(*this)); | ||
| 35 | } | ||
| 36 | |||
| 37 | bool CAudioEncoder::Init(audioenc_callbacks &callbacks) | ||
| 38 | { | ||
| 39 | if (!Initialized()) | ||
| 40 | return false; | ||
| 41 | |||
| 42 | // create encoder instance | ||
| 43 | m_context = m_pStruct->Create(&callbacks); | ||
| 44 | if (!m_context) | ||
| 45 | return false; | ||
| 46 | |||
| 47 | return m_pStruct->Start(m_context, | ||
| 48 | m_iInChannels, | ||
| 49 | m_iInSampleRate, | ||
| 50 | m_iInBitsPerSample, | ||
| 51 | m_strTitle.c_str(), | ||
| 52 | m_strArtist.c_str(), | ||
| 53 | m_strAlbumArtist.c_str(), | ||
| 54 | m_strAlbum.c_str(), | ||
| 55 | m_strYear.c_str(), | ||
| 56 | m_strTrack.c_str(), | ||
| 57 | m_strGenre.c_str(), | ||
| 58 | m_strComment.c_str(), | ||
| 59 | m_iTrackLength); | ||
| 60 | } | ||
| 61 | |||
| 62 | int CAudioEncoder::Encode(int nNumBytesRead, uint8_t* pbtStream) | ||
| 63 | { | ||
| 64 | if (!Initialized() || !m_context) | ||
| 65 | return 0; | ||
| 66 | |||
| 67 | return m_pStruct->Encode(m_context, nNumBytesRead, pbtStream); | ||
| 68 | } | ||
| 69 | |||
| 70 | bool CAudioEncoder::Close() | ||
| 71 | { | ||
| 72 | if (!Initialized() || !m_context) | ||
| 73 | return false; | ||
| 74 | |||
| 75 | if (!m_pStruct->Finish(m_context)) | ||
| 76 | return false; | ||
| 77 | |||
| 78 | m_pStruct->Free(m_context); | ||
| 79 | m_context = NULL; | ||
| 80 | |||
| 81 | return true; | ||
| 82 | } | ||
| 83 | |||
| 84 | void CAudioEncoder::Destroy() | ||
| 85 | { | ||
| 86 | AudioEncoderDll::Destroy(); | ||
| 87 | } | ||
| 88 | |||
| 89 | } /*namespace ADDON*/ | ||
| 90 | |||
