diff options
author | Sylvain Rebaud <sylvain@plutinosoft.com> | 2012-03-16 23:32:10 -0700 |
---|---|---|
committer | Jonathan Marshall <jmarshall@never.you.mind> | 2012-03-19 13:40:25 +1300 |
commit | 163fbda342046d1109f0769054cc32d9e65d37b0 (patch) | |
tree | c5c9fd6244d1dcb3864eda64ddba5180e05c509e | |
parent | ddd5ae0a17d008c1087ec61391a822302f069efe (diff) |
Merged support for audio/L16 mimetype from andrewfg PR 251
-rw-r--r-- | XBMC-ATV2.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | XBMC-IOS.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | XBMC.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | project/VS2010Express/XBMC.vcxproj | 2 | ||||
-rw-r--r-- | project/VS2010Express/XBMC.vcxproj.filters | 6 | ||||
-rw-r--r-- | xbmc/cores/paplayer/CodecFactory.cpp | 9 | ||||
-rw-r--r-- | xbmc/cores/paplayer/Makefile.in | 1 | ||||
-rw-r--r-- | xbmc/cores/paplayer/PCMCodec.cpp | 125 | ||||
-rw-r--r-- | xbmc/cores/paplayer/PCMCodec.h | 40 |
9 files changed, 203 insertions, 0 deletions
diff --git a/XBMC-ATV2.xcodeproj/project.pbxproj b/XBMC-ATV2.xcodeproj/project.pbxproj index 96b2a3f965..c606ca0fc0 100644 --- a/XBMC-ATV2.xcodeproj/project.pbxproj +++ b/XBMC-ATV2.xcodeproj/project.pbxproj @@ -25,6 +25,7 @@ 7C89627013B702F3003631FE /* GUIWindowScreensaverDim.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89626E13B702F3003631FE /* GUIWindowScreensaverDim.cpp */; }; 7C99B73F133D372300FC2B16 /* CacheCircular.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C99B73D133D372300FC2B16 /* CacheCircular.cpp */; }; 7C99B7AA134072CD00FC2B16 /* GUIDialogPlayEject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C99B7A8134072CD00FC2B16 /* GUIDialogPlayEject.cpp */; }; + 7CCFD9AA1514952700211D82 /* PCMCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCFD9A81514952700211D82 /* PCMCodec.cpp */; }; 7CEE2E6D13D6B7A8000ABF2A /* TimeSmoother.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CEE2E6B13D6B7A8000ABF2A /* TimeSmoother.cpp */; }; C807119F135DB842002F601B /* InputOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C807119D135DB842002F601B /* InputOperations.cpp */; }; C8EC5D51136954E400CCC10D /* XBMC_keytable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C8EC5D4F136954E400CCC10D /* XBMC_keytable.cpp */; }; @@ -981,6 +982,8 @@ 7C99B73E133D372300FC2B16 /* CacheCircular.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheCircular.h; sourceTree = "<group>"; }; 7C99B7A8134072CD00FC2B16 /* GUIDialogPlayEject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogPlayEject.cpp; sourceTree = "<group>"; }; 7C99B7A9134072CD00FC2B16 /* GUIDialogPlayEject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogPlayEject.h; sourceTree = "<group>"; }; + 7CCFD9A81514952700211D82 /* PCMCodec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PCMCodec.cpp; sourceTree = "<group>"; }; + 7CCFD9A91514952700211D82 /* PCMCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCMCodec.h; sourceTree = "<group>"; }; 7CEE2E6B13D6B7A8000ABF2A /* TimeSmoother.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeSmoother.cpp; sourceTree = "<group>"; }; 7CEE2E6C13D6B7A8000ABF2A /* TimeSmoother.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeSmoother.h; sourceTree = "<group>"; }; 8316267613B670FF004AED87 /* README.ios */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.ios; sourceTree = "<group>"; }; @@ -3875,6 +3878,8 @@ F56C7322131EC151000AD0F6 /* OGGcodec.h */, F56C7323131EC151000AD0F6 /* PAPlayer.cpp */, F56C7324131EC151000AD0F6 /* PAPlayer.h */, + 7CCFD9A81514952700211D82 /* PCMCodec.cpp */, + 7CCFD9A91514952700211D82 /* PCMCodec.h */, F56C7325131EC151000AD0F6 /* ReplayGain.cpp */, F56C7326131EC151000AD0F6 /* ReplayGain.h */, F56C7328131EC151000AD0F6 /* SIDCodec.cpp */, @@ -6934,6 +6939,7 @@ F5E113AD1435882400175026 /* pyrendercapture.cpp in Sources */, DF673A251443769300A5A509 /* FileUPnP.cpp in Sources */, F5BD033A148D4923001B5583 /* CryptThreading.cpp in Sources */, + 7CCFD9AA1514952700211D82 /* PCMCodec.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/XBMC-IOS.xcodeproj/project.pbxproj b/XBMC-IOS.xcodeproj/project.pbxproj index b2ce3c9dfe..9ba2d9f343 100644 --- a/XBMC-IOS.xcodeproj/project.pbxproj +++ b/XBMC-IOS.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 7C89628013B7031E003631FE /* GUIWindowScreensaverDim.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C89627E13B7031E003631FE /* GUIWindowScreensaverDim.cpp */; }; 7C99B6E9133D36E200FC2B16 /* CacheCircular.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C99B6E7133D36E200FC2B16 /* CacheCircular.cpp */; }; 7C99B7BE1340730000FC2B16 /* GUIDialogPlayEject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C99B7BC1340730000FC2B16 /* GUIDialogPlayEject.cpp */; }; + 7CCFD9991514950700211D82 /* PCMCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCFD9971514950700211D82 /* PCMCodec.cpp */; }; 7CEE2E7F13D6B7D4000ABF2A /* TimeSmoother.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CEE2E7D13D6B7D4000ABF2A /* TimeSmoother.cpp */; }; C80711AD135DB85F002F601B /* InputOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C80711AB135DB85F002F601B /* InputOperations.cpp */; }; C8EC5D26136953E100CCC10D /* XBMC_keytable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C8EC5D24136953E100CCC10D /* XBMC_keytable.cpp */; }; @@ -982,6 +983,8 @@ 7C99B6E8133D36E200FC2B16 /* CacheCircular.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheCircular.h; sourceTree = "<group>"; }; 7C99B7BC1340730000FC2B16 /* GUIDialogPlayEject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIDialogPlayEject.cpp; sourceTree = "<group>"; }; 7C99B7BD1340730000FC2B16 /* GUIDialogPlayEject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIDialogPlayEject.h; sourceTree = "<group>"; }; + 7CCFD9971514950700211D82 /* PCMCodec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PCMCodec.cpp; sourceTree = "<group>"; }; + 7CCFD9981514950700211D82 /* PCMCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCMCodec.h; sourceTree = "<group>"; }; 7CEE2E7D13D6B7D4000ABF2A /* TimeSmoother.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeSmoother.cpp; sourceTree = "<group>"; }; 7CEE2E7E13D6B7D4000ABF2A /* TimeSmoother.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeSmoother.h; sourceTree = "<group>"; }; 83D619BB13C0D25300418A0F /* README.ios */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.ios; sourceTree = "<group>"; }; @@ -4275,6 +4278,8 @@ F56C8323131F42E7000AD0F6 /* OGGcodec.h */, F56C8324131F42E7000AD0F6 /* PAPlayer.cpp */, F56C8325131F42E7000AD0F6 /* PAPlayer.h */, + 7CCFD9971514950700211D82 /* PCMCodec.cpp */, + 7CCFD9981514950700211D82 /* PCMCodec.h */, F56C8326131F42E7000AD0F6 /* ReplayGain.cpp */, F56C8327131F42E7000AD0F6 /* ReplayGain.h */, F56C8328131F42E7000AD0F6 /* SIDCodec.cpp */, @@ -6949,6 +6954,7 @@ F5E112EC143577A000175026 /* Peripherals.cpp in Sources */, DF6739E21443765F00A5A509 /* FileUPnP.cpp in Sources */, F5BD034F148D496A001B5583 /* CryptThreading.cpp in Sources */, + 7CCFD9991514950700211D82 /* PCMCodec.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/XBMC.xcodeproj/project.pbxproj b/XBMC.xcodeproj/project.pbxproj index 9347c97b0e..114d104a9a 100644 --- a/XBMC.xcodeproj/project.pbxproj +++ b/XBMC.xcodeproj/project.pbxproj @@ -565,6 +565,8 @@ 7CCF7F1E1069F3AE00992676 /* Builtins.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCF7F1B1069F3AE00992676 /* Builtins.cpp */; }; 7CCF7FC9106A0DF500992676 /* TimeUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCF7FC7106A0DF500992676 /* TimeUtils.cpp */; }; 7CCF7FCA106A0DF500992676 /* TimeUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCF7FC7106A0DF500992676 /* TimeUtils.cpp */; }; + 7CCFD98C151494E100211D82 /* PCMCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCFD98A151494E100211D82 /* PCMCodec.cpp */; }; + 7CCFD98D151494E100211D82 /* PCMCodec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CCFD98A151494E100211D82 /* PCMCodec.cpp */; }; 7CD2C3AA11940B270009EFC1 /* DirectoryNodeCountry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD2C3A811940B270009EFC1 /* DirectoryNodeCountry.cpp */; }; 7CD2C3AB11940B270009EFC1 /* DirectoryNodeCountry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD2C3A811940B270009EFC1 /* DirectoryNodeCountry.cpp */; }; 7CD2CD0111B38B000009EFC1 /* PythonAddon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD2CCFE11B38B000009EFC1 /* PythonAddon.cpp */; }; @@ -2511,6 +2513,8 @@ 7CCF7F1C1069F3AE00992676 /* Builtins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Builtins.h; sourceTree = "<group>"; }; 7CCF7FC7106A0DF500992676 /* TimeUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TimeUtils.cpp; sourceTree = "<group>"; }; 7CCF7FC8106A0DF500992676 /* TimeUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimeUtils.h; sourceTree = "<group>"; }; + 7CCFD98A151494E100211D82 /* PCMCodec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PCMCodec.cpp; sourceTree = "<group>"; }; + 7CCFD98B151494E100211D82 /* PCMCodec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PCMCodec.h; sourceTree = "<group>"; }; 7CD2C3A811940B270009EFC1 /* DirectoryNodeCountry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectoryNodeCountry.cpp; sourceTree = "<group>"; }; 7CD2C3A911940B270009EFC1 /* DirectoryNodeCountry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryNodeCountry.h; sourceTree = "<group>"; }; 7CD2CCFE11B38B000009EFC1 /* PythonAddon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PythonAddon.cpp; sourceTree = "<group>"; }; @@ -5582,6 +5586,8 @@ E38E16240D25F9FA00618676 /* OGGcodec.h */, F5987FDA0FBE2DFD008EF4FB /* PAPlayer.cpp */, F5987FD90FBE2DFD008EF4FB /* PAPlayer.h */, + 7CCFD98A151494E100211D82 /* PCMCodec.cpp */, + 7CCFD98B151494E100211D82 /* PCMCodec.h */, E38E162A0D25F9FA00618676 /* ReplayGain.cpp */, E38E162B0D25F9FA00618676 /* ReplayGain.h */, E38E16310D25F9FA00618676 /* SIDCodec.cpp */, @@ -8043,6 +8049,7 @@ DF85BAB51443669A000686BE /* FileUPnP.cpp in Sources */, DF673AA51443819600A5A509 /* AddonManager.cpp in Sources */, F5BD02F6148D3A7E001B5583 /* CryptThreading.cpp in Sources */, + 7CCFD98D151494E100211D82 /* PCMCodec.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -8963,6 +8970,7 @@ F54BCC601439345300F86B0F /* HotKeyController.m in Sources */, DF85BAB61443669A000686BE /* FileUPnP.cpp in Sources */, F5BD02F7148D3A7E001B5583 /* CryptThreading.cpp in Sources */, + 7CCFD98C151494E100211D82 /* PCMCodec.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index 240372b6ce..f3b44daba1 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -304,6 +304,7 @@ <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDCodecs\Video\CrystalHD.cpp" /> <ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDInputStreams\DVDInputStreamBluray.cpp" /> <ClCompile Include="..\..\xbmc\cores\paplayer\BXAcodec.cpp" /> + <ClCompile Include="..\..\xbmc\cores\paplayer\PCMCodec.cpp" /> <ClCompile Include="..\..\xbmc\cores\VideoRenderers\RenderCapture.cpp" /> <ClCompile Include="..\..\xbmc\cores\VideoRenderers\VideoShaders\WinVideoFilter.cpp" /> <ClCompile Include="..\..\xbmc\CueDocument.cpp" /> @@ -755,6 +756,7 @@ <ClCompile Include="..\..\xbmc\threads\LockFree.cpp" /> <ClCompile Include="..\..\xbmc\threads\platform\Implementation.cpp" /> <ClInclude Include="..\..\xbmc\cores\AudioRenderers\IAudioRenderer.h" /> + <ClInclude Include="..\..\xbmc\cores\paplayer\PCMCodec.h" /> <ClInclude Include="..\..\xbmc\filesystem\FileUPnP.h" /> <ClInclude Include="..\..\xbmc\interfaces\python\xbmcmodule\pythreadstate.h" /> <ClInclude Include="..\..\xbmc\threads\platform\win\Implementation.cpp" /> diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 1ef6452c4c..62a6f25564 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -2565,6 +2565,9 @@ <ClCompile Include="..\..\xbmc\filesystem\FileUPnP.cpp"> <Filter>filesystem</Filter> </ClCompile> + <ClCompile Include="..\..\xbmc\cores\paplayer\PCMCodec.cpp"> + <Filter>cores\paplayer</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\xbmc\win32\pch.h"> @@ -5154,6 +5157,9 @@ <ClInclude Include="..\..\xbmc\interfaces\python\xbmcmodule\pythreadstate.h"> <Filter>interfaces\python\xbmcmodule</Filter> </ClInclude> + <ClInclude Include="..\..\xbmc\cores\paplayer\PCMCodec.h"> + <Filter>cores\paplayer</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc"> diff --git a/xbmc/cores/paplayer/CodecFactory.cpp b/xbmc/cores/paplayer/CodecFactory.cpp index 8b3ca6803f..99a4065be3 100644 --- a/xbmc/cores/paplayer/CodecFactory.cpp +++ b/xbmc/cores/paplayer/CodecFactory.cpp @@ -42,11 +42,14 @@ #include "URL.h" #include "DVDPlayerCodec.h" #include "BXAcodec.h" +#include "PCMCodec.h" ICodec* CodecFactory::CreateCodec(const CStdString& strFileType) { if (strFileType.Equals("mp3") || strFileType.Equals("mp2")) return new MP3Codec(); + else if (strFileType.Equals("pcm") || strFileType.Equals("l16")) + return new PCMCodec(); else if (strFileType.Equals("ape") || strFileType.Equals("mac")) return new DVDPlayerCodec(); else if (strFileType.Equals("cdda")) @@ -117,6 +120,12 @@ ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdStri if( strContent.Equals("audio/mpeg") || strContent.Equals("audio/mp3") ) return new MP3Codec(); + else if (strContent.Left(9).Equals("audio/l16") == 0) + { + PCMCodec * pcm_codec = new PCMCodec(); + pcm_codec->SetMimeParams(strContent); + return pcm_codec; + } else if( strContent.Equals("audio/aac") || strContent.Equals("audio/aacp") ) { diff --git a/xbmc/cores/paplayer/Makefile.in b/xbmc/cores/paplayer/Makefile.in index 3a7adaab0d..035cabda30 100644 --- a/xbmc/cores/paplayer/Makefile.in +++ b/xbmc/cores/paplayer/Makefile.in @@ -17,6 +17,7 @@ SRCS=ADPCMCodec.cpp \ OggCallback.cpp \ OGGcodec.cpp \ PAPlayer.cpp \ + PCMCodec.cpp \ ReplayGain.cpp \ SIDCodec.cpp \ TimidityCodec.cpp \ diff --git a/xbmc/cores/paplayer/PCMCodec.cpp b/xbmc/cores/paplayer/PCMCodec.cpp new file mode 100644 index 0000000000..19cedf1dfa --- /dev/null +++ b/xbmc/cores/paplayer/PCMCodec.cpp @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2011-2012 Team XBMC + * http://www.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, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#include "PCMCodec.h" +#include "utils/log.h" +#include "utils/EndianSwap.h" +#include "utils/StringUtils.h" + +PCMCodec::PCMCodec() +{ + m_CodecName = "PCM"; + m_TotalTime = 0; + m_SampleRate = 44100; + m_Channels = 2; + m_BitsPerSample = 16; + m_Bitrate = m_SampleRate * m_Channels * m_BitsPerSample; +} + +PCMCodec::~PCMCodec() +{ + DeInit(); +} + +bool PCMCodec::Init(const CStdString &strFile, unsigned int filecache) +{ + m_file.Close(); + if (!m_file.Open(strFile, READ_CACHED)) + { + CLog::Log(LOGERROR, "PCMCodec::Init - Failed to open file"); + return false; + } + + int64_t length = m_file.GetLength(); + + if (m_Bitrate) + m_TotalTime = 1000 * 8 * length / m_Bitrate; + + m_file.Seek(0, SEEK_SET); + + return true; +} + +void PCMCodec::DeInit() +{ + m_file.Close(); +} + +__int64 PCMCodec::Seek(__int64 iSeekTime) +{ + m_file.Seek((iSeekTime / 1000) * (m_Bitrate / 8)); + return iSeekTime; +} + +int PCMCodec::ReadPCM(BYTE *pBuffer, int size, int *actualsize) +{ + *actualsize = 0; + + int iAmountRead = m_file.Read(pBuffer, 2 * (size / 2)); + if (iAmountRead > 0) + { + uint16_t *buffer = (uint16_t*) pBuffer; + + iAmountRead = 2 * (iAmountRead / 2); + + for (int i = 0; i < (iAmountRead / 2); i++) + buffer[i] = Endian_SwapBE16(buffer[i]); // L16 PCM is in network byte order (Big Endian) + + *actualsize = iAmountRead; + + return READ_SUCCESS; + } + return READ_ERROR; +} + +bool PCMCodec::CanInit() +{ + return true; +} + +void PCMCodec::SetMimeParams(const CStdString& strMimeParams) +{ + CStdStringArray mimeParams; + + // if there are no parameters, the default is 2 channels, 44100 samples/sec + m_Channels = 2; + m_SampleRate = 44100; + + StringUtils::SplitString(strMimeParams, ";", mimeParams); + for (size_t i = 0; i < mimeParams.size(); i++) + { + CStdStringArray thisParam; + StringUtils::SplitString(mimeParams[i], "=", thisParam, 2); + if (thisParam.size() > 1) + { + if (thisParam[0] == "rate") + { + m_SampleRate = atoi(thisParam[1].Trim()); + } + else if (thisParam[0] == "channels") + { + m_Channels = atoi(thisParam[1].Trim()); + } + } + } + + m_Bitrate = m_SampleRate * m_Channels * m_BitsPerSample; +} diff --git a/xbmc/cores/paplayer/PCMCodec.h b/xbmc/cores/paplayer/PCMCodec.h new file mode 100644 index 0000000000..6175fa595e --- /dev/null +++ b/xbmc/cores/paplayer/PCMCodec.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2012 Team XBMC + * http://www.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, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + * http://www.gnu.org/copyleft/gpl.html + * + */ + +#pragma once +#include "CachingCodec.h" + +class PCMCodec : public CachingCodec +{ +public: + PCMCodec(void); + virtual ~PCMCodec(void); + virtual bool Init(const CStdString &strFile, unsigned int filecache); + virtual void DeInit(); + virtual __int64 Seek(__int64 iSeekTime); + virtual int ReadPCM(BYTE *pBuffer, int size, int *actualsize); + virtual bool CanInit(); + virtual void SetMimeParams(const CStdString& strMimeParams); +private: + int iBytesPerSecond; +}; + + |