|
1 /* |
|
2 * Copyright (c) 2008 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 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #include "log.h" |
|
25 #include "comxil3gpdemuxeraudiooutputport.h" |
|
26 #include "comxil3gpdemuxerprocessingfunction.h" |
|
27 #include "taudioformat.h" |
|
28 |
|
29 // TODO: Possibly add other mime types, for now only AAC handled |
|
30 _LIT8(KMimeTypeAudioAac, "audio/aac"); |
|
31 _LIT(K3GPDemuxerAudioPortPanic, "COmxIL3GPDemuxerVideoOutputPort"); |
|
32 |
|
33 |
|
34 COmxIL3GPDemuxerAudioOutputPort* COmxIL3GPDemuxerAudioOutputPort::NewL(const TOmxILCommonPortData& aCommonPortData, |
|
35 COmxIL3GPDemuxerProcessingFunction& aProcessingFunction) |
|
36 { |
|
37 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::NewL")); |
|
38 // TODO this array must be left empty, to be removed from the audio port constructor |
|
39 |
|
40 COmxIL3GPDemuxerAudioOutputPort* self = new(ELeave) COmxIL3GPDemuxerAudioOutputPort(aProcessingFunction); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(aCommonPortData); |
|
43 CleanupStack::Pop(self); |
|
44 return self; |
|
45 } |
|
46 |
|
47 void COmxIL3GPDemuxerAudioOutputPort::ConstructL(const TOmxILCommonPortData& aCommonPortData) |
|
48 { |
|
49 RArray<OMX_AUDIO_CODINGTYPE> supportedCodings; |
|
50 CleanupClosePushL(supportedCodings); |
|
51 supportedCodings.AppendL(OMX_AUDIO_CodingAAC); |
|
52 COmxILAudioPort::ConstructL(aCommonPortData, supportedCodings); |
|
53 CleanupStack::PopAndDestroy(&supportedCodings); |
|
54 |
|
55 OMX_PARAM_PORTDEFINITIONTYPE& paramPortDefinition=GetParamPortDefinition(); |
|
56 // We have to finish with iParamPortDefinition |
|
57 paramPortDefinition.eDomain = OMX_PortDomainAudio; |
|
58 paramPortDefinition.format.audio.pNativeRender = 0; |
|
59 |
|
60 // TODO: Possible add in the future other mime types that can be handled by |
|
61 // this audio port... for now only AAC Check |
|
62 // COmxILAudioPort::iParamAudioPortFormat.nIndex and use |
|
63 // COmxILAudioPort::iSupportedAudioFormats[iParamAudioPortFormat.nIndex] |
|
64 |
|
65 iMimeTypeBuf.CreateL(KMimeTypeAudioAac(), KMimeTypeAudioAac().Length() + 1); |
|
66 |
|
67 TUint8* pTUint = const_cast<TUint8*>(iMimeTypeBuf.PtrZ()); |
|
68 paramPortDefinition.format.audio.cMIMEType = reinterpret_cast<OMX_STRING>(pTUint); |
|
69 |
|
70 paramPortDefinition.format.audio.bFlagErrorConcealment = OMX_FALSE; |
|
71 paramPortDefinition.format.audio.eEncoding = OMX_AUDIO_CodingAAC; |
|
72 } |
|
73 |
|
74 COmxIL3GPDemuxerAudioOutputPort::COmxIL3GPDemuxerAudioOutputPort(COmxIL3GPDemuxerProcessingFunction& aProcessingFunction) |
|
75 : iProcessingFunction(&aProcessingFunction) |
|
76 { |
|
77 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::COmxIL3GPDemuxerAudioOutputPort")); |
|
78 } |
|
79 |
|
80 COmxIL3GPDemuxerAudioOutputPort::~COmxIL3GPDemuxerAudioOutputPort() |
|
81 { |
|
82 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::~COmxIL3GPDemuxerAudioOutputPort")); |
|
83 iMimeTypeBuf.Close(); |
|
84 } |
|
85 |
|
86 OMX_ERRORTYPE COmxIL3GPDemuxerAudioOutputPort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const |
|
87 { |
|
88 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::GetLocalOmxParamIndexes")); |
|
89 OMX_ERRORTYPE omxRetValue = COmxILAudioPort::GetLocalOmxParamIndexes(aIndexArray); |
|
90 if (omxRetValue != OMX_ErrorNone) |
|
91 { |
|
92 return omxRetValue; |
|
93 } |
|
94 |
|
95 TInt err = aIndexArray.InsertInOrder(OMX_IndexParamNumAvailableStreams); |
|
96 // Note that index duplication is OK. |
|
97 if (err == KErrNone || err == KErrAlreadyExists) |
|
98 { |
|
99 err = aIndexArray.InsertInOrder(OMX_IndexParamActiveStream); |
|
100 } |
|
101 |
|
102 if (err != KErrNone && err != KErrAlreadyExists) |
|
103 { |
|
104 return OMX_ErrorInsufficientResources; |
|
105 } |
|
106 |
|
107 return OMX_ErrorNone; |
|
108 } |
|
109 |
|
110 OMX_ERRORTYPE COmxIL3GPDemuxerAudioOutputPort::GetLocalOmxConfigIndexes(RArray<TUint>& aIndexArray) const |
|
111 { |
|
112 return COmxILAudioPort::GetLocalOmxConfigIndexes(aIndexArray); |
|
113 } |
|
114 |
|
115 OMX_ERRORTYPE COmxIL3GPDemuxerAudioOutputPort::GetParameter(OMX_INDEXTYPE aParamIndex, |
|
116 TAny* apComponentParameterStructure) const |
|
117 { |
|
118 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::GetParameter")); |
|
119 switch(aParamIndex) |
|
120 { |
|
121 case OMX_IndexParamNumAvailableStreams: |
|
122 { |
|
123 OMX_PARAM_U32TYPE* u32Type = reinterpret_cast<OMX_PARAM_U32TYPE*>(apComponentParameterStructure); |
|
124 u32Type->nU32 = iProcessingFunction->NumAvailableStreams(COmxIL3GPDemuxer::EPortIndexAudioOutput); |
|
125 return OMX_ErrorNone; |
|
126 } |
|
127 |
|
128 case OMX_IndexParamActiveStream: |
|
129 { |
|
130 OMX_PARAM_U32TYPE* u32Type = reinterpret_cast<OMX_PARAM_U32TYPE*>(apComponentParameterStructure); |
|
131 u32Type->nU32 = iProcessingFunction->ActiveStream(COmxIL3GPDemuxer::EPortIndexAudioOutput); |
|
132 return OMX_ErrorNone; |
|
133 } |
|
134 |
|
135 default: |
|
136 { |
|
137 return COmxILAudioPort::GetParameter(aParamIndex, apComponentParameterStructure); |
|
138 } |
|
139 } |
|
140 } |
|
141 |
|
142 OMX_ERRORTYPE COmxIL3GPDemuxerAudioOutputPort::SetParameter(OMX_INDEXTYPE aParamIndex, |
|
143 const TAny* apComponentParameterStructure, |
|
144 TBool& aUpdateProcessingFunction) |
|
145 { |
|
146 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::SetParameter")); |
|
147 switch(aParamIndex) |
|
148 { |
|
149 case OMX_IndexParamActiveStream: |
|
150 { |
|
151 const OMX_PARAM_U32TYPE* u32Type = reinterpret_cast<const OMX_PARAM_U32TYPE*>(apComponentParameterStructure); |
|
152 return iProcessingFunction->SetActiveStream(COmxIL3GPDemuxer::EPortIndexAudioOutput, u32Type->nU32); |
|
153 } |
|
154 |
|
155 default: |
|
156 { |
|
157 return COmxILAudioPort::SetParameter(aParamIndex, apComponentParameterStructure, aUpdateProcessingFunction); |
|
158 } |
|
159 } |
|
160 } |
|
161 |
|
162 OMX_ERRORTYPE COmxIL3GPDemuxerAudioOutputPort::SetFormatInPortDefinition( |
|
163 const OMX_PARAM_PORTDEFINITIONTYPE& aPortDefinition, |
|
164 TBool& /*aUpdateProcessingFunction*/) |
|
165 { |
|
166 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::SetFormatInPortDefinition")); |
|
167 |
|
168 if (aPortDefinition.nBufferCountActual > KMaxAudioBuffers) |
|
169 { |
|
170 return OMX_ErrorBadParameter; |
|
171 } |
|
172 |
|
173 GetParamPortDefinition().format.audio = aPortDefinition.format.audio; |
|
174 |
|
175 return OMX_ErrorNone; |
|
176 } |
|
177 |
|
178 TBool COmxIL3GPDemuxerAudioOutputPort::IsTunnelledPortCompatible(const OMX_PARAM_PORTDEFINITIONTYPE& /*aPortDefinition*/) const |
|
179 { |
|
180 DEBUG_PRINTF(_L8("COmxIL3GPDemuxerAudioOutputPort::IsTunnelledPortCompatible")); |
|
181 |
|
182 // This function only gets called on input ports, so panic if this is ever called |
|
183 User::Panic(K3GPDemuxerAudioPortPanic, KErrGeneral); |
|
184 return EFalse; // to keep compiler happy |
|
185 } |
|
186 |
|
187 void COmxIL3GPDemuxerAudioOutputPort::FormatDetected(const TAudioFormat& aFormat) |
|
188 { |
|
189 GetParamPortDefinition().format.audio.eEncoding = aFormat.iCoding; |
|
190 } |
|
191 |
|
192 OMX_AUDIO_CODINGTYPE COmxIL3GPDemuxerAudioOutputPort::AudioFormat() |
|
193 { |
|
194 return GetParamPortDefinition().format.audio.eEncoding; |
|
195 } |
|
196 |
|
197 /** Returns the number of buffers configured on this port. */ |
|
198 TInt COmxIL3GPDemuxerAudioOutputPort::BufferCount() const |
|
199 { |
|
200 return GetParamPortDefinition().nBufferCountActual; |
|
201 } |