📄 rasipr.cpp
字号:
/* ***** BEGIN LICENSE BLOCK *****
* Version: RCSL 1.0/RPSL 1.0
*
* Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file, are
* subject to the current version of the RealNetworks Public Source License
* Version 1.0 (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the RealNetworks Community Source License Version 1.0
* (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
* in which case the RCSL will apply. You may also obtain the license terms
* directly from RealNetworks. You may not use this file except in
* compliance with the RPSL or, if you have a valid RCSL with RealNetworks
* applicable to this file, the RCSL. Please see the applicable RPSL or
* RCSL for the rights, obligations and limitations governing use of the
* contents of the file.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the portions
* it created.
*
* This file, and the files included with this file, is distributed and made
* available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
#include "hxcom.h"
#include "hxtypes.h"
#ifdef _WINDOWS
#include <windows.h>
#endif
#include "hxresult.h"
#include "racodec.h"
#include "hxacodec.h"
#include "wrapsipr2.h"
/*
* PROTOTYPES
*/
#ifdef _MACINTOSH
#ifndef _MAC_MACHO
extern "C"
{
// Default routines
OSErr __initialize (CFragInitBlockPtr pInitBlock);
void __terminate(void);
// Our routines
OSErr InitEntryPoint (CFragInitBlockPtr pInitBlock);
void TermEntryPoint(void);
}
#endif
#endif
/*
* GLOBALS
*/
/*
* FUNCTIONS
*/
#ifdef _WIN32
#if !defined(_STATICALLY_LINKED)
#ifndef _WINCE
BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
#else
BOOL WINAPI DllMain (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
#endif
{
return TRUE;
}
#endif /* #if !defined(_STATICALLY_LINKED) */
#endif //_WIN32
#ifdef _WIN16
int CALLBACK LibMain (HINSTANCE hinst, WORD wDataSeg, WORD cbHeap, LPSTR lpszCmdLine)
{
return TRUE;
}
int CALLBACK _WEP (int I)
{
return TRUE;
}
#endif //_WIN16
#ifdef _MACINTOSH
#ifndef _MAC_MACHO
OSErr InitEntryPoint (CFragInitBlockPtr pInitBlock)
{
OSErr result = noErr;
result = __initialize (pInitBlock);
// HoldLibraryInMemory();
return result;
}
void TermEntryPoint (void)
{
__terminate();
// UnholdLibraryInMemory();
}
#endif
#endif
/*
* NEW COOKIE API
*/
// preview compatibility only - obsolete
HX_RESULT HXEXPORT ENTRYPOINT(RAOpenCodec) (RACODEC* pCodecRef)
{
CSiproCodec* thisCodec = new CSiproCodec;
if (pCodecRef)
*pCodecRef = (RACODEC) thisCodec;
return HXR_OK;
}
HX_RESULT HXEXPORT ENTRYPOINT(RAOpenCodec2) (RACODEC* pCodecRef, const char* pCodecPath)
{
// Note: The codec path is now obtained from this library's global
// DLLAccess object, which is set in the SetDLLAccessPaths() exported
// function. The loader of this library should have already called the
// SetDLLAccessPaths() function to set the codec path. -DPS
CSiproCodec* thisCodec = new CSiproCodec;
if (pCodecRef)
*pCodecRef = (RACODEC) thisCodec;
return HXR_OK;
}
HX_RESULT HXEXPORT ENTRYPOINT(RACloseCodec) (RACODEC codecRef)
{
delete (CSiproCodec*)codecRef;
return HXR_OK;
}
// Older SDK uses *this* function to determine the number of codec flavors.
// However, if this function returns more than 4 (the original number of
// Sipro flavors), that SDK will fail...
UINT16 HXEXPORT ENTRYPOINT(RAGetNumberOfFlavors) (RACODEC codecRef)
{
UINT16 retVal = 0;
if (codecRef)
{
retVal = ((CSiproCodec*)codecRef)->mGetNumberOfFlavors();
}
return retVal;
}
// This is the *new* function that will return the true number of supported
// Sipro flavors. The Build Engine will check for the existence of this
// function, and use its result. If this function does not exist it will
// query the function above (RAGetNumberOfFlavors)
// -Gregc
// It is currently commented out since no new flavors have been added to
// Sipro since G2 Gold. If new flavor is added, un-comment this and
// export the function.
//UINT16 HXEXPORT ENTRYPOINT(RAGetNumberOfFlavors2) (RACODEC codecRef)
//{
// UINT16 retVal = 0;
//
// if (codecRef)
// {
// retVal = ((CSiproCodec*)codecRef)->mGetNumberOfFlavors2();
// }
//
// return retVal;
//}
void * HXEXPORT ENTRYPOINT(RAGetFlavorProperty)(RACODEC codecRef, UINT16 flvIndex, UINT16 Property, UINT16 * pSize)
{
void* pRet = NULL;
if (codecRef)
{
return ((CSiproCodec*)codecRef)->mGetFlavorProperty(flvIndex, Property, pSize);
}
return pRet;
}
HX_RESULT HXEXPORT ENTRYPOINT(RASetFlavor) (RACODEC codecRef, UINT16 flvIndex)
{
if (codecRef)
return ((CSiproCodec*)codecRef)->mSetFlavor(flvIndex);
else
return HXR_INVALID_PARAMETER;
}
void HXEXPORT ENTRYPOINT(RASetPwd) (RACODEC codecRef, const char *pPwd)
{
if (codecRef)
((CSiproCodec*)codecRef)->mSetPassword(pPwd);
}
#ifdef _DECODER
HX_RESULT HXEXPORT ENTRYPOINT(RAInitDecoder) (RACODEC codecRef, void* pParam)
{
return ((CSiproCodec*)codecRef)->mInitDecoder();
}
HX_RESULT HXEXPORT ENTRYPOINT(RADecode) (RACODEC codecRef, Byte* in, UINT32 inLength, Byte* out, UINT32 *pOutLength, UINT32 UserData)
{
return ((CSiproCodec*)codecRef)->mDecode(in, inLength, out, pOutLength, UserData);
}
HX_RESULT HXEXPORT ENTRYPOINT(RAFlush) (RACODEC codecRef, Byte* outBuf, UINT32* pOutLength)
{
// Re-initialize codec instead of skipping interpolation
// because Alan is afraid of the filter going unstable.
((CSiproCodec*)codecRef)->mInitDecoder();
if (pOutLength)
*pOutLength = 0;
return HXR_OK;
}
void HXEXPORT ENTRYPOINT(RAFreeDecoder) (RACODEC codecRef)
{
((CSiproCodec*)codecRef)->mFreeDecoder();
}
#endif // _DECODER
#ifdef _ENCODER
HX_RESULT HXEXPORT ENTRYPOINT(RAInitEncoder) (RACODEC codecRef, void* pParams)
{
if( NULL == pParams )
{
return HXR_INVALID_PARAMETER;
}
RAENCODER_INIT_PARAMS* pInitParams = (RAENCODER_INIT_PARAMS*)pParams;
return ((CSiproCodec*)codecRef)->mInitEncoder(
pInitParams->sampleRate,
pInitParams->bitsPerSample,
&(pInitParams->numSamplesIn),
&(pInitParams->numBytesOut) );
}
void HXEXPORT ENTRYPOINT(RAEncode) (RACODEC codecRef, UINT16* inBuf, Byte* outBuf)
{
((CSiproCodec*)codecRef)->mEncode((short*)inBuf, outBuf);
}
void HXEXPORT ENTRYPOINT(RAFreeEncoder) (RACODEC codecRef)
{
((CSiproCodec*)codecRef)->mFreeEncoder();
}
#if !defined(_STATICALLY_LINKED)
int RAHaveSetPassword(void)
{
return 1 ; // yes we do
}
#endif
#endif // _ENCODER
HX_RESULT HXEXPORT ENTRYPOINT(RAGetGUID) (UCHAR* pGUID)
{
return CSiproCodec::mGetGUID(pGUID);
}
HX_RESULT HXEXPORT ENTRYPOINT(RAGetDecoderBackendGUID) (RACODEC codecRef, UCHAR* pGUID)
{
// look mom, no backend!
return HXR_NOTIMPL ;
}
HX_RESULT HXEXPORT ENTRYPOINT(RAGetBackend) (RACODEC codecRef, void*** pFuncList)
{
return HXR_NOTIMPL ;
}
HX_RESULT HXEXPORT ENTRYPOINT(RASetComMode) (RACODEC codecRef)
{
if (codecRef)
{
return ((CSiproCodec*)codecRef)->mSetComMode();
}
return HXR_FAIL;
}
#if defined(_ENCODER) && !defined(_STATICALLY_LINKED)
/*
* RACreateEncoderInstance lives in a static library. If no
* module references RACreateEncoderInstance, it won't get
* linked in on Unix.
* To make sure that RACreateEncoderInstance gets linked against
* we make it an unresolved symbol in this module.
*/
static FPRACreateEncoderInstance temp = RACreateEncoderInstance ;
#endif /* !defined(_STATICALLY_LINKED) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -