/
OMX_AacEncoder.c
2373 lines (2067 loc) · 95.6 KB
/
OMX_AacEncoder.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) Texas Instruments - http://www.ti.com/
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* ==============================================================================
* Texas Instruments OMAP (TM) Platform Software
* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
*
* Use of this software is controlled by the terms and conditions found
* in the license agreement under which this software has been supplied.
* ============================================================================ */
/**
* @file OMX_AacEncoder.c
*
* This file implements OMX Component for AAC Encoder that
* is fully compliant with the OMX Audio specification 1.5.
*
* @path $(CSLPATH)\
*
* @rev 1.0
*/
/* ----------------------------------------------------------------------------
*!
*! Revision History
*! ===================================
*! 13-Enc-2005 mf: Initial Version. Change required per OMAPSWxxxxxxxxx
*! to provide _________________.
*!
* ============================================================================= */
/* ------compilation control switches -------------------------*/
/****************************************************************
* INCLUDE FILES
****************************************************************/
/* ----- system and platform files ----------------------------*/
#ifdef UNDER_CE
#include <windows.h>
#include <oaf_osal.h>
#include <omx_core.h>
#else
#include <wchar.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <errno.h>
#include <pthread.h>
#endif
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <dbapi.h>
#include <dlfcn.h>
/*-------program files ----------------------------------------*/
#include "LCML_DspCodec.h"
#ifndef UNDER_CE
#ifdef DSP_RENDERING_ON
#include <AudioManagerAPI.h>
#endif
#endif
#ifdef RESOURCE_MANAGER_ENABLED
#include <ResourceManagerProxyAPI.h>
#endif
#include "OMX_AacEncoder.h"
#define AAC_ENC_ROLE "audio_encoder.aac"
#include "OMX_AacEnc_Utils.h"
#include <TIDspOmx.h>
/****************************************************************
* EXTERNAL REFERENCES NOTE : only use if not found in header file
****************************************************************/
/*--------data declarations -----------------------------------*/
/*--------function prototypes ---------------------------------*/
/****************************************************************
* PUBLIC DECLARATIONS Defined here, used elsewhere
****************************************************************/
/*--------data declarations -----------------------------------*/
/*--------function prototypes ---------------------------------*/
/****************************************************************
* PRIVATE DECLARATIONS Defined here, used only here
****************************************************************/
/*--------data declarations -----------------------------------*/
/*--------function prototypes ---------------------------------*/
static OMX_ERRORTYPE SetCallbacks(OMX_HANDLETYPE hComp, OMX_CALLBACKTYPE* pCallBacks, OMX_PTR pAppData);
static OMX_ERRORTYPE GetComponentVersion(OMX_HANDLETYPE hComp, OMX_STRING pComponentName, OMX_VERSIONTYPE* pComponentVersion, OMX_VERSIONTYPE* pSpecVersion, OMX_UUIDTYPE* pComponentUUID);
static OMX_ERRORTYPE SendCommand(OMX_HANDLETYPE hComp, OMX_COMMANDTYPE nCommand, OMX_U32 nParam,OMX_PTR pCmdData);
static OMX_ERRORTYPE GetParameter(OMX_HANDLETYPE hComp, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParamStruct);
static OMX_ERRORTYPE SetParameter(OMX_HANDLETYPE hComp, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParamStruct);
static OMX_ERRORTYPE GetConfig(OMX_HANDLETYPE hComp, OMX_INDEXTYPE nConfigIndex, OMX_PTR pComponentConfigStructure);
static OMX_ERRORTYPE SetConfig(OMX_HANDLETYPE hComp, OMX_INDEXTYPE nConfigIndex, OMX_PTR pComponentConfigStructure);
static OMX_ERRORTYPE EmptyThisBuffer(OMX_HANDLETYPE hComp, OMX_BUFFERHEADERTYPE* pBuffer);
static OMX_ERRORTYPE FillThisBuffer(OMX_HANDLETYPE hComp, OMX_BUFFERHEADERTYPE* pBuffer);
static OMX_ERRORTYPE GetState(OMX_HANDLETYPE hComp, OMX_STATETYPE* pState);
static OMX_ERRORTYPE ComponentTunnelRequest(OMX_HANDLETYPE hComp, OMX_U32 nPort, OMX_HANDLETYPE hTunneledComp, OMX_U32 nTunneledPort, OMX_TUNNELSETUPTYPE* pTunnelSetup);
static OMX_ERRORTYPE ComponentDeInit(OMX_HANDLETYPE pHandle);
static OMX_ERRORTYPE AllocateBuffer(OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes);
static OMX_ERRORTYPE FreeBuffer(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
static OMX_ERRORTYPE UseBuffer(OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes, OMX_IN OMX_U8* pBuffer);
static OMX_ERRORTYPE GetExtensionIndex(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE* pIndexType);
static OMX_ERRORTYPE ComponentRoleEnum( OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_U8 *cRole,
OMX_IN OMX_U32 nIndex);
#ifdef DSP_RENDERING_ON
/* interface with audio manager*/
#define FIFO1 "/dev/fifo.1"
#define FIFO2 "/dev/fifo.2"
int Aacenc_fdwrite, Aacenc_fdread;
#ifndef UNDER_CE
AM_COMMANDDATATYPE cmd_data;
#endif
#define PERMS 0666
int errno;
#endif
/*-------------------------------------------------------------------*/
/**
* OMX_ComponentInit() Set the all the function pointers of component
*
* This method will update the component function pointer to the handle
*
* @param hComp handle for this instance of the component
*
* @retval OMX_NoError Success, ready to roll
* OMX_ErrorInsufficientResources If the malloc fails
**/
/*-------------------------------------------------------------------*/
OMX_ERRORTYPE OMX_ComponentInit (OMX_HANDLETYPE hComp)
{
OMX_ERRORTYPE rm_error = OMX_ErrorNone;
OMX_ERRORTYPE eError = OMX_ErrorNone;
OMX_PARAM_PORTDEFINITIONTYPE *pPortDef_ip = NULL;
OMX_PARAM_PORTDEFINITIONTYPE *pPortDef_op = NULL;
AACENC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
OMX_AUDIO_PARAM_AACPROFILETYPE *aac_ip = NULL;
OMX_AUDIO_PARAM_AACPROFILETYPE *aac_op = NULL;
OMX_CONF_CHECK_CMD(hComp, 1, 1); /* checking for NULL pointers */
OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*) hComp;
OMX_AUDIO_PARAM_PCMMODETYPE *aac_pcm_ip = NULL;
OMX_AUDIO_PARAM_PCMMODETYPE *aac_pcm_op = NULL;
int i;
/*Set the all component function pointer to the handle*/
pHandle->SetCallbacks = SetCallbacks;
pHandle->GetComponentVersion = GetComponentVersion;
pHandle->SendCommand = SendCommand;
pHandle->GetParameter = GetParameter;
pHandle->GetExtensionIndex = GetExtensionIndex;
pHandle->SetParameter = SetParameter;
pHandle->GetConfig = GetConfig;
pHandle->SetConfig = SetConfig;
pHandle->GetState = GetState;
pHandle->EmptyThisBuffer = EmptyThisBuffer;
pHandle->FillThisBuffer = FillThisBuffer;
pHandle->ComponentTunnelRequest = ComponentTunnelRequest;
pHandle->ComponentDeInit = ComponentDeInit;
pHandle->AllocateBuffer = AllocateBuffer;
pHandle->FreeBuffer = FreeBuffer;
pHandle->UseBuffer = UseBuffer;
pHandle->ComponentRoleEnum = ComponentRoleEnum;
OMX_MALLOC_GENERIC(pHandle->pComponentPrivate, AACENC_COMPONENT_PRIVATE);
((AACENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->pHandle = pHandle;
/* Initialize component data structures to default values */
((AACENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->sPortParam.nPorts = 0x2;
((AACENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->sPortParam.nStartPortNumber = 0x0;
/* ---------start of OMX_AUDIO_PARAM_AACPROFILETYPE --------- */
OMX_MALLOC_GENERIC(aac_ip, OMX_AUDIO_PARAM_AACPROFILETYPE);
OMX_MALLOC_GENERIC(aac_op, OMX_AUDIO_PARAM_AACPROFILETYPE);
((AACENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->aacParams[INPUT_PORT] = aac_ip;
((AACENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->aacParams[OUTPUT_PORT] = aac_op;
aac_op->nSize = sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE);
aac_op->nChannels = 2;
aac_op->nSampleRate = 44100;
aac_op->eAACProfile = OMX_AUDIO_AACObjectLC;
aac_op->eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS; /* For khronos only : should be MP4ADTS*/
aac_op->nBitRate = 128000;
aac_op->eChannelMode = OMX_AUDIO_ChannelModeStereo;
aac_op->nPortIndex = 1;
aac_op->nFrameLength = 0;
aac_op->nAudioBandWidth = 0;
/* ---------end of MX_AUDIO_PARAM_AACPROFILETYPE --------- */
/* ---------start of OMX_AUDIO_PARAM_PCMMODETYPE --------- */
OMX_MALLOC_GENERIC(aac_pcm_ip, OMX_AUDIO_PARAM_PCMMODETYPE);
OMX_MALLOC_GENERIC(aac_pcm_op, OMX_AUDIO_PARAM_PCMMODETYPE);
aac_pcm_ip->nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
aac_pcm_ip->nBitPerSample = 16; /*Will be remapped for SN. 16:2, 24:3*/
aac_pcm_ip->nPortIndex = 0;
aac_pcm_ip->nChannels = 1; /*Will be remapped for SN. 0:mono, 1:stereo*/
aac_pcm_ip->eNumData = OMX_NumericalDataSigned;
aac_pcm_ip->nSamplingRate = 8000;
aac_pcm_ip->ePCMMode = OMX_AUDIO_PCMModeLinear;
aac_pcm_ip->bInterleaved = OMX_TRUE;
((AACENC_COMPONENT_PRIVATE*) pHandle->pComponentPrivate)->pcmParam[INPUT_PORT] = aac_pcm_ip;
((AACENC_COMPONENT_PRIVATE*) pHandle->pComponentPrivate)->pcmParam[OUTPUT_PORT] = aac_pcm_op;
/* ---------end of OMX_AUDIO_PARAM_PCMMODETYPE --------- */
pComponentPrivate = pHandle->pComponentPrivate;
OMX_DBG_INIT(pComponentPrivate->dbg, "OMX_DBG_AACENC");
#ifdef ANDROID /* leave this now, we may need them later. */
pComponentPrivate->iPVCapabilityFlags.iIsOMXComponentMultiThreaded = OMX_TRUE;
pComponentPrivate->iPVCapabilityFlags.iOMXComponentNeedsNALStartCode = OMX_FALSE;
pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsExternalOutputBufferAlloc = OMX_FALSE;
pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsExternalInputBufferAlloc = OMX_FALSE;
pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsMovableInputBuffers = OMX_FALSE;
pComponentPrivate->iPVCapabilityFlags.iOMXComponentSupportsPartialFrames = OMX_TRUE;
pComponentPrivate->iPVCapabilityFlags.iOMXComponentCanHandleIncompleteFrames = OMX_TRUE;
#endif
#ifdef __PERF_INSTRUMENTATION__
pComponentPrivate->pPERF = PERF_Create(PERF_FOURCC('A','A','E','_'),
PERF_ModuleLLMM |
PERF_ModuleAudioDecode);
#endif
OMX_MALLOC_GENERIC(pComponentPrivate->pInputBufferList, BUFFERLIST);
OMX_PRBUFFER2(pComponentPrivate->dbg, "AACENC: pInputBufferList %p\n ", pComponentPrivate->pInputBufferList);
pComponentPrivate->pInputBufferList->numBuffers = 0; /* initialize number of buffers */
OMX_MALLOC_GENERIC(pComponentPrivate->pOutputBufferList, BUFFERLIST);
pComponentPrivate->pOutputBufferList->numBuffers = 0; /* initialize number of buffers */
OMX_PRBUFFER2(pComponentPrivate->dbg, "AACENC: pOutputBufferList %p\n ", pComponentPrivate->pOutputBufferList);
for (i=0; i < MAX_NUM_OF_BUFS; i++)
{
pComponentPrivate->pOutputBufferList->pBufHdr[i] = NULL;
pComponentPrivate->pInputBufferList->pBufHdr[i] = NULL;
pComponentPrivate->tickcountBufIndex[i] = 0;
pComponentPrivate->timestampBufIndex[i] = 0;
}
pComponentPrivate->IpBufindex = 0;
pComponentPrivate->OpBufindex = 0;
OMX_MALLOC_SIZE(pComponentPrivate->sDeviceString, 100*sizeof(OMX_STRING), void);
/* Initialize device string to the default value */
strcpy((char*)pComponentPrivate->sDeviceString,"/rtmdn:i2:o1/codec\0");
/*Safety value for frames per output buffer ( for Khronos) */
pComponentPrivate->FramesPer_OutputBuffer = 1;
pComponentPrivate->CustomConfiguration = OMX_FALSE;
pComponentPrivate->dasfmode = 0;
pComponentPrivate->unNumChannels = 2;
pComponentPrivate->ulSamplingRate = 44100;
pComponentPrivate->unBitrate = 128000;
pComponentPrivate->nObjectType = 2;
pComponentPrivate->bitRateMode = 0;
pComponentPrivate->File_Format = 2;
pComponentPrivate->EmptybufferdoneCount = 0;
pComponentPrivate->EmptythisbufferCount = 0;
pComponentPrivate->FillbufferdoneCount = 0;
pComponentPrivate->FillthisbufferCount = 0;
pComponentPrivate->bPortDefsAllocated = 0;
pComponentPrivate->bCompThreadStarted = 0;
pComponentPrivate->bPlayCompleteFlag = 0;
OMX_PRINT2(pComponentPrivate->dbg, "%d :: AACENC: pComponentPrivate->bPlayCompleteFlag = %ld\n",__LINE__,pComponentPrivate->bPlayCompleteFlag);
pComponentPrivate->strmAttr = NULL;
pComponentPrivate->pMarkBuf = NULL;
pComponentPrivate->pMarkData = NULL;
pComponentPrivate->pParams = NULL;
pComponentPrivate->ptAlgDynParams = NULL;
pComponentPrivate->LastOutputBufferHdrQueued = NULL;
pComponentPrivate->bDspStoppedWhileExecuting = OMX_FALSE;
pComponentPrivate->nOutStandingEmptyDones = 0;
pComponentPrivate->nOutStandingFillDones = 0;
pComponentPrivate->bPauseCommandPending = OMX_FALSE;
pComponentPrivate->bEnableCommandPending = 0;
pComponentPrivate->bDisableCommandPending = 0;
pComponentPrivate->nNumOutputBufPending = 0;
pComponentPrivate->bLoadedCommandPending = OMX_FALSE;
pComponentPrivate->bFirstOutputBuffer = 1;
pComponentPrivate->nUnhandledFillThisBuffers=0;
pComponentPrivate->nUnhandledEmptyThisBuffers = 0;
pComponentPrivate->bFlushOutputPortCommandPending = OMX_FALSE;
pComponentPrivate->bFlushInputPortCommandPending = OMX_FALSE;
pComponentPrivate->nNumInputBufPending = 0;
pComponentPrivate->nNumOutputBufPending = 0;
pComponentPrivate->PendingInPausedBufs = 0;
pComponentPrivate->PendingOutPausedBufs = 0;
/* Port format type */
pComponentPrivate->sOutPortFormat.eEncoding = OMX_AUDIO_CodingAAC;
pComponentPrivate->sOutPortFormat.nIndex = 0;/*OMX_IndexParamAudioAac;*/
pComponentPrivate->sOutPortFormat.nPortIndex = OUTPUT_PORT;
pComponentPrivate->sInPortFormat.eEncoding = OMX_AUDIO_CodingPCM;
pComponentPrivate->sInPortFormat.nIndex = 1;/*OMX_IndexParamAudioPcm; */
pComponentPrivate->sInPortFormat.nPortIndex = INPUT_PORT;
/*flags that control LCML closing*/
pComponentPrivate->ptrLibLCML = NULL;
pComponentPrivate->bGotLCML = OMX_FALSE;
pComponentPrivate->bCodecDestroyed = OMX_FALSE;
/* initialize role name */
strcpy((char *)pComponentPrivate->componentRole.cRole, "audio_encoder.aac");
#ifndef UNDER_CE
pthread_mutex_init(&pComponentPrivate->AlloBuf_mutex, NULL);
pthread_cond_init (&pComponentPrivate->AlloBuf_threshold, NULL);
pComponentPrivate->AlloBuf_waitingsignal = 0;
pthread_mutex_init(&pComponentPrivate->codecStop_mutex, NULL);
pthread_cond_init (&pComponentPrivate->codecStop_threshold, NULL);
pComponentPrivate->codecStop_waitingsignal = 0;
pthread_mutex_init(&pComponentPrivate->codecFlush_mutex, NULL);
pthread_cond_init (&pComponentPrivate->codecFlush_threshold, NULL);
pComponentPrivate->codecFlush_waitingsignal = 0;
pthread_mutex_init(&pComponentPrivate->InLoaded_mutex, NULL);
pthread_cond_init (&pComponentPrivate->InLoaded_threshold, NULL);
pComponentPrivate->InLoaded_readytoidle = 0;
pthread_mutex_init(&pComponentPrivate->InIdle_mutex, NULL);
pthread_cond_init (&pComponentPrivate->InIdle_threshold, NULL);
pComponentPrivate->InIdle_goingtoloaded = 0;
pthread_mutex_init(&bufferReturned_mutex, NULL);
pthread_cond_init (&bufferReturned_condition, NULL);
#else
OMX_CreateEvent(&(pComponentPrivate->AlloBuf_event));
pComponentPrivate->AlloBuf_waitingsignal = 0;
OMX_CreateEvent(&(pComponentPrivate->InLoaded_event));
pComponentPrivate->InLoaded_readytoidle = 0;
OMX_CreateEvent(&(pComponentPrivate->InIdle_event));
pComponentPrivate->InIdle_goingtoloaded = 0;
#endif
/* port definition, input port */
OMX_MALLOC_GENERIC(pPortDef_ip, OMX_PARAM_PORTDEFINITIONTYPE);
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: pPortDef_ip %p \n",pPortDef_ip );
/* port definition, output port */
OMX_MALLOC_GENERIC(pPortDef_op, OMX_PARAM_PORTDEFINITIONTYPE);
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: pPortDef_op %p, size: %x \n",pPortDef_op, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
((AACENC_COMPONENT_PRIVATE*) pHandle->pComponentPrivate)->pPortDef[INPUT_PORT] = pPortDef_ip;
((AACENC_COMPONENT_PRIVATE*) pHandle->pComponentPrivate)->pPortDef[OUTPUT_PORT] = pPortDef_op;
pPortDef_ip->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
pPortDef_ip->nPortIndex = 0x0;
pPortDef_ip->nBufferCountActual = NUM_AACENC_INPUT_BUFFERS;
pPortDef_ip->nBufferCountMin = NUM_AACENC_INPUT_BUFFERS;
pPortDef_ip->eDir = OMX_DirInput;
pPortDef_ip->bEnabled = OMX_TRUE;
pPortDef_ip->nBufferSize = INPUT_AACENC_BUFFER_SIZE;
pPortDef_ip->nBufferAlignment = DSP_CACHE_ALIGNMENT;
pPortDef_ip->bPopulated = 0;
pPortDef_ip->format.audio.eEncoding =OMX_AUDIO_CodingPCM;
pPortDef_ip->eDomain = OMX_PortDomainAudio;
pPortDef_op->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
pPortDef_op->nPortIndex = 0x1;
pPortDef_op->nBufferCountActual = NUM_AACENC_OUTPUT_BUFFERS;
pPortDef_op->nBufferCountMin = NUM_AACENC_OUTPUT_BUFFERS;
pPortDef_op->eDir = OMX_DirOutput;
pPortDef_op->bEnabled = OMX_TRUE;
pPortDef_op->nBufferSize = OUTPUT_AACENC_BUFFER_SIZE;
pPortDef_op->nBufferAlignment = DSP_CACHE_ALIGNMENT;
pPortDef_op->bPopulated = 0;
pPortDef_op->format.audio.eEncoding = OMX_AUDIO_CodingAAC;
pPortDef_op->eDomain = OMX_PortDomainAudio;
pComponentPrivate->bIsInvalidState = OMX_FALSE;
pComponentPrivate->bPreempted = OMX_FALSE;
#ifdef RESOURCE_MANAGER_ENABLED
/* start Resource Manager Proxy */
eError = RMProxy_NewInitalize();
if (eError != OMX_ErrorNone)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error returned from loading ResourceManagerProxy thread\n",__LINE__);
goto EXIT;
}
pComponentPrivate->rmproxyCallback.RMPROXY_Callback = (void *) AACENC_ResourceManagerCallback;
rm_error = RMProxy_NewSendCommand(pHandle, RMProxy_RequestResource, OMX_AAC_Encoder_COMPONENT,AACENC_CPU_USAGE, 3456, &(pComponentPrivate->rmproxyCallback));
if (rm_error != OMX_ErrorNone) {
RMProxy_NewSendCommand(pHandle, RMProxy_FreeResource, OMX_AAC_Encoder_COMPONENT, 0, 3456, NULL);
RMProxy_Deinitalize();
eError = OMX_ErrorInsufficientResources;
goto EXIT;
}
#endif
#ifndef UNDER_CE
#ifdef DSP_RENDERING_ON
/* start Audio Manager to get streamId */
if((Aacenc_fdwrite=open(FIFO1,O_WRONLY))<0)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: [AAC Encoder Component] - failure to open WRITE pipe\n",__LINE__);
}
if((Aacenc_fdread=open(FIFO2,O_RDONLY))<0)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: [AAC Encoder Component] - failure to open READ pipe\n",__LINE__);
}
#endif
#endif
eError = AACENC_StartComponentThread(pHandle);
if (eError != OMX_ErrorNone)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error returned from the Component\n",__LINE__);
goto EXIT;
}
#ifdef __PERF_INSTRUMENTATION__
PERF_ThreadCreated(pComponentPrivate->pPERF, pComponentPrivate->ComponentThread,
PERF_FOURCC('A','A','E','T'));
#endif
if(pthread_mutex_init(&pComponentPrivate->mutexStateChangeRequest, NULL)) {
return OMX_ErrorUndefined;
}
if(pthread_cond_init (&pComponentPrivate->StateChangeCondition, NULL)) {
return OMX_ErrorUndefined;
}
pComponentPrivate->nPendingStateChangeRequests = 0;
EXIT:
if (pComponentPrivate != NULL) {
OMX_PRINT2(pComponentPrivate->dbg, "%d :: AACENC: Exiting OMX_ComponentInit\n", __LINE__);
}
return eError;
}
/*-------------------------------------------------------------------*/
/**
* SetCallbacks() Sets application callbacks to the component
*
* This method will update application callbacks
* to the component. So that component can make use of those call back
* while sending buffers to the application. And also it will copy the
* application private data to component memory
*
* @param pComponent handle for this instance of the component
* @param pCallBacks application callbacks
* @param pAppData Application private data
*
* @retval OMX_NoError Success, ready to roll
* OMX_Error_BadParameter The input parameter pointer is null
**/
/*-------------------------------------------------------------------*/
static OMX_ERRORTYPE SetCallbacks (OMX_HANDLETYPE pComponent,
OMX_CALLBACKTYPE* pCallBacks,
OMX_PTR pAppData)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
AACENC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
OMX_CONF_CHECK_CMD(pComponent,1,1); /* Checking for NULL pointers: pAppData is NULL for Khronos */
OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*)pComponent;
pComponentPrivate = (AACENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
OMX_PRINT1(pComponentPrivate->dbg, "%d :: AACENC: Entering SetCallbacks\n", __LINE__);
if (pCallBacks == NULL)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: About to return OMX_ErrorBadParameter\n",__LINE__);
eError = OMX_ErrorBadParameter;
OMX_ERROR2(pComponentPrivate->dbg, "%d :: Received the empty callbacks from the application\n",__LINE__);
goto EXIT;
}
/*Copy the callbacks of the application to the component private*/
memcpy (&(pComponentPrivate->cbInfo), pCallBacks, sizeof(OMX_CALLBACKTYPE));
/*copy the application private data to component memory */
pHandle->pApplicationPrivate = pAppData;
pComponentPrivate->curState = OMX_StateLoaded;
EXIT:
if (pComponentPrivate != NULL) {
OMX_PRINT1(pComponentPrivate->dbg, "%d :: AACENC: Exiting SetCallbacks\n", __LINE__);
}
return eError;
}
/*-------------------------------------------------------------------*/
/**
* GetComponentVersion() This will return the component version
*
* This method will retrun the component version
*
* @param hComp handle for this instance of the component
* @param pCompnentName Name of the component
* @param pCompnentVersion handle for this instance of the component
* @param pSpecVersion application callbacks
* @param pCompnentUUID
*
* @retval OMX_NoError Success, ready to roll
* OMX_Error_BadParameter The input parameter pointer is null
**/
/*-------------------------------------------------------------------*/
static OMX_ERRORTYPE GetComponentVersion (OMX_HANDLETYPE hComp,
OMX_STRING pComponentName,
OMX_VERSIONTYPE* pComponentVersion,
OMX_VERSIONTYPE* pSpecVersion,
OMX_UUIDTYPE* pComponentUUID)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE*) hComp;
AACENC_COMPONENT_PRIVATE *pComponentPrivate = (AACENC_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
OMX_PRINT1(pComponentPrivate->dbg, "%d :: AACENC: Entering GetComponentVersion\n", __LINE__);
#ifdef _ERROR_PROPAGATION__
if (pComponentPrivate->curState == OMX_StateInvalid)
{
eError = OMX_ErrorInvalidState;
goto EXIT;
}
#endif
/* Copy component version structure */
if(pComponentVersion != NULL && pComponentName != NULL)
{
strcpy(pComponentName, pComponentPrivate->cComponentName);
memcpy(pComponentVersion, &(pComponentPrivate->ComponentVersion.s), sizeof(pComponentPrivate->ComponentVersion.s));
}
else
{
eError = OMX_ErrorBadParameter;
}
EXIT:
OMX_PRINT1(pComponentPrivate->dbg, "%d :: AACENC: Exiting GetComponentVersion\n", __LINE__);
return eError;
}
/*-------------------------------------------------------------------*/
/**
* SendCommand() used to send the commands to the component
*
* This method will be used by the application.
*
* @param phandle handle for this instance of the component
* @param Cmd Command to be sent to the component
* @param nParam indicates commmad is sent using this method
*
* @retval OMX_NoError Success, ready to roll
* OMX_Error_BadParameter The input parameter pointer is null
**/
/*-------------------------------------------------------------------*/
static OMX_ERRORTYPE SendCommand (OMX_HANDLETYPE phandle,
OMX_COMMANDTYPE Cmd,
OMX_U32 nParam,OMX_PTR pCmdData)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
AACENC_COMPONENT_PRIVATE *pCompPrivate = NULL;
OMX_CONF_CHECK_CMD(phandle,1,1); /*NOTE: Cmd, pCmdData, nParam are NULL for khronos*/
int nRet = 0;
OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *)phandle;
pCompPrivate = (AACENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate;
#ifdef _ERROR_PROPAGATION__
if (pCompPrivate->curState == OMX_StateInvalid)
{
eError = OMX_ErrorInvalidState;
goto EXIT;
}
#else
OMX_PRINT1(pCompPrivate->dbg, "%d :: AACENC: Entering SendCommand()\n", __LINE__);
if(pCompPrivate->curState == OMX_StateInvalid)
{
OMX_PRINT1(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand\n",__LINE__);
eError = OMX_ErrorInvalidState;
OMX_ERROR4(pCompPrivate->dbg, "%d :: Error Notofication Sent to App\n",__LINE__);
pCompPrivate->cbInfo.EventHandler(pHandle, pHandle->pApplicationPrivate,
OMX_EventError,
OMX_ErrorInvalidState,
OMX_TI_ErrorMinor,
"Invalid State");
goto EXIT;
}
#endif
#ifdef __PERF_INSTRUMENTATION__
PERF_SendingCommand(pCompPrivate->pPERF,Cmd,
(Cmd == OMX_CommandMarkBuffer) ? ((OMX_U32) pCmdData) : nParam,
PERF_ModuleComponent);
#endif
switch(Cmd)
{
case OMX_CommandStateSet:
if (nParam == OMX_StateLoaded)
{
pCompPrivate->bLoadedCommandPending = OMX_TRUE;
}
OMX_PRINT1(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand\n",__LINE__);
OMX_PRSTATE1(pCompPrivate->dbg, "%d :: AACENC: pCompPrivate->curState = %d\n",__LINE__,pCompPrivate->curState);
if(pCompPrivate->curState == OMX_StateLoaded)
{
if((nParam == OMX_StateExecuting) || (nParam == OMX_StatePause))
{
pCompPrivate->cbInfo.EventHandler(pHandle,
pHandle->pApplicationPrivate,
OMX_EventError,
OMX_ErrorIncorrectStateTransition,
OMX_TI_ErrorMinor,
NULL);
goto EXIT;
}
if(nParam == OMX_StateInvalid)
{
OMX_PRINT1(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand\n",__LINE__);
OMX_PRSTATE2(pCompPrivate->dbg, "AACENC: State changed to OMX_StateInvalid Line %d\n",__LINE__);
pCompPrivate->curState = OMX_StateInvalid;
pCompPrivate->cbInfo.EventHandler(pHandle,
pHandle->pApplicationPrivate,
OMX_EventError,
OMX_ErrorInvalidState,
OMX_TI_ErrorMinor,
NULL);
goto EXIT;
}
}
/* Add a pending transition */
if(AddStateTransition(pCompPrivate) != OMX_ErrorNone) {
return OMX_ErrorUndefined;
}
break;
case OMX_CommandFlush:
OMX_PRINT1(pCompPrivate->dbg, "%d :: IAACENC: nside SendCommand\n",__LINE__);
if(nParam > 1 && nParam != -1)
{
eError = OMX_ErrorBadPortIndex;
goto EXIT;
}
break;
case OMX_CommandPortDisable:
OMX_PRDSP2(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand OMX_CommandPortDisable\n",__LINE__);
break;
case OMX_CommandPortEnable:
OMX_PRDSP2(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand OMX_CommandPortEnable\n",__LINE__);
break;
case OMX_CommandMarkBuffer:
OMX_PRDSP2(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand OMX_CommandMarkBuffer\n",__LINE__);
if (nParam > 0)
{
eError = OMX_ErrorBadPortIndex;
goto EXIT;
}
break;
default:
OMX_ERROR4(pCompPrivate->dbg, "%d :: Error: Command Received Default error\n",__LINE__);
pCompPrivate->cbInfo.EventHandler(pHandle, pHandle->pApplicationPrivate,
OMX_EventError,
OMX_ErrorBadParameter,
OMX_TI_ErrorMinor,
"Invalid Command");
break;
}
OMX_PRINT1(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand\n",__LINE__);
nRet = write (pCompPrivate->cmdPipe[1], &Cmd, sizeof(Cmd));
OMX_PRCOMM2(pCompPrivate->dbg, "%d :: AACENC: Cmd pipe has been writen. nRet = %d \n",__LINE__,nRet);
OMX_PRCOMM2(pCompPrivate->dbg, "%d :: AACENC: pCompPrivate->cmdPipe[1] = %d \n",__LINE__,pCompPrivate->cmdPipe[1]);
OMX_PRCOMM2(pCompPrivate->dbg, "%d :: AACENC: &Cmd = %p \n",__LINE__,&Cmd);
if (nRet == -1)
{
OMX_PRINT1(pCompPrivate->dbg, "%d :: AACENC: Inside SendCommand\n",__LINE__);
eError = OMX_ErrorInsufficientResources;
goto EXIT;
}
if (Cmd == OMX_CommandMarkBuffer)
{
nRet = write(pCompPrivate->cmdDataPipe[1], &pCmdData, sizeof(OMX_PTR));
}
else
{
nRet = write(pCompPrivate->cmdDataPipe[1], &nParam, sizeof(OMX_U32));
}
if (nRet == -1) {
OMX_ERROR4(pCompPrivate->dbg, "%d :: OMX_ErrorInsufficientResources from SendCommand",__LINE__);
if(Cmd == OMX_CommandStateSet) {
if(RemoveStateTransition(pCompPrivate, OMX_FALSE) != OMX_ErrorNone) {
return OMX_ErrorUndefined;
}
}
return OMX_ErrorInsufficientResources;
}
EXIT:
if (pCompPrivate != NULL) {
OMX_PRINT1(pCompPrivate->dbg, "%d :: AACENC: Exiting SendCommand()\n", __LINE__);
}
return eError;
}
/*-------------------------------------------------------------------*/
/**
* GetParameter() Gets the current configurations of the component
*
* @param hComp handle for this instance of the component
* @param nParamIndex
* @param ComponentParameterStructure
*
* @retval OMX_NoError Success, ready to roll
* OMX_Error_BadParameter The input parameter pointer is null
**/
/*-------------------------------------------------------------------*/
static OMX_ERRORTYPE GetParameter (OMX_HANDLETYPE hComp, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
AACENC_COMPONENT_PRIVATE *pComponentPrivate = NULL;
OMX_CONF_CHECK_CMD(hComp, 1, 1);
OMX_PARAM_PORTDEFINITIONTYPE *pParameterStructure = NULL;
pComponentPrivate = (AACENC_COMPONENT_PRIVATE *)(((OMX_COMPONENTTYPE*)hComp)->pComponentPrivate);
OMX_PRINT1 (pComponentPrivate->dbg, "%d :: AACENC: Entering GetParameter\n", __LINE__);
pParameterStructure = (OMX_PARAM_PORTDEFINITIONTYPE*)ComponentParameterStructure;
if (pParameterStructure == NULL)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: OMX_ErrorBadParameter Inside the GetParameter Line\n",__LINE__);
eError = OMX_ErrorBadParameter;
goto EXIT;
}
#ifdef _ERROR_PROPAGATION__
if (pComponentPrivate->curState == OMX_StateInvalid)
{
eError = OMX_ErrorInvalidState;
goto EXIT;
}
#else
if(pComponentPrivate->curState == OMX_StateInvalid)
{
pComponentPrivate->cbInfo.EventHandler(hComp,
((OMX_COMPONENTTYPE *)hComp)->pApplicationPrivate,
OMX_EventError,
OMX_ErrorIncorrectStateOperation,
OMX_TI_ErrorMinor,
"Invalid State");
OMX_ERROR4(pComponentPrivate->dbg, "%d :: AACENC: Inside the GetParameter Line\n",__LINE__);
}
#endif
switch(nParamIndex)
{
case OMX_IndexParamAudioInit:
memcpy(ComponentParameterStructure, &pComponentPrivate->sPortParam, sizeof(OMX_PORT_PARAM_TYPE));
break;
case OMX_IndexParamPortDefinition:
if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pPortDef[INPUT_PORT]->nPortIndex)
{
OMX_PRDSP2(pComponentPrivate->dbg, "%d :: AACENC: Inside the GetParameter Line\n",__LINE__);
memcpy(ComponentParameterStructure,pComponentPrivate->pPortDef[INPUT_PORT], sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
}
else if(((OMX_PARAM_PORTDEFINITIONTYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pPortDef[OUTPUT_PORT]->nPortIndex)
{
memcpy(ComponentParameterStructure, pComponentPrivate->pPortDef[OUTPUT_PORT], sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
OMX_PRDSP1(pComponentPrivate->dbg, "%d :: AACENC: Inside the GetParameter \n",__LINE__);
}
else
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: BadPortIndex Inside the GetParameter \n",__LINE__);
eError = OMX_ErrorBadPortIndex;
}
break;
case OMX_IndexParamAudioPortFormat:
if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pPortDef[INPUT_PORT]->nPortIndex)
{
if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nIndex > pComponentPrivate->sInPortFormat.nIndex)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: ErrorNoMore Inside the GetParameter Line\n",__LINE__);
eError = OMX_ErrorNoMore;
}
else
{
OMX_PRDSP2(pComponentPrivate->dbg, "%d :: AACENC: About to copy Inside GetParameter \n",__LINE__);
memcpy(ComponentParameterStructure, &pComponentPrivate->sInPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
}
}
else if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pPortDef[OUTPUT_PORT]->nPortIndex)
{
if(((OMX_AUDIO_PARAM_PORTFORMATTYPE *)(ComponentParameterStructure))->nIndex > pComponentPrivate->sOutPortFormat.nIndex)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: ErrorNoMore Inside the GetParameter Line\n",__LINE__);
eError = OMX_ErrorNoMore;
}
else
{
OMX_PRDSP2(pComponentPrivate->dbg, "%d :: AACENC: About to copy Inside GetParameter \n",__LINE__);
memcpy(ComponentParameterStructure, &pComponentPrivate->sOutPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
}
}
else
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: BadPortIndex Inside the GetParameter Line\n",__LINE__);
eError = OMX_ErrorBadPortIndex;
}
break;
case OMX_IndexParamAudioAac:
OMX_PRDSP2(pComponentPrivate->dbg, "AACENC: OMX_IndexParamAudioAac : nPortIndex = %d\n", (int)((OMX_AUDIO_PARAM_AACPROFILETYPE *)(ComponentParameterStructure))->nPortIndex);
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: acParams[INPUT_PORT]->nPortIndex = %d\n", (int)pComponentPrivate->aacParams[INPUT_PORT]->nPortIndex);
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: acParams[OUPUT_PORT]->nPortIndex = %d\n", (int)pComponentPrivate->aacParams[OUTPUT_PORT]->nPortIndex);
if(((OMX_AUDIO_PARAM_AACPROFILETYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->aacParams[INPUT_PORT]->nPortIndex)
{
if (pComponentPrivate->CustomConfiguration ) /* For Testapp: An Index was providded. Getting the required Structure */
/* The flag is set in Setconfig() function*/
{
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: OMX_IndexParamAudioAac :input port \n");
memcpy(ComponentParameterStructure,pComponentPrivate->aacParams[INPUT_PORT], sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
}
else /*for Khronos: Getting the default structure (Ouput) for an index not providded*/
{
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: OMX_IndexParamAudioAac :output port \n");
memcpy(ComponentParameterStructure, pComponentPrivate->aacParams[OUTPUT_PORT], sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
}
}
else if(((OMX_AUDIO_PARAM_AACPROFILETYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->aacParams[OUTPUT_PORT]->nPortIndex)
{
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: OMX_IndexParamAudioAac :output port \n");
memcpy(ComponentParameterStructure, pComponentPrivate->aacParams[OUTPUT_PORT], sizeof(OMX_AUDIO_PARAM_AACPROFILETYPE));
}
else
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: BadPortIndex Inside the GetParameter Line\n",__LINE__);
eError = OMX_ErrorBadPortIndex;
}
break;
case OMX_IndexParamAudioPcm:
if(((OMX_AUDIO_PARAM_AACPROFILETYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pcmParam[INPUT_PORT]->nPortIndex)
{
memcpy(ComponentParameterStructure,pComponentPrivate->pcmParam[INPUT_PORT], sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: OMX_IndexParamAudioPcm :input port \n");
}
else if(((OMX_AUDIO_PARAM_AACPROFILETYPE *)(ComponentParameterStructure))->nPortIndex == pComponentPrivate->pcmParam[OUTPUT_PORT]->nPortIndex)
{
memcpy(ComponentParameterStructure, pComponentPrivate->pcmParam[OUTPUT_PORT], sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
OMX_PRCOMM2(pComponentPrivate->dbg, "AACENC: OMX_IndexParamAudioPcm :output port \n");
}
else
{
eError = OMX_ErrorBadPortIndex;
}
break;
case OMX_IndexParamCompBufferSupplier:
if(((OMX_PARAM_BUFFERSUPPLIERTYPE *)(ComponentParameterStructure))->nPortIndex == OMX_DirInput)
{
OMX_PRBUFFER2(pComponentPrivate->dbg, "AACENC: GetParameter OMX_IndexParamCompBufferSupplier \n");
}
else if(((OMX_PARAM_BUFFERSUPPLIERTYPE *)(ComponentParameterStructure))->nPortIndex == OMX_DirOutput)
{
OMX_PRBUFFER2(pComponentPrivate->dbg, "AACENC: GetParameter OMX_IndexParamCompBufferSupplier \n");
}
else
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error: OMX_ErrorBadPortIndex from GetParameter",__LINE__);
eError = OMX_ErrorBadPortIndex;
}
break;
#ifdef ANDROID
case (OMX_INDEXTYPE) PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX:
{
OMX_PRDSP2(pComponentPrivate->dbg, "Entering PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX::%d\n", __LINE__);
PV_OMXComponentCapabilityFlagsType* pCap_flags = (PV_OMXComponentCapabilityFlagsType *) ComponentParameterStructure;
if (NULL == pCap_flags)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d :: ERROR PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX\n", __LINE__);
eError = OMX_ErrorBadParameter;
goto EXIT;
}
OMX_PRDSP2(pComponentPrivate->dbg, "%d :: Copying PV_OMX_COMPONENT_CAPABILITY_TYPE_INDEX\n", __LINE__);
memcpy(pCap_flags, &(pComponentPrivate->iPVCapabilityFlags), sizeof(PV_OMXComponentCapabilityFlagsType));
eError = OMX_ErrorNone;
}
break;
#endif
case OMX_IndexParamPriorityMgmt:
break;
case OMX_IndexParamVideoInit:
break;
case OMX_IndexParamImageInit:
break;
case OMX_IndexParamOtherInit:
break;
default:
eError = OMX_ErrorUnsupportedIndex;
break;
}
EXIT:
if (pComponentPrivate != NULL) {
OMX_PRINT1(pComponentPrivate->dbg, "%d :: AACENC: Exiting GetParameter:: %x error :: %x \n", __LINE__, nParamIndex, eError);
}
return eError;
}
/*-------------------------------------------------------------------*/
/**
* SetParameter() Sets configuration paramets to the component
*