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 CPM_INTERNAL_H_INCLUDED 19 #define CPM_INTERNAL_H_INCLUDED 20 21 #ifndef OSCL_BASE_H_INCLUDED 22 #include "oscl_base.h" 23 #endif 24 #ifndef OSCL_TYPES_H_INCLUDED 25 #include "oscl_types.h" 26 #endif 27 #ifndef PVLOGGER_H_INCLUDED 28 #include "pvlogger.h" 29 #endif 30 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED 31 #include "pvmf_node_interface.h" 32 #endif 33 #ifndef PVMF_NODE_UTILS_H_INCLUDED 34 #include "pvmf_node_utils.h" 35 #endif 36 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED 37 #include "oscl_scheduler_ao.h" 38 #endif 39 #ifndef PVMF_CPMPLUGIN_INTERFACE_H_INCLUDED 40 #include "pvmf_cpmplugin_interface.h" 41 #endif 42 #ifndef PVMF_CPMPLUGIN_AUTHORIZATION_INTERFACE_H_INCLUDED 43 #include "pvmf_cpmplugin_authorization_interface.h" 44 #endif 45 #ifndef PVMF_CPMPLUGIN_AUTHENTICATION_INTERFACE_H_INCLUDED 46 #include "pvmf_cpmplugin_authentication_interface.h" 47 #endif 48 #ifndef PVMF_CPMPLUGIN_ACCESS_INTERFACE_FACTORY_H_INCLUDED 49 #include "pvmf_cpmplugin_access_interface_factory.h" 50 #endif 51 #ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED 52 #include "pvmf_data_source_init_extension.h" 53 #endif 54 #ifndef PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED 55 #include "pvmf_cpmplugin_license_interface.h" 56 #endif 57 #ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED 58 #include "pvmf_meta_data_extension.h" 59 #endif 60 #ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED 61 #include "pvmi_config_and_capability_utils.h" 62 #endif 63 #ifndef CPM_H_INCLUDED 64 #include "cpm.h" 65 #endif 66 #ifndef CPM_PLUGIN_REGISTRY_H 67 #include "cpm_plugin_registry.h" 68 #endif 69 #ifndef CPM_TYPES_H 70 #include "cpm_types.h" 71 #endif 72 #ifndef PVMI_KVP_INCLUDED 73 #include "pvmi_kvp.h" 74 #endif 75 #ifndef PVMI_KVP_UTIL_H_INCLUDED 76 #include "pvmi_kvp_util.h" 77 #endif 78 79 /** 80 * Macros for calling PVLogger 81 */ 82 #define PVMF_CPM_LOGERROR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_ERR,m); 83 #define PVMF_CPM_LOGWARNING(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_REL,iLogger,PVLOGMSG_WARNING,m); 84 #define PVMF_CPM_LOGINFOHI(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG,iLogger,PVLOGMSG_INFO,m); 85 #define PVMF_CPM_LOGINFOMED(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG,iLogger,PVLOGMSG_INFO,m); 86 #define PVMF_CPM_LOGINFOLOW(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_INFO,m); 87 #define PVMF_CPM_LOGINFO(m) PVMF_CPM_LOGINFOMED(m) 88 89 /* 90 * IDs for all of the asynchronous plugin commands. 91 */ 92 enum TPVMFCPMCommand 93 { 94 PVMF_CPM_QUERY_INTERFACE = PVMF_GENERIC_NODE_QUERYINTERFACE, 95 /* Starting value for command IDs */ 96 PVMF_CPM_COMMAND_ID_START = 40000, 97 PVMF_CPM_INIT, 98 PVMF_CPM_OPEN_SESSION, 99 PVMF_CPM_REGISTER_CONTENT, 100 PVMF_CPM_APPROVE_USAGE, 101 PVMF_CPM_USAGE_COMPLETE, 102 PVMF_CPM_CLOSE_SESSION, 103 PVMF_CPM_RESET, 104 PVMF_CPM_GET_METADATA_KEYS, 105 PVMF_CPM_GET_METADATA_VALUES, 106 PVMF_CPM_GET_LICENSE_W, 107 PVMF_CPM_GET_LICENSE, 108 PVMF_CPM_CANCEL_GET_LICENSE, 109 PVMF_CPM_COMMAND_LAST 110 }; 111 112 #define PVMF_CPM_INTERNAL_QUERY_UUID_CMD 1000 113 #define PVMF_CPM_INTERNAL_INIT_CMD 1001 114 #define PVMF_CPM_INTERNAL_QUERY_AUTHENTICATION_INTERFACE_CMD 1002 115 #define PVMF_CPM_INTERNAL_QUERY_AUTHORIZATION_INTERFACE_CMD 1003 116 #define PVMF_CPM_INTERNAL_QUERY_ACCESS_INTERFACE_FACTORY_CMD 1004 117 #define PVMF_CPM_INTERNAL_QUERY_METADATA_EXTENSION_INTERFACE_CMD 1005 118 #define PVMF_CPM_INTERNAL_AUTHENTICATE_CMD 1006 119 #define PVMF_CPM_INTERNAL_AUTHORIZE_CMD 1007 120 #define PVMF_CPM_INTERNAL_USAGE_COMPLETE_CMD 1008 121 #define PVMF_CPM_INTERNAL_RESET_CMD 1009 122 #define PVMF_CPM_INTERNAL_GET_PLUGIN_META_DATA_KEYS_CMD 1010 123 #define PVMF_CPM_INTERNAL_GET_PLUGIN_META_DATA_VALUES_CMD 1011 124 #define PVMF_CPM_INTERNAL_QUERY_LICENSE_INTERFACE_CMD 1012 125 #define PVMF_CPM_INTERNAL_GET_LICENSE_CMD 1013 126 #define PVMF_CPM_INTERNAL_QUERY_CAP_CONFIG_INTERFACE_CMD 1014 127 #define PVMF_CPM_INTERNAL_CANCEL_GET_LICENSE 1015 128 129 #define PVMF_CPM_INTERNAL_CMDQ_SIZE 10 130 131 #define PVMFCPMCommandBase PVMFGenericNodeCommand<OsclMemAllocator> 132 133 class PVMFCPMCommand : public PVMFCPMCommandBase 134 { 135 public: Construct(PVMFSessionId s,int32 cmd,OsclAny * aArg1,OsclAny * aArg2,OsclAny * aArg3,OsclAny * aArg4,const OsclAny * aContext)136 void Construct(PVMFSessionId s, 137 int32 cmd, 138 OsclAny* aArg1, 139 OsclAny* aArg2, 140 OsclAny* aArg3, 141 OsclAny* aArg4, 142 const OsclAny* aContext) 143 { 144 PVMFCPMCommandBase::Construct(s, cmd, aContext); 145 iParam1 = aArg1; 146 iParam2 = aArg2; 147 iParam3 = aArg3; 148 iParam4 = aArg4; 149 }; 150 Parse(OsclAny * & aArg1,OsclAny * & aArg2,OsclAny * & aArg3,OsclAny * & aArg4)151 void Parse(OsclAny*& aArg1, 152 OsclAny*& aArg2, 153 OsclAny*& aArg3, 154 OsclAny*& aArg4) 155 { 156 aArg1 = iParam1; 157 aArg2 = iParam2; 158 aArg3 = iParam3; 159 aArg4 = iParam4; 160 }; 161 Construct(PVMFSessionId s,int32 cmd,OsclAny * aArg1,OsclAny * aArg2,OsclAny * aArg3,OsclAny * aArg4,OsclAny * aArg5,const OsclAny * aContext)162 void Construct(PVMFSessionId s, 163 int32 cmd, 164 OsclAny* aArg1, 165 OsclAny* aArg2, 166 OsclAny* aArg3, 167 OsclAny* aArg4, 168 OsclAny* aArg5, 169 const OsclAny* aContext) 170 { 171 PVMFCPMCommandBase::Construct(s, cmd, aContext); 172 iParam1 = aArg1; 173 iParam2 = aArg2; 174 iParam3 = aArg3; 175 iParam4 = aArg4; 176 iParam5 = aArg5; 177 }; 178 Parse(OsclAny * & aArg1,OsclAny * & aArg2,OsclAny * & aArg3,OsclAny * & aArg4,OsclAny * & aArg5)179 void Parse(OsclAny*& aArg1, 180 OsclAny*& aArg2, 181 OsclAny*& aArg3, 182 OsclAny*& aArg4, 183 OsclAny*& aArg5) 184 { 185 aArg1 = iParam1; 186 aArg2 = iParam2; 187 aArg3 = iParam3; 188 aArg4 = iParam4; 189 aArg5 = iParam5; 190 }; 191 192 193 /* For Init and Reset */ Construct(int32 aCmd,const OsclAny * aContext)194 void Construct(int32 aCmd, const OsclAny* aContext) 195 { 196 iSession = 0; 197 iCmd = aCmd; 198 iContext = aContext; 199 iParam1 = NULL; 200 iParam2 = NULL; 201 iParam3 = NULL; 202 iParam4 = NULL; 203 iParam5 = NULL; 204 }; 205 206 /* For open session */ Construct(int32 aCmd,OsclAny * aArg1,const OsclAny * aContext)207 void Construct(int32 aCmd, 208 OsclAny* aArg1, 209 const OsclAny* aContext) 210 { 211 iSession = 0; 212 iCmd = aCmd; 213 iContext = aContext; 214 iParam1 = aArg1; 215 iParam2 = NULL; 216 iParam3 = NULL; 217 iParam4 = NULL; 218 iParam5 = NULL; 219 }; 220 Parse(OsclAny * & aArg1)221 void Parse(OsclAny*& aArg1) 222 { 223 aArg1 = iParam1; 224 }; 225 226 /* Constructor and parser for GetNodeMetadataKeys */ Construct(PVMFSessionId s,int32 cmd,PVMFMetadataList & aKeyList,int32 aStartingIndex,int32 aMaxEntries,char * aQueryKey,const OsclAny * aContext)227 void Construct(PVMFSessionId s, 228 int32 cmd, 229 PVMFMetadataList& aKeyList, 230 int32 aStartingIndex, 231 int32 aMaxEntries, 232 char* aQueryKey, 233 const OsclAny* aContext) 234 { 235 PVMFCPMCommandBase::Construct(s, cmd, aContext); 236 iParam1 = (OsclAny*) & aKeyList; 237 iParam2 = (OsclAny*)aStartingIndex; 238 iParam3 = (OsclAny*)aMaxEntries; 239 if (aQueryKey) 240 { 241 /* allocate a copy of the query key string. */ 242 Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str; 243 iParam4 = str.alloc_and_construct(aQueryKey); 244 } 245 } Parse(PVMFMetadataList * & MetaDataListPtr,int32 & aStartingIndex,int32 & aMaxEntries,char * & aQueryKey)246 void Parse(PVMFMetadataList*& MetaDataListPtr, 247 int32 &aStartingIndex, 248 int32 &aMaxEntries, 249 char*& aQueryKey) 250 { 251 MetaDataListPtr = (PVMFMetadataList*)iParam1; 252 aStartingIndex = (int32)iParam2; 253 aMaxEntries = (int32)iParam3; 254 aQueryKey = NULL; 255 if (iParam4) 256 { 257 OSCL_HeapString<OsclMemAllocator>* keystring = 258 (OSCL_HeapString<OsclMemAllocator>*)iParam4; 259 aQueryKey = keystring->get_str(); 260 } 261 } 262 263 /* Constructor and parser for GetNodeMetadataValue */ Construct(PVMFSessionId s,int32 cmd,PVMFMetadataList & aKeyList,Oscl_Vector<PvmiKvp,OsclMemAllocator> & aValueList,int32 aStartIndex,int32 aMaxEntries,const OsclAny * aContext)264 void Construct(PVMFSessionId s, 265 int32 cmd, 266 PVMFMetadataList& aKeyList, 267 Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, 268 int32 aStartIndex, 269 int32 aMaxEntries, 270 const OsclAny* aContext) 271 { 272 PVMFCPMCommandBase::Construct(s, cmd, aContext); 273 iParam1 = (OsclAny*) & aKeyList; 274 iParam2 = (OsclAny*) & aValueList; 275 iParam3 = (OsclAny*)aStartIndex; 276 iParam4 = (OsclAny*)aMaxEntries; 277 278 } Parse(PVMFMetadataList * & aKeyList,Oscl_Vector<PvmiKvp,OsclMemAllocator> * & aValueList,int32 & aStartingIndex,int32 & aMaxEntries)279 void Parse(PVMFMetadataList* &aKeyList, 280 Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList, 281 int32 &aStartingIndex, 282 int32 &aMaxEntries) 283 { 284 aKeyList = (PVMFMetadataList*)iParam1; 285 aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2; 286 aStartingIndex = (int32)iParam3; 287 aMaxEntries = (int32)iParam4; 288 } 289 290 /* Constructor and parser for GetLicenseW */ Construct(PVMFSessionId s,int32 cmd,OSCL_wString & aContentName,OsclAny * aLicenseData,uint32 aDataSize,int32 aTimeoutMsec,OsclAny * aContext)291 void Construct(PVMFSessionId s, 292 int32 cmd, 293 OSCL_wString& aContentName, 294 OsclAny* aLicenseData, 295 uint32 aDataSize, 296 int32 aTimeoutMsec, 297 OsclAny* aContext) 298 { 299 PVMFCPMCommandBase::Construct(s, cmd, aContext); 300 iParam1 = (OsclAny*) & aContentName; 301 iParam2 = (OsclAny*)aLicenseData; 302 iParam3 = (OsclAny*)aDataSize; 303 iParam4 = (OsclAny*)aTimeoutMsec; 304 iParam5 = NULL; 305 } Parse(OSCL_wString * & aContentName,OsclAny * & aLicenseData,uint32 & aDataSize,int32 & aTimeoutMsec)306 void Parse(OSCL_wString*& aContentName, 307 OsclAny*& aLicenseData, 308 uint32& aDataSize, 309 int32& aTimeoutMsec) 310 { 311 aContentName = (OSCL_wString*)iParam1; 312 aLicenseData = (PVMFTimestamp*)iParam2; 313 aDataSize = (uint32)iParam3; 314 aTimeoutMsec = (int32)iParam4; 315 } 316 317 /* Constructor and parser for GetLicense */ Construct(PVMFSessionId s,int32 cmd,OSCL_String & aContentName,OsclAny * aLicenseData,uint32 aDataSize,int32 aTimeoutMsec,OsclAny * aContext)318 void Construct(PVMFSessionId s, 319 int32 cmd, 320 OSCL_String& aContentName, 321 OsclAny* aLicenseData, 322 uint32 aDataSize, 323 int32 aTimeoutMsec, 324 OsclAny* aContext) 325 { 326 PVMFCPMCommandBase::Construct(s, cmd, aContext); 327 iParam1 = (OsclAny*) & aContentName; 328 iParam2 = (OsclAny*)aLicenseData; 329 iParam3 = (OsclAny*)aDataSize; 330 iParam4 = (OsclAny*)aTimeoutMsec; 331 iParam5 = NULL; 332 } Parse(OSCL_String * & aContentName,OsclAny * & aLicenseData,uint32 & aDataSize,int32 & aTimeoutMsec)333 void Parse(OSCL_String*& aContentName, 334 OsclAny*& aLicenseData, 335 uint32& aDataSize, 336 int32& aTimeoutMsec) 337 { 338 aContentName = (OSCL_String*)iParam1; 339 aLicenseData = (PVMFTimestamp*)iParam2; 340 aDataSize = (uint32)iParam3; 341 aTimeoutMsec = (int32)iParam4; 342 } 343 344 }; 345 346 typedef PVMFNodeCommandQueue<PVMFCPMCommand, OsclMemAllocator> PVMFCPMCommandCmdQ; 347 348 class CPMSessionInfo 349 { 350 public: CPMSessionInfo()351 CPMSessionInfo() 352 { 353 iSessionId = 0; 354 iSourceFormatType = 0; 355 iSourceData = NULL; 356 iNumPlugInAunthenticateRequestsPending = 0; 357 iNumPlugInAunthenticateRequestsComplete = 0; 358 iNumPlugInAuthorizeInterfaceQueryRequestsPending = 0; 359 iNumPlugInAuthorizeInterfaceQueryRequestsComplete = 0; 360 iNumPlugInAccessInterfaceFactoryQueryRequestsPending = 0; 361 iNumPlugInAccessInterfaceFactoryQueryRequestsComplete = 0; 362 iNumPlugInLicenseAcquisitionInterfaceRequestsPending = 0; 363 iNumPlugInLicenseAcquisitionInterfaceRequestsComplete = 0; 364 iAccessPlugInID = 0xFFFFFFFF; 365 }; 366 367 PVMFSessionId iSessionId; 368 OSCL_wHeapString<OsclMemAllocator> iSourceURL; 369 PVMFFormatType iSourceFormatType; 370 OsclAny* iSourceData; 371 uint32 iNumPlugInAunthenticateRequestsPending; 372 uint32 iNumPlugInAunthenticateRequestsComplete; 373 uint32 iNumPlugInAuthorizeInterfaceQueryRequestsPending; 374 uint32 iNumPlugInAuthorizeInterfaceQueryRequestsComplete; 375 uint32 iNumPlugInAccessInterfaceFactoryQueryRequestsPending; 376 uint32 iNumPlugInAccessInterfaceFactoryQueryRequestsComplete; 377 uint32 iNumPlugInLicenseAcquisitionInterfaceRequestsPending; 378 uint32 iNumPlugInLicenseAcquisitionInterfaceRequestsComplete; 379 uint32 iAccessPlugInID; 380 }; 381 382 class CPMPlugInParams 383 { 384 public: CPMPlugInParams()385 CPMPlugInParams() 386 { 387 iPlugInSessionID = 0; 388 iPlugInInterface = NULL; 389 iPlugInData = NULL; 390 iPlugInAuthenticationInterface = NULL; 391 iPlugInAuthorizationInterface = NULL; 392 iPlugInAccessInterfaceFactory = NULL; 393 iPlugInMetaDataExtensionInterface = NULL; 394 iPlugInLicenseInterface = NULL; 395 iPlugInCapConfigExtensionInterface = NULL; 396 iPlugInAuthenticationInterfacePVI = NULL; 397 iPlugInAuthorizationInterfacePVI = NULL; 398 iPlugInAccessInterfaceFactoryPVI = NULL; 399 iPlugInMetaDataExtensionInterfacePVI = NULL; 400 iPlugInLicenseInterfacePVI = NULL; 401 iPlugInCapConfigExtensionInterfacePVI = NULL; 402 403 iAuthorizationRequestTimeOut = 404 PVMF_CPM_DEFAULT_PLUGIN_AUTHORIZATION_TIMEOUT_IN_MS; 405 iConnected = false; 406 iAuthorized = false; 407 iNumMetaDataKeysAvailable = 0; 408 iGetMetaDataValuesComplete = false; 409 iNumMetaDataValuesAvailable = 0; 410 iMetaDataKeyStartIndex = 0; 411 iMetaDataKeyEndIndex = 0; 412 iMetaDataValueStartIndex = 0; 413 iMetaDataValueEndIndex = 0; 414 iGetMetaDataKeysComplete = false; 415 }; 416 417 PVMFSessionId iPlugInSessionID; 418 uint32 iPlugInID; 419 OSCL_HeapString<OsclMemAllocator> iPlugInMimeType; 420 PVMFCPMPluginInterface* iPlugInInterface; 421 OsclAny* iPlugInData; 422 Oscl_Vector<PVUuid, OsclMemAllocator> iExtensionUuids; 423 PVMFCPMPluginAuthenticationInterface* iPlugInAuthenticationInterface; 424 PVMFCPMPluginAuthorizationInterface* iPlugInAuthorizationInterface; 425 PVMFCPMPluginAccessInterfaceFactory* iPlugInAccessInterfaceFactory; 426 PVMFMetadataExtensionInterface* iPlugInMetaDataExtensionInterface; 427 PVMFCPMPluginLicenseInterface* iPlugInLicenseInterface; 428 PvmiCapabilityAndConfig* iPlugInCapConfigExtensionInterface; 429 PVInterface* iPlugInAuthenticationInterfacePVI; 430 PVInterface* iPlugInAuthorizationInterfacePVI; 431 PVInterface* iPlugInAccessInterfaceFactoryPVI; 432 PVInterface* iPlugInMetaDataExtensionInterfacePVI; 433 PVInterface* iPlugInLicenseInterfacePVI; 434 PVInterface* iPlugInCapConfigExtensionInterfacePVI; 435 uint32 iAuthorizationRequestTimeOut; 436 bool iConnected; 437 bool iAuthorized; 438 uint32 iNumMetaDataKeysAvailable; 439 Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys; 440 bool iGetMetaDataValuesComplete; 441 uint32 iNumMetaDataValuesAvailable; 442 uint32 iMetaDataKeyStartIndex; 443 uint32 iMetaDataKeyEndIndex; 444 uint32 iMetaDataValueStartIndex; 445 uint32 iMetaDataValueEndIndex; 446 bool iGetMetaDataKeysComplete; 447 }; 448 449 class CPMContentUsageContext 450 { 451 public: CPMContentUsageContext()452 CPMContentUsageContext() 453 { 454 iUsageID = 0; 455 iNumAuthorizeRequestsPending = 0; 456 iNumAuthorizeRequestsComplete = 0; 457 iNumUsageCompleteRequestsPending = 0; 458 iNumUsageCompleteRequestsComplete = 0; 459 }; 460 461 PVMFCPMUsageID iUsageID; 462 uint32 iNumAuthorizeRequestsPending; 463 uint32 iNumAuthorizeRequestsComplete; 464 uint32 iNumUsageCompleteRequestsPending; 465 uint32 iNumUsageCompleteRequestsComplete; 466 }; 467 468 typedef struct tagPVMFCPMCommandContext 469 { tagPVMFCPMCommandContexttagPVMFCPMCommandContext470 tagPVMFCPMCommandContext() 471 { 472 parentCmd = 0; 473 cmd = 0; 474 oFree = true; 475 plugInID = 0; 476 sessionid = 0; 477 usageid = 0; 478 }; 479 480 int32 parentCmd; 481 int32 cmd; 482 bool oFree; 483 uint32 plugInID; 484 PVMFSessionId sessionid; 485 PVMFCPMUsageID usageid; 486 } PVMFCPMCommandContext; 487 488 class PVMFCPMImpl : public OsclActiveObject, 489 public PVMFCPM, 490 public PVMFMetadataExtensionInterface, 491 public PvmiCapabilityAndConfig, 492 public PVMFCPMPluginCmdStatusObserver, 493 public PVMFCPMPluginLicenseInterface 494 { 495 public: 496 OSCL_IMPORT_REF PVMFCPMImpl(PVMFCPMStatusObserver& aObserver, 497 int32 aPriority = OsclActiveObject::EPriorityNominal); 498 499 ~PVMFCPMImpl(); 500 501 OSCL_IMPORT_REF void ThreadLogon(); 502 OSCL_IMPORT_REF void ThreadLogoff(); 503 504 OSCL_IMPORT_REF PVMFCommandId Init(const OsclAny* aContext = NULL); 505 506 OSCL_IMPORT_REF PVMFCommandId OpenSession(PVMFSessionId& aSessionId, 507 const OsclAny* aContext = NULL); 508 509 OSCL_IMPORT_REF PVMFCommandId RegisterContent(PVMFSessionId aSessionId, 510 OSCL_wString& aSourceURL, 511 PVMFFormatType& aSourceFormat, 512 OsclAny* aSourceData, 513 const OsclAny* aContext = NULL); 514 515 OSCL_IMPORT_REF PVMFCPMContentType GetCPMContentType(PVMFSessionId aSessionId); 516 OSCL_IMPORT_REF PVMFStatus GetCPMContentFilename(PVMFSessionId aSessionId, OSCL_wString& aFileName) ; 517 518 OSCL_IMPORT_REF PVMFStatus GetContentAccessFactory(PVMFSessionId aSessionId, 519 PVMFCPMPluginAccessInterfaceFactory*& aContentAccessFactory); 520 521 OSCL_IMPORT_REF PVMFCommandId ApproveUsage(PVMFSessionId aSessionId, 522 PvmiKvp& aRequestedUsage, 523 PvmiKvp& aApprovedUsage, 524 PvmiKvp& aAuthorizationData, 525 PVMFCPMUsageID& aUsageID, 526 const OsclAny* aContext = NULL); 527 528 OSCL_IMPORT_REF PVMFCommandId UsageComplete(PVMFSessionId aSessionId, 529 PVMFCPMUsageID& aUsageID, 530 OsclAny* aContext = NULL); 531 532 OSCL_IMPORT_REF PVMFCommandId CloseSession(PVMFSessionId& aSessionId, 533 const OsclAny* aContext = NULL); 534 535 OSCL_IMPORT_REF PVMFCommandId Reset(const OsclAny* aContext = NULL); 536 GetPluginRegistry()537 CPMPluginRegistry* GetPluginRegistry() 538 { 539 return iPluginRegistry; 540 } 541 542 OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId aSessionId, 543 const PVUuid& aUuid, 544 PVInterface*& aInterfacePtr, 545 const OsclAny* aContext = NULL); 546 547 OSCL_IMPORT_REF void CPMPluginCommandCompleted(const PVMFCmdResp& aResponse); 548 549 /* From PVInterface */ 550 OSCL_IMPORT_REF void addRef(); 551 OSCL_IMPORT_REF void removeRef(); 552 OSCL_IMPORT_REF bool queryInterface(const PVUuid& uuid, PVInterface*& iface); 553 554 /* From PVMFMetadataExtensionInterface */ 555 OSCL_IMPORT_REF uint32 GetNumMetadataKeys(char* aQueryKeyString = NULL); 556 OSCL_IMPORT_REF uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList); 557 OSCL_IMPORT_REF PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId, 558 PVMFMetadataList& aKeyList, 559 uint32 aStartingKeyIndex, 560 int32 aMaxKeyEntries, 561 char* aQueryKeyString = NULL, 562 const OsclAny* aContextData = NULL); 563 OSCL_IMPORT_REF PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId, 564 PVMFMetadataList& aKeyList, 565 Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, 566 uint32 aStartingValueIndex, 567 int32 aMaxValueEntries = -1, 568 const OsclAny* aContextData = NULL); 569 OSCL_IMPORT_REF PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, 570 uint32 aStartingKeyIndex, 571 uint32 aEndKeyIndex); 572 OSCL_IMPORT_REF PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, 573 uint32 aStartingValueIndex, 574 uint32 aEndValueIndex); 575 576 Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys; 577 578 /* From PVMFCPMPluginLicenseInterface */ GetLicenseURL(PVMFSessionId aSessionId,OSCL_wString & aContentName,OSCL_wString & aLicenseURL)579 PVMFStatus GetLicenseURL(PVMFSessionId aSessionId, 580 OSCL_wString& aContentName, 581 OSCL_wString& aLicenseURL) 582 { 583 OSCL_UNUSED_ARG(aSessionId); 584 OSCL_UNUSED_ARG(aContentName); 585 OSCL_UNUSED_ARG(aLicenseURL); 586 //must use Async method. 587 return PVMFErrNotSupported; 588 } GetLicenseURL(PVMFSessionId aSessionId,OSCL_String & aContentName,OSCL_String & aLicenseURL)589 PVMFStatus GetLicenseURL(PVMFSessionId aSessionId, 590 OSCL_String& aContentName, 591 OSCL_String& aLicenseURL) 592 { 593 OSCL_UNUSED_ARG(aSessionId); 594 OSCL_UNUSED_ARG(aContentName); 595 OSCL_UNUSED_ARG(aLicenseURL); 596 //must use Async method. 597 return PVMFErrNotSupported; 598 } 599 600 PVMFCommandId GetLicense(PVMFSessionId aSessionId, 601 OSCL_wString& aContentName, 602 OsclAny* aData, 603 uint32 aDataSize, 604 int32 aTimeoutMsec, 605 OsclAny* aContextData) ; 606 607 PVMFCommandId GetLicense(PVMFSessionId aSessionId, 608 OSCL_String& aContentName, 609 OsclAny* aData, 610 uint32 aDataSize, 611 int32 aTimeoutMsec, 612 OsclAny* aContextData); 613 614 PVMFCommandId CancelGetLicense(PVMFSessionId aSessionId 615 , PVMFCommandId aCmdId 616 , OsclAny* aContextData); 617 618 PVMFStatus GetLicenseStatus( 619 PVMFCPMLicenseStatus& aStatus) ; 620 621 /* Implement pure virtuals from PvmiCapabilityAndConfig interface */ 622 PVMFStatus getParametersSync(PvmiMIOSession aSession, 623 PvmiKeyType aIdentifier, 624 PvmiKvp*& aParameters, 625 int& num_parameter_elements, 626 PvmiCapabilityContext aContext); 627 PVMFStatus releaseParameters(PvmiMIOSession aSession, 628 PvmiKvp* aParameters, 629 int num_elements); 630 void setParametersSync(PvmiMIOSession aSession, 631 PvmiKvp* aParameters, 632 int num_elements, 633 PvmiKvp*& aRet_kvp); 634 PVMFStatus verifyParametersSync(PvmiMIOSession aSession, 635 PvmiKvp* aParameters, 636 int num_elements); 637 /* Unsupported PvmiCapabilityAndConfig methods */ setObserver(PvmiConfigAndCapabilityCmdObserver * aObserver)638 void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver) 639 { 640 OSCL_UNUSED_ARG(aObserver); 641 }; createContext(PvmiMIOSession aSession,PvmiCapabilityContext & aContext)642 void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext) 643 { 644 OSCL_UNUSED_ARG(aSession); 645 OSCL_UNUSED_ARG(aContext); 646 }; setContextParameters(PvmiMIOSession aSession,PvmiCapabilityContext & aContext,PvmiKvp * aParameters,int num_parameter_elements)647 void setContextParameters(PvmiMIOSession aSession, 648 PvmiCapabilityContext& aContext, 649 PvmiKvp* aParameters, 650 int num_parameter_elements) 651 { 652 OSCL_UNUSED_ARG(aSession); 653 OSCL_UNUSED_ARG(aContext); 654 OSCL_UNUSED_ARG(aParameters); 655 OSCL_UNUSED_ARG(num_parameter_elements); 656 }; DeleteContext(PvmiMIOSession aSession,PvmiCapabilityContext & aContext)657 void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext) 658 { 659 OSCL_UNUSED_ARG(aSession); 660 OSCL_UNUSED_ARG(aContext); 661 }; 662 PVMFCommandId setParametersAsync(PvmiMIOSession aSession, 663 PvmiKvp* aParameters, 664 int num_elements, 665 PvmiKvp*& aRet_kvp, 666 OsclAny* context = NULL) 667 { 668 OSCL_UNUSED_ARG(aRet_kvp); 669 OSCL_UNUSED_ARG(aSession); 670 OSCL_UNUSED_ARG(aParameters); 671 OSCL_UNUSED_ARG(num_elements); 672 OSCL_UNUSED_ARG(context); 673 return -1; 674 } getCapabilityMetric(PvmiMIOSession aSession)675 uint32 getCapabilityMetric(PvmiMIOSession aSession) 676 { 677 OSCL_UNUSED_ARG(aSession); 678 return 0; 679 } 680 681 private: 682 void Run(); 683 684 PVMFCPMStatusObserver& iObserver; 685 686 /* Command processing */ 687 PVMFCPMCommandContext iInternalCmdPool[PVMF_CPM_INTERNAL_CMDQ_SIZE]; 688 PVMFCPMCommandCmdQ iInputCommands; 689 PVMFCPMCommandCmdQ iCurrentCommand; 690 PVMFCPMCommandCmdQ iCancelCommand; 691 PVMFCommandId QueueCommandL(PVMFCPMCommand&); 692 PVMFCPMCommandContext* RequestNewInternalCmd(); 693 void MoveCmdToCurrentQueue(PVMFCPMCommand& aCmd); 694 void MoveCmdToCancelQueue(PVMFCPMCommand& aCmd); 695 bool ProcessCommand(PVMFCPMCommand&); 696 void CommandComplete(PVMFCPMCommandCmdQ&, 697 PVMFCPMCommand&, 698 PVMFStatus, 699 OsclAny* aData = NULL, 700 PVUuid* aEventUUID = NULL, 701 int32* aEventCode = NULL); 702 void CommandComplete(PVMFCPMCommandCmdQ& aCmdQ, 703 PVMFCPMCommand& aCmd, 704 PVMFStatus aStatus, 705 PVInterface* aErrorExtIntf); 706 707 void DoInit(PVMFCPMCommand&); 708 PVMFStatus InitRegisteredPlugIns(); 709 PVMFStatus QueryForPlugInMetaDataExtensionInterface(); 710 PVMFStatus QueryForPlugInAuthenticationInterface(); 711 PVMFStatus QueryForPlugInCapConfigInterface(); 712 void CompleteInitPlugIns(); 713 void CompleteMetaDataExtInterfaceQueryFromPlugIns(); 714 void CompleteCapConfigExtInterfaceQueryFromPlugIns(); 715 void CompleteCPMInit(); 716 717 void DoOpenSession(PVMFCPMCommand&); 718 PVMFStatus AuthenticateWithAllRegisteredPlugIns(PVMFSessionId); 719 void CompleteOpenSession(CPMSessionInfo*); 720 721 void DoRegisterContent(PVMFCPMCommand&); 722 PVMFStatus PopulateListOfActivePlugIns(CPMSessionInfo*); 723 PVMFStatus QueryForAuthorizationInterface(CPMSessionInfo*); 724 PVMFStatus QueryForAccessInterfaceFactory(CPMSessionInfo*); 725 PVMFStatus DetermineAccessPlugIn(CPMSessionInfo*); 726 PVMFStatus QueryForLicenseInterface(CPMSessionInfo*); 727 void CompleteRegisterContentPhase1(CPMSessionInfo*); 728 void CompleteRegisterContentPhase2(CPMSessionInfo*); 729 void CompleteRegisterContentPhase3(CPMSessionInfo*); 730 731 void DoApproveUsage(PVMFCPMCommand&); 732 PVMFStatus RequestApprovalFromActivePlugIns(PVMFCPMCommand& aCmd); 733 void CompleteApproveUsage(CPMContentUsageContext*); 734 bool CheckForMetaDataInterfaceAvailability(); 735 PVMFStatus QueryForMetaDataKeys(PVMFCPMCommand& aParentCmd); 736 void CompleteGetMetaDataKeys(uint32); 737 bool CheckForGetMetaDataKeysCompletion(); 738 739 void DoUsageComplete(PVMFCPMCommand&); 740 PVMFStatus SendUsageCompleteToRegisteredPlugIns(PVMFCPMUsageID); 741 void CompleteUsageComplete(CPMContentUsageContext*); 742 743 void DoCloseSession(PVMFCPMCommand&); 744 745 void DoReset(PVMFCPMCommand&); 746 PVMFStatus ResetRegisteredPlugIns(); 747 void CompleteCPMReset(); 748 749 PVMFStatus DoGetMetadataKeys(PVMFCPMCommand& aCmd); 750 void DoGetMetadataValues(PVMFCPMCommand& aCmd); 751 PVMFStatus CompleteDoGetMetadataKeys(PVMFCPMCommand& aCmd); 752 CPMPlugInParams* LookUpNextPlugInForGetMetaDataValues(); 753 bool IsGetMetaDataValuesFromPlugInsComplete(); 754 void SendGetMetaDataValuesToPlugIn(CPMPlugInParams*); 755 void CompleteGetMetaDataValues(PVMFCPMCommandContext*); 756 757 void DoQueryInterface(PVMFCPMCommand&); 758 759 PVMFStatus DoGetLicense(PVMFCPMCommand& aCmd, 760 bool aWideCharVersion = false); 761 void CompleteGetLicense(); 762 void DoCancelGetLicense(PVMFCPMCommand& aCmd); 763 764 CPMSessionInfo* LookUpSessionInfo(PVMFSessionId); 765 CPMContentUsageContext* LookUpContentUsageContext(PVMFCPMUsageID); 766 CPMPlugInParams* LookUpPlugInParams(uint32); 767 CPMPlugInParams* LookUpPlugInParamsFromActiveList(uint32); 768 int32 PushKVPKey(OSCL_String& aString, PVMFMetadataList& aKeyList); 769 PVLogger* iLogger; 770 771 CPMPluginRegistry* iPluginRegistry; 772 Oscl_Vector<CPMPlugInParams, OsclMemAllocator> iPlugInParamsVec; 773 Oscl_Vector<CPMPlugInParams, OsclMemAllocator> iActivePlugInParamsVec; 774 Oscl_Vector<CPMContentUsageContext, OsclMemAllocator> iContentUsageContextVec; 775 Oscl_Vector<CPMSessionInfo, OsclMemAllocator> iListofActiveSessions; 776 777 uint32 iNumRegisteredPlugInInitPending; 778 uint32 iNumRegisteredPlugInInitComplete; 779 uint32 iNumQueryAuthenticationInterfacePending; 780 uint32 iNumQueryAuthenticationInterfaceComplete; 781 uint32 iNumQueryMetaDataExtensionInterfacePending; 782 uint32 iNumQueryMetaDataExtensionInterfaceComplete; 783 uint32 iNumQueryCapConfigExtensionInterfacePending; 784 uint32 iNumQueryCapConfigExtensionInterfaceComplete; 785 uint32 iNumRegisteredPlugInResetPending; 786 uint32 iNumRegisteredPlugInResetComplete; 787 788 bool iGetMetaDataKeysFromPlugInsDone; 789 bool iGetMetaDataKeysInProgress; 790 791 /* Metadata related */ 792 uint32 iExtensionRefCount; 793 PVMFMetadataList* iKeyListPtr; 794 Oscl_Vector<PvmiKvp, OsclMemAllocator>* iValueListPtr; 795 int32 iGetMetaDataValuesStartingIndex; 796 int32 iGetMetaDataValuesMaxEntries; 797 798 /* License Acquire */ 799 PVMFCPMPluginLicenseInterface* iLicenseInterface ; 800 PVMFCommandId iGetLicenseCmdId; 801 PVMFCommandId iCancelGetLicenseCmdId; 802 }; 803 804 805 806 807 typedef OSCL_HeapString<OsclMemAllocator> string_key_type; 808 809 template<class Alloc> 810 struct CPMPluginMimeStringCompare 811 { operatorCPMPluginMimeStringCompare812 bool operator()(const string_key_type& x, const string_key_type& y) const 813 { 814 if ((oscl_CIstrcmp(x.get_str(), y.get_str())) < 0) 815 { 816 return true; 817 } 818 else 819 { 820 return false; 821 } 822 } 823 }; 824 825 #ifndef CPM_PLUGIN_REGISTRY_H_INCLUDED 826 #include "cpm_plugin_registry.h" 827 #endif 828 #ifndef OSCL_MAP_H_INCLUDED 829 #include "oscl_map.h" 830 #endif 831 832 class OsclSharedLibraryList; 833 class CPMPluginRegistryImpl: public CPMPluginRegistry 834 { 835 public: 836 typedef CPMPluginMimeStringCompare<OsclMemAllocator> string_key_compare_class; 837 typedef Oscl_Map<string_key_type, CPMPluginContainer*, OsclMemAllocator, string_key_compare_class>::value_type value_type; 838 839 //From CPMPluginRegistry 840 OSCL_IMPORT_REF bool addPluginToRegistry(OSCL_String& aMimeType, 841 CPMPluginContainer& aPlugInContainer) ; 842 OSCL_IMPORT_REF void removePluginFromRegistry(OSCL_String& aMimeType) ; 843 OSCL_IMPORT_REF CPMPluginContainer* lookupPlugin(OSCL_String& aMimeType) ; 844 OSCL_IMPORT_REF uint32 GetNumPlugIns() ; 845 846 OSCL_IMPORT_REF bool GetPluginMimeType(uint32 aIndex, OSCL_String& aMimeType) ; 847 AccessSharedLibraryList()848 OsclSharedLibraryList*& AccessSharedLibraryList() 849 { 850 return iSharedLibList; 851 } 852 853 private: 854 friend class CPMPluginRegistryFactory; 855 856 OSCL_IMPORT_REF CPMPluginRegistryImpl(); 857 OSCL_IMPORT_REF ~CPMPluginRegistryImpl(); 858 859 Oscl_Map<string_key_type, CPMPluginContainer*, OsclMemAllocator, string_key_compare_class> iCPMPluginRegistry; 860 861 Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iListofPlugInMimeTypes; 862 863 int32 iRefCount; 864 865 OsclSharedLibraryList* iSharedLibList; 866 }; 867 868 #endif //CPM_INTERNAL_H_INCLUDED 869 870 871