decwrapper.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:7k
- /* ***** 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 ***** */
- /* define which is the Codec class we're calling into */
- #define CodecClass CRAGecko2
- /* The include file for the codec class */
- #include "ra8lbr.h"
- /* generic RN include files */
- #include "hxtypes.h"
- #include "hxresult.h"
- /* This defines the interface we're exporting */
- #include "racodec.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
- /*
- * FUNCTIONS
- */
- #if !defined(_STATICALLY_LINKED)
- #if (defined(WIN32) || defined (_WIN32))
- #if !defined(_WINCE)
- BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
- #else
- BOOL WINAPI DllMain (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
- #endif
- {
- return TRUE;
- }
- #endif
- #ifdef _MACINTOSH
- #ifndef _MAC_MACHO
- OSErr InitEntryPoint (CFragInitBlockPtr pInitBlock)
- {
- OSErr result = noErr;
-
- result = __initialize (pInitBlock);
-
- return result;
- }
- void TermEntryPoint (void)
- {
- __terminate();
- }
- #endif
- #endif
- #endif /* #if !defined(_STATICALLY_LINKED) */
- /*
- * NEW COOKIE API
- */
- // preview compatibility only - obsolete
- HX_RESULT HXEXPORT ENTRYPOINT(RAOpenCodec) (RACODEC* pCodecRef)
- {
- if (pCodecRef)
- {
- *pCodecRef = (RACODEC) new CodecClass();
-
- if (*pCodecRef)
- return HXR_OK;
- else
- return HXR_OUTOFMEMORY;
- }
- else
- return HXR_INVALID_PARAMETER;
- }
- 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
-
- if (pCodecRef)
- {
- *pCodecRef = (RACODEC) new CodecClass();
-
- if (*pCodecRef)
- return HXR_OK;
- else
- return HXR_OUTOFMEMORY;
- }
- else
- return HXR_INVALID_PARAMETER;
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RACloseCodec) (RACODEC codecRef)
- {
- if (codecRef)
- {
- delete (CodecClass*) codecRef;
- return HXR_OK;
- }
- else
- {
- return HXR_INVALID_PARAMETER;
- }
- }
- // Older SDK uses *this* function to determine the number of codec flavors.
- // However, if this function returns more than 15 (the original number of
- // Gecko flavors), that SDK will fail...
- // For really new codecs, this should be set to 0. See comment below.
- UINT16 HXEXPORT ENTRYPOINT(RAGetNumberOfFlavors) (RACODEC codecRef)
- {
- UINT16 usRetVal = 0;
-
- if (codecRef)
- {
- usRetVal = ((CodecClass*)codecRef)->GetNumberOfFlavors();
- }
- return usRetVal;
- }
- // This is the *new* function that will return the true number of supported
- // Gecko 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
- UINT16 HXEXPORT ENTRYPOINT(RAGetNumberOfFlavors2) (RACODEC codecRef)
- {
- UINT16 usRetVal = 0;
-
- if (codecRef)
- {
- usRetVal = ((CodecClass*)codecRef)->GetNumberOfFlavors2();
- }
- return usRetVal;
- }
- void* HXEXPORT ENTRYPOINT(RAGetFlavorProperty) (RACODEC codecRef,UINT16 flvIndex, UINT16 propIndex, UINT16* pSize)
- {
- return codecRef ?
- ((CodecClass*)codecRef)->GetProperty (flvIndex, propIndex, pSize) :
- NULL ;
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RASetFlavor) (RACODEC codecRef, UINT16 flvIndex)
- {
- /* XXX wschildbach:
- if new backwards-compatible content hits an old decoder that
- does not know this flavour (but is entirely happy decoding it),
- returning an error code here will break decoding on RP8 and
- before with a "general error".
- The player really should not call SetFlavour() at all, but
- until this is fixed, we must not return an error code here. */
- if (codecRef)
- ((CodecClass*)codecRef)->SetFlavor (flvIndex) ;
- return HXR_OK ;
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RAInitDecoder) (RACODEC codecRef, void* pParam)
- {
- return codecRef ?
- ((CodecClass*)codecRef)->InitDecoder ((RADECODER_INIT_PARAMS*)pParam) :
- HXR_INVALID_PARAMETER ;
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RADecode) (RACODEC codecRef, Byte* in, UINT32 inLength, Byte* out, UINT32* pOutLength, UINT32 userData)
- {
- return codecRef ?
- ((CodecClass*)codecRef)->Decode (in, inLength, out, pOutLength, userData) :
- HXR_INVALID_PARAMETER ;
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RAFlush) (RACODEC codecRef, Byte* outBuf, UINT32* outLength)
- {
- return codecRef ?
- ((CodecClass*)codecRef)->SetFlush(outBuf,outLength) :
- HXR_INVALID_PARAMETER ;
- }
- void HXEXPORT ENTRYPOINT(RAFreeDecoder) (RACODEC codecRef)
- {
- if (codecRef)
- {
- ((CodecClass*)codecRef)->FreeDecoder();
- }
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RAGetBackend) (RACODEC codecRef, void*** pFuncList)
- {
- return HXR_NOTIMPL;
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RAGetGUID) (UCHAR* pGUID)
- {
- return CodecClass::GetGUID(pGUID);
- }
- HX_RESULT HXEXPORT ENTRYPOINT(RASetComMode) (RACODEC codecRef)
- {
- if (codecRef)
- {
- return ((CodecClass*)codecRef)->SetComMode();
- }
- return HXR_FAIL;
- }