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 OSCL_EXCLUSIVE_PTR_H_INCLUDED
19 #include "oscl_exclusive_ptr.h"
20 #endif
21 #ifndef PVMF_CPMPLUGIN_PASSTHRU_OMA1_H_INCLUDED
22 #include "pvmf_cpmplugin_passthru_oma1.h"
23 #endif
24 #ifndef PVLOGGER_H_INCLUDED
25 #include "pvlogger.h"
26 #endif
27 #ifndef PVMF_BASIC_ERRORINFOMESSAGE_H_INCLUDED
28 #include "pvmf_basic_errorinfomessage.h"
29 #endif
30 #ifndef PVMF_ERRORINFOMESSAGE_EXTENSION_H_INCLUDED
31 #include "pvmf_errorinfomessage_extension.h"
32 #endif
33 #ifndef OSCL_DLL_H_INCLUDED
34 #include "oscl_dll.h"
35 #endif
36 #include "pvmf_local_data_source.h"
37 #include "pvmf_cpmplugin_passthru_oma1_factory.h"
38 #include "pvmf_cpmplugin_passthru_oma1_types.h"
39
40 #ifndef PVMI_DRM_KVP_H_INCLUDED
41 #include "pvmi_drm_kvp.h"
42 #endif
43
44 // Define entry point for this DLL
OSCL_DLL_ENTRY_POINT_DEFAULT()45 OSCL_DLL_ENTRY_POINT_DEFAULT()
46
47 OSCL_EXPORT_REF PVMFOma1PassthruPluginFactory::PVMFOma1PassthruPluginFactory()
48 {
49 iFailAuthorizeUsage = false; // To simulate "authorizeusage" failure
50 iCancelAcquireLicense = false; //to simulate "cancelgetLicense"
51 iCPMContentType = PVMF_CPM_FORMAT_AUTHORIZE_BEFORE_ACCESS; //default value
52 iSourceInitDataNotSupported = false; //To simulate SourceInitializationData failure
53 }
54
55 //This constructor has only been introduced for test case scenarios simulation
PVMFOma1PassthruPluginFactory(bool aAuthorizeUsage,bool aCancelAcquireLicense,bool aSourceInitDataNotSupported,PVMFCPMContentType aCPMContentType)56 OSCL_EXPORT_REF PVMFOma1PassthruPluginFactory::PVMFOma1PassthruPluginFactory(bool aAuthorizeUsage, bool aCancelAcquireLicense,
57 bool aSourceInitDataNotSupported,
58 PVMFCPMContentType aCPMContentType)
59 {
60 iFailAuthorizeUsage = aAuthorizeUsage;// To simulate "authorizeusage" failure
61 iCancelAcquireLicense = aCancelAcquireLicense; //To simulate "cancelAcquire"
62 iCPMContentType = aCPMContentType; //what test case sets
63 iSourceInitDataNotSupported = aSourceInitDataNotSupported;
64 }
65
66 //Oma1 Passthru plugin factory.
CreateCPMPlugin()67 OSCL_EXPORT_REF PVMFCPMPluginInterface* PVMFOma1PassthruPluginFactory::CreateCPMPlugin()
68 {
69 return PVMFCPMPassThruPlugInOMA1::CreatePlugIn(iFailAuthorizeUsage, iCancelAcquireLicense,
70 iSourceInitDataNotSupported, iCPMContentType);
71 }
72
DestroyCPMPlugin(PVMFCPMPluginInterface * aPlugIn)73 OSCL_EXPORT_REF void PVMFOma1PassthruPluginFactory::DestroyCPMPlugin(PVMFCPMPluginInterface* aPlugIn)
74 {
75 PVMFCPMPassThruPlugInOMA1::DestroyPlugIn(aPlugIn);
76 }
77
CreatePlugIn(bool aFailAuthorizeUsage,bool aCancelAcquireLicense,bool aSourceInitDataNotSupported,PVMFCPMContentType aCPMContentType)78 PVMFCPMPluginInterface* PVMFCPMPassThruPlugInOMA1::CreatePlugIn(bool aFailAuthorizeUsage, bool aCancelAcquireLicense, bool aSourceInitDataNotSupported, PVMFCPMContentType aCPMContentType)
79 {
80 PVMFCPMPassThruPlugInOMA1* plugIn = NULL;
81 int32 err;
82 OSCL_TRY(err,
83 /*
84 * Create pass thru OMA1.0 Plugin
85 */
86 plugIn = OSCL_NEW(PVMFCPMPassThruPlugInOMA1, (aFailAuthorizeUsage, aCancelAcquireLicense, aSourceInitDataNotSupported, aCPMContentType));
87 );
88 if (err != OsclErrNone)
89 {
90 OSCL_LEAVE(err);
91 }
92
93 return (OSCL_STATIC_CAST(PVMFCPMPluginInterface*, plugIn));
94 }
95
DestroyPlugIn(PVMFCPMPluginInterface * aPlugIn)96 void PVMFCPMPassThruPlugInOMA1::DestroyPlugIn(PVMFCPMPluginInterface* aPlugIn)
97 {
98 OSCL_DELETE(aPlugIn);
99 }
100
101 /**
102 * Plugin Constructor & Destructor
103 */
PVMFCPMPassThruPlugInOMA1(bool aFailAuthorizeUsage,bool aCancelAcquireLicense,bool aSourceInitDataNotSupported,PVMFCPMContentType aCPMContentType,int32 aPriority)104 OSCL_EXPORT_REF PVMFCPMPassThruPlugInOMA1::PVMFCPMPassThruPlugInOMA1(bool aFailAuthorizeUsage, bool aCancelAcquireLicense,
105 bool aSourceInitDataNotSupported, PVMFCPMContentType aCPMContentType,
106 int32 aPriority)
107 : OsclActiveObject(aPriority, "PVMFCPMPassThruPlugInOMA1"),
108 iExtensionRefCount(0)
109 {
110 iLogger = NULL;
111 oSourceSet = false;
112 iFileHandle = NULL;
113 iDataStreamReadCapacityObserver = NULL;
114 // To simulate "authorizeusage" failure
115 iFailAuthorizeUsage = aFailAuthorizeUsage;
116 //to simualte cancelGetLic
117 iCancelAcquireLicense = aCancelAcquireLicense;
118 //to simulate "notsupported" content
119 iSourceInitDataNotSupported = aSourceInitDataNotSupported;
120
121 iCPMContentType = aCPMContentType;
122 int32 err;
123 OSCL_TRY(err,
124 /*
125 * Create the input command queue. Use a reserve to avoid lots of
126 * dynamic memory allocation
127 */
128 iInputCommands.Construct(PVMF_CPM_PASSTHRU_PLUGIN_OMA1_COMMAND_ID_START,
129 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_INTERNAL_CMDQ_SIZE);
130
131 /*
132 * Create the "current command" queue. It will only contain one
133 * command at a time, so use a reserve of 1
134 */
135 iCurrentCommand.Construct(0, 1);
136
137 );
138 if (err != OsclErrNone)
139 {
140 OSCL_LEAVE(err);
141 }
142 //set the fixed metadata query and value strings.
143 iMetaData[EIsProtectedOMA1].iQuery = PVMF_DRM_INFO_IS_PROTECTED_QUERY;
144 iMetaData[EIsProtectedOMA1].iValue = PVMF_DRM_INFO_IS_PROTECTED_VALUE;
145
146 iMetaData[ELicAvailableOMA1].iQuery = PVMF_DRM_INFO_IS_LICENSE_AVAILABLE_QUERY;
147 iMetaData[ELicAvailableOMA1].iValue = PVMF_DRM_INFO_IS_LICENSE_AVAILABLE_VALUE;
148
149 iMetaData[ELicTypeOMA1].iQuery = PVMF_DRM_INFO_LICENSE_TYPE_QUERY;
150 iMetaData[ELicTypeOMA1].iValue = PVMF_DRM_INFO_LICENSE_TYPE_VALUE;
151
152 iMetaData[EForwardLockOMA1].iQuery = PVMF_DRM_INFO_IS_FORWARD_LOCKED_QUERY;
153 iMetaData[EForwardLockOMA1].iValue = PVMF_DRM_INFO_IS_FORWARD_LOCKED_VALUE;
154
155 for (uint32 i = 0; i < ELicLastOMA1; i++)
156 {
157 iMetaData[i].iKvp.key = iMetaData[i].iValue.get_str();
158 iMetaData[i].iKvp.length = 0;
159 iMetaData[i].iKvp.capacity = 0;
160 }
161
162 }
163
~PVMFCPMPassThruPlugInOMA1()164 PVMFCPMPassThruPlugInOMA1::~PVMFCPMPassThruPlugInOMA1()
165 {
166 oSourceSet = false;
167 /*
168 * Cleanup commands
169 * The command queues are self-deleting, but we want to
170 * notify the observer of unprocessed commands.
171 */
172 while (!iCurrentCommand.empty())
173 {
174 CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFFailure);
175 }
176 while (!iInputCommands.empty())
177 {
178 CommandComplete(iInputCommands, iInputCommands.front(), PVMFFailure);
179 }
180 }
181
ThreadLogon()182 void PVMFCPMPassThruPlugInOMA1::ThreadLogon()
183 {
184 if (!iLoggedOn)
185 {
186 iLogger = PVLogger::GetLoggerObject("PVMFCPMPassThruPlugInOMA1");
187 AddToScheduler();
188 iLoggedOn = true;
189 }
190 }
191
ThreadLogoff()192 void PVMFCPMPassThruPlugInOMA1::ThreadLogoff()
193 {
194 if (iLoggedOn)
195 {
196 iLogger = NULL;
197 Cancel();
198 RemoveFromScheduler();
199 iLoggedOn = false;
200 }
201 }
202
203 OSCL_EXPORT_REF PVMFCommandId
QueryUUID(PVMFSessionId s,const PvmfMimeString & aMimeType,Oscl_Vector<PVUuid,OsclMemAllocator> & aUuids,bool aExactUuidsOnly,const OsclAny * aContext)204 PVMFCPMPassThruPlugInOMA1::QueryUUID(PVMFSessionId s,
205 const PvmfMimeString& aMimeType,
206 Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
207 bool aExactUuidsOnly,
208 const OsclAny* aContext)
209 {
210 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:QueryUUID"));
211 PVMFCPMPassThruPlugInOMA1Command cmd;
212 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(s,
213 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_QUERYUUID,
214 aMimeType,
215 aUuids,
216 aExactUuidsOnly,
217 aContext);
218 return QueueCommandL(cmd);
219 }
220
221 OSCL_EXPORT_REF PVMFCommandId
QueryInterface(PVMFSessionId s,const PVUuid & aUuid,PVInterface * & aInterfacePtr,const OsclAny * aContext)222 PVMFCPMPassThruPlugInOMA1::QueryInterface(PVMFSessionId s,
223 const PVUuid& aUuid,
224 PVInterface*& aInterfacePtr,
225 const OsclAny* aContext)
226 {
227 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:QueryInterface"));
228 PVMFCPMPassThruPlugInOMA1Command cmd;
229 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(s,
230 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_QUERYINTERFACE,
231 aUuid,
232 aInterfacePtr,
233 aContext);
234 return QueueCommandL(cmd);
235 }
236
237 OSCL_EXPORT_REF PVMFCommandId
Init(PVMFSessionId s,const OsclAny * aContext)238 PVMFCPMPassThruPlugInOMA1::Init(PVMFSessionId s, const OsclAny* aContext)
239 {
240 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:Init"));
241 PVMFCPMPassThruPlugInOMA1Command cmd;
242 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(s,
243 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_INIT,
244 aContext);
245 return QueueCommandL(cmd);
246 }
247
248 OSCL_EXPORT_REF PVMFCommandId
Reset(PVMFSessionId s,const OsclAny * aContext)249 PVMFCPMPassThruPlugInOMA1::Reset(PVMFSessionId s, const OsclAny* aContext)
250 {
251 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:Reset"));
252 PVMFCPMPassThruPlugInOMA1Command cmd;
253 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(s,
254 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_RESET,
255 aContext);
256 return QueueCommandL(cmd);
257 }
258
259 OSCL_EXPORT_REF PVMFCommandId
AuthenticateUser(PVMFSessionId aSessionId,OsclAny * aAuthenticationData,OsclAny * aContext)260 PVMFCPMPassThruPlugInOMA1::AuthenticateUser(PVMFSessionId aSessionId,
261 OsclAny* aAuthenticationData,
262 OsclAny* aContext)
263 {
264 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:AuthenticateUser"));
265 PVMFCPMPassThruPlugInOMA1Command cmd;
266 cmd.Construct(aSessionId,
267 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_AUTHENTICATE,
268 aAuthenticationData,
269 NULL,
270 aContext);
271 return QueueCommandL(cmd);
272 }
273
274 OSCL_EXPORT_REF PVMFCommandId
AuthorizeUsage(PVMFSessionId aSessionId,PvmiKvp & aRequestedUsage,PvmiKvp & aApprovedUsage,PvmiKvp & aAuthorizationData,uint32 & aRequestTimeOutInMS,OsclAny * aContext)275 PVMFCPMPassThruPlugInOMA1::AuthorizeUsage(PVMFSessionId aSessionId,
276 PvmiKvp& aRequestedUsage,
277 PvmiKvp& aApprovedUsage,
278 PvmiKvp& aAuthorizationData,
279 uint32& aRequestTimeOutInMS,
280 OsclAny* aContext)
281 {
282 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:AuthorizeUsage"));
283 PVMFCPMPassThruPlugInOMA1Command cmd;
284 cmd.Construct(aSessionId,
285 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_AUTHORIZE_USAGE,
286 &aRequestedUsage,
287 &aApprovedUsage,
288 &aAuthorizationData,
289 &aRequestTimeOutInMS,
290 aContext);
291 return QueueCommandL(cmd);
292 }
293
294 OSCL_EXPORT_REF PVMFCommandId
UsageComplete(PVMFSessionId s,const OsclAny * aContext)295 PVMFCPMPassThruPlugInOMA1::UsageComplete(PVMFSessionId s, const OsclAny* aContext)
296 {
297 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:UsageComplete"));
298 PVMFCPMPassThruPlugInOMA1Command cmd;
299 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(s,
300 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_USAGE_COMPLETE,
301 aContext);
302 return QueueCommandL(cmd);
303 }
304
305 PVMFStatus
SetSourceInitializationData(OSCL_wString & aSourceURL,PVMFFormatType & aSourceFormat,OsclAny * aSourceData)306 PVMFCPMPassThruPlugInOMA1::SetSourceInitializationData(OSCL_wString& aSourceURL,
307 PVMFFormatType& aSourceFormat,
308 OsclAny* aSourceData)
309 {
310 OSCL_UNUSED_ARG(aSourceData);
311
312 //In a real OMA1 plugin, we would be able to verify whether the source is really OMA1
313 //content or not. This passthru plugin is not smart enough to do that, so it
314 //generally accepts all formats. However, it rejects ASF content to avoid conflicts
315 //with the PV Janus plugin.
316 if (aSourceFormat == PVMF_MIME_ASFFF || PVMF_MIME_DATA_SOURCE_MS_HTTP_STREAMING_URL)
317 {
318 return PVMFErrNotSupported;
319 }
320 else
321 {
322 iFilename = aSourceURL;
323 iSourceFormatType = aSourceFormat;
324 /*
325 if(aSourceData)
326 {
327 iFileHandle=((PVMFLocalDataSource*)aSourceData)->iFileHandle;
328 }
329 else
330 {
331 iFileHandle=NULL;
332 }
333 */
334 if (iSourceInitDataNotSupported)
335 {
336 iSourceInitDataNotSupported = false; //reset for next time
337 return PVMFErrNotSupported;
338 }
339 oSourceSet = true;
340 return PVMFSuccess;
341 }
342 }
343
344 PVMFCPMContentType
GetCPMContentType()345 PVMFCPMPassThruPlugInOMA1::GetCPMContentType()
346 {
347 return iCPMContentType;
348 }
349
QueryAccessInterfaceUUIDs(Oscl_Vector<PVUuid,OsclMemAllocator> & aUuids)350 PVMFStatus PVMFCPMPassThruPlugInOMA1::QueryAccessInterfaceUUIDs(Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids)
351 {
352 aUuids.push_back(PVMIDataStreamSyncInterfaceUuid);
353 return PVMFSuccess;
354 }
355
356 PVInterface*
CreatePVMFCPMPluginAccessInterface(PVUuid & aUuid)357 PVMFCPMPassThruPlugInOMA1::CreatePVMFCPMPluginAccessInterface(PVUuid& aUuid)
358 {
359 if (aUuid == PVMIDataStreamSyncInterfaceUuid)
360 {
361 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl* iface = NULL;
362 iface = OSCL_NEW(PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl, (*this));
363
364 PVMIDataStreamSyncInterface* interimPtr1
365 = OSCL_STATIC_CAST(PVMIDataStreamSyncInterface*, iface);
366
367 return (OSCL_STATIC_CAST(PVInterface*, interimPtr1));
368 }
369
370 return NULL;
371 }
372
373 void
DestroyPVMFCPMPluginAccessInterface(PVUuid & aUuid,PVInterface * aPtr)374 PVMFCPMPassThruPlugInOMA1::DestroyPVMFCPMPluginAccessInterface(PVUuid& aUuid,
375 PVInterface* aPtr)
376 {
377 if (aUuid == PVMIDataStreamSyncInterfaceUuid)
378 {
379 PVMIDataStreamSyncInterface* interimPtr =
380 (PVMIDataStreamSyncInterface*)aPtr;
381 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl* datastream =
382 (PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl*)interimPtr;
383 OSCL_DELETE(datastream);
384 }
385 else
386 {
387 OSCL_ASSERT(false);
388 }
389 }
390
391 void
SetStreamReadCapacityObserver(PVMFDataStreamReadCapacityObserver * aObs)392 PVMFCPMPassThruPlugInOMA1::SetStreamReadCapacityObserver(PVMFDataStreamReadCapacityObserver* aObs)
393 {
394 iDataStreamReadCapacityObserver = aObs;
395 }
396
397
398 /**
399 * This routine is called by various command APIs to queue an
400 * asynchronous command for processing by the command handler AO.
401 * This function may leave if the command can't be queued due to
402 * memory allocation failure.
403 */
QueueCommandL(PVMFCPMPassThruPlugInOMA1Command & aCmd)404 PVMFCommandId PVMFCPMPassThruPlugInOMA1::QueueCommandL(PVMFCPMPassThruPlugInOMA1Command& aCmd)
405 {
406 PVMFCommandId id;
407 id = iInputCommands.AddL(aCmd);
408 /* wakeup the AO */
409 RunIfNotReady();
410 return id;
411 }
412
413 /**
414 * The various command handlers call this when a command is complete.
415 */
CommandComplete(PVMFCPMPassThruPlugInOMA1CmdQ & aCmdQ,PVMFCPMPassThruPlugInOMA1Command & aCmd,PVMFStatus aStatus,OsclAny * aEventData,PVUuid * aEventUUID,int32 * aEventCode)416 void PVMFCPMPassThruPlugInOMA1::CommandComplete(PVMFCPMPassThruPlugInOMA1CmdQ& aCmdQ,
417 PVMFCPMPassThruPlugInOMA1Command& aCmd,
418 PVMFStatus aStatus,
419 OsclAny* aEventData,
420 PVUuid* aEventUUID,
421 int32* aEventCode)
422 {
423 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:CommandComplete Id %d Cmd %d Status %d Context %d Data %d"
424 , aCmd.iId, aCmd.iCmd, aStatus, aCmd.iContext, aEventData));
425
426 PVInterface* extif = NULL;
427 PVMFBasicErrorInfoMessage* errormsg = NULL;
428 if (aEventUUID && aEventCode)
429 {
430 errormsg = OSCL_NEW(PVMFBasicErrorInfoMessage, (*aEventCode, *aEventUUID, NULL));
431 extif = OSCL_STATIC_CAST(PVInterface*, errormsg);
432 }
433
434 /* create response */
435 PVMFCmdResp resp(aCmd.iId, aCmd.iContext, aStatus, extif, aEventData);
436 PVMFSessionId session = aCmd.iSession;
437
438 /* Erase the command from the queue */
439 aCmdQ.Erase(&aCmd);
440
441 /* Report completion to the session observer */
442 ReportCmdCompleteEvent(session, resp);
443
444 if (errormsg)
445 {
446 errormsg->removeRef();
447 }
448 //Reschedule if there are more commands.
449 if (!iInputCommands.empty()
450 && IsAdded())
451 {
452 RunIfNotReady();
453 }
454 }
455
456 void
MoveCmdToCurrentQueue(PVMFCPMPassThruPlugInOMA1Command & aCmd)457 PVMFCPMPassThruPlugInOMA1::MoveCmdToCurrentQueue(PVMFCPMPassThruPlugInOMA1Command& aCmd)
458 {
459 int32 err;
460 OSCL_TRY(err, iCurrentCommand.StoreL(aCmd););
461 if (err != OsclErrNone)
462 {
463 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGERROR((0, "PVMFCPMPassThruPlugInOMA1:MoveCmdToCurrentQueue - No Memory"));
464 CommandComplete(iInputCommands, aCmd, PVMFErrNoMemory);
465 return;
466 }
467 iInputCommands.Erase(&aCmd);
468 return;
469 }
470
471 /**
472 * Called by the command handler AO to process a command from
473 * the input queue.
474 * Return true if a command was processed, false if the command
475 * processor is busy and can't process another command now.
476 */
ProcessCommand(PVMFCPMPassThruPlugInOMA1Command & aCmd)477 bool PVMFCPMPassThruPlugInOMA1::ProcessCommand(PVMFCPMPassThruPlugInOMA1Command& aCmd)
478 {
479 /*
480 * normally this node will not start processing one command
481 * until the prior one is finished. However, a hi priority
482 * command such as Cancel must be able to interrupt a command
483 * in progress.
484 */
485 if (!iCurrentCommand.empty() && !aCmd.hipri() && aCmd.iCmd != PVMF_CPM_PASSTHRU_PLUGIN_OMA1_CANCEL_GET_LICENSE)
486 return false;
487
488 switch (aCmd.iCmd)
489 {
490 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_QUERYUUID:
491 DoQueryUuid(aCmd);
492 break;
493
494 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_QUERYINTERFACE:
495 DoQueryInterface(aCmd);
496 break;
497
498 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_INIT:
499 DoInit(aCmd);
500 break;
501
502 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_RESET:
503 DoReset(aCmd);
504 break;
505
506 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_AUTHENTICATE:
507 DoAuthenticate(aCmd);
508 break;
509
510 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_AUTHORIZE_USAGE:
511 DoAuthorizeUsage(aCmd);
512 break;
513
514 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_USAGE_COMPLETE:
515 DoUsageComplete(aCmd);
516 break;
517
518 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_GET_LICENSE:
519 {
520 PVMFStatus aCmdStatus = DoGetLicense(aCmd);
521 switch (aCmdStatus)
522 {
523 case PVMFPending:
524 MoveCmdToCurrentQueue(aCmd);
525 break;
526 }
527 }
528 break;
529
530 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_CANCEL_GET_LICENSE:
531 DoCancelGetLicense(aCmd);
532 break;
533
534
535 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_METADATA_KEYS:
536 DoMetadataKeys(aCmd);
537 break;
538
539 case PVMF_CPM_PASSTHRU_PLUGIN_OMA1_METADATA_VALUES:
540 DoMetadataValues(aCmd);
541 break;
542
543 default:
544 {
545 /* unknown command type */
546 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGWARNING((0, "PVMFCPMPassThruPlugInOMA1:ProcessCommand - Unknown Command"));
547 CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
548 }
549 break;
550 }
551
552 return true;
553 }
554
555 /**
556 * Called by the command handler AO to do the Query UUID
557 */
DoQueryUuid(PVMFCPMPassThruPlugInOMA1Command & aCmd)558 void PVMFCPMPassThruPlugInOMA1::DoQueryUuid(PVMFCPMPassThruPlugInOMA1Command& aCmd)
559 {
560 OSCL_String* mimetype;
561 Oscl_Vector<PVUuid, OsclMemAllocator> *uuidvec;
562 bool exactmatch;
563 aCmd.PVMFCPMPassThruPlugInOMA1CommandBase::Parse(mimetype, uuidvec, exactmatch);
564
565 if (exactmatch == false)
566 {
567 CommandComplete(iInputCommands, aCmd, PVMFErrArgument);
568 }
569 /*
570 * Try to match the input mimetype against any of
571 * the interfaces supported by this plugin
572 */
573 if (*mimetype == PVMF_CPMPLUGIN_AUTHENTICATION_INTERFACE_MIMETYPE)
574 {
575 PVUuid uuid(PVMFCPMPluginAuthenticationInterfaceUuid);
576 uuidvec->push_back(uuid);
577 }
578 else if (*mimetype == PVMF_CPMPLUGIN_AUTHORIZATION_INTERFACE_MIMETYPE)
579 {
580 PVUuid uuid(PVMFCPMPluginAuthorizationInterfaceUuid);
581 uuidvec->push_back(uuid);
582 }
583 else if (*mimetype == PVMF_CPMPLUGIN_ACCESS_INTERFACE_FACTORY_MIMETYPE)
584 {
585 PVUuid uuid(PVMFCPMPluginAccessInterfaceFactoryUuid);
586 uuidvec->push_back(uuid);
587 }
588 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
589 }
590
591 /**
592 * Called by the command handler AO to do the Query Interface.
593 */
DoQueryInterface(PVMFCPMPassThruPlugInOMA1Command & aCmd)594 void PVMFCPMPassThruPlugInOMA1::DoQueryInterface(PVMFCPMPassThruPlugInOMA1Command& aCmd)
595 {
596 PVUuid* uuid;
597 PVInterface** ptr;
598 aCmd.PVMFCPMPassThruPlugInOMA1CommandBase::Parse(uuid, ptr);
599
600 if ((*uuid == PVMFCPMPluginAuthorizationInterfaceUuid) ||
601 (*uuid == PVMFCPMPluginAccessInterfaceFactoryUuid))
602 {
603 if (oSourceSet == false)
604 {
605 CommandComplete(iInputCommands, aCmd, PVMFErrInvalidState);
606 return;
607 }
608 }
609
610 if (queryInterface(*uuid, *ptr))
611 {
612 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
613 }
614 else
615 {
616 /* not supported */
617 *ptr = NULL;
618 CommandComplete(iInputCommands, aCmd, PVMFErrNotSupported);
619 }
620 }
621
queryInterface(const PVUuid & uuid,PVInterface * & iface)622 bool PVMFCPMPassThruPlugInOMA1::queryInterface(const PVUuid& uuid, PVInterface*& iface)
623 {
624 if (uuid == PVMFCPMPluginAuthenticationInterfaceUuid)
625 {
626 PVMFCPMPluginAuthenticationInterface* myInterface =
627 OSCL_STATIC_CAST(PVMFCPMPluginAuthenticationInterface*, this);
628 iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
629 }
630 else if (uuid == PVMFCPMPluginAuthorizationInterfaceUuid)
631 {
632 PVMFCPMPluginAuthorizationInterface* myInterface =
633 OSCL_STATIC_CAST(PVMFCPMPluginAuthorizationInterface*, this);
634 iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
635 }
636 else if (uuid == PVMFCPMPluginAccessInterfaceFactoryUuid)
637 {
638 PVMFCPMPluginAccessInterfaceFactory* myInterface =
639 OSCL_STATIC_CAST(PVMFCPMPluginAccessInterfaceFactory*, this);
640 iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
641 }
642 else if (uuid == PVMFCPMPluginLicenseInterfaceUuid)
643 {
644 PVMFCPMPluginLicenseInterface* myInterface =
645 OSCL_STATIC_CAST(PVMFCPMPluginLicenseInterface*, this);
646 iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
647 }
648 else if (uuid == KPVMFMetadataExtensionUuid)
649 {
650 PVMFMetadataExtensionInterface* myInterface
651 = OSCL_STATIC_CAST(PVMFMetadataExtensionInterface*, this);
652 iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
653 }
654 else
655 {
656 return false;
657 }
658 addRef();
659 return true;
660 }
661
DoInit(PVMFCPMPassThruPlugInOMA1Command & aCmd)662 void PVMFCPMPassThruPlugInOMA1::DoInit(PVMFCPMPassThruPlugInOMA1Command& aCmd)
663 {
664 /* Nothing to do */
665 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
666 }
667
DoReset(PVMFCPMPassThruPlugInOMA1Command & aCmd)668 void PVMFCPMPassThruPlugInOMA1::DoReset(PVMFCPMPassThruPlugInOMA1Command& aCmd)
669 {
670 oSourceSet = false;
671 /* Nothing to do */
672 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
673 }
674
DoAuthenticate(PVMFCPMPassThruPlugInOMA1Command & aCmd)675 void PVMFCPMPassThruPlugInOMA1::DoAuthenticate(PVMFCPMPassThruPlugInOMA1Command& aCmd)
676 {
677 OsclAny* authenticationData;
678 OsclAny* dummy;
679 aCmd.Parse(authenticationData, dummy);
680
681 /* Return success always, till siemens api become available */
682 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
683 }
684
DoAuthorizeUsage(PVMFCPMPassThruPlugInOMA1Command & aCmd)685 void PVMFCPMPassThruPlugInOMA1::DoAuthorizeUsage(PVMFCPMPassThruPlugInOMA1Command& aCmd)
686 {
687 if (iFailAuthorizeUsage)
688 {
689 iFailAuthorizeUsage = false; //reset for next try
690 CommandComplete(iInputCommands, aCmd, PVMFErrLicenseRequired);
691 return;
692 }
693 MakeMetadata();
694
695 OsclAny* temp1 = NULL;
696 OsclAny* temp2 = NULL;
697 OsclAny* temp3 = NULL;
698 OsclAny* temp4 = NULL;
699
700 aCmd.Parse(temp1, temp2, temp3, temp4);
701
702 PvmiKvp* requestedUsage = OSCL_STATIC_CAST(PvmiKvp*, temp1);
703 PvmiKvp* approvedUsage = OSCL_STATIC_CAST(PvmiKvp*, temp2);
704 PvmiKvp* authorizationData = OSCL_STATIC_CAST(PvmiKvp*, temp3);
705 uint32* requestTimeOutInMS = OSCL_STATIC_CAST(uint32*, temp4);
706
707 /* No check needed - approve everything */
708 approvedUsage->value.uint32_value = requestedUsage->value.uint32_value;
709 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
710 OSCL_UNUSED_ARG(authorizationData);
711 OSCL_UNUSED_ARG(requestTimeOutInMS);
712 }
713
DoUsageComplete(PVMFCPMPassThruPlugInOMA1Command & aCmd)714 void PVMFCPMPassThruPlugInOMA1::DoUsageComplete(PVMFCPMPassThruPlugInOMA1Command& aCmd)
715 {
716 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
717 }
718
DoGetLicense(PVMFCPMPassThruPlugInOMA1Command & aCmd)719 PVMFStatus PVMFCPMPassThruPlugInOMA1::DoGetLicense(PVMFCPMPassThruPlugInOMA1Command& aCmd)
720 {
721 if (!iCancelAcquireLicense)
722 {
723 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
724 return PVMFSuccess;
725 }
726 else
727 {
728 iCancelAcquireLicense = false; //Reset for next time
729 return PVMFPending;
730 }
731 }
732
DoCancelGetLicense(PVMFCPMPassThruPlugInOMA1Command & aCmd)733 void PVMFCPMPassThruPlugInOMA1::DoCancelGetLicense(PVMFCPMPassThruPlugInOMA1Command& aCmd)
734 {
735 //Complete all pending commands, basically "GetLicense"
736 while (iCurrentCommand.size() > 0)
737 {
738 CommandComplete(iCurrentCommand, iCurrentCommand.front(), PVMFErrCancelled);
739 }
740 //complete the CancelGetLicense
741 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
742 }
743
DoMetadataKeys(PVMFCPMPassThruPlugInOMA1Command & aCmd)744 void PVMFCPMPassThruPlugInOMA1::DoMetadataKeys(PVMFCPMPassThruPlugInOMA1Command& aCmd)
745 {
746 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
747 }
748
DoMetadataValues(PVMFCPMPassThruPlugInOMA1Command & aCmd)749 void PVMFCPMPassThruPlugInOMA1::DoMetadataValues(PVMFCPMPassThruPlugInOMA1Command& aCmd)
750 {
751 CommandComplete(iInputCommands, aCmd, PVMFSuccess);
752 }
753
754 /**
755 * This AO handles API commands. The AO will process one command
756 * per call. It will re-schedule itself and run continuously
757 * until it runs out of things to do.
758 */
Run()759 void PVMFCPMPassThruPlugInOMA1::Run()
760 {
761 /*
762 * Process commands.
763 */
764 if (!iInputCommands.empty())
765 {
766 ProcessCommand(iInputCommands.front());
767 }
768 }
769
770 OSCL_EXPORT_REF PVMFStatus
GetLicenseURL(PVMFSessionId aSessionId,OSCL_wString & aContentName,OSCL_wString & aLicenseURL)771 PVMFCPMPassThruPlugInOMA1::GetLicenseURL(PVMFSessionId aSessionId,
772 OSCL_wString& aContentName,
773 OSCL_wString& aLicenseURL)
774 {
775 OSCL_UNUSED_ARG(aSessionId);
776 OSCL_UNUSED_ARG(aContentName);
777 OSCL_UNUSED_ARG(aLicenseURL);
778 return PVMFErrNotSupported;
779 }
780
781 OSCL_EXPORT_REF PVMFStatus
GetLicenseURL(PVMFSessionId aSessionId,OSCL_String & aContentName,OSCL_String & aLicenseURL)782 PVMFCPMPassThruPlugInOMA1::GetLicenseURL(PVMFSessionId aSessionId,
783 OSCL_String& aContentName,
784 OSCL_String& aLicenseURL)
785 {
786 OSCL_UNUSED_ARG(aSessionId);
787 OSCL_UNUSED_ARG(aContentName);
788 OSCL_UNUSED_ARG(aLicenseURL);
789 return PVMFErrNotSupported;
790 }
791
GetLicense(PVMFSessionId aSessionId,OSCL_wString & aContentName,OsclAny * aLicenseData,uint32 aDataSize,int32 aTimeoutMsec,OsclAny * aContext)792 OSCL_EXPORT_REF PVMFCommandId PVMFCPMPassThruPlugInOMA1::GetLicense(PVMFSessionId aSessionId
793 , OSCL_wString& aContentName
794 , OsclAny* aLicenseData
795 , uint32 aDataSize
796 , int32 aTimeoutMsec
797 , OsclAny* aContext)
798 {
799 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:GetLicense"));
800 PVMFCPMPassThruPlugInOMA1Command cmd;
801 cmd.Construct(aSessionId,
802 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_GET_LICENSE,
803 &aContentName,
804 aLicenseData,
805 &aDataSize,
806 &aTimeoutMsec,
807 aContext);
808 return QueueCommandL(cmd);
809 }
810
GetLicense(PVMFSessionId aSessionId,OSCL_String & aContentName,OsclAny * aLicenseData,uint32 aDataSize,int32 aTimeoutMsec,OsclAny * aContext)811 OSCL_EXPORT_REF PVMFCommandId PVMFCPMPassThruPlugInOMA1::GetLicense(PVMFSessionId aSessionId
812 , OSCL_String& aContentName
813 , OsclAny* aLicenseData
814 , uint32 aDataSize
815 , int32 aTimeoutMsec
816 , OsclAny* aContext)
817 {
818 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1:GetLicense"));
819 PVMFCPMPassThruPlugInOMA1Command cmd;
820 cmd.Construct(aSessionId,
821 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_GET_LICENSE,
822 &aContentName,
823 aLicenseData,
824 &aDataSize,
825 &aTimeoutMsec,
826 aContext);
827 return QueueCommandL(cmd);
828 }
829
830 OSCL_EXPORT_REF PVMFCommandId
CancelGetLicense(PVMFSessionId aSessionId,PVMFCommandId aCmdId,OsclAny * aContext)831 PVMFCPMPassThruPlugInOMA1::CancelGetLicense(PVMFSessionId aSessionId, PVMFCommandId aCmdId, OsclAny* aContext)
832 {
833 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGINFO((0, "PVMFCPMPassThruPlugInOMA1::CancelGetLicense - called"));
834 PVMFCPMPassThruPlugInOMA1Command cmd;
835 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(aSessionId, PVMF_CPM_PASSTHRU_PLUGIN_OMA1_CANCEL_GET_LICENSE, aCmdId, aContext);
836 return QueueCommandL(cmd);
837 }
838
839 /**
840 * Synchronous method to return the number of metadata keys for the specified query key string
841 *
842 * @param aQueryKeyString A NULL terminated character string specifying a subset of metadata keys to count.
843 * If the string is NULL, total number of all keys will be returned
844 *
845 * @returns The number of metadata keys
846 **/
GetNumMetadataKeys(char * aQueryKeyString)847 OSCL_EXPORT_REF uint32 PVMFCPMPassThruPlugInOMA1::GetNumMetadataKeys(char* aQueryKeyString)
848 {
849 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
850 (0, "PVMFCPMPassThruPlugInOMA1::GetNumMetadataKeys() called"));
851 uint32 total = 0;
852 for (uint32 i = 0; i < ELicLastOMA1; i++)
853 {
854 if (iMetaData[i].iValid)
855 {
856 if (!aQueryKeyString
857 || iMetaData[i].iQuery == aQueryKeyString)
858 {
859 total++;
860 }
861 }
862 }
863 return total;
864 }
865
866
867 /**
868 * Synchronous method to return the number of metadata values for the specified list of key strings
869 *
870 * @param aKeyList A reference to a metadata key list to specifying the values of interest to count
871 *
872 * @returns The number of metadata values based on the provided key list
873 **/
GetNumMetadataValues(PVMFMetadataList & aKeyList)874 OSCL_EXPORT_REF uint32 PVMFCPMPassThruPlugInOMA1::GetNumMetadataValues(PVMFMetadataList& aKeyList)
875 {
876 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
877 (0, "PVMFCPMPassThruPlugInOMA1::GetNumMetadataValues() called"));
878 uint32 total = 0;
879 for (uint32 i = 0; i < aKeyList.size(); i++)
880 {
881 for (uint32 j = 0; j < ELicLastOMA1; j++)
882 {
883 if (iMetaData[j].iValid
884 && iMetaData[j].iQuery == aKeyList[i])
885 {
886 total++;
887 break;//goto next query.
888 }
889 }
890 }
891 return total;
892 }
893
894 /**
895 * Asynchronous method to retrieve a list of metadata keys. The subset of all available keys in the node can
896 * be specified by providing a combination of query key string, starting index, and maximum number of keys to retrieve
897 *
898 * @param aSessionId The assigned node session ID to use for this request
899 * @param aKeyList A reference to a metadata key list to add the metadata keys
900 * @param aStartingKeyIndex Index into the node's total key list that corresponds to the first key entry to retrieve
901 * @param aMaxKeyEntries The maximum number of key entries to add to aKeyList. If there is no maximum, set to -1.
902 * @param aQueryKeyString Optional NULL terminated character string to select a subset of keys
903 * @param aContext Optional opaque data to be passed back to user with the command response
904 *
905 * @returns A unique command ID for asynchronous completion
906 **/
GetNodeMetadataKeys(PVMFSessionId aSessionId,PVMFMetadataList & aKeyList,uint32 aStartingKeyIndex,int32 aMaxKeyEntries,char * aQueryKeyString,const OsclAny * aContextData)907 OSCL_EXPORT_REF PVMFCommandId PVMFCPMPassThruPlugInOMA1::GetNodeMetadataKeys(PVMFSessionId aSessionId,
908 PVMFMetadataList& aKeyList,
909 uint32 aStartingKeyIndex,
910 int32 aMaxKeyEntries ,
911 char* aQueryKeyString ,
912 const OsclAny* aContextData)
913 {
914 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
915 (0, "PVMFCPMPassThruPlugInOMA1::GetNodeMetadataKeys() called"));
916 int32 total = 0;
917 for (uint32 i = aStartingKeyIndex; i < ELicLastOMA1; i++)
918 {
919 if (iMetaData[i].iValid)
920 {
921 if (aMaxKeyEntries >= 0
922 && total >= aMaxKeyEntries)
923 break;
924 if (!aQueryKeyString
925 || iMetaData[i].iQuery == aQueryKeyString)
926 {
927 aKeyList.push_back(iMetaData[i].iQuery);
928 total++;
929 }
930 }
931 }
932 //MyCmdResp resp(aSessionId,aContextData);
933 //return QueueCmdResp(resp,PVMFSuccess);
934 PVMFCPMPassThruPlugInOMA1Command cmd;
935 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(aSessionId,
936 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_METADATA_KEYS,
937 aContextData);
938 return QueueCommandL(cmd);
939 }
940
941 /**
942 * Asynchronous method to retrieve a list of metadata values. The subset of all available values in the node can
943 * be specified by providing a combination of key list, starting index, and maximum number of values to retrieve
944 *
945 * @param aSessionId The assigned node session ID to use for this request
946 * @param aKeyList A reference to a metadata key list specifying the metadata values to retrieve
947 * @param aValueList A reference to a metadata value list to add the metadata values
948 * @param aStartingValueIndex Index into the node's value list specified by the key list that corresponds to the first value entry to retrieve
949 * @param aMaxValueEntries The maximum number of value entries to add to aValueList. If there is no maximum, set to -1.
950 * @param aContext Optional opaque data to be passed back to user with the command response
951 *
952 * @returns A unique command ID for asynchronous completion
953 **/
GetNodeMetadataValues(PVMFSessionId aSessionId,PVMFMetadataList & aKeyList,Oscl_Vector<PvmiKvp,OsclMemAllocator> & aValueList,uint32 aStartingValueIndex,int32 aMaxValueEntries,const OsclAny * aContextData)954 OSCL_EXPORT_REF PVMFCommandId PVMFCPMPassThruPlugInOMA1::GetNodeMetadataValues(PVMFSessionId aSessionId,
955 PVMFMetadataList& aKeyList,
956 Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
957 uint32 aStartingValueIndex,
958 int32 aMaxValueEntries ,
959 const OsclAny* aContextData)
960 {
961 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
962 (0, "PVMFCPMPassThruPlugInOMA1::GetNodeMetadataValues() called"));
963 int32 total = 0;
964 for (uint32 j = 0; j < aKeyList.size(); j++)
965 {
966 for (int32 i = aStartingValueIndex; i < ELicLastOMA1; i++)
967 {
968 if (iMetaData[i].iValid)
969 {
970 if (aMaxValueEntries >= 0
971 && total >= aMaxValueEntries)
972 break;
973 if (iMetaData[i].iQuery == aKeyList[j])
974 {
975 aValueList.push_back(iMetaData[i].iKvp);
976 total++;
977 break;//go to next key.
978 }
979 }
980 }
981 }
982 PVMFCPMPassThruPlugInOMA1Command cmd;
983 cmd.PVMFCPMPassThruPlugInOMA1CommandBase::Construct(aSessionId,
984 PVMF_CPM_PASSTHRU_PLUGIN_OMA1_METADATA_VALUES,
985 aContextData);
986 return QueueCommandL(cmd);
987 }
988
989 /**
990 * Synchronous method to free up the specified range of metadata keys in the list. It is assumed that caller of this function
991 * knows that start and end indices should correspond to metadata keys returned by this particular instance of the
992 * metadata extension interface using GetNodeMetadataKeys().
993 *
994 * @param aKeyList A reference to a metadata key list to free the key entries
995 * @param aStartingKeyIndex Index into aKeyList that corresponds to the first key entry to release
996 * @param aEndKeyIndex Index into aKeyList that corresponds to the last key entry to release
997 *
998 * @returns PVMFSuccess if the release of specified keys succeeded. PVMFErrArgument if indices are invalid or the list is empty.
999 * PVMFFailure otherwise.
1000 **/
ReleaseNodeMetadataKeys(PVMFMetadataList & aKeyList,uint32 aStartingKeyIndex,uint32 aEndKeyIndex)1001 OSCL_EXPORT_REF PVMFStatus PVMFCPMPassThruPlugInOMA1::ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList,
1002 uint32 aStartingKeyIndex,
1003 uint32 aEndKeyIndex)
1004 {
1005 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
1006 (0, "PVMFCPMPassThruPlugInOMA1::ReleaseNodeMetadataKeys() called"));
1007 //nothing needed. metadata memory persists through the life of the plugin.
1008 OSCL_UNUSED_ARG(aKeyList);
1009 OSCL_UNUSED_ARG(aStartingKeyIndex);
1010 OSCL_UNUSED_ARG(aEndKeyIndex);
1011 return PVMFSuccess;
1012 }
1013
1014 /**
1015 * Synchronous method to free up the specified range of metadata values in the list. It is assumed that caller of this function
1016 * knows that start and end indices should correspond to metadata values returned by this particular instance of the
1017 * metadata extension interface using GetNodeMetadataValues().
1018 *
1019 * @param aValueList A reference to a metadata value list to free the value entries
1020 * @param aStartingValueIndex Index into aValueList that corresponds to the first value entry to release
1021 * @param aEndValueIndex Index into aValueList that corresponds to the last value entry to release
1022 *
1023 * @returns PVMFSuccess if the release of specified values succeeded. PVMFErrArgument if indices are invalid or the list is empty.
1024 * PVMFFailure otherwise.
1025 **/
ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp,OsclMemAllocator> & aValueList,uint32 aStartingValueIndex,uint32 aEndValueIndex)1026 OSCL_EXPORT_REF PVMFStatus PVMFCPMPassThruPlugInOMA1::ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
1027 uint32 aStartingValueIndex,
1028 uint32 aEndValueIndex)
1029 {
1030 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
1031 (0, "PVMFCPMPassThruPlugInOMA1::ReleaseNodeMetadataValues() called"));
1032 OSCL_UNUSED_ARG(aValueList);
1033 OSCL_UNUSED_ARG(aStartingValueIndex);
1034 OSCL_UNUSED_ARG(aEndValueIndex);
1035 return PVMFSuccess;
1036 }
1037
1038 //Make Metadata from license state data.
MakeMetadata()1039 void PVMFCPMPassThruPlugInOMA1::MakeMetadata()
1040 {
1041 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE,
1042 (0, "PVMFCPMPassThruPlugInOMA1::MakeMetadata() called"));
1043
1044 //always set "is protected" here. we rely on the source nodes
1045 //to only use this plugin for protected content.
1046 iMetaData[EIsProtectedOMA1].iValid = true;
1047 iMetaData[EIsProtectedOMA1].iKvp.value.bool_value = true;
1048
1049 iMetaData[ELicAvailableOMA1].iValid = true;
1050 iMetaData[ELicAvailableOMA1].iKvp.value.bool_value = true;
1051
1052 iLicType = "unlimited";
1053 iMetaData[ELicTypeOMA1].iValid = true;
1054 iMetaData[ELicTypeOMA1].iKvp.value.pChar_value = iLicType.get_str();
1055
1056 iMetaData[EForwardLockOMA1].iValid = true;
1057 iMetaData[EForwardLockOMA1].iKvp.value.bool_value = true;
1058 }
1059
1060 /**
1061 ** PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl
1062 */
PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl(PVMFCPMPassThruPlugInOMA1 & c)1063 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl(PVMFCPMPassThruPlugInOMA1&c)
1064 : iContainer(c)
1065 {
1066 iFileObject = NULL;
1067 iLogger = iContainer.iLogger;
1068 iFs.Connect();
1069 iDataStreamReadCapacityObserver = iContainer.iDataStreamReadCapacityObserver;
1070 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl"));
1071 }
1072
~PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl()1073 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::~PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl()
1074 {
1075 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::~PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl"));
1076 if (iFileObject)
1077 OSCL_DELETE(iFileObject);
1078 iFileObject = NULL;
1079 iFs.Close();
1080 iLogger = NULL;
1081 iDataStreamReadCapacityObserver = NULL;
1082 }
1083
1084 OSCL_EXPORT_REF bool
queryInterface(const PVUuid & uuid,PVInterface * & iface)1085 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::queryInterface(const PVUuid& uuid,
1086 PVInterface*& iface)
1087 {
1088 iface = NULL;
1089 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::queryInterface"));
1090 if (uuid == PVMIDataStreamSyncInterfaceUuid)
1091 {
1092 PVMIDataStreamSyncInterface* myInterface
1093 = OSCL_STATIC_CAST(PVMIDataStreamSyncInterface*, this);
1094 iface = OSCL_STATIC_CAST(PVInterface*, myInterface);
1095 return true;
1096 }
1097 return false;
1098 }
1099
1100 OSCL_EXPORT_REF PvmiDataStreamStatus
OpenSession(PvmiDataStreamSession & aSessionID,PvmiDataStreamMode aMode,bool nonblocking)1101 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::OpenSession(PvmiDataStreamSession& aSessionID,
1102 PvmiDataStreamMode aMode,
1103 bool nonblocking)
1104 {
1105 OSCL_UNUSED_ARG(aSessionID);
1106 OSCL_UNUSED_ARG(nonblocking);
1107 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::OpenSession"));
1108 if (!iFileObject)
1109 iFileObject = OSCL_NEW(Oscl_File, (0, iContainer.iFileHandle));
1110
1111 int32 result;
1112 if ((aMode == PVDS_READ_ONLY) || (aMode == PVDS_READ_WRITE))
1113 {
1114 result = iFileObject->Open(iContainer.iFilename.get_cstr(), Oscl_File::MODE_READ, iFs);
1115 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::OpenSession - File Open returning %d", result));
1116 return (result == 0) ? PVDS_SUCCESS : PVDS_FAILURE;
1117 }
1118 else
1119 {
1120 return PVDS_UNSUPPORTED_MODE;
1121 }
1122
1123 return PVDS_SUCCESS;
1124 }
1125
1126 OSCL_EXPORT_REF PvmiDataStreamStatus
CloseSession(PvmiDataStreamSession sessionID)1127 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::CloseSession(PvmiDataStreamSession sessionID)
1128 {
1129 OSCL_UNUSED_ARG(sessionID);
1130 if (!iFileObject)
1131 {
1132 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::CloseSession returning %d", -1));
1133 return PVDS_FAILURE;
1134 }
1135 int32 result = iFileObject->Close();
1136 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::CloseSession returning %d", result));
1137 OSCL_DELETE(iFileObject);
1138 iFileObject = NULL;
1139 if (result == 0)
1140 return PVDS_SUCCESS;
1141
1142 return PVDS_FAILURE;
1143 }
1144
1145 OSCL_EXPORT_REF PvmiDataStreamRandomAccessType
QueryRandomAccessCapability()1146 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::QueryRandomAccessCapability()
1147 {
1148 return PVDS_FULL_RANDOM_ACCESS;
1149 }
1150
1151 OSCL_EXPORT_REF PvmiDataStreamStatus
QueryReadCapacity(PvmiDataStreamSession sessionID,uint32 & capacity)1152 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::QueryReadCapacity(PvmiDataStreamSession sessionID,
1153 uint32& capacity)
1154 {
1155 OSCL_UNUSED_ARG(sessionID);
1156 if (iDataStreamReadCapacityObserver != NULL)
1157 {
1158 return (iDataStreamReadCapacityObserver->GetStreamReadCapacity(capacity));
1159 }
1160 else
1161 {
1162 if (!iFileObject)
1163 return PVDS_FAILURE;
1164 int32 result = (TOsclFileOffsetInt32)iFileObject->Size();
1165 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::QueryReadCapacity returning %d", result));
1166 if (result < 0)
1167 {
1168 return PVDS_FAILURE;
1169 }
1170 else
1171 {
1172 capacity = result;
1173 return PVDS_SUCCESS;
1174 }
1175 }
1176 }
1177
1178 OSCL_EXPORT_REF PvmiDataStreamCommandId
RequestReadCapacityNotification(PvmiDataStreamSession sessionID,PvmiDataStreamObserver & observer,uint32 capacity,OsclAny * aContextData)1179 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::RequestReadCapacityNotification(PvmiDataStreamSession sessionID,
1180 PvmiDataStreamObserver& observer,
1181 uint32 capacity,
1182 OsclAny* aContextData)
1183 {
1184 OSCL_UNUSED_ARG(sessionID);
1185 OSCL_UNUSED_ARG(observer);
1186 OSCL_UNUSED_ARG(capacity);
1187 OSCL_UNUSED_ARG(aContextData);
1188 OSCL_LEAVE(OsclErrNotSupported);
1189 return 0;
1190 }
1191
1192 OSCL_EXPORT_REF PvmiDataStreamStatus
QueryWriteCapacity(PvmiDataStreamSession sessionID,uint32 & capacity)1193 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::QueryWriteCapacity(PvmiDataStreamSession sessionID,
1194 uint32& capacity)
1195 {
1196 OSCL_UNUSED_ARG(sessionID);
1197 OSCL_UNUSED_ARG(capacity);
1198 return PVDS_NOT_SUPPORTED;
1199 }
1200
1201 OSCL_EXPORT_REF PvmiDataStreamCommandId
RequestWriteCapacityNotification(PvmiDataStreamSession sessionID,PvmiDataStreamObserver & observer,uint32 capacity,OsclAny * aContextData)1202 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::RequestWriteCapacityNotification(PvmiDataStreamSession sessionID,
1203 PvmiDataStreamObserver& observer,
1204 uint32 capacity,
1205 OsclAny* aContextData)
1206 {
1207 OSCL_UNUSED_ARG(sessionID);
1208 OSCL_UNUSED_ARG(observer);
1209 OSCL_UNUSED_ARG(capacity);
1210 OSCL_UNUSED_ARG(aContextData);
1211 OSCL_LEAVE(OsclErrNotSupported);
1212 return 0;
1213 }
1214
1215 OSCL_EXPORT_REF PvmiDataStreamCommandId
CancelNotification(PvmiDataStreamSession sessionID,PvmiDataStreamObserver & observer,PvmiDataStreamCommandId aID,OsclAny * aContextData)1216 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::CancelNotification(PvmiDataStreamSession sessionID,
1217 PvmiDataStreamObserver& observer,
1218 PvmiDataStreamCommandId aID,
1219 OsclAny* aContextData)
1220 {
1221 OSCL_UNUSED_ARG(sessionID);
1222 OSCL_UNUSED_ARG(observer);
1223 OSCL_UNUSED_ARG(aID);
1224 OSCL_UNUSED_ARG(aContextData);
1225 OSCL_LEAVE(OsclErrNotSupported);
1226 return 0;
1227 }
1228
1229 OSCL_EXPORT_REF PvmiDataStreamStatus
Read(PvmiDataStreamSession sessionID,uint8 * buffer,uint32 size,uint32 & numelements)1230 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::Read(PvmiDataStreamSession sessionID,
1231 uint8* buffer,
1232 uint32 size,
1233 uint32& numelements)
1234 {
1235 OSCL_UNUSED_ARG(sessionID);
1236 if (!iFileObject)
1237 return PVDS_FAILURE;
1238
1239 uint32 result = iFileObject->Read(buffer, size, numelements);
1240 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::ReadAndUnlockContent returning %d", result));
1241
1242 numelements = result;
1243 return PVDS_SUCCESS;
1244 }
1245
1246 OSCL_EXPORT_REF PvmiDataStreamStatus
Write(PvmiDataStreamSession sessionID,uint8 * buffer,uint32 size,uint32 & numelements)1247 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::Write(PvmiDataStreamSession sessionID,
1248 uint8* buffer,
1249 uint32 size,
1250 uint32& numelements)
1251 {
1252 OSCL_UNUSED_ARG(sessionID);
1253 OSCL_UNUSED_ARG(buffer);
1254 OSCL_UNUSED_ARG(size);
1255 OSCL_UNUSED_ARG(numelements);
1256 return PVDS_NOT_SUPPORTED;
1257 }
1258
1259 OSCL_EXPORT_REF PvmiDataStreamStatus
Seek(PvmiDataStreamSession sessionID,int32 offset,PvmiDataStreamSeekType origin)1260 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::Seek(PvmiDataStreamSession sessionID,
1261 int32 offset,
1262 PvmiDataStreamSeekType origin)
1263 {
1264 OSCL_UNUSED_ARG(sessionID);
1265 if (!iFileObject)
1266 return PVDS_FAILURE;
1267 Oscl_File::seek_type seekType;
1268 switch (origin)
1269 {
1270 case PVDS_SEEK_SET:
1271 seekType = Oscl_File::SEEKSET;
1272 break;
1273 case PVDS_SEEK_CUR:
1274 seekType = Oscl_File::SEEKCUR;
1275 break;
1276 case PVDS_SEEK_END:
1277 seekType = Oscl_File::SEEKEND;
1278 break;
1279 default:
1280 return PVDS_FAILURE;
1281 }
1282 int32 result = iFileObject->Seek(offset, seekType);
1283 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::SeekContent returning %d", result));
1284 if (result != 0)
1285 {
1286 return PVDS_FAILURE;
1287 }
1288 return PVDS_SUCCESS;
1289 }
1290
1291 OSCL_EXPORT_REF uint32
GetCurrentPointerPosition(PvmiDataStreamSession sessionID)1292 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::GetCurrentPointerPosition(PvmiDataStreamSession sessionID)
1293 {
1294 OSCL_UNUSED_ARG(sessionID);
1295 if (!iFileObject)
1296 return PVDS_FAILURE;
1297 int32 result = (TOsclFileOffsetInt32)iFileObject->Tell();
1298 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::GetCurrentContentPosition returning %d", result));
1299 return (uint32)(result);
1300 }
1301
1302 OSCL_EXPORT_REF PvmiDataStreamStatus
Flush(PvmiDataStreamSession sessionID)1303 PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::Flush(PvmiDataStreamSession sessionID)
1304 {
1305 OSCL_UNUSED_ARG(sessionID);
1306 if (!iFileObject)
1307 {
1308 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::Flush returning %d", -1));
1309 return PVDS_FAILURE;
1310 }
1311 int32 result = iFileObject->Flush();
1312 PVMF_CPMPLUGIN_PASSTHRUOMA1_LOGDEBUG((0, "PVMFCPMPassThruPlugInOMA1DataStreamSyncInterfaceImpl::Flush returning %d", result));
1313 OSCL_UNUSED_ARG(result);
1314 return PVDS_SUCCESS;
1315 }
1316
1317