1 /* ------------------------------------------------------------------
2 * Copyright (C) 1998-2009 PacketVideo
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13 * express or implied.
14 * See the License for the specific language governing permissions
15 * and limitations under the License.
16 * -------------------------------------------------------------------
17 */
18 #ifndef PVAUTHORENGINE_H_INCLUDED
19 #include "pvauthorengine.h"
20 #endif
21 #ifndef OSCL_ERROR_CODES_H_INCLUDED
22 #include "oscl_error_codes.h"
23 #endif
24 #ifndef PVLOGGER_ACCESSORIES_H_INCLUDED
25 #include "pvlogger_accessories.h"
26 #endif
27 #ifndef PVAUTHORENGINEFACTORY_H_INCLUDED
28 #include "pvauthorenginefactory.h"
29 #endif
30 #ifndef PVAE_NODE_FACTORY_UTILITY_H_INCLUDED
31 #include "pvaenodefactoryutility.h"
32 #endif
33 #ifndef OSCL_DLL_H_INCLUDED
34 #include "oscl_dll.h"
35 #endif
36 #ifndef PVMF_COMPOSER_SIZE_AND_DURATION_H_INCLUDED
37 #include "pvmf_composer_size_and_duration.h"
38 #endif
39 #ifndef PVAE_TUNEABLES_H_INCLUDED
40 #include "pvae_tuneables.h"
41 #endif
42
43 #ifndef PVMI_CONFIG_AND_CAPABILITY_OBSERVER_H_INCLUDED
44 #include "pvmi_config_and_capability_observer.h"
45 #endif
46 #ifndef OSCL_MIME_STRING_UTILS_H
47 #include "pv_mime_string_utils.h"
48 #endif
49
50 #ifndef PVMI_KVP_UTIL_H_INCLUDED
51 #include "pvmi_kvp_util.h"
52 #endif
53 #define PVAE_NUM_PENDING_CMDS 10
54 #define PVAE_NUM_PENDING_EVENTS 10
55
56 #include "pv_author_sdkinfo.h"
57
58 // Define entry point for this DLL
OSCL_DLL_ENTRY_POINT_DEFAULT()59 OSCL_DLL_ENTRY_POINT_DEFAULT()
60
61 ////////////////////////////////////////////////////////////////////////////
62 OSCL_EXPORT_REF PVAuthorEngineInterface* PVAuthorEngineFactory::CreateAuthor(PVCommandStatusObserver* aCmdStatusObserver,
63 PVErrorEventObserver* aErrorEventObserver,
64 PVInformationalEventObserver* aInfoEventObserver)
65 {
66 return PVAuthorEngine::Create(aCmdStatusObserver, aErrorEventObserver, aInfoEventObserver);
67 }
68
69 ////////////////////////////////////////////////////////////////////////////
DeleteAuthor(PVAuthorEngineInterface * aAuthor)70 OSCL_EXPORT_REF bool PVAuthorEngineFactory::DeleteAuthor(PVAuthorEngineInterface* aAuthor)
71 {
72 if (aAuthor)
73 {
74 OSCL_DELETE(aAuthor);
75 return true;
76 }
77 return false;
78 }
79
80 ////////////////////////////////////////////////////////////////////////////
Create(PVCommandStatusObserver * aCmdStatusObserver,PVErrorEventObserver * aErrorEventObserver,PVInformationalEventObserver * aInfoEventObserver)81 PVAuthorEngineInterface* PVAuthorEngine::Create(PVCommandStatusObserver* aCmdStatusObserver,
82 PVErrorEventObserver *aErrorEventObserver,
83 PVInformationalEventObserver *aInfoEventObserver)
84 {
85 PVAuthorEngine* engine = OSCL_NEW(PVAuthorEngine, ());
86 if (engine)
87 engine->Construct(aCmdStatusObserver, aErrorEventObserver, aInfoEventObserver);
88 return (PVAuthorEngineInterface*)engine;
89 }
90
91 ////////////////////////////////////////////////////////////////////////////
PVAuthorEngine()92 PVAuthorEngine::PVAuthorEngine() :
93 OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVAuthorEngine"),
94 iCommandId(0),
95 iCmdStatusObserver(NULL),
96 iInfoEventObserver(NULL),
97 iErrorEventObserver(NULL),
98 iEncodedVideoFormat(PVMF_MIME_FORMAT_UNKNOWN),
99 iState(PVAE_STATE_IDLE),
100 iCfgCapCmdObserver(NULL),
101 iAsyncNumElements(0)
102 {
103 iLogger = PVLogger::GetLoggerObject("PVAuthorEngine");
104 iDoResetNodeContainers = false;
105 lastNodeCommandError = PVMFFailure;
106 }
107
108 ////////////////////////////////////////////////////////////////////////////
Construct(PVCommandStatusObserver * aCmdStatusObserver,PVErrorEventObserver * aErrorEventObserver,PVInformationalEventObserver * aInfoEventObserver)109 void PVAuthorEngine::Construct(PVCommandStatusObserver* aCmdStatusObserver,
110 PVErrorEventObserver *aErrorEventObserver,
111 PVInformationalEventObserver *aInfoEventObserver)
112 {
113 iCmdStatusObserver = aCmdStatusObserver;
114 iInfoEventObserver = aInfoEventObserver;
115 iErrorEventObserver = aErrorEventObserver;
116
117 iPendingCmds.reserve(PVAE_NUM_PENDING_CMDS);
118 iPendingEvents.reserve(PVAE_NUM_PENDING_EVENTS);
119
120 iNodeUtil.SetObserver(*this);
121
122 iAuthorClock.SetClockTimebase(iAuthorClockTimebase);
123 uint32 starttime = 0;
124 bool overflow = 0;
125 iAuthorClock.SetStartTime32(starttime, PVMF_MEDIA_CLOCK_MSEC, overflow);
126
127 AddToScheduler();
128 return;
129 }
130
131 ////////////////////////////////////////////////////////////////////////////
~PVAuthorEngine()132 PVAuthorEngine::~PVAuthorEngine()
133 {
134 Cancel();
135 iPendingCmds.clear();
136 iPendingEvents.clear();
137 ResetNodeContainers();
138 while (!iDataSourcePool.empty())
139 {
140 DeallocateNodeContainer(iDataSourcePool, iDataSourcePool[0]->iNode);
141 }
142
143 while (!iDataSinkPool.empty())
144 {
145 DeallocateNodeContainer(iDataSinkPool, iDataSinkPool[0]->iNode);
146 }
147 }
148
149 ////////////////////////////////////////////////////////////////////////////
SetLogAppender(const char * aTag,PVLoggerAppender & aAppender,const OsclAny * aContextData)150 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::SetLogAppender(const char* aTag,
151 PVLoggerAppender& aAppender,
152 const OsclAny* aContextData)
153 {
154 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::SetLogAppender"));
155 OSCL_UNUSED_ARG(aTag);
156 OSCL_UNUSED_ARG(aAppender);
157 OSCL_UNUSED_ARG(aContextData);
158 OSCL_LEAVE(OsclErrNotSupported);
159 return -1;
160 }
161
162
163 ////////////////////////////////////////////////////////////////////////////
RemoveLogAppender(const char * aTag,PVLoggerAppender & aAppender,const OsclAny * aContextData)164 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::RemoveLogAppender(const char* aTag,
165 PVLoggerAppender& aAppender,
166 const OsclAny* aContextData)
167 {
168 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::RemoveLogAppender"));
169 OSCL_UNUSED_ARG(aTag);
170 OSCL_UNUSED_ARG(aAppender);
171 OSCL_UNUSED_ARG(aContextData);
172 OSCL_LEAVE(OsclErrNotSupported);
173 return -1;
174 }
175
176 ////////////////////////////////////////////////////////////////////////////
SetLogLevel(const char * aTag,int32 aLevel,bool aSetSubtree,const OsclAny * aContextData)177 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::SetLogLevel(const char* aTag, int32 aLevel, bool aSetSubtree,
178 const OsclAny* aContextData)
179 {
180 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::SetLogLevel"));
181 OSCL_UNUSED_ARG(aTag);
182 OSCL_UNUSED_ARG(aLevel);
183 OSCL_UNUSED_ARG(aSetSubtree);
184 OSCL_UNUSED_ARG(aContextData);
185 OSCL_LEAVE(OsclErrNotSupported);
186 return -1;
187 }
188
189
190 ////////////////////////////////////////////////////////////////////////////
GetLogLevel(const char * aTag,PVLogLevelInfo & aLogInfo,const OsclAny * aContextData)191 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::GetLogLevel(const char* aTag, PVLogLevelInfo& aLogInfo,
192 const OsclAny* aContextData)
193 {
194 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::GetLogLevel"));
195 OSCL_UNUSED_ARG(aTag);
196 OSCL_UNUSED_ARG(aLogInfo);
197 OSCL_UNUSED_ARG(aContextData);
198 OSCL_LEAVE(OsclErrNotSupported);
199 return -1;
200 }
201
202 ////////////////////////////////////////////////////////////////////////////
Open(const OsclAny * aContextData)203 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Open(const OsclAny* aContextData)
204 {
205 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
206 (0, "PVAuthorEngine::Open: aContextData=0x%x", aContextData));
207
208 PVEngineCommand cmd(PVAE_CMD_OPEN, iCommandId, (OsclAny*)aContextData, NULL);
209 Dispatch(cmd);
210 return iCommandId++;
211 }
212
213 ////////////////////////////////////////////////////////////////////////////
Close(const OsclAny * aContextData)214 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Close(const OsclAny* aContextData)
215 {
216 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
217 (0, "PVAuthorEngine::Close: aContextData=0x%x", aContextData));
218
219 PVEngineCommand cmd(PVAE_CMD_CLOSE, iCommandId, (OsclAny*)aContextData);
220 Dispatch(cmd);
221 return iCommandId++;
222 }
223
224 ////////////////////////////////////////////////////////////////////////////
AddDataSource(const PVMFNodeInterface & aDataSource,const OsclAny * aContextData)225 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::AddDataSource(const PVMFNodeInterface& aDataSource, const OsclAny* aContextData)
226 {
227 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
228 (0, "PVAuthorEngine::AddDataSource: &aDataSource=0x%x, aContextData=0x%x", &aDataSource, aContextData));
229
230 PVEngineCommand cmd(PVAE_CMD_ADD_DATA_SOURCE, iCommandId, (OsclAny*)aContextData, (OsclAny*)&aDataSource);
231 Dispatch(cmd);
232 return iCommandId++;
233 }
234
235 ////////////////////////////////////////////////////////////////////////////
RemoveDataSource(const PVMFNodeInterface & aDataSource,const OsclAny * aContextData)236 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::RemoveDataSource(const PVMFNodeInterface& aDataSource,
237 const OsclAny* aContextData)
238 {
239 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
240 (0, "PVAuthorEngine::RemoveDataSource: &aDataSource=0x%x, aContextData=0x%x", &aDataSource, aContextData));
241
242 PVEngineCommand cmd(PVAE_CMD_REMOVE_DATA_SOURCE, iCommandId, (OsclAny*)aContextData, (OsclAny*)&aDataSource);
243 Dispatch(cmd);
244 return iCommandId++;
245 }
246
247 ////////////////////////////////////////////////////////////////////////////
SelectComposer(const PvmfMimeString & aComposerType,PVInterface * & aConfigInterface,const OsclAny * aContextData)248 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::SelectComposer(const PvmfMimeString& aComposerType,
249 PVInterface*& aConfigInterface,
250 const OsclAny* aContextData)
251 {
252 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
253 (0, "PVAuthorEngine::SelectComposer: aConfigInterface=0x%x, aContextData=0x%x",
254 aConfigInterface, aContextData));
255 PVEngineCommand cmd(PVAE_CMD_SELECT_COMPOSER, iCommandId, (OsclAny*)aContextData, (OsclAny*)(&aConfigInterface));
256 cmd.SetMimeType(aComposerType);
257 Dispatch(cmd);
258
259 return iCommandId++;
260 }
261
262 ////////////////////////////////////////////////////////////////////////////
SelectComposer(const PVUuid & aComposerUuid,PVInterface * & aConfigInterface,const OsclAny * aContextData)263 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::SelectComposer(const PVUuid& aComposerUuid,
264 PVInterface*& aConfigInterface,
265 const OsclAny* aContextData)
266 {
267 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
268 (0, "PVAuthorEngine::SelectComposer: aConfigInterface=0x%x, aContextData=0x%x",
269 aConfigInterface, aContextData));
270
271 PVEngineCommand cmd(PVAE_CMD_SELECT_COMPOSER, iCommandId, (OsclAny*)aContextData, (OsclAny*)&aConfigInterface);
272 cmd.SetUuid(aComposerUuid);
273 Dispatch(cmd);
274 return iCommandId++;
275 }
276
277 ////////////////////////////////////////////////////////////////////////////
AddMediaTrack(const PVMFNodeInterface & aDataSource,const PvmfMimeString & aEncoderType,const OsclAny * aComposer,PVInterface * & aConfigInterface,const OsclAny * aContextData)278 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::AddMediaTrack(const PVMFNodeInterface& aDataSource,
279 const PvmfMimeString& aEncoderType,
280 const OsclAny* aComposer,
281 PVInterface*& aConfigInterface,
282 const OsclAny* aContextData)
283 {
284 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
285 (0, "PVAuthorEngine::AddMediaTrack: &aDataSource=0x%x, aComposer=0x%x, aConfigInterface=0x%x, aContextData=0x%x",
286 &aDataSource, aComposer, aConfigInterface, aContextData));
287
288 PVEngineCommand cmd(PVAE_CMD_ADD_MEDIA_TRACK, iCommandId, (OsclAny*)aContextData,
289 (OsclAny*)&aDataSource, (OsclAny*)aComposer, (OsclAny*)&aConfigInterface);
290 cmd.SetMimeType(aEncoderType);
291 Dispatch(cmd);
292 return iCommandId++;
293 }
294
295 ////////////////////////////////////////////////////////////////////////////
AddMediaTrack(const PVMFNodeInterface & aDataSource,const PVUuid & aEncoderUuid,const OsclAny * aComposer,PVInterface * & aConfigInterface,const OsclAny * aContextData)296 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::AddMediaTrack(const PVMFNodeInterface& aDataSource,
297 const PVUuid& aEncoderUuid,
298 const OsclAny* aComposer,
299 PVInterface*& aConfigInterface,
300 const OsclAny* aContextData)
301 {
302 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
303 (0, "PVAuthorEngine::AddMediaTrack: &aDataSource=0x%x, aComposer=0x%x, \
304 aConfigInterface=0x%x, aContextData=0x%x",
305 &aDataSource, aConfigInterface, aContextData));
306
307
308 PVEngineCommand cmd(PVAE_CMD_ADD_MEDIA_TRACK, iCommandId, (OsclAny*)aContextData,
309 (OsclAny*)&aDataSource, (OsclAny*)aComposer, (OsclAny*)&aConfigInterface);
310 cmd.SetUuid(aEncoderUuid);
311 Dispatch(cmd);
312 return iCommandId++;
313 }
314
315 ////////////////////////////////////////////////////////////////////////////
AddDataSink(const PVMFNodeInterface & aDataSink,const OsclAny * aComposer,const OsclAny * aContextData)316 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::AddDataSink(const PVMFNodeInterface& aDataSink,
317 const OsclAny* aComposer,
318 const OsclAny* aContextData)
319 {
320 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
321 (0, "PVAuthorEngine::AddDataSink: &aDataSink=0x%x, aComposer=0x%x, aContextData=0x%x",
322 &aDataSink, aComposer, aContextData));
323
324 PVEngineCommand cmd(PVAE_CMD_ADD_DATA_SINK, iCommandId, (OsclAny*)aContextData,
325 (OsclAny*)&aDataSink, (OsclAny*)aComposer);
326 Dispatch(cmd);
327 return iCommandId++;
328 }
329
330 ////////////////////////////////////////////////////////////////////////////
RemoveDataSink(const PVMFNodeInterface & aDataSink,const OsclAny * aContextData)331 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::RemoveDataSink(const PVMFNodeInterface& aDataSink, const OsclAny* aContextData)
332 {
333 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
334 (0, "PVAuthorEngine::RemoveDataSink: &aDataSink=0x%x, aContextData=0x%x", &aDataSink, aContextData));
335
336 PVEngineCommand cmd(PVAE_CMD_REMOVE_DATA_SINK, iCommandId, (OsclAny*)aContextData, (OsclAny*)&aDataSink);
337 Dispatch(cmd);
338 return iCommandId++;
339 }
340
341 ////////////////////////////////////////////////////////////////////////////
Init(const OsclAny * aContextData)342 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Init(const OsclAny* aContextData)
343 {
344 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
345 (0, "PVAuthorEngine::Init: aContextData=0x%x", aContextData));
346
347 PVEngineCommand cmd(PVAE_CMD_INIT, iCommandId, (OsclAny*)aContextData);
348 Dispatch(cmd);
349 return iCommandId++;
350 }
351
352 ////////////////////////////////////////////////////////////////////////////
Reset(const OsclAny * aContextData)353 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Reset(const OsclAny* aContextData)
354 {
355 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
356 (0, "PVAuthorEngine::Reset: aContextData=0x%x", aContextData));
357
358 PVEngineCommand cmd(PVAE_CMD_RESET, iCommandId, (OsclAny*)aContextData);
359 Dispatch(cmd);
360 return iCommandId++;
361 }
362
363 ////////////////////////////////////////////////////////////////////////////
Start(const OsclAny * aContextData)364 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Start(const OsclAny* aContextData)
365 {
366 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
367 (0, "PVAuthorEngine::Start: aContextData=0x%x", aContextData));
368
369 PVEngineCommand cmd(PVAE_CMD_START, iCommandId, (OsclAny*)aContextData);
370 Dispatch(cmd);
371 return iCommandId++;
372 }
373
374 ////////////////////////////////////////////////////////////////////////////
Pause(const OsclAny * aContextData)375 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Pause(const OsclAny* aContextData)
376 {
377 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
378 (0, "PVAuthorEngine::Pause: aContextData=0x%x", aContextData));
379
380 PVEngineCommand cmd(PVAE_CMD_PAUSE, iCommandId, (OsclAny*)aContextData);
381 Dispatch(cmd);
382 return iCommandId++;
383 }
384
385 ////////////////////////////////////////////////////////////////////////////
Resume(const OsclAny * aContextData)386 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Resume(const OsclAny* aContextData)
387 {
388 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
389 (0, "PVAuthorEngine::Resume: aContextData=0x%x", aContextData));
390
391 PVEngineCommand cmd(PVAE_CMD_RESUME, iCommandId, (OsclAny*)aContextData);
392 Dispatch(cmd);
393 return iCommandId++;
394 }
395
396 ////////////////////////////////////////////////////////////////////////////
Stop(const OsclAny * aContextData)397 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::Stop(const OsclAny* aContextData)
398 {
399 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
400 (0, "PVAuthorEngine::Stop: aContextData=0x%x", aContextData));
401
402 PVEngineCommand cmd(PVAE_CMD_STOP, iCommandId, (OsclAny*)aContextData);
403 Dispatch(cmd);
404 return iCommandId++;
405 }
406
407 ////////////////////////////////////////////////////////////////////////////
QueryUUID(const PvmfMimeString & aMimeType,Oscl_Vector<PVUuid,OsclMemAllocator> & aUuids,bool aExactUuidsOnly,const OsclAny * aContextData)408 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::QueryUUID(const PvmfMimeString& aMimeType,
409 Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
410 bool aExactUuidsOnly,
411 const OsclAny* aContextData)
412 {
413 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
414 (0, "PVAuthorEngine::QueryUUID: &aUuid=0x%x, aExactUuidsOnly=%d, aContextData=0x%x",
415 &aUuids, aExactUuidsOnly, aContextData));
416
417 PVEngineCommand cmd(PVAE_CMD_QUERY_UUID, iCommandId, (OsclAny*)aContextData,
418 (OsclAny*)&aUuids, (OsclAny*)&aExactUuidsOnly);
419 cmd.SetMimeType(aMimeType);
420 Dispatch(cmd);
421 return iCommandId++;
422 }
423
424 ////////////////////////////////////////////////////////////////////////////
QueryInterface(const PVUuid & aUuid,PVInterface * & aInterfacePtr,const OsclAny * aContextData)425 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::QueryInterface(const PVUuid& aUuid,
426 PVInterface*& aInterfacePtr,
427 const OsclAny* aContextData)
428 {
429 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
430 (0, "PVAuthorEngine::QueryInterface: aInterfacePtr=0x%x, aContextData=0x%x", aInterfacePtr, aContextData));
431
432 PVEngineCommand cmd(PVAE_CMD_QUERY_INTERFACE, iCommandId, (OsclAny*)aContextData, (OsclAny*)&aInterfacePtr);
433 cmd.SetUuid(aUuid);
434 Dispatch(cmd);
435 return iCommandId++;
436 }
437
438 ////////////////////////////////////////////////////////////////////////////
GetPVAuthorState()439 OSCL_EXPORT_REF PVAEState PVAuthorEngine::GetPVAuthorState()
440 {
441 return GetPVAEState();
442 }
443
444 ////////////////////////////////////////////////////////////////////////////
GetSDKInfo(PVSDKInfo & aSDKInfo,const OsclAny * aContextData)445 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::GetSDKInfo(PVSDKInfo &aSDKInfo, const OsclAny* aContextData)
446 {
447 PVEngineCommand cmd(PVAE_CMD_GET_SDK_INFO, iCommandId, (OsclAny*)aContextData, (OsclAny*)&aSDKInfo);
448 Dispatch(cmd);
449 return iCommandId++;
450 }
451
452 ////////////////////////////////////////////////////////////////////////////
GetSDKModuleInfo(PVSDKModuleInfo & aSDKModuleInfo,const OsclAny * aContextData)453 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo, const OsclAny* aContextData)
454 {
455 PVEngineCommand cmd(PVAE_CMD_GET_SDK_MODULE_INFO, iCommandId, (OsclAny*)aContextData, (OsclAny*)&aSDKModuleInfo);
456 Dispatch(cmd);
457 return iCommandId++;
458 }
459
460 ////////////////////////////////////////////////////////////////////////////
CancelAllCommands(const OsclAny * aContextData)461 OSCL_EXPORT_REF PVCommandId PVAuthorEngine::CancelAllCommands(const OsclAny* aContextData)
462 {
463 PVEngineCommand cmd(PVAE_CMD_CANCEL_ALL_COMMANDS, iCommandId, (OsclAny*)aContextData);
464 Dispatch(cmd);
465
466 return iCommandId++;
467 }
468
469 ////////////////////////////////////////////////////////////////////////////
HandleNodeErrorEvent(const PVMFAsyncEvent & aEvent)470 void PVAuthorEngine::HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent)
471 {
472 OSCL_UNUSED_ARG(aEvent);
473 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
474 (0, "PVAuthorEngine::HandleNodeErrorEvent"));
475
476 if ((!iPendingCmds.empty()) && (iState != PVAE_STATE_ERROR)) //if there is a pending command
477 {
478 PVEngineCommand cmd = iPendingCmds.front();
479 int cmdtype = cmd.GetCmdType();
480
481 if (cmdtype == PVAE_CMD_RESET)
482 {
483 return; //ignore
484 }
485 else
486 {
487 SetPVAEState(PVAE_STATE_ERROR);
488 }
489 }
490 else if (iState != PVAE_STATE_ERROR) //no pending command*
491 {
492 SetPVAEState(PVAE_STATE_ERROR);
493 PVAsyncErrorEvent event(aEvent.GetEventType(), aEvent.GetEventData());
494 iErrorEventObserver->HandleErrorEvent(event);
495 }
496 }
497
498 ////////////////////////////////////////////////////////////////////////////
HandleNodeInformationalEvent(const PVMFAsyncEvent & aEvent)499 void PVAuthorEngine::HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent)
500 {
501 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
502 (0, "PVAuthorEngine::HandleNodeInformationalEvent"));
503
504 switch (aEvent.GetEventType())
505 {
506 case PVMF_COMPOSER_MAXFILESIZE_REACHED:
507 {
508 PVEngineCommand cmd(PVAE_CMD_STOP_MAX_SIZE, 0, NULL, NULL);
509 PushCmdInFront(cmd);
510 }
511 break;
512 case PVMF_COMPOSER_MAXDURATION_REACHED:
513 {
514 PVEngineCommand cmd(PVAE_CMD_STOP_MAX_DURATION, 0, NULL, NULL);
515 PushCmdInFront(cmd);
516 }
517 break;
518 case PVMF_COMPOSER_EOS_REACHED:
519 case PVMFInfoEndOfData:
520 {
521 PVEngineCommand cmd(PVAE_CMD_STOP_EOS_REACHED, 0, NULL, NULL);
522 PushCmdInFront(cmd);
523 }
524 break;
525 case PVMF_COMPOSER_FILESIZE_PROGRESS:
526 case PVMF_COMPOSER_DURATION_PROGRESS:
527 {
528 PVAsyncInformationalEvent event(aEvent.GetEventType(), aEvent.GetEventData());
529 iInfoEventObserver->HandleInformationalEvent(event);
530 }
531 break;
532
533 default:
534 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
535 (0, "PVAuthorEngine::HandleNodeInformationalEvent sends unknown eventType:%d", aEvent.GetEventType()));
536 break;
537 }
538 }
539
540 ////////////////////////////////////////////////////////////////////////////
NodeUtilCommandCompleted(const PVMFCmdResp & aResponse)541 void PVAuthorEngine::NodeUtilCommandCompleted(const PVMFCmdResp& aResponse)
542 {
543 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
544 (0, "PVAuthorEngine::NodeUtilCommandCompleted"));
545
546 if (iPendingCmds.empty())
547 {
548 // Prevent from out-of-boundary access to iPendingCmds queue
549 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
550 (0, "PVAuthorEngine::NodeUtilCommandCompleted: empty pending command queue while receiving response for command: id(%d), status(%d) and context(%p)!", aResponse.GetCmdId(), aResponse.GetCmdStatus(), aResponse.GetContext()));
551 SetPVAEState(PVAE_STATE_ERROR);
552 PVAsyncErrorEvent event(PVMFFailure);
553 iErrorEventObserver->HandleErrorEvent(event);
554 OSCL_ASSERT(false); // debugging build does abort; release build does nothing
555 return;
556 }
557
558 // Now it is safe to retrieve the first pending command from queue
559 PVEngineCommand cmd(iPendingCmds[0]);
560 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
561 (0, "PVAuthorEngine::NodeUtilCommandCompleted cmdType:%d", cmd.GetCmdType()));
562
563 if (aResponse.GetCmdStatus() != PVMFSuccess)
564 {
565 if (cmd.GetCmdType() == PVAE_CMD_RESET)
566 {
567 OSCL_ASSERT(false);//Reset can't fail.
568 return;
569 }
570 else
571 {
572 lastNodeCommandError = aResponse.GetCmdStatus();
573 SetPVAEState(PVAE_STATE_ERROR);
574 }
575 }
576 //RESET needs to be handled seperately, if the EngineState is ERROR, ignore all cmds till
577 //there are more pending commands, else send out commandComplete Failure
578 if ((iState == PVAE_STATE_ERROR) && (cmd.GetCmdType() != PVAE_CMD_RESET))
579 {
580 if (iNodeUtil.GetCommandQueueSize() > 0)
581 {
582 return; //Ignore the command
583 }
584 else
585 {
586 CompleteEngineCommand(cmd, lastNodeCommandError); //Send Failure to this command, engine is in error state
587 return;
588 }
589 }
590
591 PVMFStatus status = PVMFSuccess;
592 OsclAny* responseData = NULL;
593 int32 responseDataSize = 0;
594
595 switch (cmd.GetCmdType())
596 {
597 case PVAE_CMD_ADD_DATA_SOURCE:
598 status = PVMFSuccess;
599 break;
600 case PVAE_CMD_REMOVE_DATA_SOURCE:
601 break;
602 case PVAE_CMD_SELECT_COMPOSER:
603 if (iNodeUtil.GetCommandQueueSize() > 0)
604 {
605 status = PVMFPending;
606 }
607 else
608 {
609 responseData = OSCL_REINTERPRET_CAST(OsclAny*, iComposerNodes.back()->iNode);
610 responseDataSize = sizeof(OsclAny*);
611 }
612 break;
613
614 case PVAE_CMD_ADD_MEDIA_TRACK:
615 if (iNodeUtil.GetCommandQueueSize() > 0)
616 status = PVMFPending;
617 break;
618
619 case PVAE_CMD_ADD_DATA_SINK:
620 break;
621
622 case PVAE_CMD_REMOVE_DATA_SINK:
623 break;
624
625 case PVAE_CMD_INIT:
626 if (iNodeUtil.GetCommandQueueSize() > 0)
627 {
628 status = PVMFPending;
629 }
630 else
631 {
632 SetPVAEState(PVAE_STATE_INITIALIZED); // Init done. Change state
633 SendAuthoringClockToDataSources();
634 }
635 break;
636
637 case PVAE_CMD_RESET:
638 if (iNodeUtil.GetCommandQueueSize() > 0)
639 {
640 status = PVMFPending;
641 }
642 else
643 {
644 // Reset done. Change state
645 SetPVAEState(PVAE_STATE_OPENED);
646 iDoResetNodeContainers = true;
647 // Composer and Encoders cannot be deleted here right away as
648 // we are still in call back of node command complete invoked
649 // by one of node which can be a composer/encoder node itself
650 // just return from here after scheduling itself.
651 // Because Reset command is not yet pop-ed out from cmd queue
652 // when in next run reset is processed with state
653 // PVAE_STATE_OPENED composer/encoder nodes get deleted.
654
655 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger,
656 PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::NodeUtilCommandCompleted: Exit"));
657 RunIfNotReady();
658 return ;
659 }
660 break;
661
662 case PVAE_CMD_START:
663 case PVAE_CMD_RESUME:
664 if (iNodeUtil.GetCommandQueueSize() > 0)
665 {
666 status = PVMFPending;
667 }
668 else
669 {
670 SetPVAEState(PVAE_STATE_RECORDING); // Start done. Change state
671 iAuthorClock.Start();
672 }
673 break;
674
675 case PVAE_CMD_PAUSE:
676 if (iNodeUtil.GetCommandQueueSize() > 0)
677 status = PVMFPending;
678 else
679 SetPVAEState(PVAE_STATE_PAUSED); // Pause done. Change state
680 break;
681
682 case PVAE_CMD_STOP:
683 case PVAE_CMD_STOP_MAX_SIZE:
684 case PVAE_CMD_STOP_MAX_DURATION:
685 case PVAE_CMD_STOP_EOS_REACHED:
686 if (iNodeUtil.GetCommandQueueSize() > 0)
687 status = PVMFPending;
688 else
689 SetPVAEState(PVAE_STATE_INITIALIZED); // Stop done. Change state
690 break;
691
692 default:
693 break;
694 }
695
696 if (status != PVMFPending)
697 {
698 if (iState == PVAE_STATE_ERROR)
699 {
700 CompleteEngineCommand(cmd, status);
701 }
702 else
703 {
704 CompleteEngineCommand(cmd, status, responseData, responseDataSize);
705 }
706 }
707 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
708 (0, "PVAuthorEngine::NodeUtilCommandCompleted: Exit"));
709 }
710
711 ////////////////////////////////////////////////////////////////////////////
NodeUtilErrorEvent(const PVMFAsyncEvent & aEvent)712 void PVAuthorEngine::NodeUtilErrorEvent(const PVMFAsyncEvent& aEvent)
713 {
714 LOG_ERR((0, "PVAuthorEngine::NodeUtilErrorEvent"));
715 HandleNodeErrorEvent(aEvent);
716 }
717
718 ////////////////////////////////////////////////////////////////////////////
Run()719 void PVAuthorEngine::Run()
720 {
721 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
722 (0, "PVAuthorEngine::Run: Enter"));
723
724 if (iPendingCmds.empty())
725 return;
726
727 // Retrieve the first pending command from queue
728 PVEngineCommand cmd(iPendingCmds[0]);
729
730 PVMFStatus status = PVMFFailure;
731 switch (cmd.GetCmdType())
732 {
733 case PVAE_CMD_GET_SDK_INFO:
734 case PVAE_CMD_GET_SDK_MODULE_INFO:
735 case PVAE_CMD_SET_LOG_APPENDER:
736 case PVAE_CMD_REMOVE_LOG_APPENDER:
737 case PVAE_CMD_SET_LOG_LEVEL:
738 case PVAE_CMD_GET_LOG_LEVEL:
739 case PVAE_CMD_QUERY_UUID:
740 case PVAE_CMD_CANCEL_ALL_COMMANDS:
741 status = PVMFErrNotSupported;
742 break;
743 case PVAE_CMD_QUERY_INTERFACE:
744 status = DoQueryInterface(cmd);
745 break;
746 case PVAE_CMD_OPEN:
747 status = DoOpen(cmd);
748 break;
749 case PVAE_CMD_CLOSE:
750 status = DoClose(cmd);
751 break;
752 case PVAE_CMD_ADD_DATA_SOURCE:
753 status = DoAddDataSource(cmd);
754 break;
755 case PVAE_CMD_REMOVE_DATA_SOURCE:
756 status = DoRemoveDataSource(cmd);
757 break;
758 case PVAE_CMD_SELECT_COMPOSER:
759 status = DoSelectComposer(cmd);
760 break;
761 case PVAE_CMD_ADD_MEDIA_TRACK:
762 status = DoAddMediaTrack(cmd);
763 break;
764 case PVAE_CMD_ADD_DATA_SINK:
765 status = DoAddDataSink(cmd);
766 break;
767 case PVAE_CMD_REMOVE_DATA_SINK:
768 status = DoRemoveDataSink(cmd);
769 break;
770 case PVAE_CMD_INIT:
771 status = DoInit(cmd);
772 break;
773 case PVAE_CMD_RESET:
774 status = DoReset(cmd);
775 break;
776 case PVAE_CMD_START:
777 status = DoStart(cmd);
778 break;
779 case PVAE_CMD_PAUSE:
780 status = DoPause(cmd);
781 break;
782 case PVAE_CMD_RESUME:
783 status = DoResume(cmd);
784 break;
785 case PVAE_CMD_STOP:
786 status = DoStop(cmd);
787 break;
788 case PVAE_CMD_STOP_MAX_SIZE:
789 case PVAE_CMD_STOP_MAX_DURATION:
790 case PVAE_CMD_STOP_EOS_REACHED:
791 status = DoStopMaxSizeDuration();
792 break;
793 case PVAE_CMD_CAPCONFIG_SET_PARAMETERS:
794 status = DoCapConfigSetParameters(cmd, false);
795 break;
796 default:
797 status = PVMFErrNotSupported;
798 break;
799 }
800
801 if (status != PVMFPending)
802 CompleteEngineCommand(cmd, status);
803
804 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
805 (0, "PVAuthorEngine::Run: Exit"));
806 }
807
808 ////////////////////////////////////////////////////////////////////////////
Dispatch(PVEngineCommand & aCmd)809 void PVAuthorEngine::Dispatch(PVEngineCommand& aCmd)
810 {
811 iPendingCmds.push_back(aCmd);
812
813 // Call RunIfNotReady only if the newly added command is the only one
814 // in the queue. Otherwise, it will be processed after the current
815 // command is complete
816 if (iPendingCmds.size() == 1)
817 RunIfNotReady();
818 }
819
820 ////////////////////////////////////////////////////////////////////////////
Dispatch(PVEngineAsyncEvent & aEvent)821 void PVAuthorEngine::Dispatch(PVEngineAsyncEvent& aEvent)
822 {
823 iPendingEvents.push_back(aEvent);
824
825 // Call RunIfNotReady only if the newly added command is the only one
826 // in the queue. Otherwise, it will be processed after the current
827 // command is complete
828 if (iPendingCmds.size() == 1)
829 RunIfNotReady();
830 }
831
PushCmdInFront(PVEngineCommand & aCmd)832 void PVAuthorEngine::PushCmdInFront(PVEngineCommand& aCmd)
833 {
834 uint32 idx = 0;
835 while (idx < iPendingCmds.size())
836 {
837 PVEngineCommand cmdPenCmd(iPendingCmds[idx++]);
838 if (cmdPenCmd.GetCmdType() == PVAE_CMD_RESET) //dont erase RESET
839 {
840 return;
841 }
842 }
843 //Author engine processes commands in the order recvd.This is true for API commands, since author does
844 //not support cancelall yet.when composer node eventually reports any informational event like PVMF_COMPOSER_MAXFILESIZE_REACHED,
845 //author engine should queue this cmd into iPendingCmds using "push_front"
846 iPendingCmds.push_front(aCmd);
847 // Call RunIfNotReady only if the newly added command is the only one
848 // in the queue. Otherwise, it will be processed after the current
849 // command is complete
850 if (iPendingCmds.size() == 1)
851 RunIfNotReady();
852 }
853
854 ////////////////////////////////////////////////////////////////////////////
CompleteEngineCommand(PVEngineCommand & aCmd,PVMFStatus aStatus,OsclAny * aResponseData,int32 aResponseDataSize)855 void PVAuthorEngine::CompleteEngineCommand(PVEngineCommand& aCmd, PVMFStatus aStatus,
856 OsclAny* aResponseData, int32 aResponseDataSize)
857 {
858 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
859 (0, "PVAuthorEngine::CompleteEngineCommand: aStatus=0x%x, aResponseData=0x%x, aResponseDataSize=%d",
860 aStatus, aResponseData, aResponseDataSize));
861
862 // Erase command from command queue
863 if (!iPendingCmds.empty())
864 {
865 iPendingCmds.erase(iPendingCmds.begin());
866 }
867
868 if (IsPVMFErrCode(aStatus))
869 {
870 PVCmdResponse response(aCmd.GetCmdId(), aCmd.GetContext(), aStatus, aResponseData, aResponseDataSize);
871 iCmdStatusObserver->CommandCompleted(response);
872 // if there are pending commands, send command complete and erase them
873 while (!iPendingCmds.empty())
874 {
875 PVEngineCommand cmdPenCmd(iPendingCmds[0]);
876 if (cmdPenCmd.GetCmdType() != PVAE_CMD_RESET) //dont erase RESET
877 {
878 PVCmdResponse response(cmdPenCmd.GetCmdId(), cmdPenCmd.GetContext(), aStatus, NULL, 0);
879 iCmdStatusObserver->CommandCompleted(response);
880 iPendingCmds.erase(iPendingCmds.begin());
881 }
882 else
883 {
884 break;
885 }
886 }
887 if (!iPendingCmds.empty()) //if the RESET is still pending
888 {
889 RunIfNotReady();
890 }
891 return;
892 }
893
894 // Callback to engine observer
895 switch (aCmd.GetCmdType())
896 {
897 case PVAE_CMD_STOP_MAX_SIZE:
898 {
899 PVAsyncInformationalEvent event(PVMF_COMPOSER_MAXFILESIZE_REACHED, NULL);
900 iInfoEventObserver->HandleInformationalEvent(event);
901 }
902 break;
903
904 case PVAE_CMD_STOP_MAX_DURATION:
905 {
906 PVAsyncInformationalEvent event(PVMF_COMPOSER_MAXDURATION_REACHED, NULL);
907 iInfoEventObserver->HandleInformationalEvent(event);
908 }
909 break;
910 case PVAE_CMD_STOP_EOS_REACHED:
911 {
912 PVAsyncInformationalEvent event(PVMF_COMPOSER_EOS_REACHED, NULL);
913 iInfoEventObserver->HandleInformationalEvent(event);
914 }
915 break;
916 case PVAE_CMD_CAPCONFIG_SET_PARAMETERS:
917 // Send callback to the specified observer
918 if (iCfgCapCmdObserver)
919 {
920 iCfgCapCmdObserver->SignalEvent(0);
921 }
922 break;
923 default:
924 {
925 PVCmdResponse response(aCmd.GetCmdId(), aCmd.GetContext(), aStatus, aResponseData, aResponseDataSize);
926 iCmdStatusObserver->CommandCompleted(response);
927 }
928 break;
929 }
930 // Run next command if there are pending commands
931 if (!iPendingCmds.empty())
932 RunIfNotReady();
933 }
934
935 ////////////////////////////////////////////////////////////////////////////
DoOpen(PVEngineCommand & aCmd)936 PVMFStatus PVAuthorEngine::DoOpen(PVEngineCommand& aCmd)
937 {
938 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoOpen"));
939
940 OSCL_UNUSED_ARG(aCmd);
941
942 if (GetPVAEState() != PVAE_STATE_IDLE)
943 {
944 return PVMFErrInvalidState;
945 }
946 else
947 {
948 SetPVAEState(PVAE_STATE_OPENED);
949 return PVMFSuccess;
950 }
951 }
952
953 ////////////////////////////////////////////////////////////////////////////
DoClose(PVEngineCommand & aCmd)954 PVMFStatus PVAuthorEngine::DoClose(PVEngineCommand& aCmd)
955 {
956 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoClose"));
957
958 OSCL_UNUSED_ARG(aCmd);
959
960 switch (GetPVAEState())
961 {
962 case PVAE_STATE_OPENED:
963 while (!iDataSourcePool.empty())
964 {
965 OSCL_DELETE(iDataSourcePool[0]);
966 iDataSourcePool.erase(iDataSourcePool.begin());
967 }
968
969 while (!iDataSinkPool.empty())
970 {
971 OSCL_DELETE(iDataSinkPool[0]);
972 iDataSinkPool.erase(iDataSinkPool.begin());
973 }
974
975 SetPVAEState(PVAE_STATE_IDLE);
976 return PVMFSuccess;
977
978 case PVAE_STATE_IDLE:
979 return PVMFSuccess;
980
981 default:
982 return PVMFErrInvalidState;
983 }
984 }
985
986 ////////////////////////////////////////////////////////////////////////////
DoAddDataSource(PVEngineCommand & aCmd)987 PVMFStatus PVAuthorEngine::DoAddDataSource(PVEngineCommand& aCmd)
988 {
989 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoAddDataSource"));
990
991 if (GetPVAEState() != PVAE_STATE_OPENED)
992 {
993 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
994 (0, "PVAuthorEngine::DoAddDataSource: Error - State is not OPENED. state=%d", GetPVAEState()));
995 return PVMFErrInvalidState;
996 }
997
998 PVMFNodeInterface* node = OSCL_REINTERPRET_CAST(PVMFNodeInterface*, aCmd.GetParam1());
999 if (!node)
1000 {
1001 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
1002 (0, "PVAuthorEngine::DoAddDataSource: Error - Data source node == NULL"));
1003 return PVMFFailure;
1004 }
1005
1006 int32 err = 0;
1007 PVAENodeContainer* nodeContainer = AllocateNodeContainer(node);
1008 if (!nodeContainer)
1009 {
1010 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - AllocateNodeContainer failed"));
1011 return PVMFErrNoMemory;
1012 }
1013
1014 OSCL_TRY(err, iDataSourcePool.push_back(nodeContainer););
1015 OSCL_FIRST_CATCH_ANY(err,
1016 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - iComposerNodes.push_back() failed"));
1017 OSCL_DELETE(nodeContainer);
1018 return PVMFErrNoMemory;
1019 );
1020
1021 PVMFStatus retval = iNodeUtil.Init(nodeContainer);
1022 if (retval != PVMFPending)
1023 {
1024 LOG_ERR((0, "PVAuthorEngine::DoAddDataSource: Error - Init(datasrc) failed"));
1025 DeallocateNodeContainer(iDataSourcePool, node);
1026 }
1027
1028 return retval;
1029 }
1030
1031 ////////////////////////////////////////////////////////////////////////////
DoRemoveDataSource(PVEngineCommand & aCmd)1032 PVMFStatus PVAuthorEngine::DoRemoveDataSource(PVEngineCommand& aCmd)
1033 {
1034 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoRemoveDataSource"));
1035
1036 if (GetPVAEState() != PVAE_STATE_OPENED)
1037 {
1038 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
1039 (0, "PVAuthorEngine::DoRemoveDataSource: Error - State is not OPENED. state=%d", GetPVAEState()));
1040 return PVMFErrInvalidState;
1041 }
1042
1043 PVMFNodeInterface* node = OSCL_REINTERPRET_CAST(PVMFNodeInterface*, aCmd.GetParam1());
1044 return DeallocateNodeContainer(iDataSourcePool, node);
1045 }
1046
1047 ////////////////////////////////////////////////////////////////////////////
DoSelectComposer(PVEngineCommand & aCmd)1048 PVMFStatus PVAuthorEngine::DoSelectComposer(PVEngineCommand& aCmd)
1049 {
1050 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoSelectComposer"));
1051
1052 if (GetPVAEState() != PVAE_STATE_OPENED)
1053 {
1054 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - State is not OPENED. state=%d", GetPVAEState()));
1055 return PVMFErrInvalidState;
1056 }
1057
1058 PVUuid uuid;
1059 if (aCmd.GetUuid() == uuid)
1060 {
1061 // No specified UUID, go query for a suitable one
1062 OSCL_HeapString<OsclMemAllocator> mimeType = aCmd.GetMimeType();
1063 PVAuthorEngineNodeFactoryUtility::QueryRegistry(mimeType, uuid);
1064 }
1065 else
1066 {
1067 // Use the specified UUID
1068 uuid = aCmd.GetUuid();
1069 }
1070
1071 PVMFNodeInterface* node = PVAuthorEngineNodeFactoryUtility::CreateComposer(uuid);
1072 if (!node)
1073 {
1074 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - PVAuthorEngineNodeFactoryUtility::CreateComposer failed"));
1075 return PVMFFailure;
1076 }
1077
1078 int32 err = 0;
1079 PVAENodeContainer* nodeContainer = AllocateNodeContainer(node);
1080 if (!nodeContainer)
1081 {
1082 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - AllocateNodeContainer failed"));
1083 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1084 return PVMFErrNoMemory;
1085 }
1086 nodeContainer->iUuid = uuid;
1087
1088 OSCL_TRY(err, iComposerNodes.push_back(nodeContainer););
1089 OSCL_FIRST_CATCH_ANY(err,
1090 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - iComposerNodes.push_back() failed"));
1091 OSCL_DELETE(nodeContainer);
1092 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1093 return PVMFErrNoMemory;
1094 );
1095 OSCL_TRY(err,
1096 if (QueryNodeConfig(nodeContainer, *((PVInterface**)aCmd.GetParam1())) != PVMFPending)
1097 {
1098 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - QueryNodeConfig failed"));
1099 OSCL_LEAVE(OsclErrGeneral);
1100 }
1101
1102 if (iNodeUtil.Init(nodeContainer) != PVMFPending)
1103 {
1104 LOG_ERR((0, "PVAuthorEngine::DoSelectComposer: Error - Init(composer) failed"));
1105 OSCL_LEAVE(OsclErrGeneral);
1106 }
1107 );
1108
1109 OSCL_FIRST_CATCH_ANY(err,
1110 DeallocateNodeContainer(iComposerNodes, node);
1111 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1112 return PVMFFailure;
1113 );
1114
1115 return PVMFPending;
1116 }
1117
1118 ////////////////////////////////////////////////////////////////////////////
DoAddMediaTrack(PVEngineCommand & aCmd)1119 PVMFStatus PVAuthorEngine::DoAddMediaTrack(PVEngineCommand& aCmd)
1120 {
1121 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoAddMediaTrack"));
1122
1123 if (GetPVAEState() != PVAE_STATE_OPENED)
1124 {
1125 return PVMFErrInvalidState;
1126 }
1127
1128 // Find container for data source node
1129 PVAENodeContainer* inputNodeContainer = GetNodeContainer(iDataSourcePool, (PVMFNodeInterface*)aCmd.GetParam1());
1130 if (!inputNodeContainer)
1131 {
1132 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
1133 (0, "PVAuthorEngine::DoAddMediaTrack: Error - Source node is not among the ones added to AddDataSource()"));
1134 return PVMFFailure;
1135 }
1136
1137 // Find container for composer node and get its capability
1138 PVAENodeContainer* composerNodeContainer = GetNodeContainer(iComposerNodes, (PVMFNodeInterface*)aCmd.GetParam2());
1139 if (!composerNodeContainer)
1140 {
1141 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
1142 (0, "PVAuthorEngine::DoAddMediaTrack: Error - Composer node is not among the ones selected by SelectComposer()"));
1143 return PVMFFailure;
1144 }
1145 PVMFNodeCapability composerNodeCapability;
1146 composerNodeContainer->iNode->GetCapability(composerNodeCapability);
1147
1148 // Set encoder output format type in PVMFFormatType
1149 OSCL_HeapString<OsclMemAllocator> compressedFormatMimeType;
1150 if (GetPvmfFormatString(compressedFormatMimeType, aCmd.GetMimeType()) != PVMFSuccess)
1151 {
1152 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
1153 (0, "PVAuthorEngine::DoAddMediaTrack: Error - Encoder MIME type not supported"));
1154 return PVMFFailure;
1155 }
1156
1157 bool compressedDataSrc = false;
1158 if (IsCompressedFormatDataSource(inputNodeContainer, compressedDataSrc) != PVMFSuccess)
1159 {
1160 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - IsCompressedFormatDataSource() failed"));
1161 return PVMFFailure;
1162 }
1163 LOG_DEBUG((0, "PVAuthorEngine::DoAddMediaTrack: compressedDataSrc=%d", compressedDataSrc));
1164
1165 int32 err = 0;
1166 OSCL_TRY(err, iDataSourceNodes.push_back(inputNodeContainer););
1167 OSCL_FIRST_CATCH_ANY(err,
1168 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - iDataSourceNodes.push_back failed"));
1169 return PVMFFailure;
1170 );
1171
1172 if (compressedDataSrc)
1173 {
1174 // Encoder is not used in the graph. Connect source node with composer directly.
1175 // The composer node will be the master port in the connection attempt
1176 if (iNodeUtil.Connect(composerNodeContainer, PVAE_NODE_INPUT_PORT_TAG,
1177 inputNodeContainer, PVAE_NODE_OUTPUT_PORT_TAG, compressedFormatMimeType) != PVMFPending)
1178 {
1179 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - Connect(composer, datasrc) failed"));
1180 return PVMFFailure;
1181 }
1182 }
1183 else
1184 {
1185 PVUuid uuid;
1186 if (aCmd.GetUuid() == uuid)
1187 {
1188 // Input node outputs unencoded data. Query for a suitable encoder
1189 PVAuthorEngineNodeFactoryUtility::QueryRegistry(aCmd.GetMimeType(), uuid);
1190 }
1191 else
1192 {
1193 // Use the specified UUID
1194 uuid = aCmd.GetUuid();
1195 }
1196
1197 PVMFNodeInterface* node = PVAuthorEngineNodeFactoryUtility::CreateEncoder(uuid);
1198 if (!node)
1199 {
1200 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - PVAuthorEngineNodeFactoryUtility::CreateEncoder failed"));
1201 return PVMFErrNoMemory;
1202 }
1203
1204 PVAENodeContainer* encoderNodeContainer = AllocateNodeContainer(node);
1205 if (!encoderNodeContainer)
1206 {
1207 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - AllocateNodeContainer failed"));
1208 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1209 return PVMFErrNoMemory;
1210 }
1211 encoderNodeContainer->iUuid = uuid;
1212
1213 OSCL_TRY(err, iEncoderNodes.push_back(encoderNodeContainer););
1214 OSCL_FIRST_CATCH_ANY(err,
1215 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - iEncoderNodes.push_back() failed"));
1216 OSCL_DELETE(encoderNodeContainer);
1217 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1218 return PVMFErrNoMemory;
1219 );
1220
1221 OSCL_TRY(err,
1222 if (QueryNodeConfig(encoderNodeContainer, *((PVInterface**)aCmd.GetParam3())) != PVMFPending)
1223 {
1224 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - QueryNodeConfig failed"));
1225 OSCL_LEAVE(OsclErrGeneral);
1226 }
1227
1228 if (iNodeUtil.Init(encoderNodeContainer) != PVMFPending)
1229 {
1230 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - Init(encoder) failed"));
1231 OSCL_LEAVE(OsclErrGeneral);
1232 }
1233
1234 // Connect data source to encoder. The encoder node is the master port
1235 // in this connection. An empty string is specified as the mime type
1236 // to allow the ports to negotiate formats
1237 if (iNodeUtil.Connect(encoderNodeContainer, PVAE_NODE_INPUT_PORT_TAG,
1238 inputNodeContainer, PVAE_NODE_OUTPUT_PORT_TAG, OSCL_StackString<1>("")) != PVMFPending)
1239 {
1240 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - Connect(encoder, datasrc) failed"));
1241 OSCL_LEAVE(OsclErrGeneral);
1242 }
1243
1244 // Connect encoder to composer. The encoder node will be the master port in the connection attempt
1245 // The PVMF mime type of the compressed format is specified here
1246 if (iNodeUtil.Connect(encoderNodeContainer, PVAE_NODE_OUTPUT_PORT_TAG,
1247 composerNodeContainer, PVAE_NODE_INPUT_PORT_TAG, compressedFormatMimeType) != PVMFPending)
1248 {
1249 LOG_ERR((0, "PVAuthorEngine::DoAddMediaTrack: Error - Connect(encoder, composer) failed"));
1250 OSCL_LEAVE(OsclErrGeneral);
1251 }
1252 );
1253
1254 OSCL_FIRST_CATCH_ANY(err,
1255 DeallocateNodeContainer(iEncoderNodes, node);
1256 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1257 return PVMFFailure;
1258 );
1259 }
1260
1261 return PVMFPending;
1262 }
1263
1264 ////////////////////////////////////////////////////////////////////////////
DoAddDataSink(PVEngineCommand & aCmd)1265 PVMFStatus PVAuthorEngine::DoAddDataSink(PVEngineCommand& aCmd)
1266 {
1267 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoAddDataSink"));
1268
1269 OSCL_UNUSED_ARG(aCmd);
1270
1271 if (GetPVAEState() != PVAE_STATE_OPENED)
1272 {
1273 return PVMFErrInvalidState;
1274 }
1275 else
1276 {
1277 return PVMFSuccess;
1278 }
1279 }
1280
1281 ////////////////////////////////////////////////////////////////////////////
DoRemoveDataSink(PVEngineCommand & aCmd)1282 PVMFStatus PVAuthorEngine::DoRemoveDataSink(PVEngineCommand& aCmd)
1283 {
1284 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoRemoveDataSink"));
1285
1286 OSCL_UNUSED_ARG(aCmd);
1287
1288 if (GetPVAEState() != PVAE_STATE_OPENED)
1289 {
1290 return PVMFErrInvalidState;
1291 }
1292 else
1293 {
1294 return PVMFSuccess;
1295 }
1296 }
1297
1298 ////////////////////////////////////////////////////////////////////////////
DoInit(PVEngineCommand & aCmd)1299 PVMFStatus PVAuthorEngine::DoInit(PVEngineCommand& aCmd)
1300 {
1301 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoInit"));
1302
1303 OSCL_UNUSED_ARG(aCmd);
1304
1305 if (GetPVAEState() != PVAE_STATE_OPENED)
1306 {
1307 return PVMFErrInvalidState;
1308 }
1309
1310 if (iComposerNodes.size() == 0 || iDataSourceNodes.size() == 0)
1311 {
1312 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
1313 (0, "PVAuthorEngine::DoInit: Error - SelectComposer() or AddMediaTrack() has not been called"));
1314 return PVMFFailure;
1315 }
1316
1317 iNodeUtil.Prepare(iComposerNodes);
1318 if (iEncoderNodes.size() > 0)
1319 iNodeUtil.Prepare(iEncoderNodes);
1320 iNodeUtil.Prepare(iDataSourceNodes);
1321 PVUuid iUuid1 = PVMI_CAPABILITY_AND_CONFIG_PVUUID;
1322
1323 for (uint ii = 0; ii < iEncoderNodes.size(); ii++)
1324 {
1325 // call queryInterface of amr/video encoder node
1326 // retrieve capability class pointer in iEncoderNode
1327 // capability class pointer fetched from amr/video encoder node in iEncoderNode
1328 iEncoderNodes[ii]->iNode->QueryInterface(iEncoderNodes[ii]->iSessionId,
1329 iUuid1,
1330 iEncoderNodes[ii]->iNodeCapConfigIF,
1331 NULL);
1332 }
1333
1334 for (uint jj = 0; jj < iComposerNodes.size(); jj++)
1335 {
1336 // call queryInterface of file-ouput/mp4-composer node
1337 // retrieve capability class pointer in iComposerNode
1338 // capability class pointer fetched from file-ouput/mp4-composer node in iComposerNode
1339 iComposerNodes[jj]->iNode->QueryInterface(iComposerNodes[jj]->iSessionId,
1340 iUuid1,
1341 iComposerNodes[jj]->iNodeCapConfigIF,
1342 NULL);
1343 }
1344
1345 for (uint kk = 0; kk < iDataSourceNodes.size(); kk++)
1346 {
1347 // call queryInterface of media io node
1348 // retrieve capability class pointer in iDataSourceNodes
1349 // capability class pointer fetched from media io node in iDataSourceNodes
1350 iDataSourceNodes[kk]->iNode->QueryInterface(iDataSourceNodes[kk]->iSessionId,
1351 iUuid1,
1352 iDataSourceNodes[kk]->iNodeCapConfigIF,
1353 NULL);
1354 }
1355 return PVMFPending;
1356 }
1357
1358 ////////////////////////////////////////////////////////////////////////////
DoReset(PVEngineCommand & aCmd)1359 PVMFStatus PVAuthorEngine::DoReset(PVEngineCommand& aCmd)
1360 {
1361 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoReset"));
1362
1363 OSCL_UNUSED_ARG(aCmd);
1364
1365 if (GetPVAEState() == PVAE_STATE_IDLE)
1366 {
1367 return PVMFErrInvalidState;
1368 }
1369
1370 else
1371 {
1372 if ((iDataSourceNodes.size() == 0)
1373 && (iEncoderNodes.size() == 0)
1374 && (iComposerNodes.size() == 0))
1375 {
1376 // If there is no source/encoder/composer node present
1377 // there is nothing to reset, return success rightaway.
1378 return PVMFSuccess;
1379 }
1380 //First call reset on all child nodes, source nodes, encoder nodes, composer nodes
1381 //Pls note that since reset on child nodes can be called from any state, and since
1382 //node reset needs to clean up everything, there is no need to thru an asynchronous
1383 //release port sequence
1384 //Once all these resets complete delete them all. We use the boolean iDoResetNodeContainers
1385 //to get back in the context of author engine AO to delete stuff. We cannot delete stuff in
1386 //NodeUtilCommandCompleted
1387 if (iDoResetNodeContainers)
1388 {
1389 iDoResetNodeContainers = false;
1390 // While RESET-ing, the Composer and Encoder nodes are to be
1391 // deleted as there no user API to do deallocations for the
1392 // allocations done in the api's DoSelectComposer() and AddMediaTrack()
1393 ResetNodeContainers();
1394 return PVMFSuccess;
1395 }
1396 //Notify data sources to stop using author clock
1397 iAuthorClock.Stop();
1398 SendAuthoringClockToDataSources(true);
1399 ResetGraph();
1400 }
1401 return PVMFPending;
1402 }
1403
1404 ////////////////////////////////////////////////////////////////////////////
DoStart(PVEngineCommand & aCmd)1405 PVMFStatus PVAuthorEngine::DoStart(PVEngineCommand& aCmd)
1406 {
1407 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoStart"));
1408
1409 OSCL_UNUSED_ARG(aCmd);
1410
1411 if (GetPVAEState() != PVAE_STATE_INITIALIZED)
1412 {
1413 return PVMFErrInvalidState;
1414 }
1415
1416 iNodeUtil.Start(iComposerNodes);
1417 if (iEncoderNodes.size() > 0)
1418 iNodeUtil.Start(iEncoderNodes);
1419 iNodeUtil.Start(iDataSourceNodes);
1420 return PVMFPending;
1421 }
1422
1423 ////////////////////////////////////////////////////////////////////////////
DoPause(PVEngineCommand & aCmd)1424 PVMFStatus PVAuthorEngine::DoPause(PVEngineCommand& aCmd)
1425 {
1426 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoPause"));
1427
1428 OSCL_UNUSED_ARG(aCmd);
1429
1430 if (GetPVAEState() != PVAE_STATE_RECORDING)
1431 {
1432 return PVMFErrInvalidState;
1433 }
1434
1435 iAuthorClock.Pause();
1436
1437 iNodeUtil.Pause(iDataSourceNodes);
1438 if (iEncoderNodes.size() > 0)
1439 iNodeUtil.Pause(iEncoderNodes);
1440 iNodeUtil.Pause(iComposerNodes);
1441 return PVMFPending;
1442 }
1443
1444 ////////////////////////////////////////////////////////////////////////////
DoResume(PVEngineCommand & aCmd)1445 PVMFStatus PVAuthorEngine::DoResume(PVEngineCommand& aCmd)
1446 {
1447 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoResume"));
1448
1449 OSCL_UNUSED_ARG(aCmd);
1450
1451 if (GetPVAEState() != PVAE_STATE_PAUSED)
1452 {
1453 return PVMFErrInvalidState;
1454 }
1455
1456 iNodeUtil.Start(iComposerNodes);
1457 if (iEncoderNodes.size() > 0)
1458 iNodeUtil.Start(iEncoderNodes);
1459 iNodeUtil.Start(iDataSourceNodes);
1460 return PVMFPending;
1461 }
1462
1463 ////////////////////////////////////////////////////////////////////////////
DoStop(PVEngineCommand & aCmd)1464 PVMFStatus PVAuthorEngine::DoStop(PVEngineCommand& aCmd)
1465 {
1466 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoStop"));
1467
1468 OSCL_UNUSED_ARG(aCmd);
1469
1470 switch (GetPVAEState())
1471 {
1472 case PVAE_STATE_RECORDING:
1473 case PVAE_STATE_PAUSED:
1474 iAuthorClock.Stop();
1475 iNodeUtil.Flush(iDataSourceNodes);
1476 if (iEncoderNodes.size() > 0)
1477 iNodeUtil.Flush(iEncoderNodes);
1478 iNodeUtil.Flush(iComposerNodes);
1479 return PVMFPending;
1480
1481 default:
1482 return PVMFErrInvalidState;
1483 }
1484 }
1485
1486 ////////////////////////////////////////////////////////////////////////////
ResetNodeContainers()1487 void PVAuthorEngine::ResetNodeContainers()
1488 {
1489 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
1490 (0, "PVAuthorEngine::ResetNodeContainers"));
1491
1492 if (iAllNodes.size() > 0)
1493 iAllNodes.clear();
1494
1495 uint32 i, j;
1496 for (i = 0; i < iDataSourceNodes.size(); i++)
1497 {
1498 for (j = 0; j < iDataSourceNodes[i]->iOutputPorts.size(); j++)
1499 {
1500 iDataSourceNodes[i]->iOutputPorts[j]->Disconnect();
1501 }
1502 }
1503 iDataSourceNodes.clear();
1504
1505 PVUuid uuid;
1506 PVMFNodeInterface* node;
1507
1508 while (!iComposerNodes.empty())
1509 {
1510 uuid = iComposerNodes[0]->iUuid;
1511 node = iComposerNodes[0]->iNode;
1512 for (j = 0; j < iComposerNodes[0]->iExtensions.size(); j++)
1513 {
1514 iComposerNodes[0]->iExtensions[j]->removeRef();
1515 }
1516 iComposerNodes[0]->iExtensions.clear();
1517 iComposerNodes[0]->iExtensionUuids.clear();
1518 iComposerNodes[0]->iInputPorts.clear();
1519 iComposerNodes[0]->iOutputPorts.clear();
1520 DeallocateNodeContainer(iComposerNodes, node);
1521 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1522
1523 }
1524
1525 while (!iEncoderNodes.empty())
1526 {
1527 uuid = iEncoderNodes[0]->iUuid;
1528 node = iEncoderNodes[0]->iNode;
1529 for (j = 0; j < iEncoderNodes[0]->iExtensions.size(); j++)
1530 {
1531 iEncoderNodes[0]->iExtensions[j]->removeRef();
1532 }
1533 iEncoderNodes[0]->iExtensions.clear();
1534 iEncoderNodes[0]->iExtensionUuids.clear();
1535 iEncoderNodes[0]->iInputPorts.clear();
1536 iEncoderNodes[0]->iOutputPorts.clear();
1537 DeallocateNodeContainer(iEncoderNodes, node);
1538 PVAuthorEngineNodeFactoryUtility::Delete(uuid, node);
1539
1540 }
1541 return;
1542 }
1543
1544 ////////////////////////////////////////////////////////////////////////////
DoQueryInterface(PVEngineCommand & aCmd)1545 PVMFStatus PVAuthorEngine::DoQueryInterface(PVEngineCommand& aCmd)
1546 {
1547 if (aCmd.GetUuid() == PvmfComposerSizeAndDurationUuid && !iComposerNodes.empty())
1548 {
1549 return iNodeUtil.QueryInterface(iComposerNodes[0], aCmd.GetUuid(),
1550 *((PVInterface**)(aCmd.iParam1)), aCmd.GetContext());
1551 }
1552
1553 else if (aCmd.GetUuid() == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
1554 {
1555 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoQueryInterface() In"));
1556 PVInterface** ifptr = (PVInterface**)(aCmd.GetParam1());
1557 PVUuid uuid = aCmd.GetUuid();
1558 if (NULL == ifptr)
1559 {
1560 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoQueryInterface() Passed in parameter invalid."));
1561 return PVMFErrArgument;
1562 }
1563
1564 PVMFStatus cmdstatus = PVMFSuccess;
1565 if (false == queryInterface(uuid, *ifptr))
1566 {
1567 cmdstatus = PVMFErrNotSupported;
1568 }
1569 else
1570 {
1571 (*ifptr)->addRef();
1572 }
1573
1574 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoQueryInterface() Out"));
1575 return PVMFSuccess;
1576 }
1577 // No interface available
1578 return PVMFFailure;
1579 }
1580
1581 ////////////////////////////////////////////////////////////////////////////
DoStopMaxSizeDuration()1582 PVMFStatus PVAuthorEngine::DoStopMaxSizeDuration()
1583 {
1584 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
1585 (0, "PVAuthorEngine::DoStopMaxSizeDuration"));
1586
1587 switch (GetPVAEState())
1588 {
1589 case PVAE_STATE_RECORDING:
1590 case PVAE_STATE_PAUSED:
1591 iNodeUtil.Stop(iDataSourceNodes);
1592 if (iEncoderNodes.size() > 0)
1593 iNodeUtil.Stop(iEncoderNodes);
1594 iNodeUtil.Stop(iComposerNodes);
1595 return PVMFPending;
1596
1597 default:
1598 return PVMFErrInvalidState;
1599 }
1600 }
1601
1602 ////////////////////////////////////////////////////////////////////////////
SetPVAEState(PVAEState aState)1603 void PVAuthorEngine::SetPVAEState(PVAEState aState)
1604 {
1605 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
1606 (0, "PVAuthorEngine::SetPVAEState: aState=%d", aState));
1607 iState = aState;
1608 }
1609
1610 ////////////////////////////////////////////////////////////////////////////
GetNodeContainer(PVAENodeContainerVector & aNodeContainerVector,PVMFNodeInterface * aNode)1611 PVAENodeContainer* PVAuthorEngine::GetNodeContainer(PVAENodeContainerVector& aNodeContainerVector,
1612 PVMFNodeInterface* aNode)
1613 {
1614 for (uint32 i = 0; i < aNodeContainerVector.size(); i++)
1615 {
1616 if (aNodeContainerVector[i]->iNode == aNode)
1617 return aNodeContainerVector[i];
1618 }
1619
1620 return NULL;
1621 }
1622
1623 ////////////////////////////////////////////////////////////////////////////
IsCompressedFormatDataSource(PVAENodeContainer * aDataSrc,bool & aIsCompressedFormat)1624 PVMFStatus PVAuthorEngine::IsCompressedFormatDataSource(PVAENodeContainer* aDataSrc, bool& aIsCompressedFormat)
1625 {
1626 LOG_STACK_TRACE((0, "PVAuthorEngine::IsCompressedFormatDataSource"));
1627
1628 // Get input node capability
1629 PVMFNodeCapability capability;
1630 if (aDataSrc->iNode->GetCapability(capability) != PVMFSuccess)
1631 {
1632 LOG_ERR((0, "PVAuthorEngine::IsCompressedFormatDataSource: Error - GetCapability failed"));
1633 return PVMFFailure;
1634 }
1635 aIsCompressedFormat = false;
1636 for (uint32 i = 0; i < capability.iOutputFormatCapability.size(); i++)
1637 {
1638 PVMFFormatType format = (capability.iOutputFormatCapability[i]);
1639 if (format.isCompressed() || format.isText())
1640 {
1641 aIsCompressedFormat = true;
1642 return PVMFSuccess;
1643 }
1644 }
1645
1646 return PVMFSuccess;
1647 }
1648
1649 ////////////////////////////////////////////////////////////////////////////
ResetGraph()1650 void PVAuthorEngine::ResetGraph()
1651 {
1652
1653 if (iAllNodes.size() != (iEncoderNodes.size() + iDataSourceNodes.size() + iComposerNodes.size()))
1654 {
1655
1656 for (uint ii = 0; ii < iEncoderNodes.size(); ii++)
1657 {
1658 iAllNodes.push_back(iEncoderNodes[ii]);
1659 }
1660 for (uint jj = 0; jj < iDataSourceNodes.size(); jj++)
1661 {
1662 iAllNodes.push_back(iDataSourceNodes[jj]);
1663 }
1664 for (uint kk = 0; kk < iComposerNodes.size(); kk++)
1665 {
1666 iAllNodes.push_back(iComposerNodes[kk]);
1667 }
1668 }
1669
1670
1671 if (iAllNodes.size() > 0)
1672 {
1673 iNodeUtil.Reset(iAllNodes);
1674 }
1675
1676 }
1677
1678 ////////////////////////////////////////////////////////////////////////////
QueryNodeConfig(PVAENodeContainer * aNodeContainer,PVInterface * & aInterface)1679 PVMFStatus PVAuthorEngine::QueryNodeConfig(PVAENodeContainer* aNodeContainer, PVInterface*& aInterface)
1680 {
1681 PVUuid uuid;
1682 if (!PVAuthorEngineNodeFactoryUtility::QueryNodeConfigUuid(aNodeContainer->iUuid, uuid))
1683 {
1684 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
1685 (0, "PVAuthorEngine::QueryNodeConfig: No configuration interface available for this node."));
1686 return PVMFSuccess;
1687 }
1688
1689 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_DEBUG,
1690 (0, "PVAuthorEngine::QueryNodeConfig: Configuration interface available."));
1691
1692 if (iNodeUtil.QueryInterface(aNodeContainer, uuid, aInterface) != PVMFPending)
1693 {
1694 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_ERR,
1695 (0, "PVAuthorEngine::QueryNodeConfig: Error - QueryInterface failed"));
1696 return PVMFFailure;
1697 }
1698
1699 return PVMFPending;
1700 }
1701
1702 ////////////////////////////////////////////////////////////////////////////
GetPvmfFormatString(PvmfMimeString & aMimeType,const PvmfMimeString & aNodeMimeType)1703 PVMFStatus PVAuthorEngine::GetPvmfFormatString(PvmfMimeString& aMimeType, const PvmfMimeString& aNodeMimeType)
1704 {
1705 if (aNodeMimeType == KMp4EncMimeType)
1706 {
1707 aMimeType = PVMF_MIME_M4V;
1708 }
1709 else if (aNodeMimeType == KH263EncMimeType)
1710 {
1711 aMimeType = PVMF_MIME_H2632000;
1712 }
1713 else if (aNodeMimeType == KAmrNbEncMimeType ||
1714 aNodeMimeType == KAMRNbComposerMimeType)
1715 {
1716 aMimeType = PVMF_MIME_AMR_IETF;
1717 }
1718 else if (aNodeMimeType == KAMRWbEncMimeType)
1719 {
1720 aMimeType = PVMF_MIME_AMRWB_IETF;
1721 }
1722 else if (aNodeMimeType == KAACADIFEncMimeType ||
1723 aNodeMimeType == KAACADIFComposerMimeType)
1724 {
1725 aMimeType = PVMF_MIME_ADIF;
1726 }
1727 else if (aNodeMimeType == KAACADTSEncMimeType ||
1728 aNodeMimeType == KAACADTSComposerMimeType)
1729 {
1730 aMimeType = PVMF_MIME_ADTS;
1731 }
1732 else if (aNodeMimeType == KAACMP4EncMimeType)
1733 {
1734 aMimeType = PVMF_MIME_MPEG4_AUDIO;
1735 }
1736 else if (aNodeMimeType == KH264EncMimeType)
1737 {
1738 aMimeType = PVMF_MIME_H264_VIDEO_MP4;
1739 }
1740 else if (aNodeMimeType == KTextEncMimeType)
1741 {
1742 aMimeType = PVMF_MIME_3GPP_TIMEDTEXT;
1743 }
1744 ////////////////////////////////////////////////////////////////////////////
1745 // Future development: When integrating support for a new format, add a
1746 // mapping for the new format and return the corresponding PVMFFormatType
1747 // for the Mime type
1748 ////////////////////////////////////////////////////////////////////////////
1749 else
1750 {
1751 LOG_ERR((0, "PVAuthorEngine::GetPvmfFormatString: Error - Mapping not found"));
1752 return PVMFFailure;
1753 }
1754
1755 return PVMFSuccess;
1756 }
1757
1758 ////////////////////////////////////////////////////////////////////////////
AllocateNodeContainer(PVMFNodeInterface * aNode)1759 PVAENodeContainer* PVAuthorEngine::AllocateNodeContainer(PVMFNodeInterface* aNode)
1760 {
1761 int32 err = 0;
1762 PVAENodeContainer* nodeContainer = NULL;
1763 OSCL_TRY(err,
1764 nodeContainer = OSCL_NEW(PVAENodeContainer, ());
1765 if (!nodeContainer)
1766 OSCL_LEAVE(OsclErrNoMemory);
1767
1768 // Do thread logon and create a session to the node
1769 PVMFNodeSessionInfo session((PVMFNodeCmdStatusObserver*)&iNodeUtil, this, nodeContainer,
1770 this, nodeContainer);
1771
1772 aNode->ThreadLogon();
1773 nodeContainer->iSessionId = aNode->Connect(session);
1774
1775 nodeContainer->iNode = aNode;
1776 );
1777
1778 OSCL_FIRST_CATCH_ANY(err,
1779 LOG_ERR((0, "PVAuthorEngine::AllocateNodeContainer: Error - Node container allocation failed"));
1780 return NULL;
1781 );
1782
1783 return nodeContainer;
1784 }
1785
1786 ////////////////////////////////////////////////////////////////////////////
DeallocateNodeContainer(PVAENodeContainerVector & aVector,PVMFNodeInterface * aNode)1787 PVMFStatus PVAuthorEngine::DeallocateNodeContainer(PVAENodeContainerVector& aVector,
1788 PVMFNodeInterface* aNode)
1789 {
1790 for (uint32 i = 0; i < aVector.size(); i++)
1791 {
1792 if (aVector[i]->iNode == aNode)
1793 {
1794 aVector[i]->iNode->ThreadLogoff();
1795 aVector[i]->iNode->Disconnect(aVector[i]->iSessionId);
1796 OSCL_DELETE(aVector[i]);
1797 aVector.erase(&aVector[i]);
1798 return PVMFSuccess;
1799 }
1800 }
1801
1802 LOG_ERR((0, "PVAuthorEngine::DeallocateNodeContainer: Error - Container of node 0x%x not found", aNode));
1803 return PVMFFailure;
1804 }
1805
1806
1807
DoCapConfigSetParameters(PVEngineCommand & aCmd,bool aSyncCmd)1808 PVMFStatus PVAuthorEngine::DoCapConfigSetParameters(PVEngineCommand& aCmd, bool aSyncCmd)
1809 {
1810 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigSetParameters() In"));
1811
1812 PvmiKvp* paramkvp = NULL;
1813 int numparam = 0;
1814 PvmiKvp** retkvp;
1815
1816 paramkvp = (PvmiKvp*)(aCmd.GetParam1());
1817 numparam = *(int*)(aCmd.GetParam2());
1818 retkvp = (PvmiKvp**)(aCmd.GetParam3());
1819
1820 if (NULL == paramkvp || NULL == retkvp || numparam < 1)
1821 {
1822 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigSetParameters() Passed in parameter invalid"));
1823 return PVMFErrArgument;
1824 }
1825
1826 // Go through each parameter
1827 for (int32 paramind = 0; paramind < numparam; ++paramind)
1828 {
1829 // Count the number of components and parameters in the key
1830 int compcount = pv_mime_string_compcnt(paramkvp[paramind].key);
1831 // Retrieve the first component from the key string
1832
1833 if (compcount < 2)
1834 {
1835 *retkvp = ¶mkvp[paramind];
1836 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigSetParameters() Unsupported key"));
1837 return PVMFErrArgument;
1838 }
1839
1840 if (pv_mime_strcmp(paramkvp[paramind].key, _STRLIT_CHAR("x-pvmf/author")) >= 0)
1841 {
1842 if (3 == compcount)
1843 {
1844 // Verify and set the passed-in author setting
1845 PVMFStatus retval = DoVerifyAndSetAuthorParameter(paramkvp[paramind], true);
1846 if (retval != PVMFSuccess)
1847 {
1848 *retkvp = ¶mkvp[paramind];
1849 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigSetParameters() Setting parameter %d failed", paramind));
1850 return retval;
1851 }
1852 }
1853 else if (4 == compcount)
1854 {
1855 // Only product info keys have four components
1856 // Verify and set the passed-in product info setting
1857 PVMFStatus retval = DoVerifyAndSetAuthorProductInfoParameter(paramkvp[paramind], true);
1858 if (retval != PVMFSuccess)
1859 {
1860 *retkvp = ¶mkvp[paramind];
1861 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigSetParameters() Setting parameter %d failed", paramind));
1862 return retval;
1863 }
1864 }
1865 else
1866 {
1867 // Do not support more than 4 components right now
1868 *retkvp = ¶mkvp[paramind];
1869 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigSetParameters() Unsupported key"));
1870 return PVMFErrArgument;
1871 }
1872 }
1873 else
1874 {
1875 // Determine which node's cap-config IF needs to be used
1876 Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
1877 PVMFStatus retval = DoQueryNodeCapConfig(paramkvp[paramind].key, nodecapconfigif);
1878 *retkvp = ¶mkvp[paramind];
1879 if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
1880 {
1881 uint32 nodeind = 0;
1882 bool anysuccess = false;
1883 // Go through each returned node's cap-config until successful
1884 while (nodeind < nodecapconfigif.size())
1885 {
1886 *retkvp = NULL;
1887 ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->setParametersSync(NULL, ¶mkvp[paramind], 1, *retkvp);
1888 ++nodeind;
1889 if (*retkvp == NULL && anysuccess == false)
1890 {
1891 anysuccess = true;
1892 }
1893 }
1894 if (anysuccess == false)
1895 {
1896 // setParametersSync was not accepted by the node(s)
1897 *retkvp = ¶mkvp[paramind];
1898 return PVMFErrArgument;
1899 }
1900 }
1901 else
1902 {
1903 // Unknown key string
1904 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigSetParameters() Unsupported key"));
1905 return PVMFErrArgument;
1906 }
1907 }
1908 }
1909
1910 if (!aSyncCmd)
1911 {
1912 return PVMFSuccess;
1913 }
1914
1915 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigSetParameters() Out"));
1916 return PVMFSuccess;
1917 }
1918
1919
DoQueryNodeCapConfig(char * aKeySubString,Oscl_Vector<PVInterface *,OsclMemAllocator> & aNodeCapConfigIF)1920 PVMFStatus PVAuthorEngine::DoQueryNodeCapConfig(char* aKeySubString, Oscl_Vector<PVInterface*, OsclMemAllocator>& aNodeCapConfigIF)
1921 {
1922 int32 leavecode = 0;
1923
1924 aNodeCapConfigIF.clear();
1925
1926 if (aKeySubString == NULL)
1927 {
1928 return PVMFErrArgument;
1929 }
1930
1931 // check for "encoder/video" or "encoder/audio" keyword in MIME string
1932 if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/encoder/video")) >= 0) ||
1933 (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/encoder/audio")) >= 0))
1934 {
1935 leavecode = 0;
1936 // insert capability class pointer of amr/video encoder/avc encoder node in aNodeCapConfigIF
1937 OSCL_TRY(leavecode,
1938 for (uint ii = 0; ii < iEncoderNodes.size(); ii++)
1939 {
1940 if (iEncoderNodes[ii]->iNodeCapConfigIF)
1941 {
1942 aNodeCapConfigIF.push_back(iEncoderNodes[ii]->iNodeCapConfigIF);
1943 }
1944 }
1945 );
1946 OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
1947
1948 }
1949 // check for "fileio" or "file/output" or "x-pvmf/composer" keyword in MIME string
1950 else if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/composer")) >= 0) ||
1951 (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("fileio")) >= 0) ||
1952 (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/file/output")) >= 0))
1953 {
1954 leavecode = 0;
1955 // insert capability class pointer of mp4-composer/file-output node in aNodeCapConfigIF
1956 OSCL_TRY(leavecode,
1957 for (uint jj = 0; jj < iComposerNodes.size(); jj++)
1958 {
1959 if (iComposerNodes[jj]->iNodeCapConfigIF)
1960 {
1961 aNodeCapConfigIF.push_back(iComposerNodes[jj]->iNodeCapConfigIF);
1962 }
1963 }
1964 );
1965 OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
1966
1967 }
1968 // check for "x-pvmf/media-io" or "x-pvmf/datasource" keyword in MIME string
1969 else if ((pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/datasource")) >= 0) ||
1970 (pv_mime_strcmp(aKeySubString, _STRLIT_CHAR("x-pvmf/media-io")) >= 0))
1971 {
1972 leavecode = 0;
1973 // insert capability class pointer of media io node in aNodeCapConfigIF
1974 OSCL_TRY(leavecode,
1975 for (uint k = 0; k < iDataSourceNodes.size(); k++)
1976 {
1977 if (iDataSourceNodes[k]->iNodeCapConfigIF)
1978 {
1979 aNodeCapConfigIF.push_back(iDataSourceNodes[k]->iNodeCapConfigIF);
1980 }
1981 }
1982 );
1983 OSCL_FIRST_CATCH_ANY(leavecode, return PVMFErrNoMemory);
1984 }
1985
1986 return PVMFSuccess;
1987 }
1988
setParametersSync(PvmiMIOSession aSession,PvmiKvp * aParameters,int aNumElements,PvmiKvp * & aRetKVP)1989 void PVAuthorEngine::setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP)
1990 {
1991 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::setParametersSync()"));
1992 OSCL_UNUSED_ARG(aSession);
1993 PVEngineCommand cmd(PVAE_CMD_CAPCONFIG_SET_PARAMETERS, 0, NULL, aParameters, (OsclAny*)&aNumElements, (OsclAny*)&aRetKVP);
1994
1995 // Complete the request synchronously
1996 DoCapConfigSetParameters(cmd, true);
1997 }
1998
setParametersAsync(PvmiMIOSession aSession,PvmiKvp * aParameters,int aNumElements,PvmiKvp * & aRetKVP,OsclAny * aContext)1999 PVMFCommandId PVAuthorEngine::setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext)
2000 {
2001 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::setParametersAsync()"));
2002 OSCL_UNUSED_ARG(aSession);
2003 OSCL_UNUSED_ARG(aContext);
2004 iAsyncNumElements = aNumElements;
2005 PVEngineCommand cmd(PVAE_CMD_CAPCONFIG_SET_PARAMETERS, 0, NULL, aParameters, (OsclAny*)&iAsyncNumElements, (OsclAny*)&aRetKVP);
2006 Dispatch(cmd);
2007 return iCommandId++;
2008
2009 }
2010
2011
getCapabilityMetric(PvmiMIOSession aSession)2012 uint32 PVAuthorEngine::getCapabilityMetric(PvmiMIOSession aSession)
2013 {
2014 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::getCapabilityMetric()"));
2015 OSCL_UNUSED_ARG(aSession);
2016 // Not supported so return 0
2017 return 0;
2018 }
2019
2020
verifyParametersSync(PvmiMIOSession aSession,PvmiKvp * aParameters,int aNumElements)2021 PVMFStatus PVAuthorEngine::verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
2022 {
2023 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::verifyParametersSync()"));
2024 OSCL_UNUSED_ARG(aSession);
2025
2026 return DoCapConfigVerifyParameters(aParameters, aNumElements);
2027 }
2028
2029
setObserver(PvmiConfigAndCapabilityCmdObserver * aObserver)2030 void PVAuthorEngine::setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
2031 {
2032 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::setObserver()"));
2033 iCfgCapCmdObserver = aObserver;
2034 }
2035
2036
getParametersSync(PvmiMIOSession aSession,PvmiKeyType aIdentifier,PvmiKvp * & aParameters,int & aNumParamElements,PvmiCapabilityContext aContext)2037 PVMFStatus PVAuthorEngine::getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
2038 {
2039 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::getParametersSync()"));
2040 OSCL_UNUSED_ARG(aSession);
2041
2042 return DoCapConfigGetParametersSync(aIdentifier, aParameters, aNumParamElements, aContext);
2043 }
2044
2045
releaseParameters(PvmiMIOSession aSession,PvmiKvp * aParameters,int aNumElements)2046 PVMFStatus PVAuthorEngine::releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements)
2047 {
2048 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::releaseParameters()"));
2049 OSCL_UNUSED_ARG(aSession);
2050 return DoCapConfigReleaseParameters(aParameters, aNumElements);
2051 }
2052
DoCapConfigVerifyParameters(PvmiKvp * aParameters,int aNumElements)2053 PVMFStatus PVAuthorEngine::DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements)
2054 {
2055 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigVerifyParameters() In"));
2056
2057 if (NULL == aParameters || aNumElements < 1)
2058 {
2059 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigVerifyParameters() Passed in parameter invalid"));
2060 return PVMFErrArgument;
2061 }
2062
2063 // Go through each parameter and verify
2064 for (int32 paramind = 0; paramind < aNumElements; ++paramind)
2065 {
2066 // Count the number of components and parameters in the key
2067 int compcount = pv_mime_string_compcnt(aParameters[paramind].key);
2068 // Retrieve the first component from the key string
2069 char* compstr = NULL;
2070 pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
2071
2072 if (compcount < 2)
2073 {
2074 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigVerifyParameters() Unsupported key"));
2075 return PVMFErrArgument;
2076 }
2077
2078 // Retrieve the second component from the key string
2079 pv_mime_string_extract_type(0, aParameters[paramind].key, compstr);
2080
2081 // First check if it is key string for engine ("x-pvmf/author")
2082 if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/author")) >= 0)
2083 {
2084 if (3 == compcount)
2085 {
2086
2087 // Verify the passed-in author setting
2088 PVMFStatus retval = DoVerifyAndSetAuthorParameter(aParameters[paramind], false);
2089 if (retval != PVMFSuccess)
2090 {
2091 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigVerifyParameters() Verifying parameter %d failed", paramind));
2092 return retval;
2093 }
2094 }
2095 else if (4 == compcount)
2096 {
2097 // Only product info keys have four components
2098 // Verify the passed-in product info setting
2099 PVMFStatus retval = DoVerifyAndSetAuthorProductInfoParameter(aParameters[paramind], false);
2100 if (retval != PVMFSuccess)
2101 {
2102 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigVerifyParameters() Verifying parameter %d failed", paramind));
2103 return retval;
2104 }
2105 }
2106 else
2107 {
2108 // Do not support more than 4 components right now
2109 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigVerifyParameters() Unsupported key"));
2110 return PVMFErrArgument;
2111 }
2112 }
2113 else
2114 {
2115 // Determine which node's cap-config IF needs to be used
2116 Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
2117 PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
2118 if (retval == PVMFSuccess && !(nodecapconfigif.empty()))
2119 {
2120 uint32 nodeind = 0;
2121 retval = PVMFErrArgument;
2122 // Go through each returned node's cap-config until successful
2123 while (nodeind < nodecapconfigif.size() && retval != PVMFSuccess)
2124 {
2125 retval =
2126 ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->verifyParametersSync(NULL, &aParameters[paramind], 1);
2127 ++nodeind;
2128 }
2129
2130 if (retval != PVMFSuccess)
2131 {
2132 return retval;
2133 }
2134 }
2135 else
2136 {
2137 // Unknown key string
2138 return PVMFErrArgument;
2139 }
2140 }
2141 }
2142
2143 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigVerifyParameters() Out"));
2144 return PVMFSuccess;
2145 }
2146
2147
createContext(PvmiMIOSession aSession,PvmiCapabilityContext & aContext)2148 void PVAuthorEngine::createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
2149 {
2150 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::createContext()"));
2151 OSCL_UNUSED_ARG(aSession);
2152 // Context is not really supported so just return some member variable pointer
2153 aContext = (PvmiCapabilityContext) & iCapConfigContext;
2154 }
2155
2156
setContextParameters(PvmiMIOSession aSession,PvmiCapabilityContext & aContext,PvmiKvp * aParameters,int aNumParamElements)2157 void PVAuthorEngine::setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements)
2158 {
2159 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::setContextParameters()"));
2160 OSCL_UNUSED_ARG(aSession);
2161 OSCL_UNUSED_ARG(aContext);
2162 OSCL_UNUSED_ARG(aParameters);
2163 OSCL_UNUSED_ARG(aNumParamElements);
2164 // This method is not supported so leave
2165 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::setContextParameters() is not supported!"));
2166 OSCL_LEAVE(PVMFErrNotSupported);
2167 }
2168
2169
DeleteContext(PvmiMIOSession aSession,PvmiCapabilityContext & aContext)2170 void PVAuthorEngine::DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext)
2171 {
2172 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DeleteContext()"));
2173 OSCL_UNUSED_ARG(aSession);
2174 OSCL_UNUSED_ARG(aContext);
2175 // Do nothing since the context is just the a member variable of the engine
2176 }
2177
addRef()2178 void PVAuthorEngine::addRef()
2179 {
2180 }
2181
removeRef()2182 void PVAuthorEngine::removeRef()
2183 {
2184 }
2185
queryInterface(const PVUuid & uuid,PVInterface * & iface)2186 bool PVAuthorEngine::queryInterface(const PVUuid& uuid, PVInterface*& iface)
2187 {
2188 if (uuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
2189 {
2190 PvmiCapabilityAndConfig* capconfigiface = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
2191 iface = OSCL_STATIC_CAST(PVInterface*, capconfigiface);
2192 }
2193 else
2194 {
2195 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::queryInterface() Unsupported interface UUID."));
2196 return false;
2197 }
2198
2199 return true;
2200 }
DoCapConfigGetParametersSync(PvmiKeyType aIdentifier,PvmiKvp * & aParameters,int & aNumParamElements,PvmiCapabilityContext aContext)2201 PVMFStatus PVAuthorEngine::DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext)
2202 {
2203 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() In"));
2204 OSCL_UNUSED_ARG(aContext);
2205
2206 // Initialize the output parameters
2207 aNumParamElements = 0;
2208 aParameters = NULL;
2209
2210 // Count the number of components and parameters in the key
2211 int compcount = pv_mime_string_compcnt(aIdentifier);
2212 // Retrieve the first component from the key string
2213 char* compstr = NULL;
2214 pv_mime_string_extract_type(0, aIdentifier, compstr);
2215
2216 if (compcount < 2)
2217 {
2218 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Invalid key string"));
2219 return PVMFErrArgument;
2220 }
2221
2222 // Retrieve the second component from the key string
2223 pv_mime_string_extract_type(0, aIdentifier, compstr);
2224
2225 // First check if it is key string for engine ("x-pvmf/author")
2226 if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/author")) >= 0)
2227 {
2228 // Key is for author
2229 if (2 == compcount)
2230 {
2231 // Since key is "x-pvmf/author" return all
2232 // nodes available at this level. Ignore attribute
2233 // since capability is only allowed
2234
2235 // Allocate memory for the KVP list
2236 aParameters = (PvmiKvp*)oscl_malloc(PVAUTHORCONFIG_BASE_NUMKEYS * sizeof(PvmiKvp));
2237 if (aParameters == NULL)
2238 {
2239 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Memory allocation for KVP failed"));
2240 return PVMFErrNoMemory;
2241 }
2242 oscl_memset(aParameters, 0, PVAUTHORCONFIG_BASE_NUMKEYS*sizeof(PvmiKvp));
2243 // Allocate memory for the key strings in each KVP
2244 PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVAUTHORCONFIG_BASE_NUMKEYS * PVAUTHORCONFIG_KEYSTRING_SIZE * sizeof(char));
2245 if (memblock == NULL)
2246 {
2247 oscl_free(aParameters);
2248 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Memory allocation for key string failed"));
2249 return PVMFErrNoMemory;
2250 }
2251 oscl_strset(memblock, 0, PVAUTHORCONFIG_BASE_NUMKEYS*PVAUTHORCONFIG_KEYSTRING_SIZE*sizeof(char));
2252 // Assign the key string buffer to each KVP
2253 int32 jj;
2254
2255 for (jj = 0; jj < PVAUTHORCONFIG_BASE_NUMKEYS; ++jj)
2256 {
2257 aParameters[jj].key = memblock + (jj * PVAUTHORCONFIG_KEYSTRING_SIZE);
2258 }
2259 // Copy the requested info
2260 for (jj = 0; jj < PVAUTHORCONFIG_BASE_NUMKEYS; ++jj)
2261 {
2262 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR("x-pvmf/author/"), 14);
2263 oscl_strncat(aParameters[jj].key, PVAuthorConfigBaseKeys[jj].iString, oscl_strlen(PVAuthorConfigBaseKeys[jj].iString));
2264 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(";type="), 6);
2265 switch (PVAuthorConfigBaseKeys[jj].iType)
2266 {
2267 case PVMI_KVPTYPE_AGGREGATE:
2268 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPTYPE_AGGREGATE_STRING), oscl_strlen(PVMI_KVPTYPE_AGGREGATE_STRING));
2269 break;
2270
2271 case PVMI_KVPTYPE_POINTER:
2272 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPTYPE_POINTER_STRING), oscl_strlen(PVMI_KVPTYPE_POINTER_STRING));
2273 break;
2274
2275 case PVMI_KVPTYPE_VALUE:
2276 default:
2277 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPTYPE_VALUE_STRING), oscl_strlen(PVMI_KVPTYPE_VALUE_STRING));
2278 break;
2279 }
2280 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(";valtype="), 9);
2281 switch (PVAuthorConfigBaseKeys[jj].iValueType)
2282 {
2283 case PVMI_KVPVALTYPE_RANGE_INT32:
2284 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
2285 break;
2286
2287 case PVMI_KVPVALTYPE_KSV:
2288 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
2289 break;
2290
2291 case PVMI_KVPVALTYPE_CHARPTR:
2292 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
2293 break;
2294
2295 case PVMI_KVPVALTYPE_BOOL:
2296 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
2297 break;
2298
2299 case PVMI_KVPVALTYPE_UINT32:
2300 default:
2301 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
2302 break;
2303 }
2304 aParameters[jj].key[PVAUTHORCONFIG_KEYSTRING_SIZE-1] = 0;
2305 }
2306
2307 aNumParamElements = PVAUTHORCONFIG_BASE_NUMKEYS;
2308 }
2309 else
2310 {
2311 // Retrieve the third component from the key string
2312 pv_mime_string_extract_type(2, aIdentifier, compstr);
2313
2314 for (int32 engcomp3ind = 0; engcomp3ind < PVAUTHORCONFIG_BASE_NUMKEYS; ++engcomp3ind)
2315 {
2316 // Go through each engine component string at 3rd level
2317 if (pv_mime_strcmp(compstr, (char*)(PVAuthorConfigBaseKeys[engcomp3ind].iString)) >= 0)
2318 {
2319 if (engcomp3ind == 2) //Here '2' refers to the array index in PVAuthorConfigBaseKeys where productinfo is placed
2320 {
2321 // "x-pvmf/author/productinfo"
2322 if (compcount == 3)
2323 {
2324 // Return list of product info. Ignore the
2325 // attribute since capability is only allowed
2326
2327 // Allocate memory for the KVP list
2328 aParameters = (PvmiKvp*)oscl_malloc(PVAUTHORCONFIG_PRODINFO_NUMKEYS * sizeof(PvmiKvp));
2329 if (aParameters == NULL)
2330 {
2331 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Memory allocation for KVP failed"));
2332 return PVMFErrNoMemory;
2333 }
2334 oscl_memset(aParameters, 0, PVAUTHORCONFIG_PRODINFO_NUMKEYS*sizeof(PvmiKvp));
2335 // Allocate memory for the key strings in each KVP
2336 PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVAUTHORCONFIG_PRODINFO_NUMKEYS * PVAUTHORCONFIG_KEYSTRING_SIZE * sizeof(char));
2337 if (memblock == NULL)
2338 {
2339 oscl_free(aParameters);
2340 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Memory allocation for key string failed"));
2341 return PVMFErrNoMemory;
2342 }
2343 oscl_strset(memblock, 0, PVAUTHORCONFIG_PRODINFO_NUMKEYS*PVAUTHORCONFIG_KEYSTRING_SIZE*sizeof(char));
2344 // Assign the key string buffer to each KVP
2345 int32 jj;
2346 for (jj = 0; jj < PVAUTHORCONFIG_PRODINFO_NUMKEYS; ++jj)
2347 {
2348 aParameters[jj].key = memblock + (jj * PVAUTHORCONFIG_KEYSTRING_SIZE);
2349 }
2350 // Copy the requested info
2351 for (jj = 0; jj < PVAUTHORCONFIG_PRODINFO_NUMKEYS; ++jj)
2352 {
2353 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR("x-pvmf/author/productinfo/"), 26);
2354 oscl_strncat(aParameters[jj].key, PVAuthorConfigProdInfoKeys[jj].iString, oscl_strlen(PVAuthorConfigProdInfoKeys[jj].iString));
2355 oscl_strncat(aParameters[jj].key, _STRLIT_CHAR(";type=value;valtype=char*"), 25);
2356 aParameters[jj].key[PVAUTHORCONFIG_KEYSTRING_SIZE-1] = 0;
2357 }
2358
2359 aNumParamElements = PVAUTHORCONFIG_PRODINFO_NUMKEYS;
2360 }
2361 else if (compcount == 4)
2362 {
2363 // Retrieve the fourth component from the key string
2364 pv_mime_string_extract_type(3, aIdentifier, compstr);
2365
2366 for (int32 engcomp4ind = 0; engcomp4ind < PVAUTHORCONFIG_PRODINFO_NUMKEYS; ++engcomp4ind)
2367 {
2368 if (pv_mime_strcmp(compstr, (char*)(PVAuthorConfigProdInfoKeys[engcomp4ind].iString)) >= 0)
2369 {
2370 // Determine what is requested
2371 PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
2372 if (reqattr == PVMI_KVPATTR_UNKNOWN)
2373 {
2374 // Default is current setting
2375 reqattr = PVMI_KVPATTR_CUR;
2376 }
2377
2378 // Return the requested info
2379 PVMFStatus retval = DoGetAuthorProductInfoParameter(aParameters, aNumParamElements, engcomp4ind, reqattr);
2380 if (retval != PVMFSuccess)
2381 {
2382 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Retrieving product info failed"));
2383 return retval;
2384 }
2385
2386 // Break out of the for(engcomp4ind) loop
2387 break;
2388 }
2389 }
2390 }
2391 else
2392 {
2393 // Right now engine doesn't support more than 4 components
2394 // so error out
2395 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Unsupported key"));
2396 return PVMFErrArgument;
2397 }
2398 }
2399 else
2400 {
2401 if (compcount == 3)
2402 {
2403 // Determine what is requested
2404 PvmiKvpAttr reqattr = GetAttrTypeFromKeyString(aIdentifier);
2405 if (reqattr == PVMI_KVPATTR_UNKNOWN)
2406 {
2407 reqattr = PVMI_KVPATTR_CUR;
2408 }
2409
2410 // Return the requested info
2411 PVMFStatus retval = DoGetAuthorParameter(aParameters, aNumParamElements, engcomp3ind, reqattr);
2412 if (retval != PVMFSuccess)
2413 {
2414 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Retrieving author parameter failed"));
2415 return retval;
2416 }
2417 }
2418 else
2419 {
2420 // Right now engine doesn't support more than 3 components
2421 // for this sub-key string so error out
2422 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Unsupported key"));
2423 return PVMFErrArgument;
2424 }
2425 }
2426
2427 // Breakout of the for(engcomp3ind) loop
2428 break;
2429 }
2430 }
2431 }
2432 }
2433 else
2434 {
2435 // Determine which node's cap-config IF needs to be used
2436 Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
2437 PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
2438 if (PVMFSuccess == retval && !(nodecapconfigif.empty()))
2439 {
2440 uint32 nodeind = 0;
2441 // Go through each returned node's cap-config until successful
2442 while (nodeind < nodecapconfigif.size() && 0 == aNumParamElements)
2443 {
2444 retval =
2445 ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->getParametersSync(NULL, aIdentifier, aParameters, aNumParamElements, aContext);
2446 ++nodeind;
2447 }
2448 }
2449 }
2450
2451 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Out"));
2452 if (0 == aNumParamElements)
2453 {
2454 // If no one could get the parameter, return error
2455 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigGetParametersSync() Unsupported key"));
2456 return PVMFFailure;
2457 }
2458 return PVMFSuccess;
2459 }
2460
2461
2462
DoCapConfigReleaseParameters(PvmiKvp * aParameters,int aNumElements)2463 PVMFStatus PVAuthorEngine::DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements)
2464 {
2465 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigReleaseParameters() In"));
2466
2467 if (NULL == aParameters || aNumElements < 1)
2468 {
2469 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigReleaseParameters() KVP list is NULL or number of elements is 0"));
2470 return PVMFErrArgument;
2471 }
2472
2473 // Count the number of components and parameters in the key
2474 int compcount = pv_mime_string_compcnt(aParameters[0].key);
2475 // Retrieve the first component from the key string
2476 char* compstr = NULL;
2477 pv_mime_string_extract_type(0, aParameters[0].key, compstr);
2478
2479 if (compcount < 2)
2480 {
2481 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigReleaseParameters() Unsupported key"));
2482 return PVMFErrArgument;
2483 }
2484
2485 // Retrieve the second component from the key string
2486 pv_mime_string_extract_type(0, aParameters[0].key, compstr);
2487
2488 // Assume all the parameters come from the same component so the base components are the same
2489 // First check if it is key string for engine ("x-pvmf/author")
2490 if (pv_mime_strcmp(compstr, _STRLIT_CHAR("x-pvmf/author")) >= 0)
2491 {
2492 // Go through each KVP and release memory for value if allocated from heap
2493 for (int32 ii = 0; ii < aNumElements; ++ii)
2494 {
2495 // Next check if it is a value type that allocated memory
2496 PvmiKvpType kvptype = GetTypeFromKeyString(aParameters[ii].key);
2497 if (PVMI_KVPTYPE_VALUE == kvptype || PVMI_KVPTYPE_UNKNOWN == kvptype)
2498 {
2499 PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameters[ii].key);
2500 if (PVMI_KVPVALTYPE_UNKNOWN == keyvaltype)
2501 {
2502 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoCapConfigReleaseParameters() Valtype not specified in key string"));
2503 return PVMFErrArgument;
2504 }
2505
2506 if (PVMI_KVPVALTYPE_CHARPTR == keyvaltype && NULL != aParameters[ii].value.pChar_value)
2507 {
2508 oscl_free(aParameters[ii].value.pChar_value);
2509 aParameters[ii].value.pChar_value = NULL;
2510 }
2511 else if (PVMI_KVPVALTYPE_KSV == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
2512 {
2513 oscl_free(aParameters[ii].value.key_specific_value);
2514 aParameters[ii].value.key_specific_value = NULL;
2515 }
2516 else if (PVMI_KVPVALTYPE_RANGE_INT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
2517 {
2518 range_int32* ri32 = (range_int32*)aParameters[ii].value.key_specific_value;
2519 aParameters[ii].value.key_specific_value = NULL;
2520 oscl_free(ri32);
2521 }
2522 else if (PVMI_KVPVALTYPE_RANGE_UINT32 == keyvaltype && NULL != aParameters[ii].value.key_specific_value)
2523 {
2524 range_uint32* rui32 = (range_uint32*)aParameters[ii].value.key_specific_value;
2525 aParameters[ii].value.key_specific_value = NULL;
2526 oscl_free(rui32);
2527 }
2528 // @TODO Add more types if engine starts returning more types
2529 }
2530 }
2531
2532 // Author engine allocated its key strings in one chunk so just free the first key string ptr
2533 oscl_free(aParameters[0].key);
2534
2535 // Free memory for the parameter list
2536 oscl_free(aParameters);
2537 aParameters = NULL;
2538 }
2539 else
2540 {
2541 // Determine which node's cap-config IF needs to be used
2542 Oscl_Vector<PVInterface*, OsclMemAllocator> nodecapconfigif;
2543 PVMFStatus retval = DoQueryNodeCapConfig(compstr, nodecapconfigif);
2544 if (PVMFSuccess == retval && !(nodecapconfigif.empty()))
2545 {
2546 uint32 nodeind = 0;
2547 retval = PVMFErrArgument;
2548 // Go through each returned node's cap-config until successful
2549 while (nodeind < nodecapconfigif.size() && PVMFSuccess != retval)
2550 {
2551 retval =
2552 ((PvmiCapabilityAndConfig*)nodecapconfigif[nodeind])->releaseParameters(NULL, aParameters, aNumElements);
2553 ++nodeind;
2554 }
2555
2556 if (retval != PVMFSuccess)
2557 {
2558 return retval;
2559 }
2560 }
2561 else
2562 {
2563 // Unknown key string
2564 return PVMFErrArgument;
2565 }
2566 }
2567
2568 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoCapConfigReleaseParameters() Out"));
2569 return PVMFSuccess;
2570 }
2571
DoVerifyAndSetAuthorParameter(PvmiKvp & aParameter,bool aSetParam)2572 PVMFStatus PVAuthorEngine::DoVerifyAndSetAuthorParameter(PvmiKvp& aParameter, bool aSetParam)
2573 {
2574 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoVerifyAndSetAuthorParameter() In"));
2575
2576 // Determine the valtype
2577 PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
2578 if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
2579 {
2580 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorParameter() Valtype in key string unknown"));
2581 return PVMFErrArgument;
2582 }
2583 // Retrieve the third component from the key string
2584 char* compstr = NULL;
2585 pv_mime_string_extract_type(2, aParameter.key, compstr);
2586
2587 int32 engcomp3ind = 0;
2588 for (engcomp3ind = 0; engcomp3ind < PVAUTHORCONFIG_BASE_NUMKEYS; ++engcomp3ind)
2589 {
2590 // Go through each engine component string at 3rd level
2591 if (pv_mime_strcmp(compstr, (char*)(PVAuthorConfigBaseKeys[engcomp3ind].iString)) >= 0)
2592 {
2593 // Break out of the for loop
2594 break;
2595 }
2596 }
2597
2598 if (engcomp3ind >= PVAUTHORCONFIG_BASE_NUMKEYS || engcomp3ind == 2) //'2' refers to the place where productinfo is placed in PVAuthorConfigBaseKeys
2599 {
2600 // Match couldn't be found or non-leaf node ("productinfo") specified
2601 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorParameter() Unsupported key or non-leaf node"));
2602 return PVMFErrArgument;
2603 }
2604
2605 // Verify the valtype
2606 if (keyvaltype != PVAuthorConfigBaseKeys[engcomp3ind].iValueType)
2607 {
2608 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorParameter() Valtype does not match for key"));
2609 return PVMFErrArgument;
2610 }
2611
2612 switch (engcomp3ind)
2613 {
2614 case 0:
2615 // Change the config if to set
2616 if (aSetParam)
2617 {
2618
2619 }
2620 break;
2621
2622 case 1:
2623 // Change the config if to set
2624 if (aSetParam)
2625 {
2626 }
2627 break;
2628
2629 default:
2630 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorParameter() Invalid index for author parameter"));
2631 return PVMFErrArgument;
2632 }
2633
2634 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoVerifyAndSetAuthorParameter() Out"));
2635 return PVMFSuccess;
2636 }
2637
2638
DoVerifyAndSetAuthorProductInfoParameter(PvmiKvp & aParameter,bool aSetParam)2639 PVMFStatus PVAuthorEngine::DoVerifyAndSetAuthorProductInfoParameter(PvmiKvp& aParameter, bool aSetParam)
2640 {
2641 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoVerifyAndSetAuthorProductInfoParameter() In"));
2642
2643 // Determine the valtype
2644 PvmiKvpValueType keyvaltype = GetValTypeFromKeyString(aParameter.key);
2645 if (keyvaltype == PVMI_KVPVALTYPE_UNKNOWN)
2646 {
2647 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorProductInfoParameter() Valtype unknown"));
2648 return PVMFErrArgument;
2649 }
2650 // Retrieve the 4th component from the key string
2651 char* compstr = NULL;
2652 pv_mime_string_extract_type(3, aParameter.key, compstr);
2653
2654 int32 engcomp4ind = 0;
2655 for (engcomp4ind = 0; engcomp4ind < PVAUTHORCONFIG_PRODINFO_NUMKEYS; ++engcomp4ind)
2656 {
2657 // Go through each engine component string at 4th level
2658 if (pv_mime_strcmp(compstr, (char*)(PVAuthorConfigProdInfoKeys[engcomp4ind].iString)) >= 0)
2659 {
2660 // Break out of the for loop
2661 break;
2662 }
2663 }
2664
2665 if (engcomp4ind >= PVAUTHORCONFIG_PRODINFO_NUMKEYS)
2666 {
2667 // Match couldn't be found
2668 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorProductInfoParameter() Unsupported key"));
2669 return PVMFErrArgument;
2670 }
2671
2672 // Verify the valtype
2673 if (keyvaltype != PVAuthorConfigProdInfoKeys[engcomp4ind].iValueType)
2674 {
2675 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorProductInfoParameter() Valtype does not match for key"));
2676 return PVMFErrArgument;
2677 }
2678
2679 switch (engcomp4ind)
2680 {
2681 case 0:
2682 // Change the config if to set
2683 if (aSetParam)
2684 {
2685 }
2686 break;
2687
2688 case 1:
2689 // Change the config if to set
2690 if (aSetParam)
2691 {
2692 }
2693 break;
2694
2695 default:
2696 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoVerifyAndSetAuthorProductInfoParameter() Invalid index for product info"));
2697 return PVMFErrArgument;
2698 }
2699
2700 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoVerifyAndSetAuthorProductInfoParameter() Out"));
2701 return PVMFSuccess;
2702 }
2703
DoGetAuthorParameter(PvmiKvp * & aParameters,int & aNumParamElements,int32 aIndex,PvmiKvpAttr reqattr)2704 PVMFStatus PVAuthorEngine::DoGetAuthorParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr)
2705 {
2706 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoGetAuthorParameter() In"));
2707
2708 aNumParamElements = 0;
2709
2710 // Allocate memory for the KVP
2711 aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
2712 if (aParameters == NULL)
2713 {
2714 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoGetAuthorParameter() Memory allocation for KVP failed"));
2715 return PVMFErrNoMemory;
2716 }
2717 oscl_memset(aParameters, 0, sizeof(PvmiKvp));
2718 // Allocate memory for the key string in KVP
2719 PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVAUTHORCONFIG_KEYSTRING_SIZE * sizeof(char));
2720 if (memblock == NULL)
2721 {
2722 oscl_free(aParameters);
2723 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoGetAuthorParameter() Memory allocation for key string failed"));
2724 return PVMFErrNoMemory;
2725 }
2726 oscl_strset(memblock, 0, PVAUTHORCONFIG_KEYSTRING_SIZE*sizeof(char));
2727 // Assign the key string buffer to KVP
2728 aParameters[0].key = memblock;
2729
2730 // Copy the key string
2731 oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/author/"), 14);
2732 oscl_strncat(aParameters[0].key, PVAuthorConfigBaseKeys[aIndex].iString, oscl_strlen(PVAuthorConfigBaseKeys[aIndex].iString));
2733 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype="), 20);
2734 switch (PVAuthorConfigBaseKeys[aIndex].iValueType)
2735 {
2736 case PVMI_KVPVALTYPE_RANGE_INT32:
2737 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_INT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_INT32_STRING));
2738 break;
2739
2740 case PVMI_KVPVALTYPE_KSV:
2741 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_KSV_STRING), oscl_strlen(PVMI_KVPVALTYPE_KSV_STRING));
2742 break;
2743
2744 case PVMI_KVPVALTYPE_CHARPTR:
2745 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_CHARPTR_STRING), oscl_strlen(PVMI_KVPVALTYPE_CHARPTR_STRING));
2746 break;
2747
2748 case PVMI_KVPVALTYPE_BOOL:
2749 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_BOOL_STRING), oscl_strlen(PVMI_KVPVALTYPE_BOOL_STRING));
2750 break;
2751
2752 case PVMI_KVPVALTYPE_UINT32:
2753 default:
2754 if (reqattr == PVMI_KVPATTR_CAP)
2755 {
2756 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_RANGE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_RANGE_UINT32_STRING));
2757 }
2758 else
2759 {
2760 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(PVMI_KVPVALTYPE_UINT32_STRING), oscl_strlen(PVMI_KVPVALTYPE_UINT32_STRING));
2761 }
2762 break;
2763 }
2764 aParameters[0].key[PVAUTHORCONFIG_KEYSTRING_SIZE-1] = 0;
2765
2766 // Copy the requested info
2767 switch (aIndex)
2768 {
2769 case 0:
2770 if (reqattr == PVMI_KVPATTR_CUR)
2771 {
2772 // Return current value
2773 // Allocate memory for the string
2774 }
2775 else if (reqattr == PVMI_KVPATTR_DEF)
2776 {
2777 // Return default
2778 // Allocate memory for the string
2779 }
2780 else
2781 {
2782 // Return capability
2783 // Allocate memory for the string
2784 }
2785 break;
2786
2787 case 1:
2788 if (reqattr == PVMI_KVPATTR_CUR)
2789 {
2790 // Return current value
2791 }
2792 else if (reqattr == PVMI_KVPATTR_DEF)
2793 {
2794 // Return default
2795 }
2796 else
2797 {
2798 // Return capability
2799 }
2800 break;
2801
2802 default:
2803 // Invalid index
2804 oscl_free(aParameters[0].key);
2805 oscl_free(aParameters);
2806 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoGetAuthorParameter() Invalid index to author parameter"));
2807 return PVMFErrArgument;
2808 }
2809
2810 aNumParamElements = 1;
2811
2812 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoGetAuthorParameter() Out"));
2813 return PVMFSuccess;
2814 }
2815
DoGetAuthorProductInfoParameter(PvmiKvp * & aParameters,int & aNumParamElements,int32 aIndex,PvmiKvpAttr reqattr)2816 PVMFStatus PVAuthorEngine::DoGetAuthorProductInfoParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr)
2817 {
2818 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoGetAuthorProductInfoParameter() In"));
2819
2820 aNumParamElements = 0;
2821
2822 // Allocate memory for the KVP
2823 aParameters = (PvmiKvp*)oscl_malloc(sizeof(PvmiKvp));
2824 if (aParameters == NULL)
2825 {
2826 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoGetAuthorProductInfoParameter() Memory allocation for KVP failed"));
2827 return PVMFErrNoMemory;
2828 }
2829 oscl_memset(aParameters, 0, sizeof(PvmiKvp));
2830 // Allocate memory for the key string in KVP
2831 PvmiKeyType memblock = (PvmiKeyType)oscl_malloc(PVAUTHORCONFIG_KEYSTRING_SIZE * sizeof(char));
2832 if (memblock == NULL)
2833 {
2834 oscl_free(aParameters);
2835 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoGetAuthorProductInfoParameter() Memory allocation for key string"));
2836 return PVMFErrNoMemory;
2837 }
2838 oscl_strset(memblock, 0, PVAUTHORCONFIG_KEYSTRING_SIZE*sizeof(char));
2839 // Assign the key string buffer to KVP
2840 aParameters[0].key = memblock;
2841
2842 // Copy the key string
2843 oscl_strncat(aParameters[0].key, _STRLIT_CHAR("x-pvmf/author/productinfo/"), 26);
2844 oscl_strncat(aParameters[0].key, PVAuthorConfigProdInfoKeys[aIndex].iString, oscl_strlen(PVAuthorConfigProdInfoKeys[aIndex].iString));
2845 oscl_strncat(aParameters[0].key, _STRLIT_CHAR(";type=value;valtype=char*"), 25);
2846 aParameters[0].key[PVAUTHORCONFIG_KEYSTRING_SIZE-1] = 0;
2847
2848 // Copy the requested info
2849 switch (aIndex)
2850 {
2851 case 0:
2852 if (reqattr == PVMI_KVPATTR_CUR)
2853 {
2854 // Return current value
2855 // Allocate memory for the string
2856 }
2857 else if (reqattr == PVMI_KVPATTR_DEF)
2858 {
2859 // Return default
2860 // Allocate memory for the string
2861 }
2862 else
2863 {
2864 // Return capability
2865 }
2866 break;
2867
2868 case 1:
2869 if (reqattr == PVMI_KVPATTR_CUR)
2870 {
2871 // Return current value
2872 // Allocate memory for the string
2873 }
2874 else if (reqattr == PVMI_KVPATTR_DEF)
2875 {
2876 // Return default
2877 // Allocate memory for the string
2878 }
2879 else
2880 {
2881 // Return capability
2882 }
2883 break;
2884 default:
2885 // Invalid index
2886 oscl_free(aParameters[0].key);
2887 oscl_free(aParameters);
2888 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, (0, "PVAuthorEngine::DoGetAuthorProductInfoParameter() Invalid index for product info"));
2889 return PVMFErrArgument;
2890 }
2891
2892 aNumParamElements = 1;
2893
2894 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVAuthorEngine::DoGetAuthorProductInfoParameter() Out"));
2895 return PVMFSuccess;
2896 }
2897
2898
2899 OSCL_EXPORT_REF
2900 void
GetSDKInfo(PVSDKInfo & aSdkInfo)2901 PVAuthorEngineInterface::GetSDKInfo
2902 (
2903 PVSDKInfo& aSdkInfo
2904 )
2905 {
2906 aSdkInfo.iLabel = PVAUTHOR_ENGINE_SDKINFO_LABEL;
2907 aSdkInfo.iDate = PVAUTHOR_ENGINE_SDKINFO_DATE;
2908 }
2909
SendAuthoringClockToDataSources(bool aReset)2910 PVMFStatus PVAuthorEngine::SendAuthoringClockToDataSources(bool aReset)
2911 {
2912 // Create the kvp for the Authoring clock
2913 OsclMemAllocator alloc;
2914 PvmiKvp kvp;
2915 kvp.key = NULL;
2916 kvp.length = oscl_strlen(PVMF_AUTHORING_CLOCK_KEY) + 1; // +1 for \0
2917 kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
2918 if (kvp.key == NULL)
2919 {
2920 return PVMFErrNoMemory;
2921 }
2922 oscl_strncpy(kvp.key, PVMF_AUTHORING_CLOCK_KEY, kvp.length);
2923 if (aReset)
2924 {
2925 kvp.value.key_specific_value = NULL;
2926 }
2927 else
2928 {
2929 kvp.value.key_specific_value = (OsclAny*)(&iAuthorClock);
2930 }
2931 kvp.capacity = 1;
2932 PvmiKvp* retKvp = NULL; // for return value
2933 int32 err;
2934
2935 OSCL_TRY (err,
2936 for (uint index = 0; index < iDataSourceNodes.size(); index++)
2937 {
2938 //use data source node capconfig to pass the clock pointer to
2939 //source nodes. if reset is true, we send NULL. author does this
2940 //to notify that clock pointer should no longer be used
2941 if (iDataSourceNodes[index]->iNodeCapConfigIF != NULL)
2942 {
2943 PvmiCapabilityAndConfig* dataSrcCapConfig =
2944 OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, iDataSourceNodes[index]->iNodeCapConfigIF);
2945 dataSrcCapConfig->setParametersSync(NULL, &kvp, 1, retKvp);
2946 }
2947 }
2948 );
2949
2950 if (err != OsclErrNone)
2951 {
2952 /* ignore the error */
2953 PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR,
2954 (0, "PVAuthorEngine::SendAuthoringClockToDataSources() SetParameterSync for AuthorClock failed"));
2955 }
2956
2957 alloc.deallocate((OsclAny*)(kvp.key));
2958 return PVMFSuccess;
2959 }
2960
2961
2962