|
1 /* |
|
2 * Copyright (c) 2009 Aricent and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "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 * Aricent - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Implementation of member functions of Plugin class |
|
16 * (CAriAmrNbEncMmfCodec). |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <ecom.h> |
|
21 #include <implementationproxy.h> |
|
22 |
|
23 #include "ariamrnbencwrapper.h" |
|
24 #include "ariamrnbencmmfcodec.h" |
|
25 #include "ariamrnbencmmfcodec_uid.hrh" |
|
26 #include "AriPrint.h" |
|
27 |
|
28 //Minimum bytes that contain 160 samples that has to be encoded at a time |
|
29 const TUint KMinBytesInput = 320; |
|
30 const TUint KMinDstLen = 32; |
|
31 |
|
32 |
|
33 // -------------------------------------------------------------------------- |
|
34 // Two-phased constructor. |
|
35 // Creates an instance of CAriAmrNbEncMmfCodec. |
|
36 // Instance is not left on cleanup stack. |
|
37 // -------------------------------------------------------------------------- |
|
38 // |
|
39 CMMFCodec* CAriAmrNbEncMmfCodec::NewL() |
|
40 { |
|
41 PRINT_ENTRY; |
|
42 CAriAmrNbEncMmfCodec* self = new ( ELeave ) CAriAmrNbEncMmfCodec(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop( self ); |
|
46 PRINT_EXIT; |
|
47 return ( CMMFCodec* )self; |
|
48 } |
|
49 |
|
50 // -------------------------------------------------------------------------- |
|
51 // Destructor;Destroys the encoder instance and any internal buffers |
|
52 // -------------------------------------------------------------------------- |
|
53 // |
|
54 CAriAmrNbEncMmfCodec::~CAriAmrNbEncMmfCodec() |
|
55 { |
|
56 PRINT_ENTRY; |
|
57 if ( iInternalInputBuffer ) |
|
58 { |
|
59 delete iInternalInputBuffer; |
|
60 iInternalInputBuffer = NULL; |
|
61 } |
|
62 if ( iInternalOutputBuffer ) |
|
63 { |
|
64 delete iInternalOutputBuffer; |
|
65 iInternalOutputBuffer = NULL; |
|
66 } |
|
67 if ( iCodec ) |
|
68 { |
|
69 delete iCodec; |
|
70 iCodec = NULL; |
|
71 } |
|
72 iConfigured = EFalse; |
|
73 PRINT_EXIT; |
|
74 } |
|
75 |
|
76 |
|
77 // -------------------------------------------------------------------------- |
|
78 // From class CMMFCodec. |
|
79 // The function sets codec configuration. |
|
80 // value used for aConfigType must be KUidMmfCodecAudioSettings |
|
81 // (defined in include\mmf\plugins\mmfCodecImplementationUIDs.hrh) |
|
82 // |
|
83 // -------------------------------------------------------------------------- |
|
84 // |
|
85 void CAriAmrNbEncMmfCodec::ConfigureL( TUid /* aConfigType */, |
|
86 const TDesC8& aParam ) |
|
87 { |
|
88 PRINT_ENTRY; |
|
89 if ( !iConfigured ) |
|
90 { |
|
91 TInt encMode = 0; |
|
92 TInt dtx = 0; |
|
93 TInt offset = 0; |
|
94 |
|
95 Mem::Copy( &encMode, aParam.Ptr() + offset, sizeof( TInt ) ); |
|
96 offset += sizeof(TInt); |
|
97 |
|
98 Mem::Copy( &dtx, aParam.Ptr() + offset, sizeof( TInt ) ); |
|
99 offset += sizeof(TInt); |
|
100 |
|
101 iParam.iMode = ( TInt16 )encMode; |
|
102 iParam.iDtx = ( TInt16 )dtx; |
|
103 |
|
104 PRINT_MSG( LEVEL_HIGH, ( "Mode: %d", iParam.iMode ) ); |
|
105 PRINT_MSG( LEVEL_HIGH, ( "DTX: %d", iParam.iDtx ) ); |
|
106 |
|
107 User::LeaveIfError( iCodec->Reset( &iParam ) ); |
|
108 |
|
109 iConfigured = ETrue; |
|
110 } |
|
111 PRINT_EXIT; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // From class CMMFCodec. |
|
116 // This function is used to flush out status information when a |
|
117 // reposition occurs. |
|
118 // This is used if the codec requires resetting prior to use. |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CAriAmrNbEncMmfCodec::ResetL() |
|
122 { |
|
123 PRINT_ENTRY; |
|
124 User::LeaveIfError( iCodec->Reset( &iParam ) ); |
|
125 PRINT_EXIT; |
|
126 } |
|
127 |
|
128 |
|
129 // -------------------------------------------------------------------------- |
|
130 // From class CMMFCodec. |
|
131 // This function is used to encode the given source and fill the destination |
|
132 // buffer with the encode data. |
|
133 // The buffers can be of any size. Since the buffers can be of any size |
|
134 // there is no guarantee that all the source buffer can be processed to fill |
|
135 // the destination buffer or that the all the source buffer may be processed |
|
136 // before the destination is full. Therefore the ProcessL needs to return a |
|
137 // TCodecProcessResult returing the number of source bytes processed and the |
|
138 // number of destination bytes processed along with a process result code |
|
139 // defined thus: |
|
140 // - EProcessComplete: the codec processed all the source data into the |
|
141 // sink buffer |
|
142 // - EProcessIncomplete: the codec filled sink buffer before all the source |
|
143 // buffer |
|
144 // was processed |
|
145 // - EDstNotFilled: the codec processed the source buffer but the sink |
|
146 // buffer was not filled |
|
147 // - EEndOfData: the codec detected the end data - all source data is |
|
148 // processed but sink may not be full |
|
149 // - EProcessError: the codec process error condition |
|
150 // |
|
151 // The ProcessL should start processing the source buffer from the iPosition |
|
152 // data member of the source data and start filling the destination buffer |
|
153 // from its iPosition. |
|
154 // ------------------------------------------------------------------------- |
|
155 // |
|
156 TCodecProcessResult CAriAmrNbEncMmfCodec::ProcessL( const CMMFBuffer& aSrc, |
|
157 CMMFBuffer& aDst ) |
|
158 { |
|
159 PRINT_ENTRY; |
|
160 |
|
161 // total encoded bytes added to the dst buffer |
|
162 TInt totalDstBytesAdded = 0; |
|
163 // total src bytes added to the internal src buffer |
|
164 TInt totalSrcBytesCopied = 0; |
|
165 // temporary variable to use for copying the sorce or destination data |
|
166 TInt numberOfBytesCopied = 0; |
|
167 TInt dstBufferRemainingBytes = 0; |
|
168 TInt srcBufferRemainingBytes = 0; |
|
169 |
|
170 /** |
|
171 * Process the dst buffer, update the dstBufferPos and check |
|
172 * whether dst buffer is NULL or not. |
|
173 */ |
|
174 CMMFDataBuffer* dst = static_cast<CMMFDataBuffer*>( &aDst ); |
|
175 const TInt dstMaxLen = dst->Data().MaxLength(); |
|
176 TUint8* dstPtr = const_cast<TUint8*>( dst->Data().Ptr() ); |
|
177 TInt dstBufferPos = dst->Position(); |
|
178 |
|
179 /** |
|
180 * Process the src buffer, update srcbuffer length, position and |
|
181 * flag for last frame. check whether src buffer is NULL or not |
|
182 * and check src buffer contains any data |
|
183 */ |
|
184 const CMMFDataBuffer* src = static_cast<const CMMFDataBuffer*>( &aSrc ); |
|
185 TUint8* srcPtr = const_cast <TUint8*>( src->Data().Ptr() ); |
|
186 TInt srcBufferLen = src->Data().Length(); |
|
187 TInt srcBufferPos = src->Position(); |
|
188 TBool lastFrame = src->LastBuffer(); |
|
189 |
|
190 PRINT_MSG( LEVEL_HIGH, ( "Src Buffer Pos: %d", srcBufferPos ) ); |
|
191 PRINT_MSG( LEVEL_HIGH, ( "Dst Buffer Pos: %d", dstBufferPos ) ); |
|
192 PRINT_MSG( LEVEL_HIGH, ( "Residue in internal output buffer: %d", |
|
193 iInternalOutputBufferResidueLen - iInternalOutputBufferPos ) ); |
|
194 PRINT_MSG( LEVEL_HIGH, ( "Residue in internal input buffer: %d", |
|
195 iInternalInputBufferResidueLen ) ); |
|
196 |
|
197 /** |
|
198 * if any destination bytes from internal destination buffer is not |
|
199 * given to the dst buffer from the previous call, give it to the |
|
200 * dst buffer. After this block, it ensures that no bytes are remaining |
|
201 * in the internal destination buffer. |
|
202 */ |
|
203 if ( iInternalOutputBufferResidueLen - iInternalOutputBufferPos > 0 ) |
|
204 { |
|
205 numberOfBytesCopied = CopyToDstBuffer( dst, totalDstBytesAdded ); |
|
206 |
|
207 if ( iInternalOutputBufferResidueLen - iInternalOutputBufferPos > 0 ) |
|
208 { |
|
209 PRINT_EXIT; |
|
210 return Result( TCodecProcessResult::EProcessIncomplete, |
|
211 totalSrcBytesCopied, totalDstBytesAdded ); |
|
212 } |
|
213 else |
|
214 { |
|
215 if ( lastFrame && ( srcBufferLen - srcBufferPos == 0 ) && |
|
216 ( iInternalInputBufferResidueLen == 0 ) ) |
|
217 { |
|
218 totalSrcBytesCopied = 0; |
|
219 iInternalOutputBufferResidueLen = 0; |
|
220 iInternalInputBufferResidueLen = 0; |
|
221 iInternalOutputBufferPos = 0; |
|
222 PRINT_EXIT; |
|
223 return Result( TCodecProcessResult::EEndOfData, |
|
224 totalSrcBytesCopied, totalDstBytesAdded ); |
|
225 } |
|
226 iInternalOutputBufferPos = 0; |
|
227 iInternalOutputBufferResidueLen = 0; |
|
228 } |
|
229 } |
|
230 |
|
231 /** |
|
232 * copy the src buffer data into the internal buffer till internal buffer |
|
233 * holds minimum bytes to process i.e KMinBytesInput. After this block, it |
|
234 * ensures that internal source buffer holds KMinBytesInput. |
|
235 * if it is a last frame, treat remaining residual buffer as internal |
|
236 * buffer. |
|
237 */ |
|
238 if ( ( iSrclenToProcess - iInternalInputBufferResidueLen > 0 ) && |
|
239 ( srcBufferLen - srcBufferPos > 0 ) ) |
|
240 { |
|
241 numberOfBytesCopied = CopyFromSrcBuffer( src, totalSrcBytesCopied ); |
|
242 } |
|
243 |
|
244 if ( ( iSrclenToProcess > iInternalInputBufferResidueLen ) && |
|
245 ( !lastFrame ) ) |
|
246 { |
|
247 PRINT_EXIT; |
|
248 return Result( TCodecProcessResult::EDstNotFilled, |
|
249 srcBufferLen - srcBufferPos, totalDstBytesAdded ); |
|
250 } |
|
251 srcBufferRemainingBytes = srcBufferLen - srcBufferPos - |
|
252 totalSrcBytesCopied; |
|
253 dstBufferRemainingBytes = dstMaxLen - dstBufferPos - totalDstBytesAdded; |
|
254 |
|
255 if ( lastFrame && ( ( iSrclenToProcess > iInternalInputBufferResidueLen ) |
|
256 && ( iSrclenToProcess > srcBufferRemainingBytes ) ) |
|
257 && ( iInternalOutputBufferResidueLen - |
|
258 iInternalOutputBufferPos == 0 ) ) |
|
259 { |
|
260 totalSrcBytesCopied = 0; |
|
261 iInternalOutputBufferResidueLen = 0; |
|
262 iInternalInputBufferResidueLen = 0; |
|
263 iInternalOutputBufferPos = 0; |
|
264 PRINT_EXIT; |
|
265 return Result( TCodecProcessResult::EEndOfData, |
|
266 totalSrcBytesCopied, totalDstBytesAdded ); |
|
267 } |
|
268 |
|
269 if ( iInternalOutputBufferResidueLen - iInternalOutputBufferPos == 0 ) |
|
270 { |
|
271 iInternalOutputBufferResidueLen = 0; |
|
272 iInternalOutputBufferPos = 0; |
|
273 } |
|
274 /** |
|
275 * process the src buffer till destination buffer or source buffer or |
|
276 * both buffers are exhausted. |
|
277 */ |
|
278 do |
|
279 { |
|
280 srcBufferRemainingBytes = srcBufferLen - srcBufferPos - |
|
281 totalSrcBytesCopied; |
|
282 dstBufferRemainingBytes = dstMaxLen - dstBufferPos - |
|
283 totalDstBytesAdded; |
|
284 TInt internalInputBufferPos = 0; |
|
285 |
|
286 /** |
|
287 * initialize the variables like srcUsed and dstLen accordingly. |
|
288 * call encode. |
|
289 */ |
|
290 TInt index; |
|
291 TInt srcUsed = iSrclenToProcess; |
|
292 TInt dstLen = KMinDstLen; |
|
293 TInt* tempIn = NULL; |
|
294 TInt len = KMinBytesInput / sizeof( TInt ); |
|
295 tempIn = ( TInt* ) ( ( iInternalInputBuffer + |
|
296 internalInputBufferPos ) ); |
|
297 for ( index = 0; index < len; index++ ) |
|
298 { |
|
299 tempIn[index] &= 0xfff8fff8; |
|
300 } |
|
301 |
|
302 TInt error = iCodec->Encode( tempIn, srcUsed, |
|
303 iInternalOutputBuffer, dstLen ); |
|
304 if ( error != 0 ) |
|
305 { |
|
306 iInternalInputBufferResidueLen = 0; |
|
307 totalSrcBytesCopied = srcBufferLen; |
|
308 PRINT_ERR( error ); |
|
309 return Result( |
|
310 TCodecProcessResult::EProcessError, |
|
311 totalSrcBytesCopied, totalDstBytesAdded + dstBufferPos ); |
|
312 } |
|
313 |
|
314 /** |
|
315 * Fill Destination Buffer |
|
316 */ |
|
317 iInternalOutputBufferResidueLen = dstLen; |
|
318 numberOfBytesCopied = CopyToDstBuffer( dst, totalDstBytesAdded ); |
|
319 dstBufferRemainingBytes -= numberOfBytesCopied; |
|
320 |
|
321 /*** |
|
322 * Fill Source Buffer |
|
323 */ |
|
324 internalInputBufferPos += srcUsed ; |
|
325 ShiftData( internalInputBufferPos, 0 ); |
|
326 numberOfBytesCopied = CopyFromSrcBuffer( src, totalSrcBytesCopied ); |
|
327 srcBufferRemainingBytes -= numberOfBytesCopied; |
|
328 |
|
329 /*** |
|
330 * check four conditions if else for src and if else for dst |
|
331 */ |
|
332 // src has available bytes |
|
333 if ( srcBufferRemainingBytes > 0 || iInternalInputBufferResidueLen >= |
|
334 iSrclenToProcess ) |
|
335 { |
|
336 if( dstBufferRemainingBytes == 0 ) |
|
337 { |
|
338 PRINT_EXIT; |
|
339 return Result( |
|
340 TCodecProcessResult::EProcessIncomplete, |
|
341 totalSrcBytesCopied, totalDstBytesAdded ); |
|
342 } |
|
343 } |
|
344 else |
|
345 { |
|
346 // dst buffer has availabe space for encoded bytes |
|
347 if ( dstBufferRemainingBytes > 0 ) |
|
348 { |
|
349 if ( lastFrame ) |
|
350 { |
|
351 if ( iInternalInputBufferResidueLen == 0 ) |
|
352 { |
|
353 iInternalOutputBufferResidueLen = 0; |
|
354 iInternalInputBufferResidueLen = 0; |
|
355 iInternalOutputBufferPos = 0; |
|
356 PRINT_EXIT; |
|
357 return Result( TCodecProcessResult::EEndOfData, |
|
358 totalSrcBytesCopied, totalDstBytesAdded ); |
|
359 } |
|
360 } |
|
361 else |
|
362 { |
|
363 PRINT_EXIT; |
|
364 return Result( TCodecProcessResult::EDstNotFilled, |
|
365 totalSrcBytesCopied, totalDstBytesAdded ); |
|
366 } |
|
367 } |
|
368 else |
|
369 { |
|
370 if ( iInternalOutputBufferResidueLen - |
|
371 iInternalOutputBufferPos > 0 ) |
|
372 { |
|
373 PRINT_EXIT; |
|
374 return Result( TCodecProcessResult::EProcessIncomplete, |
|
375 totalSrcBytesCopied, totalDstBytesAdded ); |
|
376 } |
|
377 else |
|
378 { |
|
379 if ( lastFrame && |
|
380 ( iInternalInputBufferResidueLen == 0 ) ) |
|
381 { |
|
382 iInternalOutputBufferResidueLen = 0; |
|
383 iInternalInputBufferResidueLen = 0; |
|
384 iInternalOutputBufferPos = 0; |
|
385 PRINT_EXIT; |
|
386 return Result( TCodecProcessResult::EEndOfData, |
|
387 totalSrcBytesCopied, totalDstBytesAdded ); |
|
388 } |
|
389 else |
|
390 { |
|
391 PRINT_EXIT; |
|
392 return Result( |
|
393 TCodecProcessResult::EProcessComplete, |
|
394 totalSrcBytesCopied, totalDstBytesAdded ); |
|
395 } |
|
396 } |
|
397 } |
|
398 } |
|
399 }while ( 1 ); |
|
400 } |
|
401 |
|
402 |
|
403 // -------------------------------------------------------------------------- |
|
404 // Default constructor for performing 1st stage construction. |
|
405 // Should not contain any code that could leave. |
|
406 // -------------------------------------------------------------------------- |
|
407 // |
|
408 CAriAmrNbEncMmfCodec::CAriAmrNbEncMmfCodec() |
|
409 { |
|
410 PRINT_ENTRY; |
|
411 iCodec = NULL; |
|
412 iConfigured = EFalse; |
|
413 iSrclenToProcess = KMinBytesInput; |
|
414 iInternalInputBufferResidueLen = 0; |
|
415 iInternalOutputBufferResidueLen = 0; |
|
416 iInternalOutputBufferPos = 0; |
|
417 iInternalInputBuffer = NULL; |
|
418 iInternalOutputBuffer = NULL; |
|
419 //default Parameters |
|
420 iParam.iMode = 0; |
|
421 iParam.iDtx = 0; |
|
422 iParam.iFileFormat = 0; |
|
423 PRINT_EXIT; |
|
424 } |
|
425 |
|
426 |
|
427 // -------------------------------------------------------------------------- |
|
428 // Second phase of the two-phased constructor. |
|
429 // Creates an instance of encoder |
|
430 // -------------------------------------------------------------------------- |
|
431 // |
|
432 void CAriAmrNbEncMmfCodec::ConstructL() |
|
433 { |
|
434 PRINT_ENTRY; |
|
435 iCodec = CAriAmrNbEncWrapper::NewL(); |
|
436 |
|
437 iInternalInputBuffer = ( TUint8* ) User::AllocZL( KMinBytesInput ); |
|
438 iInternalOutputBuffer = ( TUint8* ) User::AllocZL( KMinDstLen ); |
|
439 |
|
440 PRINT_MSG( LEVEL_HIGH, ( "Default mode: %d", iParam.iMode ) ); |
|
441 PRINT_MSG( LEVEL_HIGH, ( "Default DTX: %d", iParam.iDtx ) ); |
|
442 //Reset encoder with default parameters |
|
443 User::LeaveIfError( iCodec->Reset( &iParam ) ); |
|
444 PRINT_EXIT; |
|
445 } |
|
446 |
|
447 //---------------------------------------------------------------------------- |
|
448 // Updates the result of the processing |
|
449 //---------------------------------------------------------------------------- |
|
450 // |
|
451 TCodecProcessResult CAriAmrNbEncMmfCodec::Result( |
|
452 TCodecProcessResult::TCodecProcessResultStatus aStatus, |
|
453 TInt aSrcBytesConsumed, TInt aDstBytesAdded ) |
|
454 { |
|
455 PRINT_ENTRY; |
|
456 TCodecProcessResult result; |
|
457 |
|
458 result.iDstBytesAdded = aDstBytesAdded; |
|
459 result.iSrcBytesProcessed = aSrcBytesConsumed; |
|
460 |
|
461 switch ( aStatus ) |
|
462 { |
|
463 case TCodecProcessResult::EProcessComplete: |
|
464 result.iStatus = TCodecProcessResult::EProcessComplete; |
|
465 break; |
|
466 case TCodecProcessResult::EProcessIncomplete: |
|
467 result.iStatus = TCodecProcessResult::EProcessIncomplete; |
|
468 break; |
|
469 case TCodecProcessResult::EEndOfData: |
|
470 result.iStatus = TCodecProcessResult::EEndOfData; |
|
471 break; |
|
472 case TCodecProcessResult::EDstNotFilled: |
|
473 result.iStatus = TCodecProcessResult::EDstNotFilled; |
|
474 break; |
|
475 case TCodecProcessResult::EProcessError: |
|
476 result.iStatus = TCodecProcessResult::EProcessError; |
|
477 break; |
|
478 default: |
|
479 result.iStatus = TCodecProcessResult::EProcessError; |
|
480 break; |
|
481 } |
|
482 PRINT_MSG( LEVEL_HIGH, ( "result.iSrcBytesProcessed = %d", |
|
483 result.iSrcBytesProcessed ) ); |
|
484 PRINT_MSG( LEVEL_HIGH, ( "result.iDstBytesAdded = %d", |
|
485 result.iDstBytesAdded ) ); |
|
486 PRINT_MSG( LEVEL_HIGH, ( "result.iStatus = %d", |
|
487 result.iStatus ) ); |
|
488 PRINT_EXIT; |
|
489 return result; |
|
490 } |
|
491 |
|
492 //---------------------------------------------------------------------------- |
|
493 // Copy the bytes to destination buffer from the internal buffer |
|
494 // first checks whether the number of bytes to be copied is lesser of the |
|
495 // destination buffer reamining bytes and internal input internal remaining |
|
496 // remaining bytes and then copies that many bytes. |
|
497 //---------------------------------------------------------------------------- |
|
498 // |
|
499 TInt CAriAmrNbEncMmfCodec::CopyToDstBuffer( CMMFDataBuffer* aDst, |
|
500 TInt &aDstBytesConsumed ) |
|
501 { |
|
502 PRINT_ENTRY; |
|
503 TInt numberOfBytesToBeCopied; |
|
504 const TInt dstMaxLen = aDst->Data().MaxLength(); |
|
505 TUint8* dstPtr = const_cast<TUint8*>( aDst->Data().Ptr() ); |
|
506 TInt dstBufferPos = aDst->Position(); |
|
507 |
|
508 TInt dstBufferRemainingBytes = dstMaxLen |
|
509 - dstBufferPos |
|
510 - aDstBytesConsumed; |
|
511 TInt internalOutputBufferRemainingBytes = |
|
512 iInternalOutputBufferResidueLen |
|
513 - iInternalOutputBufferPos; |
|
514 |
|
515 if ( internalOutputBufferRemainingBytes > dstBufferRemainingBytes ) |
|
516 { |
|
517 numberOfBytesToBeCopied = dstBufferRemainingBytes; |
|
518 } |
|
519 else |
|
520 { |
|
521 numberOfBytesToBeCopied = internalOutputBufferRemainingBytes; |
|
522 iInternalOutputBufferResidueLen = 0; |
|
523 } |
|
524 |
|
525 Mem::Copy( dstPtr + dstBufferPos + aDstBytesConsumed, |
|
526 iInternalOutputBuffer + iInternalOutputBufferPos, |
|
527 numberOfBytesToBeCopied ); |
|
528 |
|
529 if( iInternalOutputBufferResidueLen ) |
|
530 { |
|
531 iInternalOutputBufferPos += dstBufferRemainingBytes; |
|
532 } |
|
533 else |
|
534 { |
|
535 iInternalOutputBufferPos = 0; |
|
536 } |
|
537 |
|
538 aDstBytesConsumed += numberOfBytesToBeCopied; |
|
539 aDst->Data().SetLength( dstBufferPos + aDstBytesConsumed ); |
|
540 PRINT_EXIT; |
|
541 return numberOfBytesToBeCopied; |
|
542 } |
|
543 |
|
544 //--------------------------------------------------------------------------- |
|
545 // Copy the bytes from the source buffer to the internal input buffer. |
|
546 // first it checks number of bytes to be copied is lesser of the source buffer |
|
547 // remaining bytes or internal input buffer remaining bytes and then copies |
|
548 // that many bytes. |
|
549 //--------------------------------------------------------------------------- |
|
550 // |
|
551 TInt CAriAmrNbEncMmfCodec::CopyFromSrcBuffer(const CMMFDataBuffer* aSrc, |
|
552 TInt &aSrcBytesConsumed ) |
|
553 { |
|
554 PRINT_ENTRY; |
|
555 TInt numberOfBytesToBeCopied; |
|
556 TUint8* srcPtr = const_cast <TUint8*>( aSrc->Data().Ptr() ); |
|
557 TInt srcBufferLen = aSrc->Data().Length(); |
|
558 TInt srcBufferPos = aSrc->Position(); |
|
559 |
|
560 TInt srcBufferRemainingBytes = srcBufferLen - srcBufferPos |
|
561 - aSrcBytesConsumed; |
|
562 |
|
563 TInt internalInputBufferRemaingBytes = KMinBytesInput |
|
564 - iInternalInputBufferResidueLen; |
|
565 |
|
566 if ( internalInputBufferRemaingBytes > srcBufferRemainingBytes ) |
|
567 { |
|
568 numberOfBytesToBeCopied = srcBufferRemainingBytes; |
|
569 } |
|
570 else |
|
571 { |
|
572 numberOfBytesToBeCopied = internalInputBufferRemaingBytes; |
|
573 } |
|
574 |
|
575 Mem::Copy( iInternalInputBuffer + iInternalInputBufferResidueLen, |
|
576 srcPtr + srcBufferPos + aSrcBytesConsumed, |
|
577 numberOfBytesToBeCopied ); |
|
578 |
|
579 iInternalInputBufferResidueLen += numberOfBytesToBeCopied; |
|
580 aSrcBytesConsumed += numberOfBytesToBeCopied; |
|
581 PRINT_EXIT; |
|
582 return numberOfBytesToBeCopied; |
|
583 } |
|
584 |
|
585 //--------------------------------------------------------------------------- |
|
586 // Moves the data of the internal input buffer to the start position |
|
587 //--------------------------------------------------------------------------- |
|
588 // |
|
589 void CAriAmrNbEncMmfCodec::ShiftData( TInt aFromPos, TInt aToPos ) |
|
590 { |
|
591 PRINT_ENTRY; |
|
592 for ( TInt i = aFromPos; i < ( iInternalInputBufferResidueLen - |
|
593 aFromPos ); i++ ) |
|
594 { |
|
595 iInternalInputBuffer[i] = |
|
596 iInternalInputBuffer[i + aFromPos]; |
|
597 } |
|
598 iInternalInputBufferResidueLen -= aFromPos; |
|
599 PRINT_EXIT; |
|
600 } |
|
601 |
|
602 |
|
603 // -------------------------------------------------------------------------- |
|
604 // Exported proxy for instantiation method resolution |
|
605 // Define the interface UIDs |
|
606 // -------------------------------------------------------------------------- |
|
607 // |
|
608 const TImplementationProxy ImplementationTable[] = |
|
609 { |
|
610 IMPLEMENTATION_PROXY_ENTRY( KUidAmrNbEncMmfImplUid, |
|
611 CAriAmrNbEncMmfCodec::NewL ) |
|
612 }; |
|
613 |
|
614 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( |
|
615 TInt& aTableCount ) |
|
616 { |
|
617 PRINT_ENTRY; |
|
618 aTableCount = sizeof( ImplementationTable ) / |
|
619 sizeof( TImplementationProxy ); |
|
620 PRINT_EXIT; |
|
621 return ImplementationTable; |
|
622 } |