rm_recog.cpp
上传用户:dangjiwu
上传日期:2013-07-19
资源大小:42019k
文件大小:5k
- /*============================================================================*
- *
- * (c) 1995-2002 RealNetworks, Inc. Patents pending. All rights reserved.
- *
- *============================================================================*/
- /*
- * Description:
- *
- */
- #include <e32svr.h>
- #include <apmrec.h>
- #include <apmstd.h>
- #include "hxassert.h"
- //#include "debug.h"
- #include "hxsym_mimetypes.h"
- #include "recog_util.h"
- #include "rm_recog.h"
- //
- // some constants
- //
- // UID
- const TUid KUidMimeRealMediaRecognizer={0x10009D0D};
- // min and max buffer length required to recognize file datatype
- const TInt KMinBufferLength=4;
- const TInt KMaxBufferLength=256;
- //
- // list of mimetypes we recognize
- //
- const TUint8* const k_dataTypes[] =
- {
- // basic datatypes always recognized
- HXSYM_MIMETYPE_RM,
- HXSYM_MIMETYPE_RAM,
- HXSYM_MIMETYPE_SDP,
- HXSYM_MIMETYPE_AMR,
- // mp3
- #if defined(HELIX_FEATURE_AUDIO_MPA_LAYER3)
- HXSYM_MIMETYPE_MP3,
- #endif
- // 3gpp
- #if defined(HELIX_FEATURE_3GPP)
- HXSYM_MIMETYPE_3GPAUDIO,
- HXSYM_MIMETYPE_3GPVIDEO,
- HXSYM_MIMETYPE_MP4AUDIO,
- HXSYM_MIMETYPE_MP4VIDEO,
- #endif
- // smil
- #if defined(HELIX_FEATURE_SMIL2)
- HXSYM_MIMETYPE_SMIL
- #endif
- };
- #define ARRAY_COUNT(x) (sizeof(x) / sizeof(x[0]))
- const TUint MIMETYPE_COUNT = ARRAY_COUNT(k_dataTypes);
- CApaRealMediaRecognizer::CApaRealMediaRecognizer()
- : CApaDataRecognizerType(KUidMimeRealMediaRecognizer, CApaDataRecognizerType::EHigh)
- {
- iCountDataTypes = MIMETYPE_COUNT;
- }
- TUint CApaRealMediaRecognizer::PreferredBufSize()
- {
- return KMaxBufferLength;
- }
- TDataType CApaRealMediaRecognizer::SupportedDataTypeL(TInt aIndex) const
- {
- HX_ASSERT(aIndex < MIMETYPE_COUNT);
- return TDataType(_L8(k_dataTypes[aIndex]));
- }
- void CApaRealMediaRecognizer::DoRecognizeL(const TDesC& aName,
- const TDesC8& aBuffer)
- {
- iConfidence = ENotRecognized;
- _LIT(KRtspScheme, "rtsp");
- // first check name for scheme ('rtsp://')
- if(RecogUtil::FindScheme(KRtspScheme, aName))
- {
- iDataType = TDataType(_L8(HXSYM_MIMETYPE_RM));
- iConfidence = ECertain;
- }
- else
- {
- // not a scheme; look at buffer...
- TInt length=aBuffer.Length();
- if (length>=KMinBufferLength)
- {
- // HXSYM_MIMETYPE_RM
- if ((iConfidence = RecogUtil::IsRMFile(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_RM));
- }
- // HXSYM_MIMETYPE_SMIL
- else if ((iConfidence = RecogUtil::IsSMILFile(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_SMIL));
- }
- // HXSYM_MIMETYPE_SDP
- else if ((iConfidence = RecogUtil::IsSDPFile(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_SDP));
- }
- // HXSYM_MIMETYPE_RAM
- else if ((iConfidence = RecogUtil::IsRAMFile(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_RAM));
- }
- // HXSYM_MIMETYPE_AMR
- else if ((iConfidence = RecogUtil::IsAMRFile(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_AMR));
- }
- #if defined(HELIX_FEATURE_3GPP)
- // HXSYM_MIMETYPE_3GPAUDIO/VIDEO
- else if (RecogUtil::Is3GPPFile(aName, aBuffer) != ENotRecognized)
- {
- if ((iConfidence = RecogUtil::IsMPEG4Audio(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_3GPAUDIO));
- }
- else
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_3GPVIDEO));
- iConfidence = EProbable;
- }
- }
- // HXSYM_MIMETYPE_MP4AUDIO/VIDEO
- else if (RecogUtil::IsMPEG4File(aName, aBuffer) != ENotRecognized)
- {
- if ((iConfidence = RecogUtil::IsMPEG4Audio(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_MP4AUDIO));
- }
- else
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_MP4VIDEO));
- iConfidence = EProbable;
- }
- }
- //HELIX_FEATURE_3GPP
- #endif
- #if defined(HELIX_FEATURE_AUDIO_MPA_LAYER3)
- // HXSYM_MIMETYPE_MP3
- else if ((iConfidence = RecogUtil::IsMP3File(aName, aBuffer)) != ENotRecognized)
- {
- iDataType=TDataType(_L8(HXSYM_MIMETYPE_MP3));
- }
- #endif
- #if !defined(HELIX_FEATURE_SMIL2)
- // HXSYM_MIMETYPE_SMIL
- if (iDataType==TDataType(_L8(HXSYM_MIMETYPE_SMIL)))
- {
- iConfidence = ENotRecognized;
- }
- #endif
- }
- }
- }
- EXPORT_C CApaDataRecognizerType* CreateRecognizer()
- // The gate function - ordinal 1
- //
- {
- CApaDataRecognizerType* thing=new CApaRealMediaRecognizer();
- return thing;
- }
- GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
- //
- // DLL entry point
- //
- {
- return KErrNone;
- }