|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "TSU_MMF_ACOD_AAAABBBBTest2Codec.h" |
|
20 |
|
21 // __________________________________________________________________________ |
|
22 // Implementation |
|
23 |
|
24 /** @xxxx |
|
25 * This function instantiates a CMMFAAAABBBBTest2Codec |
|
26 * |
|
27 * @param "TAny* aInitParams" |
|
28 * pointer to initial codec parameters |
|
29 * |
|
30 * @return pointer to newly instantiated codec |
|
31 */ |
|
32 CMMFCodec* CMMFAAAABBBBTest2Codec::NewL(TAny* aInitParams) |
|
33 { |
|
34 CMMFAAAABBBBTest2Codec* self=new(ELeave) CMMFAAAABBBBTest2Codec(); |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(aInitParams); |
|
37 CleanupStack::Pop(self); |
|
38 return STATIC_CAST( CMMFCodec*, self ); |
|
39 } |
|
40 |
|
41 CMMFAAAABBBBTest2Codec::~CMMFAAAABBBBTest2Codec() |
|
42 { |
|
43 } |
|
44 |
|
45 CMMFAAAABBBBTest2Codec::CMMFAAAABBBBTest2Codec() |
|
46 { |
|
47 } |
|
48 |
|
49 void CMMFAAAABBBBTest2Codec::ConstructL(TAny* /*aInitParams*/) |
|
50 { |
|
51 } |
|
52 |
|
53 /** @xxxx |
|
54 * This function writes '7's to the destination buffer, regardless of what is in the source buffer. |
|
55 * This codec only exists to test the preferred supplier codec instantiation. |
|
56 * |
|
57 * @param "const CMMFBuffer& aSrc" |
|
58 * reference to source buffer |
|
59 * "CMMFBuffer& aDst" |
|
60 * reference to destination buffer |
|
61 * |
|
62 * @return result of operation. |
|
63 */ |
|
64 TCodecProcessResult CMMFAAAABBBBTest2Codec::ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst) |
|
65 { |
|
66 //convert from generic CMMFBuffer to CMMFDataBuffer |
|
67 iSrc = STATIC_CAST(const CMMFDataBuffer*, &aSrc); |
|
68 iDst = STATIC_CAST(CMMFDataBuffer*, &aDst); |
|
69 |
|
70 const TUint dstMaxLen = iDst->Data().MaxLength(); |
|
71 |
|
72 if (!dstMaxLen) |
|
73 User::Leave(KErrArgument); |
|
74 |
|
75 //don't scribble Destination (pDst) by only consuming enough source to fill pDst |
|
76 TUint srcUse = dstMaxLen - iDst->Position(); |
|
77 const TUint srcLen = iSrc->Data().Length(); |
|
78 const TUint sourceRemain = srcLen - iSrc->Position(); |
|
79 |
|
80 //make sure we don't blow source by checking against remaining |
|
81 //and clipping to minimum remaining if necessary |
|
82 srcUse = (srcUse<sourceRemain ? srcUse : sourceRemain); |
|
83 |
|
84 TUint8* pDst = CONST_CAST(TUint8*,iDst->Data().Ptr()); |
|
85 pDst += iDst->Position(); |
|
86 |
|
87 TUint samplesToProcess = srcUse; |
|
88 while (samplesToProcess--) |
|
89 { |
|
90 *pDst++ = 7; |
|
91 } |
|
92 |
|
93 TCodecProcessResult result; |
|
94 result.iStatus = TCodecProcessResult::EProcessComplete; |
|
95 |
|
96 result.iSrcBytesProcessed = srcUse; |
|
97 result.iDstBytesAdded = srcUse; |
|
98 |
|
99 iDst->Data().SetLength(iDst->Position() + result.iDstBytesAdded); |
|
100 |
|
101 return result; |
|
102 |
|
103 } |