1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "ProcEncoder.h" |
|
22 #include "audconstants.h" |
|
23 #include <MmfDatabuffer.h> |
|
24 #include <mmfcontrollerpluginresolver.h> |
|
25 #include <mmfutilities.h> |
|
26 #include <mmf/plugin/mmfCodecImplementationUIDs.hrh> |
|
27 #include <MMFCodec.h> |
|
28 |
|
29 |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // Debug print macro |
|
34 #if defined _DEBUG |
|
35 #include <e32svr.h> |
|
36 #define PRINT(x) RDebug::Print x; |
|
37 #else |
|
38 #define PRINT(x) |
|
39 #endif |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // TCMRAMREncParams |
|
43 // Encoding parameters structure for SW AMR codec |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 class TVedACAMREncParams |
|
47 { |
|
48 public: |
|
49 // encoding mode (for AMR-NB: 0=MR475,1=MR515,...,7=MR122, default 7) |
|
50 TInt iMode; |
|
51 // DTX flag (TRUE or default FALSE) |
|
52 TInt iDTX; |
|
53 }; |
|
54 |
|
55 CProcEncoder* CProcEncoder::NewL() |
|
56 |
|
57 { |
|
58 CProcEncoder* self = NewLC(); |
|
59 CleanupStack::Pop(self); |
|
60 return self; |
|
61 |
|
62 } |
|
63 |
|
64 |
|
65 CProcEncoder* CProcEncoder::NewLC() |
|
66 |
|
67 { |
|
68 |
|
69 CProcEncoder* self = new (ELeave) CProcEncoder(); |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 return self; |
|
73 |
|
74 } |
|
75 |
|
76 CProcEncoder::~CProcEncoder() |
|
77 { |
|
78 |
|
79 |
|
80 delete iSourceInputBuffer; |
|
81 |
|
82 delete iDestInputBuffer; |
|
83 |
|
84 delete iDestCodec; |
|
85 |
|
86 |
|
87 } |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 TBool CProcEncoder::InitL(TAudType aAudioType, TInt aTargetSamplingRate, TChannelMode aChannelMode, |
|
93 TInt aBitrate) |
|
94 { |
|
95 PRINT((_L("CProcEncoder::InitL() in"))); |
|
96 |
|
97 if (aAudioType == EAudAMR) |
|
98 { |
|
99 iOutputFrameDurationMilli = 20; |
|
100 } |
|
101 else if (aAudioType == EAudAAC_MPEG4) |
|
102 { |
|
103 iOutputFrameDurationMilli = (1024*1000)/(aTargetSamplingRate); |
|
104 } |
|
105 else |
|
106 { |
|
107 // only AMR & AAC encoding supported |
|
108 PRINT((_L("CProcEncoder::InitL() out, unsupported audio type"))); |
|
109 User::Leave(KErrNotSupported); |
|
110 } |
|
111 |
|
112 iToBitRate = aBitrate; |
|
113 |
|
114 iAudioType = aAudioType; |
|
115 |
|
116 iNumberOfFramesInOutputBuffer = 0; |
|
117 |
|
118 iToSampleRate = aTargetSamplingRate; |
|
119 |
|
120 iToChannels = 1; |
|
121 |
|
122 if (aChannelMode == EAudStereo) |
|
123 { |
|
124 iToChannels = 2; |
|
125 } |
|
126 |
|
127 |
|
128 TInt destInputBufferSize = 0; |
|
129 TInt sourceInputBufferSize = 0; |
|
130 |
|
131 // input buffer size: |
|
132 // we never get longer than 64 milliseconds input |
|
133 // as it is limited by the input formats |
|
134 // for 16kHz AAC the frame duration is 64 ms |
|
135 // |
|
136 const TInt KMaxInputDurationMilli = 64; |
|
137 |
|
138 // multiplied by 2 as we have a bitdepth of 16 |
|
139 sourceInputBufferSize = (2*aTargetSamplingRate*KMaxInputDurationMilli)/1000; |
|
140 |
|
141 if (aChannelMode == EAudStereo) |
|
142 { |
|
143 sourceInputBufferSize *= 2; |
|
144 } |
|
145 |
|
146 if ( aAudioType == EAudAMR ) |
|
147 { |
|
148 |
|
149 // from 64 ms input we can have maximum 4 AMR frames |
|
150 destInputBufferSize = KAedMaxAMRFrameLength*4; |
|
151 |
|
152 |
|
153 } |
|
154 else if (aAudioType == EAudAAC_MPEG4) |
|
155 { |
|
156 |
|
157 if ( aChannelMode == EAudSingleChannel ) |
|
158 { |
|
159 destInputBufferSize = KAedMaxAACFrameLengthPerChannel; |
|
160 } |
|
161 else |
|
162 { |
|
163 destInputBufferSize = 2 * KAedMaxAACFrameLengthPerChannel; |
|
164 |
|
165 } |
|
166 } |
|
167 |
|
168 if ( iSourceInputBuffer ) |
|
169 { |
|
170 delete iSourceInputBuffer; |
|
171 iSourceInputBuffer = NULL; |
|
172 } |
|
173 |
|
174 iSourceInputBuffer = CMMFDataBuffer::NewL(sourceInputBufferSize*5); |
|
175 |
|
176 |
|
177 if ( iDestInputBuffer ) |
|
178 { |
|
179 delete iDestInputBuffer; |
|
180 iDestInputBuffer = NULL; |
|
181 } |
|
182 |
|
183 TInt errC = KErrNone; |
|
184 |
|
185 if (aAudioType == EAudAMR) |
|
186 { |
|
187 |
|
188 // shouldn't get more than 6 AMR frames at a time -> 120 ms |
|
189 iDestInputBuffer = CMMFDataBuffer::NewL( destInputBufferSize); |
|
190 |
|
191 } |
|
192 else |
|
193 { |
|
194 |
|
195 iDestInputBuffer = CMMFDataBuffer::NewL( destInputBufferSize); |
|
196 |
|
197 } |
|
198 |
|
199 TRAP (errC,SetDestCodecL()); |
|
200 |
|
201 if (errC != KErrNone) |
|
202 { |
|
203 // initialization failed for some reason |
|
204 User::Leave(KErrNotSupported); |
|
205 |
|
206 } |
|
207 |
|
208 TInt err = KErrNone; |
|
209 |
|
210 if ( iAudioType == EAudAAC_MPEG4 ) |
|
211 { |
|
212 TRAP( err, ConfigureAACEncoderL()); |
|
213 |
|
214 } |
|
215 else if (iAudioType == EAudAMR) |
|
216 { |
|
217 TRAP( err, ConfigureAMREncoderL()); |
|
218 } |
|
219 |
|
220 |
|
221 if (err != KErrNone || errC != KErrNone) |
|
222 { |
|
223 |
|
224 // initialization failed for some reason |
|
225 User::Leave(KErrNotSupported); |
|
226 } |
|
227 |
|
228 iReady = ETrue; |
|
229 PRINT((_L("CProcEncoder::InitL() out"))); |
|
230 |
|
231 return ETrue; |
|
232 } |
|
233 |
|
234 TBool CProcEncoder::FillEncBufferL(const TDesC8& aRawFrame, HBufC8* aEncBuffer, TInt& aOutputDurationMilli) |
|
235 { |
|
236 PRINT((_L("CProcEncoder::FillEncBufferL() in"))); |
|
237 |
|
238 aOutputDurationMilli = 0; |
|
239 |
|
240 |
|
241 if (!iReady) |
|
242 { |
|
243 User::Leave(KErrNotReady); |
|
244 } |
|
245 |
|
246 iEncBuffer = aEncBuffer; |
|
247 |
|
248 if (iEncBuffer->Length() == 0) |
|
249 { |
|
250 iNumberOfFramesInOutputBuffer = 0; |
|
251 } |
|
252 |
|
253 if ( !aRawFrame.Length() ) |
|
254 { |
|
255 return EFalse; |
|
256 } |
|
257 |
|
258 if ( (TInt)(aRawFrame.Length() + iSourceInputBuffer->Position() ) > iSourceInputBuffer->Data().MaxLength() ) |
|
259 { |
|
260 ReAllocBufferL( iSourceInputBuffer, aRawFrame.Length() + iSourceInputBuffer->Position() ); |
|
261 |
|
262 } |
|
263 |
|
264 |
|
265 // copy the input data to MMF buffer |
|
266 iSourceInputBuffer->Data().SetLength( 0 ); |
|
267 iSourceInputBuffer->SetPosition( 0 ); |
|
268 |
|
269 iSourceInputBuffer->Data().Append( aRawFrame ); |
|
270 iSourceInputBuffer->Data().SetLength( iSourceInputBuffer->Data().Length() ); |
|
271 iSourceInputBuffer->SetStatus(EFull); |
|
272 |
|
273 iDestInputBuffer->Data().SetLength(0); |
|
274 iDestInputBuffer->SetPosition(0); |
|
275 |
|
276 FeedCodecL( iDestCodec, iSourceInputBuffer, iDestInputBuffer); |
|
277 |
|
278 |
|
279 |
|
280 iDestInputBuffer->Data().SetLength(0); |
|
281 iDestInputBuffer->SetPosition(0); |
|
282 |
|
283 if (iEncBuffer->Size() > 0) |
|
284 { |
|
285 |
|
286 aOutputDurationMilli = iOutputFrameDurationMilli * iNumberOfFramesInOutputBuffer; |
|
287 PRINT((_L("CProcEncoder::FillEncBufferL() out with ETrue (complete)"))); |
|
288 return ETrue; |
|
289 } |
|
290 |
|
291 PRINT((_L("CProcEncoder::FillEncBufferL() out with EFalse (incomplete)"))); |
|
292 return EFalse; |
|
293 } |
|
294 |
|
295 TAudType CProcEncoder::DestAudType() |
|
296 { |
|
297 return iAudioType; |
|
298 } |
|
299 |
|
300 void CProcEncoder::ConstructL() |
|
301 { |
|
302 |
|
303 } |
|
304 |
|
305 CProcEncoder::CProcEncoder() |
|
306 { |
|
307 |
|
308 } |
|
309 |
|
310 |
|
311 void CProcEncoder::ConfigureAMREncoderL() |
|
312 { |
|
313 PRINT((_L("CProcEncoder::ConfigureAMREncoderL() in"))); |
|
314 |
|
315 if ( (iToBitRate < KAedMinAMRBitRate) || (iToBitRate > KAedMaxAMRBitRate) ) |
|
316 { |
|
317 User::Leave( KErrArgument ); |
|
318 } |
|
319 |
|
320 TVedACAMREncParams* configData = new (ELeave) TVedACAMREncParams; |
|
321 CleanupStack::PushL( configData ); |
|
322 |
|
323 // the bitrates in the switch & if below are not magic numbers but AMR bitrates in bits per seconds and mode indices from TAmrEncParams |
|
324 |
|
325 switch ( iToBitRate ) |
|
326 { |
|
327 case 4750: |
|
328 configData->iMode = 0; |
|
329 configData->iDTX = EFalse; |
|
330 break; |
|
331 case 5150: |
|
332 configData->iMode = 1; |
|
333 configData->iDTX = EFalse; |
|
334 break; |
|
335 case 5900: |
|
336 configData->iMode = 2; |
|
337 configData->iDTX = EFalse; |
|
338 break; |
|
339 case 6700: |
|
340 configData->iMode = 3; |
|
341 configData->iDTX = EFalse; |
|
342 break; |
|
343 case 7400: |
|
344 configData->iMode = 4; |
|
345 configData->iDTX = EFalse; |
|
346 break; |
|
347 case 7950: |
|
348 configData->iMode = 5; |
|
349 configData->iDTX = EFalse; |
|
350 break; |
|
351 case 10200: |
|
352 configData->iMode = 6; |
|
353 configData->iDTX = EFalse; |
|
354 break; |
|
355 case 12200: |
|
356 configData->iMode = 7; |
|
357 configData->iDTX = EFalse; |
|
358 break; |
|
359 default : |
|
360 // Interprets now the bitrate proprietarily: bitrates that are not exactly AMR bitrates |
|
361 // mean that voice activity detection is used and the AMR bitrates is the given bitrate rounded upwards to the next AMR bitrate |
|
362 if ( iToBitRate < 4750 ) |
|
363 { |
|
364 configData->iMode = 0; |
|
365 configData->iDTX = ETrue; |
|
366 } |
|
367 else if ( iToBitRate < 5150 ) |
|
368 { |
|
369 configData->iMode = 1; |
|
370 configData->iDTX = ETrue; |
|
371 } |
|
372 else if ( iToBitRate < 5900 ) |
|
373 { |
|
374 configData->iMode = 2; |
|
375 configData->iDTX = ETrue; |
|
376 } |
|
377 else if ( iToBitRate < 6700 ) |
|
378 { |
|
379 configData->iMode = 3; |
|
380 configData->iDTX = ETrue; |
|
381 } |
|
382 else if ( iToBitRate < 7400 ) |
|
383 { |
|
384 configData->iMode = 4; |
|
385 configData->iDTX = ETrue; |
|
386 } |
|
387 else if ( iToBitRate < 7950 ) |
|
388 { |
|
389 configData->iMode = 5; |
|
390 configData->iDTX = ETrue; |
|
391 } |
|
392 else if ( iToBitRate < 10200 ) |
|
393 { |
|
394 configData->iMode = 6; |
|
395 configData->iDTX = ETrue; |
|
396 } |
|
397 else // must be: ( iToBitRate < 12200 ) since checked earlier |
|
398 { |
|
399 configData->iMode = 7; |
|
400 configData->iDTX = ETrue; |
|
401 } |
|
402 } |
|
403 |
|
404 TUid uid ={KUidMmfCodecAudioSettings}; // Use Uid reserved for codec configurations |
|
405 iDestCodec->ConfigureL( uid, reinterpret_cast<TDesC8&>(*configData)); |
|
406 CleanupStack::PopAndDestroy( configData ); |
|
407 PRINT((_L("CProcEncoder::ConfigureAMREncoderL() out"))); |
|
408 } |
|
409 |
|
410 // ----------------------------------------------------------------------------- |
|
411 // CProcEncoder::ConfigureAACEncoderL |
|
412 // |
|
413 // (other items were commented in a header). |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 void CProcEncoder::ConfigureAACEncoderL() |
|
417 { |
|
418 PRINT((_L("CProcEncoder::ConfigureAACEncoderL() in"))); |
|
419 |
|
420 TInt i = 0; |
|
421 TBool iSet = EFalse; |
|
422 for ( i = 0; i < KAedNumSupportedAACSampleRates; i++ ) |
|
423 { |
|
424 if ( iToSampleRate == KAedSupportedAACSampleRates[i] ) |
|
425 { |
|
426 iSet = ETrue; |
|
427 } |
|
428 } |
|
429 if ( !iSet ) |
|
430 { |
|
431 // given samplerate is not supported |
|
432 User::Leave( KErrNotSupported ); |
|
433 } |
|
434 |
|
435 // AAC codec interprets the input as array of TInts, not as a class |
|
436 RArray<TInt> config; |
|
437 config.Append (iToBitRate); //BitRate |
|
438 config.Append (iToSampleRate); //SamplingRate |
|
439 config.Append (0); //iToolFlags |
|
440 config.Append (iToChannels); //iNumChan |
|
441 |
|
442 // NOTE Ali: for 48kHz stereo we might need to use ADTS as output format |
|
443 // as we can get more than one frame in synchronous call! |
|
444 config.Append (0); //iuseFormat 0=RAW; 1=ADTS; 2=ADIF |
|
445 config.Append (0); // 0 = 1 Frame only; 1 = Full Buffer |
|
446 |
|
447 TUid uid ={KUidMmfCodecAudioSettings}; // Use Uid reserved for codec configurations |
|
448 iDestCodec->ConfigureL( uid, reinterpret_cast<TDesC8&>(config)); |
|
449 config.Close(); |
|
450 PRINT((_L("CProcEncoder::ConfigureAACEncoderL() out"))); |
|
451 } |
|
452 |
|
453 |
|
454 void CProcEncoder::ReAllocBufferL( CMMFDataBuffer* aBuffer, TInt aNewMaxSize ) |
|
455 { |
|
456 if ( aBuffer->Data().Length() ) |
|
457 { |
|
458 TInt position = aBuffer->Position(); |
|
459 TInt length = aBuffer->Data().Length(); |
|
460 HBufC8* oldData = aBuffer->Data().AllocL(); |
|
461 CleanupStack::PushL( oldData ); |
|
462 ((CMMFDescriptorBuffer*)aBuffer)->ReAllocBufferL( aNewMaxSize ); |
|
463 aBuffer->Data().Copy( *oldData ); |
|
464 CleanupStack::PopAndDestroy( oldData ); |
|
465 aBuffer->Data().SetLength( length ); |
|
466 aBuffer->SetPosition( position ); |
|
467 } |
|
468 else |
|
469 { |
|
470 ((CMMFDescriptorBuffer*)aBuffer)->ReAllocBufferL( aNewMaxSize ); |
|
471 } |
|
472 } |
|
473 |
|
474 void CProcEncoder::FeedCodecL( CMMFCodec* aCodec, CMMFDataBuffer* aSourceBuffer, CMMFDataBuffer* aDestBuffer ) |
|
475 { |
|
476 PRINT((_L("CProcEncoder::FeedCodecL() in"))); |
|
477 TBool completed = EFalse; |
|
478 TCodecProcessResult result; |
|
479 TInt aSrcUsed = 0; |
|
480 |
|
481 while ( !completed ) |
|
482 { |
|
483 |
|
484 // encode and check the result |
|
485 result = EncodeL(aCodec, aSourceBuffer, aDestBuffer); |
|
486 |
|
487 switch ( result.iStatus ) |
|
488 { |
|
489 case TCodecProcessResult::EProcessIncomplete: |
|
490 // Not all data from input was consumed (EncodeL updated buffer members), but output was generated |
|
491 |
|
492 iEncBuffer->Des().Append(aDestBuffer->Data()); |
|
493 iNumberOfFramesInOutputBuffer++; |
|
494 |
|
495 aDestBuffer->Data().SetLength( 0 ); |
|
496 aDestBuffer->SetPosition( 0 ); |
|
497 |
|
498 break; |
|
499 |
|
500 case TCodecProcessResult::EProcessComplete: |
|
501 // all data from input was used and output was generated |
|
502 |
|
503 iEncBuffer->Des().Append(aDestBuffer->Data()); |
|
504 |
|
505 iNumberOfFramesInOutputBuffer++; |
|
506 |
|
507 aDestBuffer->Data().SetLength( 0 ); |
|
508 aDestBuffer->SetPosition( 0 ); |
|
509 |
|
510 //completed = ETrue; |
|
511 |
|
512 break; |
|
513 |
|
514 case TCodecProcessResult::EDstNotFilled: |
|
515 // need more input data, can't fill the output yet; put it back to the empty queue |
|
516 //completed = ETrue; |
|
517 |
|
518 break; |
|
519 |
|
520 default: |
|
521 // EEndOfData, EProcessError, EProcessIncompleteRepositionRequest, EProcessCompleteRepositionRequest |
|
522 User::Leave( KErrUnknown ); |
|
523 } |
|
524 |
|
525 aSrcUsed += result.iSrcBytesProcessed; |
|
526 if (aSrcUsed >= (STATIC_CAST(CMMFDataBuffer*, aSourceBuffer)->Data().Length())) |
|
527 { |
|
528 PRINT((_L("CProcEncoder::FeedCodecL() ProcessL is completed aSrcUsed[%d]"), aSrcUsed)); |
|
529 completed = ETrue; |
|
530 } |
|
531 |
|
532 |
|
533 } |
|
534 |
|
535 PRINT((_L("CProcEncoder::FeedCodecL() out"))); |
|
536 } |
|
537 |
|
538 |
|
539 TBool CProcEncoder::GetIsSupportedDestCodec() |
|
540 { |
|
541 TFourCC fourCC; |
|
542 TUid euid; |
|
543 |
|
544 if (iAudioType == EAudAMR) |
|
545 { |
|
546 fourCC = TFourCC(KMMFFourCCCodeAMR); |
|
547 euid = KAedAMRNBEncSWCodecUid; |
|
548 } |
|
549 else if (iAudioType == EAudAAC_MPEG4 ) |
|
550 { |
|
551 fourCC = TFourCC(KMMFFourCCCodeAAC); |
|
552 euid = KAedAACEncSWCodecUid; |
|
553 } |
|
554 |
|
555 _LIT8(emptyFourCCString, " , "); |
|
556 TBufC8<9> fourCCString(emptyFourCCString); |
|
557 TPtr8 fourCCPtr = fourCCString.Des(); |
|
558 TPtr8 fourCCPtr1(&fourCCPtr[0], 4); |
|
559 TPtr8 fourCCPtr2(&fourCCPtr[5], 4 ); |
|
560 |
|
561 TFourCC srcFourCC(' ','P','1','6'); |
|
562 srcFourCC.FourCC(&fourCCPtr1); |
|
563 fourCC.FourCC(&fourCCPtr2); |
|
564 |
|
565 TBool found = EFalse; |
|
566 TRAPD( err, found = CheckIfCodecAvailableL( fourCCPtr, euid )); |
|
567 |
|
568 if (err == KErrNone) |
|
569 { |
|
570 return found; |
|
571 } |
|
572 else |
|
573 { |
|
574 return EFalse; |
|
575 } |
|
576 |
|
577 } |
|
578 |
|
579 |
|
580 void CProcEncoder::SetDestCodecL() |
|
581 { |
|
582 PRINT((_L("CProcEncoder::SetDestCodecL() in"))); |
|
583 |
|
584 if ( !GetIsSupportedDestCodec() ) |
|
585 { |
|
586 PRINT((_L("CProcEncoder::SetDestCodecL() error, unsupported codec"))); |
|
587 User::Leave( KErrNotSupported ); |
|
588 } |
|
589 |
|
590 if ( iDestCodec ) |
|
591 { |
|
592 delete iDestCodec; |
|
593 iDestCodec = NULL; |
|
594 } |
|
595 |
|
596 TUid euid = TUid::Null(); |
|
597 |
|
598 if (iAudioType == EAudAMR) |
|
599 { |
|
600 euid = KAedAMRNBEncSWCodecUid; |
|
601 } |
|
602 else if (iAudioType == EAudAAC_MPEG4 ) |
|
603 { |
|
604 euid = KAedAACEncSWCodecUid; |
|
605 } |
|
606 |
|
607 |
|
608 iDestCodec = CMMFCodec::NewL (euid); |
|
609 iReady = EFalse; |
|
610 |
|
611 PRINT((_L("CProcEncoder::SetDestCodecL() out"))); |
|
612 } |
|
613 |
|
614 |
|
615 TBool CProcEncoder::CheckIfCodecAvailableL( |
|
616 const TDesC8& aCodecFourCCString, const TUid& aCodecUId ) |
|
617 { |
|
618 PRINT((_L("CProcEncoder::CheckIfCodecAvailableL() in"))); |
|
619 TBool found = EFalse; |
|
620 |
|
621 // Create a TEcomResolverParams structure. |
|
622 TEComResolverParams resolverParams ; |
|
623 resolverParams.SetDataType( aCodecFourCCString ) ; |
|
624 resolverParams.SetWildcardMatch( EFalse ) ; |
|
625 |
|
626 RImplInfoPtrArray plugInArray ; // Array to return matching decoders in (place on cleanupstack _after_ ListImplementationsL() ) |
|
627 |
|
628 TUid UidMmfPluginInterfaceCodec = {KMmfUidPluginInterfaceCodec}; |
|
629 |
|
630 // ListImplementationsL leaves if it cannot find anything so trap the error and ignore it. |
|
631 TRAPD( err, REComSession::ListImplementationsL(UidMmfPluginInterfaceCodec, resolverParams, plugInArray ) ) ; |
|
632 CleanupResetAndDestroyPushL(plugInArray); |
|
633 |
|
634 if (err == KErrNone) |
|
635 { |
|
636 found = EFalse; |
|
637 for ( TInt i = 0; i < plugInArray.Count(); i++) |
|
638 { |
|
639 // there is a match, but 1st we need to ensure it is the one we have tested with, and that have compatible implementation of ConfigureL |
|
640 PRINT((_L("CProcEncoder::CheckIfCodecAvailable() plugin found with Uid 0x%x"), plugInArray[i]->ImplementationUid().iUid )); |
|
641 if ( plugInArray[i]->ImplementationUid() == aCodecUId ) |
|
642 { |
|
643 //match accepted |
|
644 PRINT((_L("CProcEncoder::CheckIfCodecAvailable() plugin accepted"))); |
|
645 found = ETrue; |
|
646 } |
|
647 } |
|
648 } |
|
649 else |
|
650 { |
|
651 PRINT((_L("CProcEncoder::CheckIfCodecAvailable() Error in ListImp.: %d"), err)); |
|
652 //no match |
|
653 found = EFalse; |
|
654 } |
|
655 |
|
656 |
|
657 CleanupStack::PopAndDestroy(); //plugInArray |
|
658 PRINT((_L("CProcEncoder::CheckIfCodecAvailableL() out"))); |
|
659 return found; |
|
660 } |
|
661 |
|
662 TCodecProcessResult CProcEncoder::EncodeL( CMMFCodec* aCodec, CMMFDataBuffer* aInBuffer, CMMFDataBuffer* aOutBuffer) |
|
663 { |
|
664 PRINT((_L("CProcEncoder::EncodeL() in, input pos: %d, length: %d"), aInBuffer->Position(), aInBuffer->Data().Length() )); |
|
665 TCodecProcessResult result; |
|
666 |
|
667 result = aCodec->ProcessL (*aInBuffer, *aOutBuffer); |
|
668 |
|
669 switch (result.iStatus) |
|
670 { |
|
671 case TCodecProcessResult::EProcessComplete: |
|
672 // finished processing source data, all data in sink buffer |
|
673 PRINT((_L("CProcEncoder::FeedCodecL() EProcessComplete"))); |
|
674 aInBuffer->SetPosition( 0 ); |
|
675 aInBuffer->Data().SetLength(0); |
|
676 break; |
|
677 |
|
678 case TCodecProcessResult::EDstNotFilled: |
|
679 // the destination is not full, we need more data. Handled in caller |
|
680 PRINT((_L("CProcEncoder::FeedCodecL() EDstNotFilled"))); |
|
681 aInBuffer->SetPosition( 0 ); |
|
682 aInBuffer->Data().SetLength(0); |
|
683 break; |
|
684 |
|
685 case TCodecProcessResult::EProcessIncomplete: |
|
686 // the sink was filled before all the source was processed |
|
687 PRINT((_L("CProcEncoder::FeedCodecL() EProcessIncomplete"))); |
|
688 aOutBuffer->SetPosition( 0 ); |
|
689 aInBuffer->SetPosition( aInBuffer->Position() + result.iSrcBytesProcessed ); |
|
690 break; |
|
691 |
|
692 default: |
|
693 break; |
|
694 } |
|
695 |
|
696 |
|
697 |
|
698 PRINT((_L("CProcEncoder::EncodeL() out, %d -> %d"),result.iSrcBytesProcessed, result.iDstBytesAdded)); |
|
699 PRINT((_L("CProcEncoder::EncodeL() out, input pos: %d, length: %d"), aInBuffer->Position(), aInBuffer->Data().Length() )); |
|
700 return result; |
|
701 } |
|
702 |
|