author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// |
sl@0 | 15 |
|
sl@0 | 16 |
#include <s32mem.h> |
sl@0 | 17 |
#include <mdf/codecapiresolverdata.h> |
sl@0 | 18 |
// The biggest descriptor that will be built when internalizing the object |
sl@0 | 19 |
const TInt KMaxDescriptorLength = 128; |
sl@0 | 20 |
|
sl@0 | 21 |
/** |
sl@0 | 22 |
Default constructor. |
sl@0 | 23 |
*/ |
sl@0 | 24 |
CCodecApiResolverData::CCodecApiResolverData() |
sl@0 | 25 |
{ |
sl@0 | 26 |
} |
sl@0 | 27 |
|
sl@0 | 28 |
|
sl@0 | 29 |
/** |
sl@0 | 30 |
Destructor. |
sl@0 | 31 |
*/ |
sl@0 | 32 |
CCodecApiResolverData::~CCodecApiResolverData() |
sl@0 | 33 |
{ |
sl@0 | 34 |
delete iInputDataFormat; |
sl@0 | 35 |
delete iOutputDataFormat; |
sl@0 | 36 |
} |
sl@0 | 37 |
|
sl@0 | 38 |
|
sl@0 | 39 |
/** |
sl@0 | 40 |
Creates a new CodedApiResolverStandard object. |
sl@0 | 41 |
@return A pointer to the newly constructed object. |
sl@0 | 42 |
*/ |
sl@0 | 43 |
EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewL() |
sl@0 | 44 |
{ |
sl@0 | 45 |
CCodecApiResolverData* self = new(ELeave) CCodecApiResolverData; |
sl@0 | 46 |
return self; |
sl@0 | 47 |
} |
sl@0 | 48 |
|
sl@0 | 49 |
|
sl@0 | 50 |
/** |
sl@0 | 51 |
Creates a new CodedApiResolverStandard object. |
sl@0 | 52 |
@param aPackage |
sl@0 | 53 |
A reference to a descriptor created using <code>PackL()</code> |
sl@0 | 54 |
used to initialize the object. |
sl@0 | 55 |
@return A pointer to the newly constructed object. |
sl@0 | 56 |
*/ |
sl@0 | 57 |
EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewL(const TDesC8& aPackage) |
sl@0 | 58 |
{ |
sl@0 | 59 |
CCodecApiResolverData* self = CCodecApiResolverData::NewLC(aPackage); |
sl@0 | 60 |
CleanupStack::Pop(self); |
sl@0 | 61 |
return self; |
sl@0 | 62 |
} |
sl@0 | 63 |
|
sl@0 | 64 |
|
sl@0 | 65 |
/** |
sl@0 | 66 |
Creates a new CodedApiResolverStandard object and leaves a pointer to it on the cleanup stack. |
sl@0 | 67 |
@return A pointer to the newly constructed object. |
sl@0 | 68 |
*/ |
sl@0 | 69 |
EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewLC() |
sl@0 | 70 |
{ |
sl@0 | 71 |
CCodecApiResolverData* self = CCodecApiResolverData::NewL(); |
sl@0 | 72 |
CleanupStack::PushL(self); |
sl@0 | 73 |
return self; |
sl@0 | 74 |
} |
sl@0 | 75 |
|
sl@0 | 76 |
|
sl@0 | 77 |
/** |
sl@0 | 78 |
Creates a new CodedApiResolverStandard object and leaves a pointer to it on the cleanup stack. |
sl@0 | 79 |
@param aPackage |
sl@0 | 80 |
A reference to a descriptor created using <code>PackL()</code> |
sl@0 | 81 |
used to initialize the object. |
sl@0 | 82 |
@return A pointer to the newly constructed match data object. |
sl@0 | 83 |
*/ |
sl@0 | 84 |
EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewLC(const TDesC8& aPackage) |
sl@0 | 85 |
{ |
sl@0 | 86 |
CCodecApiResolverData* self = new(ELeave) CCodecApiResolverData; |
sl@0 | 87 |
CleanupStack::PushL(self); |
sl@0 | 88 |
self->ConstructL(aPackage); |
sl@0 | 89 |
return self; |
sl@0 | 90 |
} |
sl@0 | 91 |
|
sl@0 | 92 |
|
sl@0 | 93 |
/** |
sl@0 | 94 |
Sets up the data inside the class by calling <code>UnPackL()</code>. |
sl@0 | 95 |
@param aPackage |
sl@0 | 96 |
A reference to the data that will be contained by this class. |
sl@0 | 97 |
*/ |
sl@0 | 98 |
void CCodecApiResolverData::ConstructL(const TDesC8& aPackage) |
sl@0 | 99 |
{ |
sl@0 | 100 |
UnPackL(aPackage); |
sl@0 | 101 |
} |
sl@0 | 102 |
|
sl@0 | 103 |
|
sl@0 | 104 |
/** |
sl@0 | 105 |
Externalizes the object to a stream. |
sl@0 | 106 |
All the member variables will be written to the stream. |
sl@0 | 107 |
@param aStream |
sl@0 | 108 |
A reference to the stream to which the member variables will |
sl@0 | 109 |
be written. |
sl@0 | 110 |
*/ |
sl@0 | 111 |
void CCodecApiResolverData::ExternalizeL(RWriteStream& aStream) const |
sl@0 | 112 |
{ |
sl@0 | 113 |
aStream.WriteInt32L(iMatchType); |
sl@0 | 114 |
aStream.WriteInt32L(iImplementationType.iUid); |
sl@0 | 115 |
|
sl@0 | 116 |
aStream << InputDataFormat(); |
sl@0 | 117 |
aStream << OutputDataFormat(); |
sl@0 | 118 |
} |
sl@0 | 119 |
|
sl@0 | 120 |
|
sl@0 | 121 |
/** |
sl@0 | 122 |
Internalizes the object from a stream. |
sl@0 | 123 |
All the member variables will be read from the streamed. |
sl@0 | 124 |
@param aStream |
sl@0 | 125 |
A reference to the stream from which data will be read to |
sl@0 | 126 |
setup the member variables. |
sl@0 | 127 |
*/ |
sl@0 | 128 |
void CCodecApiResolverData::InternalizeL(RReadStream& aStream) |
sl@0 | 129 |
{ |
sl@0 | 130 |
iMatchType = static_cast<TCodecApiResolverMatchType>(aStream.ReadInt32L()); |
sl@0 | 131 |
iImplementationType.iUid = aStream.ReadInt32L(); |
sl@0 | 132 |
|
sl@0 | 133 |
delete iInputDataFormat; |
sl@0 | 134 |
iInputDataFormat = NULL; |
sl@0 | 135 |
iInputDataFormat = HBufC8::NewL(aStream,KMaxDescriptorLength); //KErrOverflow |
sl@0 | 136 |
|
sl@0 | 137 |
delete iOutputDataFormat; |
sl@0 | 138 |
iOutputDataFormat = NULL; |
sl@0 | 139 |
iOutputDataFormat = HBufC8::NewL(aStream,KMaxDescriptorLength); //KErrOverflow |
sl@0 | 140 |
} |
sl@0 | 141 |
|
sl@0 | 142 |
|
sl@0 | 143 |
/** |
sl@0 | 144 |
Sets the match type to match against. |
sl@0 | 145 |
@param aMatchType |
sl@0 | 146 |
The type of match requested. |
sl@0 | 147 |
*/ |
sl@0 | 148 |
EXPORT_C void CCodecApiResolverData::SetMatchType(const TCodecApiResolverMatchType& aMatchType) |
sl@0 | 149 |
{ |
sl@0 | 150 |
iMatchType = aMatchType; |
sl@0 | 151 |
} |
sl@0 | 152 |
|
sl@0 | 153 |
|
sl@0 | 154 |
/** |
sl@0 | 155 |
Sets the implementation type to match against. |
sl@0 | 156 |
@param aImplementationType |
sl@0 | 157 |
The implementation uid of a specific codec to match against. |
sl@0 | 158 |
*/ |
sl@0 | 159 |
EXPORT_C void CCodecApiResolverData::SetImplementationType(const TUid& aImplementationType) |
sl@0 | 160 |
{ |
sl@0 | 161 |
iImplementationType = aImplementationType; |
sl@0 | 162 |
} |
sl@0 | 163 |
|
sl@0 | 164 |
|
sl@0 | 165 |
/** |
sl@0 | 166 |
Sets the input data type to match against. |
sl@0 | 167 |
@param aDataType |
sl@0 | 168 |
The input data type of a codec to match against. |
sl@0 | 169 |
*/ |
sl@0 | 170 |
EXPORT_C void CCodecApiResolverData::SetInputDataL(const TDesC8& aDataType) |
sl@0 | 171 |
{ |
sl@0 | 172 |
delete iInputDataFormat; |
sl@0 | 173 |
iInputDataFormat = NULL; |
sl@0 | 174 |
iInputDataFormat = aDataType.AllocL(); |
sl@0 | 175 |
} |
sl@0 | 176 |
|
sl@0 | 177 |
|
sl@0 | 178 |
/** |
sl@0 | 179 |
Sets the output data type to match against. |
sl@0 | 180 |
@param aDataType |
sl@0 | 181 |
The output data type of a codec to match against. |
sl@0 | 182 |
*/ |
sl@0 | 183 |
EXPORT_C void CCodecApiResolverData::SetOutputDataL(const TDesC8& aDataType) |
sl@0 | 184 |
{ |
sl@0 | 185 |
delete iOutputDataFormat; |
sl@0 | 186 |
iOutputDataFormat = NULL; |
sl@0 | 187 |
iOutputDataFormat = aDataType.AllocL(); |
sl@0 | 188 |
} |
sl@0 | 189 |
|
sl@0 | 190 |
|
sl@0 | 191 |
/** |
sl@0 | 192 |
Retrieves the match type to match against. |
sl@0 | 193 |
@return The type of match requested. |
sl@0 | 194 |
*/ |
sl@0 | 195 |
EXPORT_C TCodecApiResolverMatchType CCodecApiResolverData::MatchType() const |
sl@0 | 196 |
{ |
sl@0 | 197 |
return iMatchType; |
sl@0 | 198 |
} |
sl@0 | 199 |
|
sl@0 | 200 |
|
sl@0 | 201 |
/** |
sl@0 | 202 |
Retrieves the implementation type to match against. |
sl@0 | 203 |
@return The implementation of a specific codec to match against. |
sl@0 | 204 |
*/ |
sl@0 | 205 |
EXPORT_C TUid CCodecApiResolverData::ImplementationType() const |
sl@0 | 206 |
{ |
sl@0 | 207 |
return iImplementationType; |
sl@0 | 208 |
} |
sl@0 | 209 |
|
sl@0 | 210 |
|
sl@0 | 211 |
|
sl@0 | 212 |
/** |
sl@0 | 213 |
Retrieves the input data format string to match against. If no string is set |
sl@0 | 214 |
a null descriptor is returned. |
sl@0 | 215 |
@return The string to match against. |
sl@0 | 216 |
*/ |
sl@0 | 217 |
EXPORT_C const TPtrC8 CCodecApiResolverData::InputDataFormat() const |
sl@0 | 218 |
{ |
sl@0 | 219 |
TPtrC8 result; |
sl@0 | 220 |
if(iInputDataFormat) |
sl@0 | 221 |
{ |
sl@0 | 222 |
result.Set(*iInputDataFormat); |
sl@0 | 223 |
} |
sl@0 | 224 |
else |
sl@0 | 225 |
{ |
sl@0 | 226 |
result.Set(KNullDesC8); |
sl@0 | 227 |
} |
sl@0 | 228 |
return result; |
sl@0 | 229 |
} |
sl@0 | 230 |
|
sl@0 | 231 |
|
sl@0 | 232 |
/** |
sl@0 | 233 |
Retrieves the output data format string to match against. If no string is set |
sl@0 | 234 |
a null descriptor is returned. |
sl@0 | 235 |
@return The string to match against. |
sl@0 | 236 |
*/ |
sl@0 | 237 |
EXPORT_C const TPtrC8 CCodecApiResolverData::OutputDataFormat() const |
sl@0 | 238 |
{ |
sl@0 | 239 |
TPtrC8 result; |
sl@0 | 240 |
if(iOutputDataFormat) |
sl@0 | 241 |
{ |
sl@0 | 242 |
result.Set(*iOutputDataFormat); |
sl@0 | 243 |
} |
sl@0 | 244 |
else |
sl@0 | 245 |
{ |
sl@0 | 246 |
result.Set(KNullDesC8); |
sl@0 | 247 |
} |
sl@0 | 248 |
return result; |
sl@0 | 249 |
} |
sl@0 | 250 |
|
sl@0 | 251 |
|
sl@0 | 252 |
|
sl@0 | 253 |
|
sl@0 | 254 |
/** |
sl@0 | 255 |
Packages the object up into a descriptor. |
sl@0 | 256 |
@return A pointer to a desctriptor with the object packed in it. |
sl@0 | 257 |
*/ |
sl@0 | 258 |
EXPORT_C HBufC8* CCodecApiResolverData::NewPackLC() const |
sl@0 | 259 |
{ |
sl@0 | 260 |
//Calculate the size necessary size for the descriptor to pack the object |
sl@0 | 261 |
TInt size = 0; |
sl@0 | 262 |
size = sizeof(iMatchType) + sizeof(iImplementationType.iUid) + 2*sizeof(TInt32); |
sl@0 | 263 |
// the operator << write first the length of the string so we need to add it to the total size |
sl@0 | 264 |
if(iInputDataFormat) |
sl@0 | 265 |
{ |
sl@0 | 266 |
size += iInputDataFormat->Size(); |
sl@0 | 267 |
} |
sl@0 | 268 |
if(iOutputDataFormat) |
sl@0 | 269 |
{ |
sl@0 | 270 |
size += iOutputDataFormat->Size(); |
sl@0 | 271 |
} |
sl@0 | 272 |
|
sl@0 | 273 |
HBufC8* package = HBufC8::NewLC(size); |
sl@0 | 274 |
TPtr8 packageDes = package->Des(); |
sl@0 | 275 |
RDesWriteStream stream(packageDes); |
sl@0 | 276 |
CleanupClosePushL(stream); |
sl@0 | 277 |
ExternalizeL(stream); |
sl@0 | 278 |
CleanupStack::PopAndDestroy(&stream); |
sl@0 | 279 |
return package; |
sl@0 | 280 |
} |
sl@0 | 281 |
|
sl@0 | 282 |
|
sl@0 | 283 |
|
sl@0 | 284 |
/** |
sl@0 | 285 |
Unpacks a packed descriptor. |
sl@0 | 286 |
@param aPackage |
sl@0 | 287 |
A reference to a desctriptor created. |
sl@0 | 288 |
*/ |
sl@0 | 289 |
EXPORT_C void CCodecApiResolverData::UnPackL(const TDesC8& aPackage) |
sl@0 | 290 |
{ |
sl@0 | 291 |
RDesReadStream stream(aPackage); |
sl@0 | 292 |
CleanupClosePushL(stream); |
sl@0 | 293 |
InternalizeL(stream); |
sl@0 | 294 |
CleanupStack::PopAndDestroy(&stream); |
sl@0 | 295 |
} |