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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include <mdf/codecapiresolverdata.h>
18 // The biggest descriptor that will be built when internalizing the object
19 const TInt KMaxDescriptorLength = 128;
24 CCodecApiResolverData::CCodecApiResolverData()
32 CCodecApiResolverData::~CCodecApiResolverData()
34 delete iInputDataFormat;
35 delete iOutputDataFormat;
40 Creates a new CodedApiResolverStandard object.
41 @return A pointer to the newly constructed object.
43 EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewL()
45 CCodecApiResolverData* self = new(ELeave) CCodecApiResolverData;
51 Creates a new CodedApiResolverStandard object.
53 A reference to a descriptor created using <code>PackL()</code>
54 used to initialize the object.
55 @return A pointer to the newly constructed object.
57 EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewL(const TDesC8& aPackage)
59 CCodecApiResolverData* self = CCodecApiResolverData::NewLC(aPackage);
60 CleanupStack::Pop(self);
66 Creates a new CodedApiResolverStandard object and leaves a pointer to it on the cleanup stack.
67 @return A pointer to the newly constructed object.
69 EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewLC()
71 CCodecApiResolverData* self = CCodecApiResolverData::NewL();
72 CleanupStack::PushL(self);
78 Creates a new CodedApiResolverStandard object and leaves a pointer to it on the cleanup stack.
80 A reference to a descriptor created using <code>PackL()</code>
81 used to initialize the object.
82 @return A pointer to the newly constructed match data object.
84 EXPORT_C CCodecApiResolverData* CCodecApiResolverData::NewLC(const TDesC8& aPackage)
86 CCodecApiResolverData* self = new(ELeave) CCodecApiResolverData;
87 CleanupStack::PushL(self);
88 self->ConstructL(aPackage);
94 Sets up the data inside the class by calling <code>UnPackL()</code>.
96 A reference to the data that will be contained by this class.
98 void CCodecApiResolverData::ConstructL(const TDesC8& aPackage)
105 Externalizes the object to a stream.
106 All the member variables will be written to the stream.
108 A reference to the stream to which the member variables will
111 void CCodecApiResolverData::ExternalizeL(RWriteStream& aStream) const
113 aStream.WriteInt32L(iMatchType);
114 aStream.WriteInt32L(iImplementationType.iUid);
116 aStream << InputDataFormat();
117 aStream << OutputDataFormat();
122 Internalizes the object from a stream.
123 All the member variables will be read from the streamed.
125 A reference to the stream from which data will be read to
126 setup the member variables.
128 void CCodecApiResolverData::InternalizeL(RReadStream& aStream)
130 iMatchType = static_cast<TCodecApiResolverMatchType>(aStream.ReadInt32L());
131 iImplementationType.iUid = aStream.ReadInt32L();
133 delete iInputDataFormat;
134 iInputDataFormat = NULL;
135 iInputDataFormat = HBufC8::NewL(aStream,KMaxDescriptorLength); //KErrOverflow
137 delete iOutputDataFormat;
138 iOutputDataFormat = NULL;
139 iOutputDataFormat = HBufC8::NewL(aStream,KMaxDescriptorLength); //KErrOverflow
144 Sets the match type to match against.
146 The type of match requested.
148 EXPORT_C void CCodecApiResolverData::SetMatchType(const TCodecApiResolverMatchType& aMatchType)
150 iMatchType = aMatchType;
155 Sets the implementation type to match against.
156 @param aImplementationType
157 The implementation uid of a specific codec to match against.
159 EXPORT_C void CCodecApiResolverData::SetImplementationType(const TUid& aImplementationType)
161 iImplementationType = aImplementationType;
166 Sets the input data type to match against.
168 The input data type of a codec to match against.
170 EXPORT_C void CCodecApiResolverData::SetInputDataL(const TDesC8& aDataType)
172 delete iInputDataFormat;
173 iInputDataFormat = NULL;
174 iInputDataFormat = aDataType.AllocL();
179 Sets the output data type to match against.
181 The output data type of a codec to match against.
183 EXPORT_C void CCodecApiResolverData::SetOutputDataL(const TDesC8& aDataType)
185 delete iOutputDataFormat;
186 iOutputDataFormat = NULL;
187 iOutputDataFormat = aDataType.AllocL();
192 Retrieves the match type to match against.
193 @return The type of match requested.
195 EXPORT_C TCodecApiResolverMatchType CCodecApiResolverData::MatchType() const
202 Retrieves the implementation type to match against.
203 @return The implementation of a specific codec to match against.
205 EXPORT_C TUid CCodecApiResolverData::ImplementationType() const
207 return iImplementationType;
213 Retrieves the input data format string to match against. If no string is set
214 a null descriptor is returned.
215 @return The string to match against.
217 EXPORT_C const TPtrC8 CCodecApiResolverData::InputDataFormat() const
222 result.Set(*iInputDataFormat);
226 result.Set(KNullDesC8);
233 Retrieves the output data format string to match against. If no string is set
234 a null descriptor is returned.
235 @return The string to match against.
237 EXPORT_C const TPtrC8 CCodecApiResolverData::OutputDataFormat() const
240 if(iOutputDataFormat)
242 result.Set(*iOutputDataFormat);
246 result.Set(KNullDesC8);
255 Packages the object up into a descriptor.
256 @return A pointer to a desctriptor with the object packed in it.
258 EXPORT_C HBufC8* CCodecApiResolverData::NewPackLC() const
260 //Calculate the size necessary size for the descriptor to pack the object
262 size = sizeof(iMatchType) + sizeof(iImplementationType.iUid) + 2*sizeof(TInt32);
263 // the operator << write first the length of the string so we need to add it to the total size
266 size += iInputDataFormat->Size();
268 if(iOutputDataFormat)
270 size += iOutputDataFormat->Size();
273 HBufC8* package = HBufC8::NewLC(size);
274 TPtr8 packageDes = package->Des();
275 RDesWriteStream stream(packageDes);
276 CleanupClosePushL(stream);
277 ExternalizeL(stream);
278 CleanupStack::PopAndDestroy(&stream);
285 Unpacks a packed descriptor.
287 A reference to a desctriptor created.
289 EXPORT_C void CCodecApiResolverData::UnPackL(const TDesC8& aPackage)
291 RDesReadStream stream(aPackage);
292 CleanupClosePushL(stream);
293 InternalizeL(stream);
294 CleanupStack::PopAndDestroy(&stream);