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 PV_PLAYER_ENGINE_H_INCLUDED 19 #define PV_PLAYER_ENGINE_H_INCLUDED 20 21 #ifndef OSCL_BASE_H_INCLUDED 22 #include "oscl_base.h" 23 #endif 24 25 #ifndef OSCL_MEM_H_INCLUDED 26 #include "oscl_mem.h" 27 #endif 28 29 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED 30 #include "oscl_scheduler_ao.h" 31 #endif 32 33 #ifndef OSCL_VECTOR_H_INCLUDED 34 #include "oscl_vector.h" 35 #endif 36 37 #ifndef OSCL_PRIQUEUE_H_INCLUDED 38 #include "oscl_priqueue.h" 39 #endif 40 41 #ifndef PVMF_MEDIA_CLOCK_H_INCLUDED 42 #include "pvmf_media_clock.h" 43 #endif 44 45 #ifndef PV_ENGINE_TYPES_H_INCLUDED 46 #include "pv_engine_types.h" 47 #endif 48 49 #ifndef PV_PLAYER_DATASOURCE_H_INCLUDED 50 #include "pv_player_datasource.h" 51 #endif 52 53 #ifndef PV_PLAYER_DATASINK_H_INCLUDED 54 #include "pv_player_datasink.h" 55 #endif 56 57 #ifndef PV_PLAYER_INTERFACE_H_INCLUDED 58 #include "pv_player_interface.h" 59 #endif 60 61 #ifndef PV_ENGINE_OBSERVER_H_INCLUDED 62 #include "pv_engine_observer.h" 63 #endif 64 65 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED 66 #include "pvmf_node_interface.h" 67 #endif 68 69 #ifndef PV_PLAYER_DATAPATH_H_INCLUDED 70 #include "pv_player_datapath.h" 71 #endif 72 73 #ifndef PV_PLAYER_NODE_REGISTRY_H_INCLUDED 74 #include "pv_player_node_registry.h" 75 #endif 76 77 #ifndef PVMF_META_DATA_TYPES_H_INCLUDED 78 #include "pvmf_meta_data_types.h" 79 #endif 80 81 #ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED 82 #include "pvmf_meta_data_extension.h" 83 #endif 84 85 #ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED 86 #include "pvmf_data_source_init_extension.h" 87 #endif 88 89 #ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED 90 #include "pvmf_media_presentation_info.h" 91 #endif 92 93 #ifndef OSCL_TIMER_H_INCLUDED 94 #include "oscl_timer.h" 95 #endif 96 97 #ifndef OSCL_MEM_MEMPOOL_H_INCLUDED 98 #include "oscl_mem_mempool.h" 99 #endif 100 101 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED 102 #include "pvmi_config_and_capability.h" 103 #endif 104 105 #ifndef PV_PLAYER_LICENSE_ACQUISITION_INTERFACE_H_INCLUDED 106 #include "pv_player_license_acquisition_interface.h" 107 #endif 108 109 #ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED 110 #include "pvmf_data_source_playback_control.h" 111 #endif 112 113 #ifndef PV_PLAYER_TRACK_SELECTION_INTERFACE_H_INCLUDED 114 #include "pv_player_track_selection_interface.h" 115 #endif 116 117 #ifndef PV_PLAYER_REGISTRY_INTERFACE_H_INCLUDED 118 #include "pv_player_registry_interface.h" 119 #endif 120 121 #include "threadsafe_queue.h" 122 123 /** 124 * PVPlayerEngineState enum 125 * 126 * Enumeration of internal pvPlayer engine state. 127 * 128 **/ 129 typedef enum 130 { 131 PVP_ENGINE_STATE_IDLE = 1, 132 PVP_ENGINE_STATE_INITIALIZING, 133 PVP_ENGINE_STATE_INITIALIZED, 134 PVP_ENGINE_STATE_PREPARING, 135 PVP_ENGINE_STATE_TRACK_SELECTION_1_DONE, 136 PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE, 137 PVP_ENGINE_STATE_TRACK_SELECTION_3_DONE, 138 PVP_ENGINE_STATE_PREPARED, 139 PVP_ENGINE_STATE_STARTING, 140 PVP_ENGINE_STATE_STARTED, 141 PVP_ENGINE_STATE_AUTO_PAUSING, 142 PVP_ENGINE_STATE_AUTO_PAUSED, 143 PVP_ENGINE_STATE_AUTO_RESUMING, 144 PVP_ENGINE_STATE_PAUSING, 145 PVP_ENGINE_STATE_PAUSED, 146 PVP_ENGINE_STATE_RESUMING, 147 PVP_ENGINE_STATE_STOPPING, 148 PVP_ENGINE_STATE_RESETTING, 149 PVP_ENGINE_STATE_ERROR 150 } PVPlayerEngineState; 151 152 153 typedef union PVPlayerEngineCommandParamUnion 154 { 155 bool bool_value; 156 float float_value; 157 double double_value; 158 uint8 uint8_value; 159 int32 int32_value; 160 uint32 uint32_value; 161 PVPPlaybackPosition playbackpos_value; 162 oscl_wchar* pWChar_value; 163 char* pChar_value; 164 uint8* pUint8_value; 165 int32* pInt32_value; 166 uint32* pUint32_value; 167 int64* pInt64_value; 168 uint64* pUint64_value; 169 PVPPlaybackPosition* pPlaybackpos_value; 170 OsclAny* pOsclAny_value; 171 } _PVPlayerEngineCommandParamUnion; 172 173 /** 174 * PVPlayerEngineCommand Class 175 * 176 * PVPlayerEngineCommand class is a data class to hold issued commands inside the player engine 177 **/ 178 class PVPlayerEngineCommand 179 { 180 public: 181 /** 182 * The constructor for PVPlayerEngineCommand which allows the data values to be set. 183 * 184 * @param aCmdType The command type value for this command. The value is an engine-specific 32-bit value. 185 * @param aCmdId The command ID assigned by the engine for this command. 186 * @param aContextData The pointer to the passed-in context data for this command. 187 * 188 * @returns None 189 **/ 190 PVPlayerEngineCommand(int32 aCmdType, PVCommandId aCmdId, OsclAny* aContextData = NULL, 191 Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector = NULL, bool aAPICommand = true) : iCmdType(aCmdType)192 iCmdType(aCmdType), iCmdId(aCmdId), iContextData(aContextData), iAPICommand(aAPICommand) 193 { 194 iParamVector.clear(); 195 if (aParamVector) 196 { 197 iParamVector = *aParamVector; 198 } 199 } 200 201 /** 202 * The copy constructor for PVPlayerEngineCommand. Used mainly for Oscl_Vector. 203 * 204 * @param aCmd The reference to the source PVPlayerEngineCommand to copy the data values from. 205 * 206 * @returns None 207 **/ PVPlayerEngineCommand(const PVPlayerEngineCommand & aCmd)208 PVPlayerEngineCommand(const PVPlayerEngineCommand& aCmd) 209 { 210 iCmdType = aCmd.iCmdType; 211 iCmdId = aCmd.iCmdId; 212 iContextData = aCmd.iContextData; 213 iAPICommand = aCmd.iAPICommand; 214 iParamVector = aCmd.iParamVector; 215 iMimeType = aCmd.iMimeType; 216 iUuid = aCmd.iUuid; 217 } 218 219 /** 220 * This function returns the stored command type value. 221 * 222 * @returns The signed 32-bit command type value for this command. 223 **/ GetCmdType()224 int32 GetCmdType()const 225 { 226 return iCmdType; 227 } 228 229 /** 230 * This function returns the stored command ID value. 231 * 232 * @returns The PVCommandId value for this command. 233 **/ GetCmdId()234 PVCommandId GetCmdId()const 235 { 236 return iCmdId; 237 } 238 239 /** 240 * This function returns the stored context data pointer. 241 * 242 * @returns The pointer to the context data for this command 243 **/ GetContext()244 OsclAny* GetContext()const 245 { 246 return iContextData; 247 } 248 249 /** 250 * This function tells whether the command is an API command or not 251 * 252 * @returns true if API command, false if not. 253 **/ IsAPICommand()254 bool IsAPICommand()const 255 { 256 return iAPICommand; 257 } 258 259 /** 260 * This function returns the command parameter from the specified index. 261 * If the specified index is not available, empty parameter will be returned 262 * 263 * @param aIndex The index of the parameter to return 264 * 265 * @returns The stored parameter for this command 266 **/ GetParam(uint32 aIndex)267 PVPlayerEngineCommandParamUnion GetParam(uint32 aIndex)const 268 { 269 if (aIndex >= iParamVector.size()) 270 { 271 PVPlayerEngineCommandParamUnion param; 272 oscl_memset(¶m, 0, sizeof(PVPlayerEngineCommandParamUnion)); 273 return param; 274 } 275 else 276 { 277 return iParamVector[aIndex]; 278 } 279 } 280 281 /** 282 * This function returns Mime type parameter for this command 283 * 284 * @returns The Mime type parameter for this command 285 */ GetMimeType()286 const PvmfMimeString& GetMimeType()const 287 { 288 return iMimeType; 289 } 290 291 /** 292 * This function returns Uuid parameter for this command 293 * 294 * @returns The Uuid parameter for this command 295 */ GetUuid()296 PVUuid GetUuid()const 297 { 298 return iUuid; 299 } 300 301 /** 302 * This function stores Mime type parameter of this command 303 */ SetMimeType(const PvmfMimeString & aMimeType)304 void SetMimeType(const PvmfMimeString& aMimeType) 305 { 306 iMimeType = aMimeType; 307 } 308 309 /** 310 * This function stores the Uuid parameter of this command 311 */ SetUuid(const PVUuid & aUuid)312 void SetUuid(const PVUuid& aUuid) 313 { 314 iUuid = aUuid; 315 } 316 317 /** 318 * Equality operator, for use by OsclPriorityQueue. 319 */ 320 bool operator==(const PVPlayerEngineCommand& aCmd) const 321 { 322 return iCmdId == aCmd.iCmdId; 323 } 324 325 int32 iCmdType; 326 PVCommandId iCmdId; 327 OsclAny* iContextData; 328 bool iAPICommand; 329 Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> iParamVector; 330 OSCL_HeapString<OsclMemAllocator> iMimeType; 331 PVUuid iUuid; 332 }; 333 334 /** 335 * PVPlayerEngineCommandType enum 336 * 337 * Enumeration of types of commands that can be issued to the pvPlayer. 338 * 339 **/ 340 typedef enum 341 { 342 // Engine API commands 343 PVP_ENGINE_COMMAND_GET_SDK_INFO = 1, 344 PVP_ENGINE_COMMAND_GET_SDK_MODULE_INFO, 345 PVP_ENGINE_COMMAND_SET_LOG_APPENDER, 346 PVP_ENGINE_COMMAND_REMOVE_LOG_APPENDER, 347 PVP_ENGINE_COMMAND_SET_LOG_LEVEL, 348 PVP_ENGINE_COMMAND_GET_LOG_LEVEL, 349 PVP_ENGINE_COMMAND_QUERY_UUID, 350 PVP_ENGINE_COMMAND_QUERY_INTERFACE, 351 PVP_ENGINE_COMMAND_CANCEL_COMMAND, 352 PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS, 353 PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE, 354 PVP_ENGINE_COMMAND_ADD_DATA_SOURCE, 355 PVP_ENGINE_COMMAND_INIT, 356 PVP_ENGINE_COMMAND_GET_METADATA_KEY, 357 PVP_ENGINE_COMMAND_GET_METADATA_VALUE, 358 PVP_ENGINE_COMMAND_RELEASE_METADATA_VALUE, 359 PVP_ENGINE_COMMAND_ADD_DATA_SINK, 360 PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE, 361 PVP_ENGINE_COMMAND_GET_PLAYBACK_RANGE, 362 PVP_ENGINE_COMMAND_GET_CURRENT_POSITION, 363 PVP_ENGINE_COMMAND_SET_PLAYBACK_RATE, 364 PVP_ENGINE_COMMAND_GET_PLAYBACK_RATE, 365 PVP_ENGINE_COMMAND_GET_PLAYBACK_MINMAX_RATE, 366 PVP_ENGINE_COMMAND_PREPARE, 367 PVP_ENGINE_COMMAND_START, 368 PVP_ENGINE_COMMAND_PAUSE, 369 PVP_ENGINE_COMMAND_RESUME, 370 PVP_ENGINE_COMMAND_STOP, 371 PVP_ENGINE_COMMAND_REMOVE_DATA_SINK, 372 PVP_ENGINE_COMMAND_RESET, 373 PVP_ENGINE_COMMAND_REMOVE_DATA_SOURCE, 374 PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS, 375 PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR, 376 PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR, 377 PVP_ENGINE_COMMAND_CANCEL_ACQUIRE_LICENSE, 378 PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE_OOTSYNC, 379 PVP_ENGINE_COMMAND_GET_CURRENT_POSITION_OOTSYNC, 380 PVP_ENGINE_COMMAND_CAPCONFIG_SET_OBSERVER_OOTSYNC, 381 PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS_OOTSYNC, 382 PVP_ENGINE_COMMAND_GET_LICENSE_STATUS_OOTSYNC, 383 PVP_ENGINE_COMMAND_CAPCONFIG_GET_PARAMETERS_OOTSYNC, 384 PVP_ENGINE_COMMAND_CAPCONFIG_RELEASE_PARAMETERS_OOTSYNC, 385 PVP_ENGINE_COMMAND_CAPCONFIG_VERIFY_PARAMETERS_OOTSYNC, 386 // Internal engine commands 387 PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDTIME_REACHED, 388 PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDOFCLIP, 389 PVP_ENGINE_COMMAND_PAUSE_DUE_TO_BUFFER_UNDERFLOW, 390 PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY, 391 // Internal Error Handling Commands 392 PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE, 393 PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT, 394 PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE, 395 PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE, 396 PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME, 397 PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE, 398 PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE, 399 PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP, 400 PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS, 401 PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL 402 } PVPlayerEngineCommandType; 403 404 405 /** 406 * PVPlayerEngineCommandCompareLess Class 407 * 408 * PVPlayerEngineCommandCompareLess class is a utility class to allow the OSCL priority queue perform command priority comparison. 409 * The class is meant to be used inside the player engine and not exposed to the interface layer or above. 410 **/ 411 class PVPlayerEngineCommandCompareLess 412 { 413 public: 414 /** 415 * The algorithm used in OsclPriorityQueue needs a compare function 416 * that returns true when A's priority is less than B's 417 * @return true if A's priority is less than B's, else false 418 */ compare(PVPlayerEngineCommand & a,PVPlayerEngineCommand & b)419 int compare(PVPlayerEngineCommand& a, PVPlayerEngineCommand& b) const 420 { 421 int a_pri = PVPlayerEngineCommandCompareLess::GetPriority(a); 422 int b_pri = PVPlayerEngineCommandCompareLess::GetPriority(b); 423 if (a_pri < b_pri) 424 { 425 // Higher priority 426 return false; 427 } 428 else if (a_pri == b_pri) 429 { 430 // Same priority so look at the command ID to maintain FIFO 431 return (a.GetCmdId() > b.GetCmdId()); 432 } 433 else 434 { 435 // Lower priority 436 return true; 437 } 438 } 439 440 /** 441 * Returns the priority of each command 442 * @return A 0-based priority number. A lower number indicates higher priority. 443 */ GetPriority(PVPlayerEngineCommand & aCmd)444 static int GetPriority(PVPlayerEngineCommand& aCmd) 445 { 446 switch (aCmd.GetCmdType()) 447 { 448 case PVP_ENGINE_COMMAND_GET_SDK_INFO: 449 return 5; 450 case PVP_ENGINE_COMMAND_GET_SDK_MODULE_INFO: 451 return 5; 452 case PVP_ENGINE_COMMAND_SET_LOG_APPENDER: 453 return 5; 454 case PVP_ENGINE_COMMAND_REMOVE_LOG_APPENDER: 455 return 5; 456 case PVP_ENGINE_COMMAND_SET_LOG_LEVEL: 457 return 5; 458 case PVP_ENGINE_COMMAND_GET_LOG_LEVEL: 459 return 5; 460 case PVP_ENGINE_COMMAND_QUERY_UUID: 461 return 5; 462 case PVP_ENGINE_COMMAND_QUERY_INTERFACE: 463 return 5; 464 case PVP_ENGINE_COMMAND_CANCEL_COMMAND: 465 case PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS: 466 return 3; 467 case PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE: 468 return 5; 469 case PVP_ENGINE_COMMAND_ADD_DATA_SOURCE: 470 return 5; 471 case PVP_ENGINE_COMMAND_INIT: 472 return 5; 473 case PVP_ENGINE_COMMAND_GET_METADATA_KEY: 474 return 5; 475 case PVP_ENGINE_COMMAND_GET_METADATA_VALUE: 476 return 5; 477 case PVP_ENGINE_COMMAND_ADD_DATA_SINK: 478 return 5; 479 case PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE: 480 return 5; 481 case PVP_ENGINE_COMMAND_GET_PLAYBACK_RANGE: 482 return 5; 483 case PVP_ENGINE_COMMAND_GET_CURRENT_POSITION: 484 return 5; 485 case PVP_ENGINE_COMMAND_SET_PLAYBACK_RATE: 486 return 5; 487 case PVP_ENGINE_COMMAND_GET_PLAYBACK_RATE: 488 return 5; 489 case PVP_ENGINE_COMMAND_GET_PLAYBACK_MINMAX_RATE: 490 return 5; 491 case PVP_ENGINE_COMMAND_PREPARE: 492 return 5; 493 case PVP_ENGINE_COMMAND_START: 494 return 5; 495 case PVP_ENGINE_COMMAND_PAUSE: 496 return 5; 497 case PVP_ENGINE_COMMAND_RESUME: 498 return 5; 499 case PVP_ENGINE_COMMAND_STOP: 500 return 5; 501 case PVP_ENGINE_COMMAND_REMOVE_DATA_SINK: 502 return 5; 503 case PVP_ENGINE_COMMAND_RESET: 504 return 5; 505 case PVP_ENGINE_COMMAND_REMOVE_DATA_SOURCE: 506 return 5; 507 case PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS: 508 return 5; 509 case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR: 510 return 5; 511 case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR: 512 return 5; 513 case PVP_ENGINE_COMMAND_CANCEL_ACQUIRE_LICENSE: 514 return 3; 515 516 case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDTIME_REACHED: 517 return 4; 518 case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDOFCLIP: 519 return 4; 520 case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_BUFFER_UNDERFLOW: 521 return 5; 522 case PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY: 523 return 5; 524 525 case PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE: 526 case PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT: 527 case PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE: 528 case PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE: 529 case PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME: 530 case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE: 531 case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE: 532 case PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP: 533 case PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS: 534 return 1; 535 default: 536 return 0; 537 } 538 } 539 }; 540 541 542 // Structure to hold the key string info for 543 // player engine's capability-and-config 544 struct PVPlayerKeyStringData 545 { 546 char iString[64]; 547 PvmiKvpType iType; 548 PvmiKvpValueType iValueType; 549 }; 550 551 // The number of characters to allocate for the key string 552 #define PVPLAYERCONFIG_KEYSTRING_SIZE 128 553 554 555 556 // Key string info at the base level ("x-pvmf/player/") 557 #define PVPLAYERCONFIG_BASE_NUMKEYS 13 558 const PVPlayerKeyStringData PVPlayerConfigBaseKeys[PVPLAYERCONFIG_BASE_NUMKEYS] = 559 { 560 {"pbpos_units", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}, 561 {"pbpos_interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 562 {"endtimecheck_interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 563 {"seektosyncpoint", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}, 564 {"skiptorequestedpos", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}, 565 {"syncpointseekwindow", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 566 {"syncmargin_video", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32}, 567 {"syncmargin_audio", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32}, 568 {"syncmargin_text", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32}, 569 {"nodecmd_timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 570 {"nodedataqueuing_timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32}, 571 {"productinfo", PVMI_KVPTYPE_AGGREGATE, PVMI_KVPVALTYPE_KSV}, 572 {"pbpos_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL} 573 }; 574 575 enum PlayerConfigBaseKeys_IndexMap 576 { 577 PBPOS_UNITS = 0, 578 PBPOS_INTERVAL, 579 ENDTIMECHECK_INTERVAL, 580 SEEKTOSYNCPOINT, 581 SKIPTOREQUESTEDPOSITION, 582 SYNCPOINTSEEKWINDOW, 583 SYNCMARGIN_VIDEO, 584 SYNCMARGIN_AUDIO, 585 SYNCMARGIN_TEXT, 586 NODECMD_TIMEOUT, 587 NODEDATAQUEIUING_TIMEOUT, 588 PRODUCTINFO, 589 PBPOS_ENABLE 590 }; 591 592 // Key string info at the productinfo level ("x-pvmf/player/productinfo/") 593 #define PVPLAYERCONFIG_PRODINFO_NUMKEYS 5 594 const PVPlayerKeyStringData PVPlayerConfigProdInfoKeys[PVPLAYERCONFIG_PRODINFO_NUMKEYS] = 595 { 596 {"productname", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}, 597 {"partnumber", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}, 598 {"hardwareplatform", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}, 599 {"softwareplatform", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}, 600 {"device", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR} 601 }; 602 603 enum ProductInfoKeys_IndexMap 604 { 605 PRODUCTNAME = 0, 606 PARTNUMBER, 607 HARDWAREPLATFORM, 608 SOFTWAREPLATFORM, 609 DEVICE 610 }; 611 612 // Player engine's timebase with rate change capability 613 class PVPlayerTimebase : public PVMFTimebase_Tickcount 614 { 615 public: PVPlayerTimebase()616 PVPlayerTimebase() 617 { 618 iRate = 100000; 619 iRateChangeTCTime = 0; 620 iRateChangeTC = 0; 621 } 622 ~PVPlayerTimebase()623 ~PVPlayerTimebase() 624 { 625 } GetCurrentTick32(uint32 & aTimebaseTickCount,bool & aOverflow)626 void GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow) 627 { 628 // Retrieve the tickcount time 629 uint32 tickcount = 0; 630 631 PVMFTimebase_Tickcount::GetCurrentTick32(tickcount, aOverflow); 632 633 if (aOverflow) 634 { 635 aTimebaseTickCount = 0; 636 return; 637 } 638 639 // Calculate the tickcount since last rate change 640 uint32 ticksSinceChange = 0; 641 PVTimeComparisonUtils::IsEarlier(iRateChangeTC, tickcount, ticksSinceChange); 642 643 if (iRate != 100000) 644 { 645 // Adjust according to rate 646 // Rate change resolution is 0.1 647 uint32 convnum = (iRate / 10000); 648 uint32 convden = 10; 649 aTimebaseTickCount = ((ticksSinceChange * convnum) / convden); 650 } 651 else 652 { 653 aTimebaseTickCount = ticksSinceChange; 654 } 655 656 // Add the timebase since last rate change 657 aTimebaseTickCount = aTimebaseTickCount + iRateChangeTCTime; 658 } 659 SetRate(int32 aRate)660 void SetRate(int32 aRate) 661 { 662 bool overflow = 0; 663 // Save the tickcount time when the rate changed 664 uint32 temp = 0; 665 GetCurrentTick32(temp, overflow); 666 iRateChangeTCTime = temp; 667 668 uint32 tickcount = 0; 669 PVMFTimebase_Tickcount::GetCurrentTick32(tickcount, overflow); 670 iRateChangeTC = tickcount; 671 // Change the rate 672 iRate = aRate; 673 } 674 GetRate()675 int32 GetRate() 676 { 677 return iRate; 678 } 679 680 private: 681 int32 iRate; // In millipercent of "real-time" 682 uint32 iRateChangeTCTime; // The tickcount's time when rate last changed 683 uint32 iRateChangeTC; 684 }; 685 686 687 class PVMFNodeInterface; 688 class PVMFDataSourceInitializationExtensionInterface; 689 class PVMFTrackSelectionExtensionInterface; 690 class PvmfDataSourcePlaybackControlInterface; 691 class PvmfDataSourceDirectionControlInterface; 692 class PVMFTrackLevelInfoExtensionInterface; 693 class PvmfNodesSyncControlInterface; 694 class PvmfFileOutputNodeConfigInterface; 695 class PVMFErrorInfoMessageInterface; 696 class PVLogger; 697 class PVMFCPMPluginLicenseInterface; 698 class PVMFBasicErrorInfoMessage; 699 class PVPlayerWatchdogTimer; 700 701 typedef enum 702 { 703 PVP_NODETYPE_SOURCE, 704 PVP_NODETYPE_SINK, 705 PVP_NODETYPE_DECODER, 706 PVP_NODETYPE_UNKNOWN 707 } PVPlayerNodeType; 708 709 class PVPlayerEngineDatapath 710 { 711 public: PVPlayerEngineDatapath()712 PVPlayerEngineDatapath() 713 { 714 iTrackInfo = NULL; 715 iSrcFormat = PVMF_MIME_FORMAT_UNKNOWN; 716 iDataSink = NULL; 717 iDatapath = NULL; 718 iDecNode = NULL; 719 iDecNodeSessionId = 0; 720 iDecNodeCapConfigIF = NULL; 721 iDecNodeMetadataExtIF = NULL; 722 iDecNodePVInterfaceMetadataExt = NULL; 723 iSinkNode = NULL; 724 iSinkNodeSessionId = 0; 725 iSinkNodeFOConfigIF = NULL; 726 iSinkNodeSyncCtrlIF = NULL; 727 iSinkNodeCapConfigIF = NULL; 728 iSinkNodeMetadataExtIF = NULL; 729 iSinkFormat = PVMF_MIME_FORMAT_UNKNOWN; 730 iSinkNodePVInterfaceSyncCtrl = NULL; 731 iSinkNodePVInterfaceCapConfig = NULL; 732 iSinkNodePVInterfaceMetadataExt = NULL; 733 iNumPendingCmd = 0; 734 iEndOfDataReceived = false; 735 }; 736 PVPlayerEngineDatapath(const PVPlayerEngineDatapath & aSrc)737 PVPlayerEngineDatapath(const PVPlayerEngineDatapath& aSrc) 738 { 739 iTrackInfo = aSrc.iTrackInfo; 740 iSrcFormat = aSrc.iSrcFormat; 741 iDataSink = aSrc.iDataSink; 742 iDatapath = aSrc.iDatapath; 743 iDecNode = aSrc.iDecNode; 744 iDecNodeSessionId = aSrc.iDecNodeSessionId; 745 iDecNodeCapConfigIF = aSrc.iDecNodeCapConfigIF; 746 iDecNodeMetadataExtIF = aSrc.iDecNodeMetadataExtIF; 747 iDecNodePVInterfaceMetadataExt = aSrc.iDecNodePVInterfaceMetadataExt; 748 iSinkNode = aSrc.iSinkNode; 749 iSinkNodeSessionId = aSrc.iSinkNodeSessionId; 750 iSinkNodeFOConfigIF = aSrc.iSinkNodeFOConfigIF; 751 iSinkNodeSyncCtrlIF = aSrc.iSinkNodeSyncCtrlIF; 752 iSinkNodeCapConfigIF = aSrc.iSinkNodeCapConfigIF; 753 iSinkNodeMetadataExtIF = aSrc.iSinkNodeMetadataExtIF; 754 iSinkFormat = aSrc.iSinkFormat; 755 iSinkNodePVInterfaceSyncCtrl = aSrc.iSinkNodePVInterfaceSyncCtrl; 756 iSinkNodePVInterfaceCapConfig = aSrc.iSinkNodePVInterfaceCapConfig; 757 iSinkNodePVInterfaceMetadataExt = aSrc.iSinkNodePVInterfaceMetadataExt; 758 iNumPendingCmd = aSrc.iNumPendingCmd; 759 iEndOfDataReceived = aSrc.iEndOfDataReceived; 760 }; 761 ~PVPlayerEngineDatapath()762 ~PVPlayerEngineDatapath() 763 { 764 }; 765 766 PVMFTrackInfo* iTrackInfo; 767 PVMFFormatType iSrcFormat; 768 769 PVPlayerDataSink* iDataSink; 770 PVPlayerDatapath* iDatapath; 771 772 PVMFNodeInterface* iDecNode; 773 PVMFSessionId iDecNodeSessionId; 774 PvmiCapabilityAndConfig* iDecNodeCapConfigIF; 775 PVMFMetadataExtensionInterface* iDecNodeMetadataExtIF; 776 PVInterface* iDecNodePVInterfaceMetadataExt; 777 778 PVMFNodeInterface* iSinkNode; 779 PVMFSessionId iSinkNodeSessionId; 780 PvmfFileOutputNodeConfigInterface* iSinkNodeFOConfigIF; 781 PvmfNodesSyncControlInterface* iSinkNodeSyncCtrlIF; 782 PvmiCapabilityAndConfig* iSinkNodeCapConfigIF; 783 PVMFMetadataExtensionInterface* iSinkNodeMetadataExtIF; 784 PVMFFormatType iSinkFormat; 785 PVInterface* iSinkNodePVInterfaceSyncCtrl; 786 PVInterface* iSinkNodePVInterfaceCapConfig; 787 PVInterface* iSinkNodePVInterfaceMetadataExt; 788 789 uint32 iNumPendingCmd; 790 bool iEndOfDataReceived; 791 }; 792 793 struct PVPlayerEngineContext 794 { 795 PVPlayerEngineDatapath* iEngineDatapath; 796 PVMFNodeInterface* iNode; 797 PVPlayerDatapath* iDatapath; 798 PVCommandId iCmdId; 799 OsclAny* iCmdContext; 800 int32 iCmdType; 801 }; 802 803 class PVPlayerEngineTrackSelection 804 { 805 public: PVPlayerEngineTrackSelection()806 PVPlayerEngineTrackSelection() 807 { 808 iTsSinkNode = NULL; 809 iTsSinkNodeSessionId = 0; 810 iTsSinkNodeCapConfigIF = NULL; 811 iTsDecNode = NULL; 812 iTsDecNodeSessionId = 0; 813 iTsDecNodeCapConfigIF = NULL; 814 iTsDecNodePVInterfaceCapConfig = NULL; 815 iTsTrackID = -1; 816 iTsTrackValidForPlayableList = false; 817 }; 818 PVPlayerEngineTrackSelection(const PVPlayerEngineTrackSelection & aTrackSelection)819 PVPlayerEngineTrackSelection(const PVPlayerEngineTrackSelection& aTrackSelection) 820 { 821 iTsSinkNode = aTrackSelection.iTsSinkNode; 822 iTsSinkNodeSessionId = aTrackSelection.iTsSinkNodeSessionId; 823 iTsSinkNodeCapConfigIF = aTrackSelection.iTsSinkNodeCapConfigIF; 824 iTsDecNode = aTrackSelection.iTsDecNode; 825 iTsDecNodeSessionId = aTrackSelection.iTsDecNodeSessionId; 826 iTsDecNodeCapConfigIF = aTrackSelection.iTsDecNodeCapConfigIF; 827 iTsDecNodePVInterfaceCapConfig = aTrackSelection.iTsDecNodePVInterfaceCapConfig; 828 iTsTrackID = aTrackSelection.iTsTrackID; 829 iTsTrackValidForPlayableList = aTrackSelection.iTsTrackValidForPlayableList; 830 }; 831 832 PVPlayerEngineTrackSelection& operator=(const PVPlayerEngineTrackSelection& aTrackSelection) 833 { 834 iTsSinkNode = aTrackSelection.iTsSinkNode; 835 iTsSinkNodeSessionId = aTrackSelection.iTsSinkNodeSessionId; 836 iTsSinkNodeCapConfigIF = aTrackSelection.iTsSinkNodeCapConfigIF; 837 iTsDecNode = aTrackSelection.iTsDecNode; 838 iTsDecNodeSessionId = aTrackSelection.iTsDecNodeSessionId; 839 iTsDecNodeCapConfigIF = aTrackSelection.iTsDecNodeCapConfigIF; 840 iTsDecNodePVInterfaceCapConfig = aTrackSelection.iTsDecNodePVInterfaceCapConfig; 841 iTsTrackID = aTrackSelection.iTsTrackID; 842 iTsTrackValidForPlayableList = aTrackSelection.iTsTrackValidForPlayableList; 843 return *this; 844 }; 845 ~PVPlayerEngineTrackSelection()846 ~PVPlayerEngineTrackSelection() 847 { 848 }; 849 850 PVMFNodeInterface* iTsSinkNode; 851 PVMFSessionId iTsSinkNodeSessionId; 852 PvmiCapabilityAndConfig* iTsSinkNodeCapConfigIF; 853 854 PVMFNodeInterface* iTsDecNode; 855 PVMFSessionId iTsDecNodeSessionId; 856 PvmiCapabilityAndConfig* iTsDecNodeCapConfigIF; 857 PVInterface* iTsDecNodePVInterfaceCapConfig; 858 859 int32 iTsTrackID; 860 bool iTsTrackValidForPlayableList; 861 }; 862 863 864 /** 865 * Observer class for the inactivity timer AO 866 */ 867 class PVPlayerWatchdogTimerObserver 868 { 869 public: ~PVPlayerWatchdogTimerObserver()870 virtual ~PVPlayerWatchdogTimerObserver() {} 871 /** 872 * A timer event, indicating that the inactivity timer has expired. 873 */ 874 virtual void PVPlayerWatchdogTimerEvent() = 0; 875 }; 876 877 878 class PVPlayerEngine : public OsclTimerObject, 879 public PVPlayerInterface, 880 public PvmiCapabilityAndConfig, 881 public PVMFNodeCmdStatusObserver, 882 public PVMFNodeInfoEventObserver, 883 public PVMFNodeErrorEventObserver, 884 public PVPlayerDatapathObserver, 885 public OsclTimerObserver, 886 public PVPlayerLicenseAcquisitionInterface, 887 public PVPlayerRecognizerRegistryObserver, 888 public PVPlayerWatchdogTimerObserver, 889 public PVPlayerTrackSelectionInterface, 890 public PVMFMediaClockNotificationsObs, 891 public ThreadSafeQueueObserver 892 { 893 public: 894 static PVPlayerEngine* New(PVCommandStatusObserver *aCmdObserver, 895 PVErrorEventObserver *aErrorObserver, 896 PVInformationalEventObserver *aInfoObserver); 897 ~PVPlayerEngine(); 898 899 // From PVPlayerInterface 900 PVCommandId GetSDKInfo(PVSDKInfo &aSDKInfo, const OsclAny* aContextData = NULL); 901 PVCommandId GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo, const OsclAny* aContextData = NULL); 902 PVCommandId SetLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, const OsclAny* aContextData = NULL); 903 PVCommandId RemoveLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, const OsclAny* aContextData = NULL); 904 PVCommandId SetLogLevel(const char* aTag, int32 aLevel, bool aSetSubtree = false, const OsclAny* aContextData = NULL); 905 PVCommandId GetLogLevel(const char* aTag, PVLogLevelInfo& aLogInfo, const OsclAny* aContextData = NULL); 906 PVCommandId QueryUUID(const PvmfMimeString& aMimeType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids, bool aExactUuidsOnly = false, const OsclAny* aContextData = NULL); 907 PVCommandId QueryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr, const OsclAny* aContextData = NULL); 908 PVCommandId CancelCommand(PVCommandId aCancelCmdId, const OsclAny* aContextData = NULL); 909 PVCommandId CancelAllCommands(const OsclAny* aContextData = NULL); 910 PVCommandId GetPVPlayerState(PVPlayerState& aState, const OsclAny* aContextData = NULL); 911 PVMFStatus GetPVPlayerStateSync(PVPlayerState& aState); 912 PVCommandId AddDataSource(PVPlayerDataSource& aDataSource, const OsclAny* aContextData = NULL); 913 PVCommandId Init(const OsclAny* aContextData = NULL); 914 PVCommandId GetMetadataKeys(PVPMetadataList& aKeyList, int32 aStartingIndex = 0, int32 aMaxEntries = -1, char* aQueryKey = NULL, const OsclAny* aContextData = NULL); 915 PVCommandId GetMetadataValues(PVPMetadataList& aKeyList, int32 aStartingValueIndex, int32 aMaxValueEntries, int32& aNumAvailableValueEntries, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL, bool aMetadataValuesCopiedInCallBack = true); 916 PVCommandId ReleaseMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL); 917 PVCommandId AddDataSink(PVPlayerDataSink& aDataSink, const OsclAny* aContextData = NULL); 918 PVCommandId SetPlaybackRange(PVPPlaybackPosition aBeginPos, PVPPlaybackPosition aEndPos, bool aQueueRange, const OsclAny* aContextData = NULL); 919 PVCommandId GetPlaybackRange(PVPPlaybackPosition &aBeginPos, PVPPlaybackPosition &aEndPos, bool aQueued, const OsclAny* aContextData = NULL); 920 PVCommandId GetCurrentPosition(PVPPlaybackPosition &aPos, const OsclAny* aContextData = NULL); 921 PVMFStatus GetCurrentPositionSync(PVPPlaybackPosition &aPos); 922 PVCommandId SetPlaybackRate(int32 aRate, PVMFTimebase* aTimebase = NULL, const OsclAny* aContextData = NULL); 923 PVCommandId GetPlaybackRate(int32& aRate, PVMFTimebase*& aTimebase, const OsclAny* aContextData = NULL); 924 PVCommandId GetPlaybackMinMaxRate(int32& aMinRate, int32& aMaxRate, const OsclAny* aContextData = NULL); 925 PVCommandId Prepare(const OsclAny* aContextData = NULL); 926 PVCommandId Start(const OsclAny* aContextData = NULL); 927 PVCommandId Pause(const OsclAny* aContextData = NULL); 928 PVCommandId Resume(const OsclAny* aContextData = NULL); 929 PVCommandId Stop(const OsclAny* aContextData = NULL); 930 PVCommandId RemoveDataSink(PVPlayerDataSink& aDataSink, const OsclAny* aContextData = NULL); 931 PVCommandId Reset(const OsclAny* aContextData = NULL); 932 PVCommandId RemoveDataSource(PVPlayerDataSource& aDataSource, const OsclAny* aContextData = NULL); 933 934 // From PvmiCapabilityAndConfig 935 void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver); 936 PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext); 937 PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements); 938 void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext); 939 void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements); 940 void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext); 941 void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP); 942 PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext = NULL); 943 uint32 getCapabilityMetric(PvmiMIOSession aSession); 944 PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements); 945 946 // From PVPlayerLicenseAcquisitionInterface 947 PVCommandId AcquireLicense(OsclAny* aLicenseData, uint32 aDataSize, oscl_wchar* aContentName, int32 aTimeoutMsec, const OsclAny* aContextData = NULL); 948 PVCommandId AcquireLicense(OsclAny* aLicenseData, uint32 aDataSize, char* aContentName, int32 aTimeoutMsec, const OsclAny* aContextData = NULL); 949 PVCommandId CancelAcquireLicense(PVMFCommandId aCmdId, const OsclAny* aContextData = NULL); 950 PVMFStatus GetLicenseStatus(PVMFCPMLicenseStatus& aStatus); 951 952 //From PVPlayerTrackSelectionInterface 953 PVMFStatus GetCompleteList(PVMFMediaPresentationInfo& aList); 954 PVMFStatus ReleaseCompleteList(PVMFMediaPresentationInfo& aList); 955 PVMFStatus GetPlayableList(PVMFMediaPresentationInfo& aList); 956 PVMFStatus ReleasePlayableList(PVMFMediaPresentationInfo& aList); 957 PVMFStatus GetSelectedList(PVMFMediaPresentationInfo& aList); 958 PVMFStatus ReleaseSelectedList(PVMFMediaPresentationInfo& aList); 959 PVMFStatus RegisterHelperObject(PVMFTrackSelectionHelper* aObject); 960 961 // From PVInterface 962 void addRef(); 963 void removeRef(); 964 bool queryInterface(const PVUuid& uuid, PVInterface*& iface); 965 966 // From PVPlayerWatchdogTimerObserver 967 void PVPlayerWatchdogTimerEvent(); 968 969 private: 970 PVPlayerEngine(); 971 void Construct(PVCommandStatusObserver *aCmdObserver, 972 PVErrorEventObserver *aErrorObserver, 973 PVInformationalEventObserver *aInfoObserver); 974 975 // From OsclTimerObject 976 void Run(); 977 978 // Utility function to determine the type of node in the player datapath and of the datapath which it belongs to 979 bool FindNodeTypeByNode(PVMFNodeInterface* aUnknownNode, PVPlayerNodeType& aNodeType, int32& aDatapathListIndex); 980 981 // Utility function to find the track for given datapath based on mime string 982 bool FindTrackForDatapathUsingMimeString(bool& aVideoTrack, bool& aAudioTrack, bool& aTextTrack, PVPlayerEngineDatapath* aDatapath); 983 984 // Utility function to find the datapath list index based on mime string 985 bool FindDatapathForTrackUsingMimeString(bool aVideoTrack, bool aAudioTrack, bool aTextTrack, int32& aDatapathListIndex); 986 987 // From PVMFNodeCmdStatusObserver 988 void NodeCommandCompleted(const PVMFCmdResp& aResponse); 989 990 // From PVMFNodeInfoEventObserver 991 void HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent); 992 993 // From PVMFNodeErrorEventObserver 994 void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent); 995 996 // From PVPlayerDatapathObserver 997 void HandlePlayerDatapathEvent(int32 aDatapathEvent, PVMFStatus aEventStatus, OsclAny* aContext = NULL, PVMFCmdResp* aCmdResp = NULL); 998 999 // From OsclTimerObserver 1000 void TimeoutOccurred(int32 timerID, int32 timeoutInfo); 1001 1002 //From PVMFMediaClockNotificationsObs 1003 void ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 delta, 1004 const OsclAny* acontextData, PVMFStatus aStatus); 1005 void NotificationsInterfaceDestroyed(); 1006 1007 //For sending PVMFInfoPositionStatus 1008 void SendPositionStatusUpdate(void); 1009 1010 // For checking of any pending error handling cmd in the queue 1011 bool CheckForPendingErrorHandlingCmd(); 1012 1013 // From PVPlayerRecognizerRegistryObserver 1014 void RecognizeCompleted(PVMFFormatType aSourceFormatType, OsclAny* aContext); 1015 1016 // Command and event queueing related functions 1017 PVCommandId AddCommandToQueue(int32 aCmdType, OsclAny* aContextData = NULL, 1018 Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector = NULL, 1019 const PVUuid* aUuid = NULL, bool aAPICommand = true, PVCommandId* aId = NULL); 1020 1021 // Thread-safety mechanisms 1022 ThreadSafeQueue iThreadSafeQueue; 1023 void ThreadSafeQueueDataAvailable(ThreadSafeQueue*); 1024 OsclSemaphore iOOTSyncCommandSem; 1025 OsclMutex iCommandIdMut; 1026 PVMFStatus DoOOTSyncCommand(int32 aCmdType, 1027 Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector, 1028 const PVUuid* aUuid = NULL); 1029 void OOTSyncCommandComplete(PVPlayerEngineCommand& aCmd, PVMFStatus aStatus); 1030 1031 // start the playback clock once skip is completed by one of the tracks 1032 void StartPlaybackClock(); 1033 1034 // Functions for engine state handling 1035 void SetEngineState(PVPlayerEngineState aState); 1036 PVPlayerState GetPVPlayerState(void); 1037 1038 // Keeps track of next available command ID 1039 PVCommandId iCommandId; 1040 1041 // Current engine state 1042 PVPlayerEngineState iState; 1043 1044 // Reference to observers 1045 PVCommandStatusObserver *iCmdStatusObserver; 1046 PVErrorEventObserver *iErrorEventObserver; 1047 PVInformationalEventObserver *iInfoEventObserver; 1048 1049 PvmiConfigAndCapabilityCmdObserver *iCfgCapCmdObserver; 1050 1051 // Retrieve current playback clock position 1052 void GetPlaybackClockPosition(PVPPlaybackPosition& aClockPos); 1053 1054 // Utility functions to convert to/from milliseconds to other playback position units 1055 PVMFStatus ConvertToMillisec(PVPPlaybackPosition& aPBPos, uint32& aTimeMS); 1056 PVMFStatus ConvertFromMillisec(uint32 aTimeMS, PVPPlaybackPosition& aPBPos); 1057 1058 // OsclTimer for polling checks 1059 OsclTimer<OsclMemAllocator>* iPollingCheckTimer; 1060 1061 // Command and event callback functions 1062 void EngineCommandCompleted(PVCommandId aId, OsclAny* aContext, PVMFStatus aStatus, PVInterface* aExtInterface = NULL, 1063 OsclAny* aEventData = NULL, int32 aEventDataSize = 0); 1064 void SendInformationalEvent(PVMFEventType aEventType, PVInterface* aExtInterface = NULL, 1065 OsclAny* aEventData = NULL, uint8* aLocalBuffer = NULL, uint32 aLocalBufferSize = 0); 1066 void SendErrorEvent(PVMFEventType aEventType, PVInterface* aExtInterface = NULL, 1067 OsclAny* aEventData = NULL, uint8* aLocalBuffer = NULL, uint32 aLocalBufferSize = 0); 1068 1069 // Queue for engine commands 1070 Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> iCurrentCmd; // Vector of size 1 to hold the command being currently processed 1071 Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> iCmdToCancel; // Vector of size 1 to hold the command being currently cancelled 1072 Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> iCmdToDlaCancel; // Vector of size 1 to hold the command being currently cancelled 1073 OsclPriorityQueue<PVPlayerEngineCommand, OsclMemAllocator, Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator>, PVPlayerEngineCommandCompareLess> iPendingCmds; // Vector to hold the command that has been requested 1074 1075 // Variables for completing engine commands after error handling 1076 PVMFStatus iCommandCompleteStatusInErrorHandling; 1077 PVMFBasicErrorInfoMessage* iCommandCompleteErrMsgInErrorHandling; 1078 1079 // Command handling functions 1080 void DoCancelCommand(PVPlayerEngineCommand& aCmd); 1081 void DoCancelAllCommands(PVPlayerEngineCommand& aCmd); 1082 void DoCancelCommandBeingProcessed(void); 1083 void DoCancelAcquireLicense(PVPlayerEngineCommand& aCmd); 1084 PVMFStatus DoCancelPendingNodeDatapathCommand(void); 1085 PVMFStatus DoErrorHandling(void); 1086 PVMFStatus DoGetSDKInfo(PVPlayerEngineCommand& aCmd); 1087 PVMFStatus DoSetLogAppender(PVPlayerEngineCommand& aCmd); 1088 PVMFStatus DoRemoveLogAppender(PVPlayerEngineCommand& aCmd); 1089 PVMFStatus DoSetLogLevel(PVPlayerEngineCommand& aCmd); 1090 PVMFStatus DoGetLogLevel(PVPlayerEngineCommand& aCmd); 1091 PVMFStatus DoQueryUUID(PVPlayerEngineCommand& aCmd); 1092 PVMFStatus DoQueryInterface(PVPlayerEngineCommand& aCmd); 1093 PVMFStatus DoGetPVPlayerState(PVPlayerEngineCommand& aCmd, bool aSyncCmd = false); 1094 PVMFStatus DoAddDataSource(PVPlayerEngineCommand& aCmd); 1095 PVMFStatus DoQuerySourceFormatType(PVCommandId aCmdId, OsclAny* aCmdContext); 1096 PVMFStatus DoSetupSourceNode(PVCommandId aCmdId, OsclAny* aCmdContext); 1097 PVMFStatus SetupDataSourceForUnknownURLAccess(); 1098 PVMFStatus DoSourceNodeQueryTrackSelIF(PVCommandId aCmdId, OsclAny* aCmdContext); 1099 PVMFStatus DoSourceNodeQueryInterfaceOptional(PVCommandId aCmdId, OsclAny* aCmdContext); 1100 PVMFStatus DoGetMetadataKey(PVPlayerEngineCommand& aCmd); 1101 PVMFStatus DoGetMetadataValue(PVPlayerEngineCommand& aCmd); 1102 PVMFStatus DoReleaseMetadataValues(PVPlayerEngineCommand& aCmd); 1103 PVMFStatus AddToMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId, PVPlayerEngineDatapath* aEngineDatapath, PVMFNodeInterface* aNode); 1104 PVMFStatus RemoveFromMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId); 1105 PVMFStatus DoInit(PVPlayerEngineCommand& aCmd); 1106 PVMFStatus DoSourceNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext); 1107 PVMFStatus DoSourceNodeGetDurationValue(PVCommandId aCmdId, OsclAny* aCmdContext); 1108 PVMFStatus DoAcquireLicense(PVPlayerEngineCommand& aCmd); 1109 PVMFStatus DoSourceNodeGetLicense(PVCommandId aCmdId, OsclAny* aCmdContext); 1110 PVMFStatus DoAddDataSink(PVPlayerEngineCommand& aCmd); 1111 PVMFStatus DoSetPlaybackRange(PVPlayerEngineCommand& aCmd); 1112 PVMFStatus UpdateCurrentEndPosition(PVPPlaybackPosition& aEndPos); 1113 PVMFStatus UpdateCurrentBeginPosition(PVPPlaybackPosition& aBeginPos, PVPlayerEngineCommand& aCmd); 1114 PVMFStatus DoChangePlaybackPosition(PVCommandId aCmdId, OsclAny* aCmdContext); 1115 PVMFStatus DoSourceNodeSetDataSourcePositionDuringPlayback(PVCommandId aCmdId, OsclAny* aCmdContext); 1116 PVMFStatus DoSinkNodeSkipMediaDataDuringPlayback(PVCommandId aCmdId, 1117 OsclAny* aCmdContext, 1118 bool aSFR = false); 1119 PVMFStatus DoGetPlaybackRange(PVPlayerEngineCommand& aCmd); 1120 PVMFStatus DoGetCurrentPosition(PVPlayerEngineCommand& aCmd, bool aSyncCmd = false); 1121 PVMFStatus DoSetPlaybackRate(PVPlayerEngineCommand& aCmd); 1122 PVMFStatus DoGetPlaybackRate(PVPlayerEngineCommand& aCmd); 1123 PVMFStatus DoGetPlaybackMinMaxRate(PVPlayerEngineCommand& aCmd); 1124 PVMFStatus DoPrepare(PVPlayerEngineCommand& aCmd); 1125 PVMFStatus DoSinkNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext); 1126 PVMFStatus DoSinkNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext); 1127 PVMFStatus DoSinkNodeTrackSelection(PVCommandId aCmdId, OsclAny* aCmdContext); 1128 PVMFStatus DoDecNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext); 1129 PVMFStatus DoDecNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext); 1130 PVMFStatus DoSourceNodeTrackSelection(PVCommandId aCmdId, OsclAny* aCmdContext); 1131 PVMFStatus DoTrackSelection(bool oPopulatePlayableListOnly, bool oUsePreferenceList); 1132 PVMFStatus DoVerifyTrackInfo(PVPlayerEngineTrackSelection &aTrackSelection, PVMFTrackInfo* aTrack, PVMFStatus& aCheckcodec); 1133 PVMFStatus DoSinkNodeDecNodeReset(PVCommandId aCmdId, OsclAny* aCmdContext); 1134 PVMFStatus DoSinkDecCleanupSourcePrepare(PVCommandId aCmdId, OsclAny* aCmdContext); 1135 PVMFStatus DoSourceNodePrepare(PVCommandId aCmdId, OsclAny* aCmdContext); 1136 PVMFStatus DoSinkNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1137 PVMFStatus DoDecNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1138 PVMFStatus DoDatapathPrepare(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1139 PVMFStatus DoSourceNodeQueryDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext); 1140 PVMFStatus DoSourceNodeSetDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext); 1141 PVMFStatus DoSourceNodeSetDataSourceDirection(PVCommandId aCmdId, OsclAny* aCmdContext); 1142 PVMFStatus DoSourceNodeStart(PVCommandId aCmdId, OsclAny* aCmdContext); 1143 PVMFStatus DoDatapathStart(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1144 PVMFStatus DoSinkNodeSkipMediaData(PVCommandId aCmdId, OsclAny* aCmdContext); 1145 PVMFStatus DoStart(PVPlayerEngineCommand& aCmd); 1146 PVMFStatus DoPause(PVPlayerEngineCommand& aCmd); 1147 PVMFStatus DoDatapathPause(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext, bool aSinkPaused); 1148 PVMFStatus DoSourceNodePause(PVCommandId aCmdId, OsclAny* aCmdContext); 1149 PVMFStatus DoResume(PVPlayerEngineCommand& aCmd); 1150 PVMFStatus DoStop(PVPlayerEngineCommand& aCmd); 1151 PVMFStatus DoDatapathStop(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1152 PVMFStatus DoSourceNodeStop(PVCommandId aCmdId, OsclAny* aCmdContext); 1153 PVMFStatus DoDatapathTeardown(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1154 PVMFStatus DoDatapathReset(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1155 PVMFStatus DoRemoveDataSink(PVPlayerEngineCommand& aCmd); 1156 PVMFStatus DoReset(PVPlayerEngineCommand& aCmd); 1157 PVMFStatus DoRemoveDataSource(PVPlayerEngineCommand& aCmd); 1158 PVMFStatus RemoveDataSourceSync(PVPlayerDataSource &aSrc); 1159 PVMFStatus DoSourceUnderflowAutoPause(PVPlayerEngineCommand& aCmd); 1160 PVMFStatus DoSourceDataReadyAutoResume(PVPlayerEngineCommand& aCmd); 1161 PVMFStatus DoSinkNodePause(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1162 PVMFStatus DoSinkNodeResume(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext); 1163 void DoRemoveAllSinks(void); 1164 void DoEngineDatapathTeardown(PVPlayerEngineDatapath& aDatapath); 1165 void DoEngineDatapathCleanup(PVPlayerEngineDatapath& aDatapath); 1166 void DoSourceNodeCleanup(void); 1167 1168 PVMFStatus DoSetObserverSync(PVPlayerEngineCommand& aCmd); 1169 PVMFStatus DoGetLicenseStatusSync(PVPlayerEngineCommand& aCmd); 1170 PVMFStatus DoGetParametersSync(PVPlayerEngineCommand& aCmd); 1171 PVMFStatus DoReleaseParametersSync(PVPlayerEngineCommand& aCmd); 1172 PVMFStatus DoVerifyParametersSync(PVPlayerEngineCommand& aCmd); 1173 PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext); 1174 PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements); 1175 PVMFStatus DoCapConfigSetParameters(PVPlayerEngineCommand& aCmd, bool aSyncCmd = false); 1176 PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements); 1177 PVMFStatus DoGetPlayerParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr); 1178 PVMFStatus DoGetPlayerProductInfoParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr); 1179 PVMFStatus DoVerifyAndSetPlayerParameter(PvmiKvp& aParameter, bool aSetParam); 1180 PVMFStatus DoVerifyAndSetPlayerProductInfoParameter(PvmiKvp& aParameter, bool aSetParam); 1181 PVMFStatus DoSetConfigSyncMargin(int32 aEarlyMargin, int32 aLateMargin, int32 aMediaType); 1182 int32 iCapConfigContext; 1183 1184 // Engine datapath and related variables 1185 Oscl_Vector<PVPlayerEngineDatapath, OsclMemAllocator> iDatapathList; 1186 uint32 iNumPendingNodeCmd; 1187 int32 iNumPendingSkipCompleteEvent; 1188 PVPlayerWatchdogTimer* iWatchDogTimer; 1189 uint32 iNumPendingDatapathCmd; 1190 int32 iNumPVMFInfoStartOfDataPending; 1191 1192 // Data source, data sink, and nodes 1193 PVPlayerDataSource* iDataSource; 1194 1195 PVMFFormatType iSourceFormatType; 1196 PVMFNodeInterface* iSourceNode; 1197 PVMFSessionId iSourceNodeSessionId; 1198 PVMFDataSourceInitializationExtensionInterface* iSourceNodeInitIF; 1199 PVMFTrackSelectionExtensionInterface* iSourceNodeTrackSelIF; 1200 PvmfDataSourcePlaybackControlInterface* iSourceNodePBCtrlIF; 1201 PvmfDataSourceDirectionControlInterface* iSourceNodeDirCtrlIF; 1202 PVMFTrackLevelInfoExtensionInterface* iSourceNodeTrackLevelInfoIF; 1203 PVMFMetadataExtensionInterface* iSourceNodeMetadataExtIF; 1204 PvmiCapabilityAndConfig* iSourceNodeCapConfigIF; 1205 PVMFDataSourceNodeRegistryInitInterface* iSourceNodeRegInitIF; 1206 PVMFCPMPluginLicenseInterface* iSourceNodeCPMLicenseIF; 1207 PVInterface* iSourceNodePVInterfaceInit; 1208 PVInterface* iSourceNodePVInterfaceTrackSel; 1209 PVInterface* iSourceNodePVInterfacePBCtrl; 1210 PVInterface* iSourceNodePVInterfaceDirCtrl; 1211 PVInterface* iSourceNodePVInterfaceTrackLevelInfo; 1212 PVInterface* iSourceNodePVInterfaceMetadataExt; 1213 PVInterface* iSourceNodePVInterfaceCapConfig; 1214 PVInterface* iSourceNodePVInterfaceRegInit; 1215 PVInterface* iSourceNodePVInterfaceCPMLicense; 1216 1217 // For CPM license acquisition 1218 struct PVPlayerEngineCPMAcquireLicenseParam 1219 { 1220 OsclAny* iLicenseData; 1221 uint32 iLicenseDataSize; 1222 char* iContentNameChar; 1223 oscl_wchar* iContentNameWChar; 1224 int32 iTimeoutMsec; 1225 }; 1226 PVPlayerEngineCPMAcquireLicenseParam iCPMAcquireLicenseParam; 1227 OSCL_HeapString<OsclMemAllocator> iCPMContentNameStr; 1228 OSCL_wHeapString<OsclMemAllocator> iCPMContentNameWStr; 1229 PVMFCommandId iCPMGetLicenseCmdId; 1230 1231 // For metadata handling 1232 // Vector to hold a list of metadata interface available from the node 1233 struct PVPlayerEngineMetadataIFInfo 1234 { 1235 PVMFMetadataExtensionInterface* iInterface; 1236 PVMFSessionId iSessionId; 1237 PVPlayerEngineDatapath* iEngineDatapath; 1238 PVMFNodeInterface* iNode; 1239 }; 1240 Oscl_Vector<PVPlayerEngineMetadataIFInfo, OsclMemAllocator> iMetadataIFList; 1241 1242 // Structure to hold the parameters for GetMetadataKeys() 1243 struct PVPlayerEngineGetMetadataKeysParam 1244 { 1245 int32 iStartingKeyIndex; 1246 int32 iMaxKeyEntries; 1247 char* iQueryKey; 1248 PVPMetadataList* iKeyList; 1249 1250 uint32 iCurrentInterfaceIndex; 1251 int32 iNumKeyEntriesToFill; 1252 int32 iNumKeyEntriesInList; 1253 }; 1254 PVPlayerEngineGetMetadataKeysParam iGetMetadataKeysParam; 1255 1256 // Structure to hold the parameters for GetMetadataValues() 1257 struct PVPlayerEngineGetMetadataValuesParam 1258 { 1259 int32 iStartingValueIndex; 1260 int32 iMaxValueEntries; 1261 int32* iNumAvailableValues; 1262 PVPMetadataList* iKeyList; 1263 Oscl_Vector<PvmiKvp, OsclMemAllocator>* iValueList; 1264 1265 uint32 iCurrentInterfaceIndex; 1266 int32 iNumValueEntriesToFill; 1267 int32 iNumValueEntriesInList; 1268 }; 1269 PVPlayerEngineGetMetadataValuesParam iGetMetadataValuesParam; 1270 1271 // Boolean to let engine know if metadata values have been copied by the app 1272 bool iMetadataValuesCopiedInCallBack; 1273 1274 // Boolean to check if Metadata values have been released 1275 bool iReleaseMetadataValuesPending; 1276 1277 // Vector hold a list of metadata interfaces with key/value to release memory 1278 struct PVPlayerEngineMetadataReleaseEntry 1279 { 1280 uint32 iMetadataIFListIndex; 1281 int32 iStartIndex; 1282 int32 iEndIndex; 1283 }; 1284 Oscl_Vector<PVPlayerEngineMetadataReleaseEntry, OsclMemAllocator> iMetadataKeyReleaseList; 1285 Oscl_Vector<PVPlayerEngineMetadataReleaseEntry, OsclMemAllocator> iMetadataValueReleaseList; 1286 1287 // Engine context related objects and utility functions 1288 OsclMemPoolFixedChunkAllocator iCurrentContextListMemPool; 1289 Oscl_Vector<PVPlayerEngineContext*, OsclMemAllocator> iCurrentContextList; 1290 PVPlayerEngineContext* AllocateEngineContext(PVPlayerEngineDatapath* aEngineDatapath, PVMFNodeInterface* aNode, PVPlayerDatapath* aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext, int32 aCmdType); 1291 void FreeEngineContext(PVPlayerEngineContext* aContext); 1292 void RemoveDatapathContextFromList(); 1293 1294 // Cancel and error handling related variables 1295 uint32 iNumberCancelCmdPending; 1296 1297 enum 1298 { 1299 // Node commands 1300 PVP_CMD_SourceNodeQueryInitIF, 1301 PVP_CMD_SourceNodeQueryTrackSelIF, 1302 PVP_CMD_SourceNodeQueryTrackLevelInfoIF, 1303 PVP_CMD_SourceNodeQueryPBCtrlIF, 1304 PVP_CMD_SourceNodeQueryDirCtrlIF, 1305 PVP_CMD_SourceNodeQueryMetadataIF, 1306 PVP_CMD_SourceNodeQueryCapConfigIF, 1307 PVP_CMD_SourceNodeQueryCPMLicenseIF, 1308 PVP_CMD_SourceNodeQuerySrcNodeRegInitIF, 1309 PVP_CMD_SourceNodeInit, 1310 PVP_CMD_SourceNodeGetDurationValue, 1311 PVP_CMD_SourceNodeSetDataSourceRate, 1312 PVP_CMD_SourceNodePrepare, 1313 PVP_CMD_SourceNodeGetLicense, 1314 PVP_CMD_SourceNodeCancelGetLicense, 1315 PVP_CMD_SinkNodeQuerySyncCtrlIF, 1316 PVP_CMD_SinkNodeQueryMetadataIF, 1317 PVP_CMD_SinkNodeQueryCapConfigIF, 1318 PVP_CMD_DecNodeQueryMetadataIF, 1319 PVP_CMD_DecNodeQueryCapConfigIF, 1320 PVP_CMD_SinkNodeInit, 1321 PVP_CMD_DecNodeInit, 1322 PVP_CMD_SourceNodeQueryDataSourcePosition, 1323 PVP_CMD_SourceNodeSetDataSourcePosition, 1324 PVP_CMD_SourceNodeSetDataSourceDirection, 1325 PVP_CMD_SourceNodeStart, 1326 PVP_CMD_SourceNodeQueryDataSourcePositionDuringPlayback, 1327 PVP_CMD_SourceNodeSetDataSourcePositionDuringPlayback, 1328 PVP_CMD_SinkNodeSkipMediaDataDuringPlayback, 1329 PVP_CMD_SinkNodeSkipMediaData, 1330 PVP_CMD_SinkNodeDecNodeReset, 1331 PVP_CMD_SinkNodeReset, 1332 PVP_CMD_DecNodeReset, 1333 PVP_CMD_GetNodeMetadataValue, 1334 PVP_CMD_GetNodeMetadataKey, 1335 PVP_CMD_SinkNodeAutoPause, 1336 PVP_CMD_SinkNodeAutoResume, 1337 PVP_CMD_SourceNodeStop, 1338 PVP_CMD_SourceNodeReset, 1339 // Datapath commands 1340 PVP_CMD_DPPrepare, 1341 PVP_CMD_DPStart, 1342 PVP_CMD_DPStop, 1343 PVP_CMD_DPTeardown, 1344 PVP_CMD_DPReset, 1345 // Recognizer command 1346 PVP_CMD_QUERYSOURCEFORMATTYPE, 1347 // source roll over 1348 PVP_CMD_SourceNodeRollOver 1349 }; 1350 1351 // Node command handling functions 1352 void HandleSourceNodeQueryInitIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1353 void HandleSourceNodeQueryTrackSelIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1354 void HandleSourceNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1355 void HandleSourceNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1356 void HandleSourceNodeGetDurationValue(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1357 void HandleSourceNodeGetLicense(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1358 void HandleSourceNodeCancelGetLicense(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1359 1360 void HandleSourceNodeSetDataSourceRate(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1361 PVMFStatus DoSinkNodeChangeClockRate(); 1362 PVMFStatus DoSinkPlaybackDirectionChange(); 1363 PVMFStatus UpdateCurrentDirection(PVMFCommandId, OsclAny*); 1364 void UpdateTimebaseAndRate(); 1365 void UpdateDirection(PVMFTimestamp, PVMFTimestamp, PVPPlaybackPosition&); 1366 void HandleSourceNodePrepare(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1367 void HandleSinkNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1368 void HandleDecNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1369 void HandleSourceNodeQueryDataSourcePosition(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1370 void HandleSourceNodeSetDataSourcePosition(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1371 void HandleSourceNodeSetDataSourceDirection(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1372 void HandleSourceNodeStart(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1373 void HandleSinkNodeSkipMediaData(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1374 1375 void HandleSourceNodeQueryDataSourcePositionDuringPlayback(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1376 void HandleSourceNodeSetDataSourcePositionDuringPlayback(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1377 void HandleSinkNodeSkipMediaDataDuringPlayback(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1378 1379 void HandleSourceNodePause(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1380 void HandleSourceNodeResume(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1381 void HandleSourceNodeStop(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1382 void HandleSourceNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1383 1384 void HandleSinkNodePause(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1385 void HandleSinkNodeResume(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1386 void HandleSinkNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1387 void HandleDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1388 1389 void HandleSinkNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1390 void HandleSinkNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1391 void HandleDecNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1392 void HandleDecNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1393 1394 void HandleSinkNodeDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp); 1395 1396 // Datapath command handling functions 1397 void HandleDatapathPrepare(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp); 1398 void HandleDatapathStart(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp); 1399 void HandleDatapathPause(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp); 1400 void HandleDatapathResume(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp); 1401 void HandleDatapathStop(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp); 1402 void HandleDatapathTeardown(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp); 1403 void HandleDatapathReset(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp); 1404 1405 // Node error event handling functions 1406 void HandleSourceNodeErrorEvent(const PVMFAsyncEvent& aEvent); 1407 void HandleDecNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex); 1408 void HandleSinkNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex); 1409 1410 // Node informational event handling functions 1411 void HandleSourceNodeInfoEvent(const PVMFAsyncEvent& aEvent); 1412 void HandleDecNodeInfoEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex); 1413 void HandleSinkNodeInfoEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex); 1414 bool AllDatapathReceivedEndOfData(); 1415 1416 // Utility functions to send specific async events 1417 void SendEndOfClipInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL); 1418 void SendEndTimeReachedInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL); 1419 void SendSourceUnderflowInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL); 1420 void SendSourceDataReadyInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL); 1421 1422 // Utility to retrieve the PVMFErrorInfoMessageInterface from a PVInterface 1423 PVMFErrorInfoMessageInterface* GetErrorInfoMessageInterface(PVInterface& aInterface); 1424 1425 // Utility functions to start/stop playback status timer 1426 void StartPlaybackStatusTimer(void); 1427 void StopPlaybackStatusTimer(void); 1428 1429 // Utility Fucntion to calculate the nearest sync frame 1430 void CalculateActualPlaybackPosition(); 1431 1432 // to save config values in case of protocol rollover 1433 PVMFStatus VerifyAndSaveKVPValues(PvmiKvp *aKvpValue); 1434 void SetRollOverKVPValues(); 1435 void DeleteKVPValues(); 1436 1437 // to reset reposition related variables. 1438 void ResetReposVariables(bool aResetAll); 1439 1440 PVMFStatus IssueNodeCancelCommand(PVPlayerEngineContext* aCurrentListContext, PVMFSessionId aSessionId, OsclAny* aNumberCancelCmdPending); 1441 PVMFStatus IssueDatapathCancelCommand(PVPlayerEngineContext* aCurrentListContext, OsclAny* aNumberCancelCmdPending); 1442 PVMFStatus IssueRecognizerRegistryCancel(OsclAny* aNumberCancelCmdPending); 1443 PVMFStatus IssueSinkNodeInit(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId); 1444 PVMFStatus IssueSinkNodeReset(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId); 1445 PVMFStatus IssueSinkSkipMediaData(PVPlayerEngineDatapath* aDatapath, bool aSFR, OsclAny* aCmdContext); 1446 PVMFStatus IssueSourceSetDataSourcePosition(bool aIsPosUnitPlayList, OsclAny* aCmdContext); 1447 PVMFStatus IssueDecNodeInit(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId); 1448 PVMFStatus IssueDecNodeReset(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId); 1449 PVMFStatus IssueQueryInterface(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, const PVUuid aUuid, PVInterface*& aInterfacePtr, OsclAny* aCmdContext, PVMFCommandId& aCmdId); 1450 1451 // Handle to the logger node 1452 PVLogger* iLogger; 1453 PVLogger* iReposLogger; 1454 PVLogger* iPerfLogger; 1455 1456 // The node registry for the player engine 1457 PVPlayerNodeRegistry iPlayerNodeRegistry; 1458 1459 // The recognizer registry for the player engine 1460 PVPlayerRecognizerRegistry iPlayerRecognizerRegistry; 1461 1462 // Objects for playback clock and playback rate control 1463 PVPlayerTimebase iPlaybackTimebase; 1464 PVMFMediaClock iPlaybackClock; 1465 PVMFMediaClockNotificationsInterface* iClockNotificationsInf; 1466 uint32 iPlayStatusCallbackTimerID; 1467 uint32 iPlayStatusCallbackTimerMarginWindow; 1468 1469 1470 uint32 iCurrCallbackTimerLatency; 1471 int32 iPlaybackClockRate;//always >=0 1472 PVMFTimebase* iOutsideTimebase; 1473 int32 iPlaybackClockRate_New; 1474 PVMFTimebase* iOutsideTimebase_New; 1475 1476 PVMFDataSourcePositionParams iDataSourcePosParams; 1477 1478 // Objects for direction control. 1479 int32 iPlaybackDirection;//1=forward, (-1)=backward. 1480 int32 iPlaybackDirection_New; 1481 bool iChangePlaybackDirectionWhenResuming; 1482 PVPPlaybackPosition iChangeDirectionNPT; 1483 1484 // Variables to store data for SetPlaybackRange() 1485 PVPPlaybackPosition iCurrentBeginPosition; 1486 PVPPlaybackPosition iCurrentEndPosition; 1487 bool iEndTimeCheckEnabled; 1488 bool iQueuedRangePresent; 1489 PVPPlaybackPosition iQueuedBeginPosition; 1490 PVPPlaybackPosition iQueuedEndPosition; 1491 bool iChangePlaybackPositionWhenResuming; 1492 1493 PVMFTimestamp iActualNPT; 1494 PVMFTimestamp iTargetNPT; 1495 PVMFTimestamp iActualMediaDataTS; 1496 PVMFTimestamp iSkipMediaDataTS; 1497 PVMFTimestamp iStartNPT; 1498 PVMFTimestamp iStartMediaDataTS; 1499 uint32 iWatchDogTimerInterval; 1500 PVMFTimestamp iSeekPointBeforeTargetNPT; 1501 PVMFTimestamp iSeekPointAfterTargetNPT; 1502 // forward and reverse flags, a single flag can also serve, but kept for MP4 parser alignment. 1503 bool iForwardReposFlag; 1504 bool iBackwardReposFlag; 1505 1506 // Flag to keep track of whether play status event is enabled or not 1507 bool iPlayStatusTimerEnabled; 1508 1509 // Flags to keep track of source auto-pause/resume 1510 bool iDataReadySent; 1511 bool removeCmdFromQ(OsclPriorityQueue<PVPlayerEngineCommand, OsclMemAllocator, Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator>, PVPlayerEngineCommandCompareLess> &aVec, const PVPlayerEngineCommandType aCmdType, bool aRemove); 1512 bool removeCmdFromQ(Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> &aVec, const PVPlayerEngineCommandType aCmdType, bool aRemove); 1513 1514 // Flag to keep track of whether playback has ended with end of clip 1515 bool iPlaybackPausedDueToEndOfClip; 1516 1517 // Variables to store the source data duration 1518 bool iSourceDurationAvailable; 1519 uint32 iSourceDurationInMS; 1520 PVMFMetadataList iSourceDurationKeyList; 1521 Oscl_Vector<PvmiKvp, OsclMemAllocator> iSourceDurationValueList; 1522 1523 // Variables to store the source data duration 1524 PVMFMetadataList iDlaDataKeyList; 1525 Oscl_Vector<PvmiKvp, OsclMemAllocator> iDlaDataValueList; 1526 1527 // Player engine configuration 1528 bool iPBPosEnable; 1529 PVPPlaybackPositionUnit iPBPosStatusUnit; 1530 uint32 iPBPosStatusInterval; 1531 uint32 iEndTimeCheckInterval; 1532 bool iSeekToSyncPoint; 1533 bool iSkipToRequestedPosition; 1534 bool iBackwardRepos; /* To avoid backward looping :: Flag to remember if this is a case of backward repositioning */ 1535 uint32 iSyncPointSeekWindow; 1536 range_int32 iSyncMarginVideo; 1537 range_int32 iSyncMarginAudio; 1538 range_int32 iSyncMarginText; 1539 uint32 iNodeCmdTimeout; 1540 uint32 iNodeDataQueuingTimeout; 1541 OSCL_HeapString<OsclMemAllocator> iProdInfoProdName; 1542 OSCL_HeapString<OsclMemAllocator> iProdInfoPartNum; 1543 OSCL_HeapString<OsclMemAllocator> iProdInfoHWPlatform; 1544 OSCL_HeapString<OsclMemAllocator> iProdInfoSWPlatform; 1545 OSCL_HeapString<OsclMemAllocator> iProdInfoDevice; 1546 // stream ID for media streams 1547 uint32 iStreamID; 1548 1549 //source roll over related 1550 PVMFStatus DoSourceNodeRollOver(PVCommandId aCmdId, OsclAny* aCmdContext); 1551 uint32 iAlternateSrcFormatIndex; 1552 bool CheckForSourceRollOver(); 1553 enum RollOverState 1554 { 1555 RollOverStateIdle, 1556 RollOverStateStart, 1557 RollOverStateInProgress 1558 }; 1559 RollOverState iRollOverState; 1560 1561 //To save CapnCapability in case of Protocol Rollover 1562 Oscl_Vector<PvmiKvp *, OsclMemAllocator> iPvmiKvpCapNConfig; 1563 1564 struct PVPlayerEngineUuidNodeMapping 1565 { 1566 PVUuid iUuid; 1567 PVMFNodeInterface* iNode; PVPlayerEngineUuidNodeMappingPVPlayerEngineUuidNodeMapping1568 PVPlayerEngineUuidNodeMapping(PVUuid aUuid, PVMFNodeInterface* aNode): 1569 iUuid(aUuid), iNode(aNode) {} 1570 }; 1571 //Vector to store the Uuids for the nodes created throughout the playback 1572 Oscl_Vector<PVPlayerEngineUuidNodeMapping, OsclMemAllocator> iNodeUuids; 1573 1574 // For Track Selection during Prepare 1575 Oscl_Vector<PVPlayerEngineTrackSelection, OsclMemAllocator> iTrackSelectionList; 1576 PVMFMediaPresentationInfo iSourcePresInfoList; 1577 PVMFMediaPresentationInfo iPlayableList; 1578 PVMFMediaPresentationInfo iPreferenceList; 1579 PVMFTrackSelectionHelper* iTrackSelectionHelper; 1580 1581 PVPPlaybackPositionMode iPlaybackPositionMode; 1582 bool iOverflowFlag; 1583 }; 1584 1585 /** 1586 * Inactivity timer object to Jitter Buffer node. This object generates event 1587 * on remote inactivity (no UDP traffic from server for a certain time) 1588 */ 1589 #define DEFAULT_WATCHDOG_TIMERDURATION 10 1590 #define PVPLAYERENGINE_DEFAULT_WATCHDOGTIMER_INTERVAL 1000 1591 1592 class PVPlayerWatchdogTimer : public OsclTimerObject 1593 { 1594 public: PVPlayerWatchdogTimer(PVPlayerWatchdogTimerObserver * aTimerObserver)1595 PVPlayerWatchdogTimer(PVPlayerWatchdogTimerObserver* aTimerObserver): 1596 OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVPlayerWatchDogTimer"), 1597 iTimerDuration(DEFAULT_WATCHDOG_TIMERDURATION), 1598 iObserver(aTimerObserver), 1599 iStarted(false) 1600 { 1601 AddToScheduler(); 1602 } 1603 ~PVPlayerWatchdogTimer()1604 virtual ~PVPlayerWatchdogTimer() 1605 { 1606 Stop(); 1607 } 1608 1609 /** Start Timer */ Start()1610 PVMFStatus Start() 1611 { 1612 if (iTimerDuration != 0) 1613 { 1614 RunIfNotReady(iTimerDuration * 1000); 1615 iStarted = true; 1616 return PVMFSuccess; 1617 } 1618 else 1619 { 1620 return PVMFFailure; 1621 } 1622 } 1623 setTimerDuration(uint32 aTimerDuration)1624 void setTimerDuration(uint32 aTimerDuration) 1625 { 1626 Cancel(); 1627 if (aTimerDuration == 0) 1628 { 1629 iTimerDuration = PVPLAYERENGINE_DEFAULT_WATCHDOGTIMER_INTERVAL; 1630 } 1631 else 1632 { 1633 iTimerDuration = aTimerDuration; 1634 } 1635 } 1636 getTimerDurationInMS()1637 uint32 getTimerDurationInMS() 1638 { 1639 return iTimerDuration; 1640 } 1641 1642 /** Stop Timer events */ Stop()1643 PVMFStatus Stop() 1644 { 1645 Cancel(); 1646 iStarted = false; 1647 return PVMFSuccess; 1648 } 1649 IsTimerStarted()1650 bool IsTimerStarted() 1651 { 1652 return iStarted; 1653 } 1654 1655 private: Run()1656 void Run() 1657 { 1658 if (!iStarted) 1659 return; 1660 1661 if (!iObserver) 1662 { 1663 // Error, No observer set 1664 return; 1665 } 1666 1667 iObserver->PVPlayerWatchdogTimerEvent(); 1668 /* 1669 * Do not reschudule the AO here. Observer would reschedule this AO 1670 * once it is done processing the timer event. 1671 */ 1672 } 1673 1674 1675 uint32 iTimerDuration; 1676 PVPlayerWatchdogTimerObserver* iObserver; 1677 PVLogger* iLogger; 1678 bool iStarted; 1679 }; 1680 1681 #endif 1682