|
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 "comxil3gpmuxerprocessingfunction.h" |
|
25 #include "c3gpmuxer.h" |
|
26 #include <openmax/il/common/omxilcallbacknotificationif.h> |
|
27 #include "comxil3gpmuxerconfigmanager.h" |
|
28 #include "comxil3gpmuxervideoinputport.h" |
|
29 #include "comxil3gpmuxeraudioinputport.h" |
|
30 #include "log.h" |
|
31 #include "c3gpmuxerwriterthreadobserver.h" |
|
32 |
|
33 COmxIL3GPMuxerProcessingFunction* COmxIL3GPMuxerProcessingFunction::NewL(MOmxILCallbackNotificationIf& aCallbacks) |
|
34 { |
|
35 DEBUG_PRINTF(_L8("COmxIL3GPMuxerProcessingFunction::NewL")); |
|
36 COmxIL3GPMuxerProcessingFunction* self = new (ELeave) COmxIL3GPMuxerProcessingFunction(aCallbacks); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 COmxIL3GPMuxerProcessingFunction::COmxIL3GPMuxerProcessingFunction(MOmxILCallbackNotificationIf& aCallbacks) : |
|
44 COmxILProcessingFunction(aCallbacks), |
|
45 iMuxer(NULL) |
|
46 { |
|
47 } |
|
48 |
|
49 void COmxIL3GPMuxerProcessingFunction::ConstructL() |
|
50 { |
|
51 } |
|
52 |
|
53 COmxIL3GPMuxerProcessingFunction::~COmxIL3GPMuxerProcessingFunction() |
|
54 { |
|
55 DEBUG_PRINTF(_L8("COmxIL3GPMuxerProcessingFunction::~COmxIL3GPMuxerProcessingFunction")); |
|
56 delete iMuxer; |
|
57 delete iWriterThreadObserver; |
|
58 } |
|
59 |
|
60 void COmxIL3GPMuxerProcessingFunction::SetConfigManager(COmxIL3GPMuxerConfigManager& aConfigManager) |
|
61 { |
|
62 iConfigManager = &aConfigManager; |
|
63 } |
|
64 |
|
65 OMX_ERRORTYPE COmxIL3GPMuxerProcessingFunction::StateTransitionIndication(TStateIndex aNewState) |
|
66 { |
|
67 DEBUG_PRINTF2(_L8("COmxIL3GPMuxerProcessingFunction::StateTransitionIndication : aNewState[%u]"), aNewState); |
|
68 OMX_ERRORTYPE omxError = OMX_ErrorNone; |
|
69 |
|
70 switch(aNewState) |
|
71 { |
|
72 case EStateExecuting: |
|
73 { |
|
74 TRAPD(error, iMuxer->StartL(iAudioPort->IsEnabled(), iVideoPort->IsEnabled())); |
|
75 if (error != KErrNone) |
|
76 { |
|
77 omxError = SymbianErrorToOmx(error); |
|
78 } |
|
79 //Creating Writer thread observer |
|
80 TRAP(error, iWriterThreadObserver = C3GPMuxerWriterThreadObserver::NewL(iMuxer)); |
|
81 |
|
82 if (error != KErrNone) |
|
83 { |
|
84 omxError = SymbianErrorToOmx(error); |
|
85 } |
|
86 iWriterThreadObserver->IssueRequest(); |
|
87 break; |
|
88 } |
|
89 |
|
90 case ESubStateLoadedToIdle: |
|
91 { |
|
92 OMX_U32 frameWidth = 0; |
|
93 OMX_U32 frameHeight = 0; |
|
94 OMX_U32 framerate = 0; |
|
95 OMX_U32 bitRate = 0; |
|
96 OMX_U32 audioFramerate = 0; |
|
97 |
|
98 iVideoPort->GetVideoProperties(frameWidth, frameHeight, framerate, bitRate); |
|
99 audioFramerate = iAudioPort->GetAudioFrameRate(); |
|
100 |
|
101 const HBufC* filename = iConfigManager->Filename(); |
|
102 if(!filename) |
|
103 { |
|
104 // no file name has been set |
|
105 omxError = OMX_ErrorUnsupportedSetting; |
|
106 break; |
|
107 } |
|
108 |
|
109 delete iMuxer; |
|
110 iMuxer = NULL; |
|
111 |
|
112 TRAPD(error, iMuxer = C3GPMuxer::NewL(iCallbacks)); |
|
113 if (error != KErrNone) |
|
114 { |
|
115 omxError = SymbianErrorToOmx(error); |
|
116 break; |
|
117 } |
|
118 |
|
119 iMuxer->SetFilename(filename); |
|
120 iMuxer->SetAudioVideoProperties(frameWidth, frameHeight, framerate, bitRate, audioFramerate); |
|
121 |
|
122 break; |
|
123 } |
|
124 |
|
125 case EStateLoaded: |
|
126 { |
|
127 delete iMuxer; |
|
128 iMuxer = NULL; |
|
129 break; |
|
130 } |
|
131 |
|
132 case EStatePause: |
|
133 { |
|
134 iMuxer->Pause(); |
|
135 break; |
|
136 } |
|
137 |
|
138 default: |
|
139 { |
|
140 break; |
|
141 } |
|
142 } |
|
143 |
|
144 return omxError; |
|
145 } |
|
146 |
|
147 OMX_ERRORTYPE COmxIL3GPMuxerProcessingFunction::BufferFlushingIndication(TUint32 aPortIndex, OMX_DIRTYPE aDirection) |
|
148 { |
|
149 DEBUG_PRINTF3(_L8("COmxIL3GPMuxerProcessingFunction::BufferFlushingIndication : aPortIndex[%u]; aDirection[%u]"), aPortIndex, aDirection); |
|
150 if (aDirection == OMX_DirInput) |
|
151 { |
|
152 iMuxer->FlushBuffers(aPortIndex); |
|
153 } |
|
154 else |
|
155 { |
|
156 return OMX_ErrorBadParameter; |
|
157 } |
|
158 |
|
159 return OMX_ErrorNone; |
|
160 } |
|
161 |
|
162 OMX_ERRORTYPE COmxIL3GPMuxerProcessingFunction::ParamIndication(OMX_INDEXTYPE /*aParamIndex*/, const TAny* /*apComponentParameterStructure*/) |
|
163 { |
|
164 DEBUG_PRINTF(_L8("COmxIL3GPMuxerProcessingFunction::ParamIndication")); |
|
165 return OMX_ErrorNone; |
|
166 } |
|
167 |
|
168 OMX_ERRORTYPE COmxIL3GPMuxerProcessingFunction::ConfigIndication(OMX_INDEXTYPE /*aConfigIndex*/, const TAny* /*apComponentConfigStructure*/) |
|
169 { |
|
170 DEBUG_PRINTF(_L8("COmxIL3GPMuxerProcessingFunction::ConfigIndication")); |
|
171 return OMX_ErrorNone; |
|
172 } |
|
173 |
|
174 OMX_ERRORTYPE COmxIL3GPMuxerProcessingFunction::BufferIndication(OMX_BUFFERHEADERTYPE* apBufferHeader, |
|
175 OMX_DIRTYPE aDirection) |
|
176 { |
|
177 DEBUG_PRINTF2(_L8("COmxIL3GPMuxerProcessingFunction::BufferIndication : aBufferHeader[%X]"), apBufferHeader); |
|
178 // Check if the previous buffer processing invalidated the Muxer |
|
179 if (iMuxer->IsMuxerInvalid()) |
|
180 { |
|
181 return OMX_ErrorInvalidState; |
|
182 } |
|
183 |
|
184 TUint32 portIndex; |
|
185 if (aDirection == OMX_DirInput) |
|
186 { |
|
187 portIndex = apBufferHeader->nInputPortIndex; |
|
188 } |
|
189 else |
|
190 { |
|
191 return OMX_ErrorBadParameter; |
|
192 } |
|
193 |
|
194 TRAPD(err, iMuxer->ProcessThisBufferL(apBufferHeader, portIndex)); |
|
195 return SymbianErrorToOmx(err); |
|
196 } |
|
197 |
|
198 OMX_BOOL COmxIL3GPMuxerProcessingFunction::BufferRemovalIndication(OMX_BUFFERHEADERTYPE* apBufferHeader, OMX_DIRTYPE /*aDirection*/) |
|
199 { |
|
200 DEBUG_PRINTF2(_L8("COmxIL3GPMuxerProcessingFunction::BufferRemovalIndication : aBufferHeader[%X]"), apBufferHeader); |
|
201 if (iMuxer->RemoveBuffer(apBufferHeader)) |
|
202 { |
|
203 return OMX_TRUE; |
|
204 } |
|
205 |
|
206 return OMX_FALSE; |
|
207 } |
|
208 |
|
209 void COmxIL3GPMuxerProcessingFunction::SetVideoPort(COmxIL3GPMuxerVideoInputPort& aVideoPort) |
|
210 { |
|
211 iVideoPort = &aVideoPort; |
|
212 } |
|
213 |
|
214 void COmxIL3GPMuxerProcessingFunction::SetAudioPort(COmxIL3GPMuxerAudioInputPort& aAudioPort) |
|
215 { |
|
216 iAudioPort = &aAudioPort; |
|
217 } |
|
218 |
|
219 OMX_ERRORTYPE COmxIL3GPMuxerProcessingFunction::SymbianErrorToOmx(TInt aError) |
|
220 { |
|
221 switch(aError) |
|
222 { |
|
223 case KErrNone: |
|
224 return OMX_ErrorNone; |
|
225 case KErrNoMemory: |
|
226 return OMX_ErrorInsufficientResources; |
|
227 default: |
|
228 return OMX_ErrorUndefined; |
|
229 } |
|
230 } |