0
|
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_AAAABBBBTestCodec.h"
|
|
20 |
|
|
21 |
|
|
22 |
// __________________________________________________________________________
|
|
23 |
// Implementation
|
|
24 |
|
|
25 |
/** @xxxx
|
|
26 |
* This function instantiates a CMMFAAAABBBBTestCodec
|
|
27 |
*
|
|
28 |
* @param "TAny* aInitParams"
|
|
29 |
* pointer to initial codec parameters
|
|
30 |
*
|
|
31 |
* @return pointer to newly instantiated codec
|
|
32 |
*/
|
|
33 |
CMMFCodec* CMMFAAAABBBBTestCodec::NewL(TAny* aInitParams)
|
|
34 |
{
|
|
35 |
CMMFAAAABBBBTestCodec* self=new(ELeave) CMMFAAAABBBBTestCodec();
|
|
36 |
CleanupStack::PushL(self);
|
|
37 |
self->ConstructL(aInitParams);
|
|
38 |
CleanupStack::Pop(self);
|
|
39 |
return STATIC_CAST( CMMFCodec*, self );
|
|
40 |
}
|
|
41 |
|
|
42 |
CMMFAAAABBBBTestCodec::~CMMFAAAABBBBTestCodec()
|
|
43 |
{
|
|
44 |
}
|
|
45 |
|
|
46 |
CMMFAAAABBBBTestCodec::CMMFAAAABBBBTestCodec()
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
void CMMFAAAABBBBTestCodec::ConstructL(TAny* /*aInitParams*/)
|
|
51 |
{
|
|
52 |
}
|
|
53 |
|
|
54 |
/** @xxxx
|
|
55 |
* This function writes '4's to the destination buffer, regardless of what is in the source buffer.
|
|
56 |
* This codec only exists to test the preferred supplier codec instantiation.
|
|
57 |
*
|
|
58 |
* @param "const CMMFBuffer& aSrc"
|
|
59 |
* reference to source buffer
|
|
60 |
* "CMMFBuffer& aDst"
|
|
61 |
* reference to destination buffer
|
|
62 |
*
|
|
63 |
* @return result of operation.
|
|
64 |
*/
|
|
65 |
TCodecProcessResult CMMFAAAABBBBTestCodec::ProcessL(const CMMFBuffer& aSrc, CMMFBuffer& aDst)
|
|
66 |
{
|
|
67 |
//convert from generic CMMFBuffer to CMMFDataBuffer
|
|
68 |
iSrc = STATIC_CAST(const CMMFDataBuffer*, &aSrc);
|
|
69 |
iDst = STATIC_CAST(CMMFDataBuffer*, &aDst);
|
|
70 |
|
|
71 |
const TUint dstMaxLen = iDst->Data().MaxLength();
|
|
72 |
|
|
73 |
if (!dstMaxLen)
|
|
74 |
User::Leave(KErrArgument);
|
|
75 |
|
|
76 |
//don't scribble Destination (pDst) by only consuming enough source to fill pDst
|
|
77 |
TUint srcUse = dstMaxLen - iDst->Position();
|
|
78 |
const TUint srcLen = iSrc->Data().Length();
|
|
79 |
const TUint sourceRemain = srcLen - iSrc->Position();
|
|
80 |
|
|
81 |
//make sure we don't blow source by checking against remaining
|
|
82 |
//and clipping to minimum remaining if necessary
|
|
83 |
srcUse = (srcUse<sourceRemain ? srcUse : sourceRemain);
|
|
84 |
|
|
85 |
TUint8* pDst = CONST_CAST(TUint8*,iDst->Data().Ptr());
|
|
86 |
pDst += iDst->Position();
|
|
87 |
|
|
88 |
TUint samplesToProcess = srcUse;
|
|
89 |
while (samplesToProcess--)
|
|
90 |
{
|
|
91 |
*pDst++ = 4;
|
|
92 |
}
|
|
93 |
|
|
94 |
TCodecProcessResult result;
|
|
95 |
result.iStatus = TCodecProcessResult::EProcessComplete;
|
|
96 |
|
|
97 |
result.iSrcBytesProcessed = srcUse;
|
|
98 |
result.iDstBytesAdded = srcUse;
|
|
99 |
|
|
100 |
iDst->Data().SetLength(iDst->Position() + result.iDstBytesAdded);
|
|
101 |
|
|
102 |
return result;
|
|
103 |
}
|
|
104 |
|