os/mm/mmdevicefw/mdf/src/codecapi/codecapivideoresolverutils.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <mdf/codecapivideoresolverutils.h>
    17 #include <mmf/devvideo/devvideoplay.h>
    18 #include "codecapiresolverconsts.h"
    19 
    20 /**
    21  Creates a new CCodecApiVideoOpaqueData object.
    22  @param  aOpaqueData
    23  		 A reference to the opaque data value.
    24  @return A pointer to the newly constructed match data object.
    25  */
    26 EXPORT_C CCodecApiVideoOpaqueData* CCodecApiVideoOpaqueData::NewL(const TDesC8& aOpaqueData)
    27 	{
    28 	CCodecApiVideoOpaqueData* result = CCodecApiVideoOpaqueData::NewLC(aOpaqueData);
    29 	CleanupStack::Pop(result);
    30 	return result;
    31 	}
    32 
    33 
    34 /**
    35  Creates a new CCodecApiOpaqueData object and leaves a pointer to it on the cleanup stack.
    36  @param  aOpaqueData
    37  		 A reference to the opaque data value.
    38  @return A pointer to the newly constructed match data object.
    39  */
    40 EXPORT_C CCodecApiVideoOpaqueData* CCodecApiVideoOpaqueData::NewLC(const TDesC8& aOpaqueData)
    41 	{
    42 	CCodecApiVideoOpaqueData* result = new (ELeave) CCodecApiVideoOpaqueData(aOpaqueData);
    43 	CleanupStack::PushL(result);
    44 	result->ConstructL();
    45 	return result;	
    46 	}
    47 
    48 
    49 /**
    50  Constructor
    51  @param  aOpaqueData
    52  		 A reference to the opaque data value.
    53  */
    54 CCodecApiVideoOpaqueData::CCodecApiVideoOpaqueData(const TDesC8& aOpaqueData) :
    55 	CCodecApiOpaqueData(aOpaqueData),
    56 	iManufacturer(NULL)
    57 	{
    58 	}
    59 
    60 /**
    61  Sets up the data inside the class by calling <code>ParseTaggedDataL()</code>. 
    62  */
    63 void CCodecApiVideoOpaqueData::ConstructL()
    64 	{
    65 	ParseTaggedDataL();
    66 	}
    67 
    68 
    69 /**
    70  Returns the value of the maximun picture size data member.
    71  @return The maximum picture size.
    72  */
    73 EXPORT_C const TSize& CCodecApiVideoOpaqueData::MaxPictureSize() const
    74 	{	
    75 	return iMaxPictureSize;
    76 	}
    77 
    78 /**
    79  Returns the value of the manufacturer name data member.
    80  @return Constant reference to the manufactured name.
    81  */	
    82 EXPORT_C const TDesC8& CCodecApiVideoOpaqueData::Manufacturer() const
    83 	{
    84 	if (iManufacturer)
    85 		{
    86 		return *iManufacturer;
    87 		}
    88 	return KNullDesC8;
    89 	}
    90 
    91 /**
    92  Returns the array with values for the picture rate and size.
    93  @return Array containing the picture rate and size values.
    94  */	
    95 EXPORT_C const RArray<TPictureRateAndSize>& CCodecApiVideoOpaqueData::MaxPictureRates() const
    96 	{
    97 	return iMaxPictureRates;
    98 	}
    99 
   100 
   101 /**
   102  Sets the values in the TPictureRateAndSize structure.
   103  @param aData
   104 		A constant reference to the data containting values for TPictureRateAndSize.
   105  */	
   106 void CCodecApiVideoOpaqueData::SetPictureRateAndSizeL(const TDesC8& aData)
   107 	{
   108 	TPictureRateAndSize pictureRateAndSize;
   109 	TInt position = 0;
   110 	TUint32 value = 0;
   111 	TPtrC8 restOfData = aData;
   112 	position = aData.MatchF(KComma);
   113 	if (position == KErrNotFound)
   114 		{
   115 		User::Leave(KErrCorrupt);
   116 		}		
   117 	TLex8 lex(restOfData.Left(position));
   118 	User::LeaveIfError(lex.Val(value, EDecimal));	
   119 	pictureRateAndSize.iPictureRate = value;
   120 	position++;
   121 	restOfData.Set(aData.Mid(position));
   122 	position = restOfData.MatchF(KComma);
   123 	if (position == KErrNotFound)
   124 		{
   125 		User::Leave(KErrCorrupt);
   126 		}		
   127 	lex = restOfData.Left(position);
   128 	User::LeaveIfError(lex.Val(value, EDecimal));	
   129 	pictureRateAndSize.iPictureSize.iWidth = value;
   130 	position++;
   131 	restOfData.Set(restOfData.Mid(position));
   132 	lex = restOfData;
   133 	User::LeaveIfError(lex.Val(value, EDecimal));
   134 	pictureRateAndSize.iPictureSize.iHeight = value;		
   135 	
   136 	iMaxPictureRates.AppendL(pictureRateAndSize);
   137 	}
   138 
   139 /**
   140  Sets the values in the TPictureRateAndSize structure.
   141  @param aData
   142 		A constant reference to the data containting values for TPictureRateAndSize.
   143  */	
   144 void CCodecApiVideoOpaqueData::SetMaxPictureSizeL(const TDesC8& aData)
   145 	{
   146 	TPictureRateAndSize pictureRateAndSize;
   147 	TInt position = 0;
   148 	TPtrC8 restOfData = aData.Mid(position);
   149 	position = restOfData.MatchF(KComma);
   150 	if (position == KErrNotFound)
   151 		{
   152 		User::Leave(KErrCorrupt);
   153 		}		
   154 	iMaxPictureSize.iWidth = ConvertTextToTUintL(restOfData.Left(position));
   155 	position++;
   156 	restOfData.Set(aData.Mid(position));
   157 	iMaxPictureSize.iHeight = ConvertTextToTUintL(restOfData);
   158 	}
   159 
   160 /**
   161  Sets member data to the value of the given opaque data, based upon the tag value provided. 
   162  @param  aTag
   163  		 A constant reference to a tag from the opaque data. Can be \<m\>, \<l\>, \<p\>.
   164  @param  aData
   165  		 The data associated with a tag.
   166  */
   167 void CCodecApiVideoOpaqueData::ProcessTaggedDataL(const TDesC8& aTag, const TDesC8& aData)
   168 	{
   169 	if (aTag == KManufacturer)
   170 		{
   171 		if(!iManufacturer)
   172 			{
   173 			iManufacturer = aData.AllocL();
   174 			return;		
   175 			}
   176 		else
   177 			{
   178 			User::Leave(KErrCorrupt);
   179 			}		
   180 		}
   181 	if (aTag == KMaxPictureSize)
   182 		{
   183 		SetMaxPictureSizeL(aData);
   184 		return;
   185 		}
   186 	if (aTag == KListOfPictureRateAndSize)
   187 		{
   188 		return SetPictureRateAndSizeL(aData);
   189 		}
   190 	CCodecApiOpaqueData::ProcessTaggedDataL(aTag, aData);
   191 	}
   192 
   193 
   194 /**
   195  Destructor
   196  */
   197 CCodecApiVideoOpaqueData::~CCodecApiVideoOpaqueData()
   198 	{
   199 	delete iManufacturer;
   200 	iMaxPictureRates.Reset();
   201 	iMaxPictureRates.Close();
   202 	}
   203