sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "codecapiresolverconsts.h" sl@0: sl@0: /** sl@0: Creates a new CCodecApiVideoOpaqueData object. sl@0: @param aOpaqueData sl@0: A reference to the opaque data value. sl@0: @return A pointer to the newly constructed match data object. sl@0: */ sl@0: EXPORT_C CCodecApiVideoOpaqueData* CCodecApiVideoOpaqueData::NewL(const TDesC8& aOpaqueData) sl@0: { sl@0: CCodecApiVideoOpaqueData* result = CCodecApiVideoOpaqueData::NewLC(aOpaqueData); sl@0: CleanupStack::Pop(result); sl@0: return result; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Creates a new CCodecApiOpaqueData object and leaves a pointer to it on the cleanup stack. sl@0: @param aOpaqueData sl@0: A reference to the opaque data value. sl@0: @return A pointer to the newly constructed match data object. sl@0: */ sl@0: EXPORT_C CCodecApiVideoOpaqueData* CCodecApiVideoOpaqueData::NewLC(const TDesC8& aOpaqueData) sl@0: { sl@0: CCodecApiVideoOpaqueData* result = new (ELeave) CCodecApiVideoOpaqueData(aOpaqueData); sl@0: CleanupStack::PushL(result); sl@0: result->ConstructL(); sl@0: return result; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Constructor sl@0: @param aOpaqueData sl@0: A reference to the opaque data value. sl@0: */ sl@0: CCodecApiVideoOpaqueData::CCodecApiVideoOpaqueData(const TDesC8& aOpaqueData) : sl@0: CCodecApiOpaqueData(aOpaqueData), sl@0: iManufacturer(NULL) sl@0: { sl@0: } sl@0: sl@0: /** sl@0: Sets up the data inside the class by calling ParseTaggedDataL(). sl@0: */ sl@0: void CCodecApiVideoOpaqueData::ConstructL() sl@0: { sl@0: ParseTaggedDataL(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Returns the value of the maximun picture size data member. sl@0: @return The maximum picture size. sl@0: */ sl@0: EXPORT_C const TSize& CCodecApiVideoOpaqueData::MaxPictureSize() const sl@0: { sl@0: return iMaxPictureSize; sl@0: } sl@0: sl@0: /** sl@0: Returns the value of the manufacturer name data member. sl@0: @return Constant reference to the manufactured name. sl@0: */ sl@0: EXPORT_C const TDesC8& CCodecApiVideoOpaqueData::Manufacturer() const sl@0: { sl@0: if (iManufacturer) sl@0: { sl@0: return *iManufacturer; sl@0: } sl@0: return KNullDesC8; sl@0: } sl@0: sl@0: /** sl@0: Returns the array with values for the picture rate and size. sl@0: @return Array containing the picture rate and size values. sl@0: */ sl@0: EXPORT_C const RArray& CCodecApiVideoOpaqueData::MaxPictureRates() const sl@0: { sl@0: return iMaxPictureRates; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the values in the TPictureRateAndSize structure. sl@0: @param aData sl@0: A constant reference to the data containting values for TPictureRateAndSize. sl@0: */ sl@0: void CCodecApiVideoOpaqueData::SetPictureRateAndSizeL(const TDesC8& aData) sl@0: { sl@0: TPictureRateAndSize pictureRateAndSize; sl@0: TInt position = 0; sl@0: TUint32 value = 0; sl@0: TPtrC8 restOfData = aData; sl@0: position = aData.MatchF(KComma); sl@0: if (position == KErrNotFound) sl@0: { sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: TLex8 lex(restOfData.Left(position)); sl@0: User::LeaveIfError(lex.Val(value, EDecimal)); sl@0: pictureRateAndSize.iPictureRate = value; sl@0: position++; sl@0: restOfData.Set(aData.Mid(position)); sl@0: position = restOfData.MatchF(KComma); sl@0: if (position == KErrNotFound) sl@0: { sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: lex = restOfData.Left(position); sl@0: User::LeaveIfError(lex.Val(value, EDecimal)); sl@0: pictureRateAndSize.iPictureSize.iWidth = value; sl@0: position++; sl@0: restOfData.Set(restOfData.Mid(position)); sl@0: lex = restOfData; sl@0: User::LeaveIfError(lex.Val(value, EDecimal)); sl@0: pictureRateAndSize.iPictureSize.iHeight = value; sl@0: sl@0: iMaxPictureRates.AppendL(pictureRateAndSize); sl@0: } sl@0: sl@0: /** sl@0: Sets the values in the TPictureRateAndSize structure. sl@0: @param aData sl@0: A constant reference to the data containting values for TPictureRateAndSize. sl@0: */ sl@0: void CCodecApiVideoOpaqueData::SetMaxPictureSizeL(const TDesC8& aData) sl@0: { sl@0: TPictureRateAndSize pictureRateAndSize; sl@0: TInt position = 0; sl@0: TPtrC8 restOfData = aData.Mid(position); sl@0: position = restOfData.MatchF(KComma); sl@0: if (position == KErrNotFound) sl@0: { sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: iMaxPictureSize.iWidth = ConvertTextToTUintL(restOfData.Left(position)); sl@0: position++; sl@0: restOfData.Set(aData.Mid(position)); sl@0: iMaxPictureSize.iHeight = ConvertTextToTUintL(restOfData); sl@0: } sl@0: sl@0: /** sl@0: Sets member data to the value of the given opaque data, based upon the tag value provided. sl@0: @param aTag sl@0: A constant reference to a tag from the opaque data. Can be \, \, \. sl@0: @param aData sl@0: The data associated with a tag. sl@0: */ sl@0: void CCodecApiVideoOpaqueData::ProcessTaggedDataL(const TDesC8& aTag, const TDesC8& aData) sl@0: { sl@0: if (aTag == KManufacturer) sl@0: { sl@0: if(!iManufacturer) sl@0: { sl@0: iManufacturer = aData.AllocL(); sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: User::Leave(KErrCorrupt); sl@0: } sl@0: } sl@0: if (aTag == KMaxPictureSize) sl@0: { sl@0: SetMaxPictureSizeL(aData); sl@0: return; sl@0: } sl@0: if (aTag == KListOfPictureRateAndSize) sl@0: { sl@0: return SetPictureRateAndSizeL(aData); sl@0: } sl@0: CCodecApiOpaqueData::ProcessTaggedDataL(aTag, aData); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: CCodecApiVideoOpaqueData::~CCodecApiVideoOpaqueData() sl@0: { sl@0: delete iManufacturer; sl@0: iMaxPictureRates.Reset(); sl@0: iMaxPictureRates.Close(); sl@0: } sl@0: