0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 "comxil3gpdemuxerrequesthelper.h"
|
|
26 |
#include "comxil3gpdemuxerprocessingfunction.h"
|
|
27 |
#include "comxil3gpdemuxer.h"
|
|
28 |
|
|
29 |
COmxIL3GPDemuxerRequestHelper* COmxIL3GPDemuxerRequestHelper::NewL(COmxILProcessingFunction* aProcessingFunction)
|
|
30 |
{
|
|
31 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::NewL"));
|
|
32 |
|
|
33 |
COmxIL3GPDemuxerRequestHelper* self = new (ELeave) COmxIL3GPDemuxerRequestHelper(aProcessingFunction);
|
|
34 |
CleanupStack::PushL(self);
|
|
35 |
self->ConstructL();
|
|
36 |
CleanupStack::Pop(self);
|
|
37 |
return self;
|
|
38 |
}
|
|
39 |
|
|
40 |
COmxIL3GPDemuxerRequestHelper::COmxIL3GPDemuxerRequestHelper(COmxILProcessingFunction* aProcessingFunction):
|
|
41 |
CActive(EPriorityStandard),
|
|
42 |
iProcessingFunction(aProcessingFunction),
|
|
43 |
iFunctionCode(EC3GPDemuxerFunctionCodeNone)
|
|
44 |
{
|
|
45 |
CActiveScheduler::Add(this);
|
|
46 |
}
|
|
47 |
|
|
48 |
void COmxIL3GPDemuxerRequestHelper::ConstructL()
|
|
49 |
{
|
|
50 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::ConstructL"));
|
|
51 |
|
|
52 |
RThread me;
|
|
53 |
iConstructionThreadId = me.Id();
|
|
54 |
|
|
55 |
iStatus = KRequestPending;
|
|
56 |
SetActive();
|
|
57 |
}
|
|
58 |
|
|
59 |
COmxIL3GPDemuxerRequestHelper::~COmxIL3GPDemuxerRequestHelper()
|
|
60 |
{
|
|
61 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::~COmxIL3GPDemuxerRequestHelper"));
|
|
62 |
|
|
63 |
Cancel(); // safe as takes place in core thread which has Active Scheduler running.
|
|
64 |
}
|
|
65 |
|
|
66 |
void COmxIL3GPDemuxerRequestHelper::RunL()
|
|
67 |
{
|
|
68 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::RunL"));
|
|
69 |
|
|
70 |
__ASSERT_DEBUG(iStatus == KErrNone, User::Panic(_L("Demuxer COmxIL3GPDemuxerRequestHelper::RunL"), KErrUnknown));
|
|
71 |
|
|
72 |
iStatus = KRequestPending;
|
|
73 |
SetActive();
|
|
74 |
|
|
75 |
// list of requests that need to be synchronised with AS
|
|
76 |
switch(iFunctionCode)
|
|
77 |
{
|
|
78 |
case EC3GPDemuxerFunctionCodeStateTransitionIndication:
|
|
79 |
DoStateTransitionIndication();
|
|
80 |
break;
|
|
81 |
|
|
82 |
case EC3GPDemuxerFunctionCodeBufferFlushingIndication:
|
|
83 |
DoBufferFlushingIndication();
|
|
84 |
break;
|
|
85 |
|
|
86 |
case EC3GPDemuxerFunctionCodeBufferRemovalIndication:
|
|
87 |
DoBufferRemovalIndication();
|
|
88 |
break;
|
|
89 |
|
|
90 |
default:
|
|
91 |
// should never reach here
|
|
92 |
User::Panic(_L("COmxIL3GPDemuxerRequestHelper"), KErrArgument);
|
|
93 |
}
|
|
94 |
|
|
95 |
TRequestStatus *status = iCallingStatus;
|
|
96 |
RThread callingThread;
|
|
97 |
callingThread.Open(iCallingThreadId);
|
|
98 |
callingThread.RequestComplete(status, KErrNone);
|
|
99 |
callingThread.Close();
|
|
100 |
}
|
|
101 |
|
|
102 |
void COmxIL3GPDemuxerRequestHelper::DoCancel()
|
|
103 |
{
|
|
104 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::DoCancel"));
|
|
105 |
|
|
106 |
TRequestStatus* status = &iStatus;
|
|
107 |
User::RequestComplete(status, KErrCancel);
|
|
108 |
}
|
|
109 |
|
|
110 |
OMX_ERRORTYPE COmxIL3GPDemuxerRequestHelper::StateTransitionIndication(TStateIndex aNewState)
|
|
111 |
{
|
|
112 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::StateTransitionIndication"));
|
|
113 |
|
|
114 |
iNewState = aNewState;
|
|
115 |
|
|
116 |
RThread me;
|
|
117 |
if(me.Id() != iConstructionThreadId)
|
|
118 |
{
|
|
119 |
// in different thread to that which 'this' was constructed
|
|
120 |
iFunctionCode = EC3GPDemuxerFunctionCodeStateTransitionIndication;
|
|
121 |
DoRequest();
|
|
122 |
}
|
|
123 |
else
|
|
124 |
{
|
|
125 |
// in same thread to that which 'this' was constructed therefore
|
|
126 |
// active scheduler must exist and following call is safe
|
|
127 |
DoStateTransitionIndication();
|
|
128 |
}
|
|
129 |
|
|
130 |
return iOMXError;
|
|
131 |
}
|
|
132 |
|
|
133 |
OMX_ERRORTYPE COmxIL3GPDemuxerRequestHelper::BufferFlushingIndication(TUint32 aPortIndex, OMX_DIRTYPE aDirection)
|
|
134 |
{
|
|
135 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::BufferFlushingIndication"));
|
|
136 |
|
|
137 |
iPortIndex = aPortIndex;
|
|
138 |
iDirection = aDirection;
|
|
139 |
|
|
140 |
RThread me;
|
|
141 |
if(me.Id() != iConstructionThreadId)
|
|
142 |
{
|
|
143 |
// in different thread to that which 'this' was constructed
|
|
144 |
iFunctionCode = EC3GPDemuxerFunctionCodeBufferFlushingIndication;
|
|
145 |
DoRequest();
|
|
146 |
}
|
|
147 |
else
|
|
148 |
{
|
|
149 |
// in same thread to that which 'this' was constructed therefore
|
|
150 |
// active scheduler must exist and following call is safe
|
|
151 |
DoBufferFlushingIndication();
|
|
152 |
}
|
|
153 |
|
|
154 |
return iOMXError;
|
|
155 |
}
|
|
156 |
|
|
157 |
OMX_BOOL COmxIL3GPDemuxerRequestHelper::BufferRemovalIndication(OMX_BUFFERHEADERTYPE* apBufferHeader, OMX_DIRTYPE aDirection)
|
|
158 |
{
|
|
159 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::BufferRemovalIndication"));
|
|
160 |
|
|
161 |
ipBufferHeader = apBufferHeader;
|
|
162 |
iDirection = aDirection;
|
|
163 |
|
|
164 |
RThread me;
|
|
165 |
if(me.Id() != iConstructionThreadId)
|
|
166 |
{
|
|
167 |
// in different thread to that which 'this' was constructed
|
|
168 |
iFunctionCode = EC3GPDemuxerFunctionCodeBufferRemovalIndication;
|
|
169 |
DoRequest();
|
|
170 |
}
|
|
171 |
else
|
|
172 |
{
|
|
173 |
// in same thread to that which 'this' was constructed therefore
|
|
174 |
// active scheduler must exist and following call is safe
|
|
175 |
DoBufferRemovalIndication();
|
|
176 |
}
|
|
177 |
|
|
178 |
return iOMXBool;
|
|
179 |
}
|
|
180 |
|
|
181 |
void COmxIL3GPDemuxerRequestHelper::DoRequest()
|
|
182 |
{
|
|
183 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::DoRequest"));
|
|
184 |
|
|
185 |
RThread me;
|
|
186 |
iCallingThreadId = me.Id();
|
|
187 |
TRequestStatus requestStatus = KRequestPending;
|
|
188 |
iCallingStatus = &requestStatus;
|
|
189 |
|
|
190 |
// send request to active scheduler thread
|
|
191 |
RThread schedulerThread;
|
|
192 |
schedulerThread.Open(iConstructionThreadId);
|
|
193 |
|
|
194 |
TRequestStatus* schedulerRequest = &iStatus;
|
|
195 |
schedulerThread.RequestComplete(schedulerRequest, KErrNone);
|
|
196 |
schedulerThread.Close();
|
|
197 |
|
|
198 |
// block until request completes
|
|
199 |
User::WaitForRequest(requestStatus);
|
|
200 |
|
|
201 |
iFunctionCode = EC3GPDemuxerFunctionCodeNone;
|
|
202 |
}
|
|
203 |
|
|
204 |
void COmxIL3GPDemuxerRequestHelper::DoStateTransitionIndication()
|
|
205 |
{
|
|
206 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::DoStateTransitionIndication"));
|
|
207 |
|
|
208 |
COmxIL3GPDemuxerProcessingFunction* processingFunction =
|
|
209 |
dynamic_cast<COmxIL3GPDemuxerProcessingFunction*>(iProcessingFunction);
|
|
210 |
|
|
211 |
iOMXError = processingFunction->DoStateTransitionIndication(iNewState);
|
|
212 |
}
|
|
213 |
|
|
214 |
void COmxIL3GPDemuxerRequestHelper::DoBufferFlushingIndication()
|
|
215 |
{
|
|
216 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::DoBufferFlushingIndication"));
|
|
217 |
|
|
218 |
COmxIL3GPDemuxerProcessingFunction* processingFunction =
|
|
219 |
dynamic_cast<COmxIL3GPDemuxerProcessingFunction*>(iProcessingFunction);
|
|
220 |
|
|
221 |
iOMXError = processingFunction->DoBufferFlushingIndication(iPortIndex, iDirection);
|
|
222 |
}
|
|
223 |
|
|
224 |
void COmxIL3GPDemuxerRequestHelper::DoBufferRemovalIndication()
|
|
225 |
{
|
|
226 |
DEBUG_PRINTF(_L8("COmxIL3GPDemuxerRequestHelper::DoBufferRemovalIndication"));
|
|
227 |
|
|
228 |
COmxIL3GPDemuxerProcessingFunction* processingFunction =
|
|
229 |
dynamic_cast<COmxIL3GPDemuxerProcessingFunction*>(iProcessingFunction);
|
|
230 |
|
|
231 |
iOMXBool = processingFunction->DoBufferRemovalIndication(ipBufferHeader, iDirection);
|
|
232 |
}
|
|
233 |
|