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 PVMF_MP3FFPARSER_NODE_H_INCLUDED 19 #define PVMF_MP3FFPARSER_NODE_H_INCLUDED 20 21 22 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED 23 #include "oscl_scheduler_ao.h" 24 #endif 25 26 #ifndef OSCL_FILE_IO_H_INCLUDED 27 #include "oscl_file_io.h" 28 #endif 29 30 #ifndef PVMF_NODE_UTILS_H_INCLUDED 31 #include "pvmf_node_utils.h" 32 #endif 33 34 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED 35 #include "pvmf_node_interface.h" 36 #endif 37 38 #ifndef OSCL_MEM_MEMPOOL_H_INCLUDED 39 #include "oscl_mem_mempool.h" 40 #endif 41 #ifndef PVMF_MEMPOOL_H_INCLUDED 42 #include "pvmf_mempool.h" 43 #endif 44 45 #ifndef PVMF_MEDIA_DATA_H_INCLUDED 46 #include "pvmf_media_data.h" 47 #endif 48 49 #ifndef PVMF_RESIZABLE_SIMPLE_MEDIAMSG_H_INCLUDED 50 #include "pvmf_resizable_simple_mediamsg.h" 51 #endif 52 53 #ifndef PVMF_FFPARSERNODE_PORT_H_INCLUDED 54 #include "pvmf_mp3ffparser_outport.h" 55 #endif 56 57 #ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED 58 #include "pvmf_meta_data_extension.h" 59 #endif 60 61 #ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED 62 #include "pvmf_data_source_init_extension.h" 63 #endif 64 65 #ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED 66 #include "pvmf_data_source_playback_control.h" 67 #endif 68 69 #ifndef PVMF_TRACK_SELECTION_EXTENSION_H_INCLUDED 70 #include "pvmf_track_selection_extension.h" 71 #endif 72 73 #ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED 74 #include "pvmf_media_presentation_info.h" 75 #endif 76 77 #ifndef PVMF_MP3FFPARSER_NODE_INTERNAL_H_INCLUDED 78 #include "pvmf_mp3ffparser_node_internal.h" 79 #endif 80 81 #ifndef PVMF_COMMON_AUDIO_DECNODE_H_INCLUDE 82 #include "pvmf_common_audio_decnode.h" 83 #endif 84 85 #ifndef PVMF_LOCAL_DATA_SOURCE_H_INCLUDED 86 #include "pvmf_local_data_source.h" 87 #endif 88 89 #ifndef PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED 90 #include "pvmf_cpmplugin_license_interface.h" 91 #endif 92 93 #ifndef PVMF_FORMAT_PROGDOWNLOAD_SUPPORT_EXTENSION_H_INCLUDED 94 #include "pvmf_format_progdownload_support_extension.h" 95 #endif 96 97 #ifndef PVMF_DOWNLOAD_PROGRESS_EXTENSION_H 98 #include "pvmf_download_progress_interface.h" 99 #endif 100 101 #ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED 102 #include "pvmf_source_context_data.h" 103 #endif 104 105 #ifndef PVMI_DATASTREAMUSER_INTERFACE_H_INCLUDED 106 #include "pvmi_datastreamuser_interface.h" 107 #endif 108 109 #ifndef PVFILE_H_INCLUDED 110 #include "pvfile.h" 111 #endif 112 113 #ifndef IMP3FF_H_INCLUDED 114 #include "imp3ff.h" // Includes for the core file format mp3 parser library 115 #endif 116 117 #ifndef USE_CML2_CONFIG 118 #ifndef PVMF_MP3FFPASER_NODE_CONFIG_H_INCLUDED 119 #include "pvmf_mp3ffparser_node_config.h" 120 #endif 121 #endif 122 123 #if PV_HAS_SHOUTCAST_SUPPORT_ENABLED // include scsp only when SHOUTCAST support is enabled 124 #ifndef PVMF_SHOUTCAST_STREAM_PARSER_H_INCLUDED 125 #include "pvmf_shoutcast_stream_parser.h" 126 #endif 127 #endif 128 129 #define PVMF_MP3_PARSER_NODE_MAX_CPM_METADATA_KEYS 256 130 131 /** 132 * Container for the CPM object 133 */ 134 #ifndef CPM_H_INCLUDED 135 #include "cpm.h" 136 #endif 137 138 // Forward declaration 139 class PVMFMP3FFParserNode; 140 class MediaClockConverter; 141 142 class PVMFSubNodeContainerBaseMp3 143 { 144 public: 145 PVMFSubNodeContainerBaseMp3() 146 { 147 iCmdState = EIdle; 148 iCancelCmdState = EIdle; 149 iContainer = NULL; 150 } 151 virtual ~PVMFSubNodeContainerBaseMp3() 152 { 153 } 154 enum NodeType {ECPM}; 155 enum CmdType 156 { 157 //CPM commands 158 ECPMCleanup = 0 159 , ECPMInit 160 , ECPMOpenSession 161 , ECPMRegisterContent 162 , ECPMGetLicenseInterface 163 , ECPMGetLicense 164 , ECPMGetLicenseW 165 , ECPMApproveUsage 166 , ECPMCheckUsage 167 , ECPMUsageComplete 168 , ECPMCloseSession 169 , ECPMReset 170 , ECPMCancelGetLicense 171 }; 172 173 void Construct(NodeType n, PVMFMP3FFParserNode* c) 174 { 175 iType = n; 176 iContainer = c; 177 } 178 179 virtual void Cleanup() = 0; 180 virtual PVMFStatus IssueCommand(int32) = 0; 181 virtual bool CancelPendingCommand() = 0; 182 183 void CommandDone(PVMFStatus, PVInterface*, OsclAny*); 184 void CancelCommandDone(PVMFStatus, PVInterface*, OsclAny*); 185 186 bool CmdPending() 187 { 188 return iCancelCmdState != EIdle 189 || iCmdState != EIdle; 190 } 191 192 protected: 193 PVMFMP3FFParserNode*iContainer; 194 NodeType iType; 195 196 //Command processing . 197 PVMFCommandId iCmdId; 198 enum CmdState 199 { 200 EIdle, //no command 201 EBusy //command issued to the sub-node, completion pending. 202 }; 203 CmdState iCmdState; 204 int32 iCmd; 205 PVMFCommandId iCancelCmdId; 206 CmdState iCancelCmdState; 207 }; 208 209 class PVMFCPMContainerMp3: public PVMFSubNodeContainerBaseMp3, 210 public PVMFCPMStatusObserver 211 { 212 public: 213 PVMFCPMContainerMp3() 214 { 215 iRequestedUsage.key = NULL; 216 iApprovedUsage.key = NULL; 217 iAuthorizationDataKvp.key = NULL; 218 iCPMContentAccessFactory = NULL; 219 iCPM = NULL; 220 } 221 222 ~PVMFCPMContainerMp3() 223 { 224 Cleanup(); 225 } 226 227 // From PVMFCPMStatusObserver 228 OSCL_IMPORT_REF void CPMCommandCompleted(const PVMFCmdResp& aResponse) ; 229 230 //from PVMFSubNodeContainerBase 231 PVMFStatus IssueCommand(int32); 232 bool CancelPendingCommand(); 233 void Cleanup(); 234 235 //CPM session ID 236 PVMFSessionId iSessionId; 237 238 //CPM object 239 PVMFCPM* iCPM; 240 241 //CPM data 242 PVMFCPMContentType iCPMContentType; 243 PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory; 244 PvmiKvp iRequestedUsage; 245 PvmiKvp iApprovedUsage; 246 PvmiKvp iAuthorizationDataKvp; 247 PVMFCPMUsageID iUsageID; 248 PVMFCPMPluginLicenseInterface* iCPMLicenseInterface; 249 PVInterface* iCPMLicenseInterfacePVI; 250 PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface; 251 252 PVMFStatus CreateUsageKeys(); 253 PVMFStatus CheckApprovedUsage(); 254 PVMFCommandId GetCPMLicenseInterface(); 255 bool GetCPMMetaDataExtensionInterface(); 256 }; 257 258 259 class PVMP3FFNodeTrackPortInfo 260 { 261 public: 262 enum TrackState 263 { 264 TRACKSTATE_UNINITIALIZED, 265 TRACKSTATE_INITIALIZED, 266 TRACKSTATE_TRANSMITTING_GETDATA, 267 TRACKSTATE_TRANSMITTING_SENDDATA, 268 TRACKSTATE_TRANSMITTING_SENDBOS, 269 TRACKSTATE_SEND_ENDOFTRACK, 270 TRACKSTATE_TRACKDATAPOOLEMPTY, 271 TRACKSTATE_MEDIADATAPOOLEMPTY, 272 TRACKSTATE_DESTFULL, 273 TRACKSTATE_SOURCEEMPTY, 274 TRACKSTATE_ENDOFTRACK, 275 TRACKSTATE_DOWNLOAD_AUTOPAUSE, 276 TRACKSTATE_ERROR 277 }; 278 279 PVMP3FFNodeTrackPortInfo() 280 { 281 282 iClockConverter = NULL; 283 iPort = NULL; 284 iState = TRACKSTATE_UNINITIALIZED; 285 iTrackDataMemoryPool = NULL; 286 iMediaDataImplAlloc = NULL; 287 iMediaDataMemPool = NULL; 288 timestamp_offset = 0; 289 iSeqNum = 0; 290 iSendBOS = false; 291 iFirstFrame = false; 292 } 293 294 PVMP3FFNodeTrackPortInfo(const PVMP3FFNodeTrackPortInfo& aSrc) 295 { 296 iPort = aSrc.iPort; 297 iClockConverter = aSrc.iClockConverter; 298 iMediaData = aSrc.iMediaData; 299 iState = aSrc.iState; 300 iTrackDataMemoryPool = aSrc.iTrackDataMemoryPool; 301 iMediaDataImplAlloc = aSrc.iMediaDataImplAlloc; 302 iMediaDataMemPool = aSrc.iMediaDataMemPool; 303 timestamp_offset = aSrc.timestamp_offset; 304 iSeqNum = aSrc.iSeqNum; 305 iSendBOS = aSrc.iSendBOS; 306 iFirstFrame = aSrc.iFirstFrame; 307 } 308 309 ~PVMP3FFNodeTrackPortInfo() 310 { 311 } 312 313 // Output port to send the data downstream 314 PVMFMP3FFParserPort* iPort; 315 316 // Shared memory pointer holding the currently retrieved track data 317 PVMFSharedMediaDataPtr iMediaData; 318 319 // Current state of this track 320 TrackState iState; 321 322 // Output buffer memory pool 323 OsclMemPoolResizableAllocator *iTrackDataMemoryPool; 324 325 // Allocator for simple media data buffer impl 326 PVMFResizableSimpleMediaMsgAlloc *iMediaDataImplAlloc; 327 328 // Memory pool for simple media data 329 PVMFMemPoolFixedChunkAllocator *iMediaDataMemPool; 330 331 // Converter to convert from track timescale to milliseconds 332 MediaClockConverter* iClockConverter; 333 334 335 PVMFFormatType iFormatType; 336 uint32 iBitrate; 337 int32 timestamp_offset; 338 339 // Sequence number 340 uint32 iSeqNum; 341 //bos flag 342 bool iSendBOS; 343 // Random access point idenfier 344 bool iFirstFrame; 345 }; // end class PVMP3FFNodeTrackPortInfo 346 347 //Forward Declarations 348 class IMpeg3File; 349 class PVLogger; 350 351 /* 352 * The class PVMp3DurationCalculator is the external interface for calculating 353 * the clip duration as a background AO. 354 **/ 355 class PVMp3DurationCalculator : public OsclTimerObject 356 { 357 public: 358 PVMp3DurationCalculator(int32 aPriority, IMpeg3File* aMP3File, PVMFNodeInterface* aNode, bool aScanEnabled = true); 359 ~PVMp3DurationCalculator(); 360 void Run(); 361 void ScheduleAO(); 362 private: 363 PVFile* iFile; 364 bool iScanComplete; 365 bool iScanEnabled; 366 MP3ErrorType iErrorCode; 367 IMpeg3File* iMP3File; 368 PVMFNodeInterface* iNode; 369 uint32 totalticks; 370 }; 371 /* 372 * The class PVMFMP3FFParserNode is the external interface for using the node. 373 * Move this to a separate interface file and all the stuff above can go in a 374 * private header in the src directory. 375 * */ 376 377 class PVMFMP3FFParserNode : public OsclTimerObject, 378 public PVMFNodeInterface, 379 public PVMFDataSourceInitializationExtensionInterface, 380 public PVMFTrackSelectionExtensionInterface, 381 public PVMFMetadataExtensionInterface, 382 public OsclMemPoolFixedChunkAllocatorObserver, 383 public PVMFFormatProgDownloadSupportInterface, 384 public PvmiDataStreamObserver, 385 public PVMIDatastreamuserInterface, 386 public OsclMemPoolResizableAllocatorObserver, 387 public PvmfDataSourcePlaybackControlInterface, 388 public PVMFCPMPluginLicenseInterface 389 #if PV_HAS_SHOUTCAST_SUPPORT_ENABLED 390 , public PVMFMetadataUpdatesObserver 391 #endif 392 { 393 public: 394 PVMFMP3FFParserNode(int32 aPriority = OsclActiveObject::EPriorityNominal); 395 ~PVMFMP3FFParserNode(); 396 397 //from PVMFNodeInterface 398 PVMFStatus ThreadLogon(); 399 PVMFStatus ThreadLogoff(); 400 PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability); 401 PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL); 402 PVMFCommandId QueryUUID(PVMFSessionId, const PvmfMimeString& aMimeType, 403 Oscl_Vector<PVUuid, PVMFMP3FFParserNodeAllocator>& aUuids, 404 bool aExactUuidsOnly = false, const OsclAny* aContext = NULL); 405 PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid, 406 PVInterface*& aInterfacePtr, const OsclAny* aContext = NULL); 407 PVMFCommandId RequestPort(PVMFSessionId, int32 aPortTag, const PvmfMimeString* aPortConfig = NULL, const OsclAny* aContext = NULL); 408 PVMFCommandId ReleasePort(PVMFSessionId, PVMFPortInterface& aPort, const OsclAny* aContext = NULL); 409 PVMFCommandId Init(PVMFSessionId, const OsclAny* aContext = NULL); 410 PVMFCommandId Prepare(PVMFSessionId, const OsclAny* aContext = NULL); 411 PVMFCommandId Start(PVMFSessionId, const OsclAny* aContext = NULL); 412 PVMFCommandId Stop(PVMFSessionId, const OsclAny* aContext = NULL); 413 PVMFCommandId Flush(PVMFSessionId, const OsclAny* aContext = NULL); 414 PVMFCommandId Pause(PVMFSessionId, const OsclAny* aContext = NULL); 415 PVMFCommandId Reset(PVMFSessionId, const OsclAny* aContext = NULL); 416 PVMFCommandId CancelAllCommands(PVMFSessionId, const OsclAny* aContextData = NULL); 417 PVMFCommandId CancelCommand(PVMFSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL); 418 PVMFStatus QueryInterfaceSync(PVMFSessionId aSession, 419 const PVUuid& aUuid, 420 PVInterface*& aInterfacePtr); 421 422 //From PVMFDataSourceInitializationExtensionInterface 423 void addRef(); 424 void removeRef(); 425 bool queryInterface(const PVUuid& uuid, PVInterface *& iface); 426 427 PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData); 428 PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock); 429 PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock); 430 431 //From PVMFTrackSelectionExtensionInterface 432 PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo); 433 PVMFStatus SelectTracks(PVMFMediaPresentationInfo& aInfo); 434 435 #if PV_HAS_SHOUTCAST_SUPPORT_ENABLED 436 //From PVMFMetadataUpdatesObserver 437 void MetadataUpdated(uint32 aMetadataSize); 438 #endif 439 // From PVMFMetadataExtensionInterface 440 uint32 GetNumMetadataKeys(char* aQueryKeyString = NULL); 441 uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList); 442 PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, 443 uint32 aStartingKeyIndex, int32 aMaxValueEntries, char* aQueryKeyString = NULL, const OsclAny* aContextData = NULL); 444 PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, 445 Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 aStartingValueIndex, int32 aMaxValueEntries, const OsclAny* aContextData = NULL); 446 PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, uint32 aStartingKeyIndex, uint32 aEndKeyIndex); 447 PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 aStartingValueIndex, uint32 aEndValueIndex); 448 449 // From PvmfDataSourcePlaybackControlInterface 450 virtual PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId, 451 PVMFTimestamp aTargetNPT, 452 PVMFTimestamp& aActualNPT, 453 PVMFTimestamp& aActualMediaDataTS, 454 bool aSeekToSyncPoint = true, 455 uint32 aStreamID = 0, 456 OsclAny* aContext = NULL); 457 458 virtual PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId, 459 PVMFTimestamp aTargetNPT, 460 PVMFTimestamp& aActualNPT, 461 bool aSeekToSyncPoint = true, 462 OsclAny* aContext = NULL); 463 464 virtual PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId, 465 PVMFTimestamp aTargetNPT, 466 PVMFTimestamp& aSeekPointBeforeTargetNPT, 467 PVMFTimestamp& aSeekPointAfterTargetNPT, 468 OsclAny* aContext = NULL, 469 bool aSeekToSyncPoint = true); 470 471 virtual PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId, 472 int32 aRate, 473 PVMFTimebase* aTimebase = NULL, 474 OsclAny* aContext = NULL); 475 476 /* From PVMFFormatProgDownloadSupportInterface */ 477 int32 convertSizeToTime(uint32 fileSize, uint32& aNPTInMS); 478 bool setProtocolInfo(Oscl_Vector<PvmiKvp*, OsclMemAllocator>& aInfoKvpVec); 479 void setFileSize(const uint32 aFileSize); 480 void setDownloadProgressInterface(PVMFDownloadProgressInterface* download_progress); 481 void playResumeNotification(bool aDownloadComplete); 482 void notifyDownloadComplete() 483 { 484 playResumeNotification(true); 485 }; 486 487 /* From PVMIDatastreamuserInterface */ 488 void PassDatastreamFactory(PVMFDataStreamFactory& aFactory, 489 int32 aFactoryTag, 490 const PvmfMimeString* aFactoryConfig = NULL); 491 492 void PassDatastreamReadCapacityObserver(PVMFDataStreamReadCapacityObserver* aObserver); 493 494 /* From PVMFCPMPluginLicenseInterface */ 495 PVMFStatus GetLicenseURL(PVMFSessionId aSessionId, 496 OSCL_wString& aContentName, 497 OSCL_wString& aLicenseURL) 498 { 499 OSCL_UNUSED_ARG(aSessionId); 500 OSCL_UNUSED_ARG(aContentName); 501 OSCL_UNUSED_ARG(aLicenseURL); 502 //must use Async method. 503 return PVMFErrNotSupported; 504 } 505 PVMFStatus GetLicenseURL(PVMFSessionId aSessionId, 506 OSCL_String& aContentName, 507 OSCL_String& aLicenseURL) 508 { 509 OSCL_UNUSED_ARG(aSessionId); 510 OSCL_UNUSED_ARG(aContentName); 511 OSCL_UNUSED_ARG(aLicenseURL); 512 //must use Async method. 513 return PVMFErrNotSupported; 514 } 515 516 PVMFCommandId GetLicense(PVMFSessionId aSessionId, 517 OSCL_wString& aContentName, 518 OsclAny* aData, 519 uint32 aDataSize, 520 int32 aTimeoutMsec, 521 OsclAny* aContextData) ; 522 523 PVMFCommandId GetLicense(PVMFSessionId aSessionId, 524 OSCL_String& aContentName, 525 OsclAny* aData, 526 uint32 aDataSize, 527 int32 aTimeoutMsec, 528 OsclAny* aContextData); 529 530 PVMFCommandId CancelGetLicense(PVMFSessionId aSessionId 531 , PVMFCommandId aCmdId 532 , OsclAny* aContextData); 533 534 private: 535 PVMFStatus CheckForMP3HeaderAvailability(); 536 PVMFStatus GetFileOffsetForAutoResume(uint32& aOffset, PVMP3FFNodeTrackPortInfo* aTrackPortInfo); 537 PVMFStatus ParseShoutcastMetadata(char* aMetadataBuf, uint32 aMetadataSize, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aKvpVector); 538 539 void Construct(); 540 541 //from OsclActiveObject 542 void Run(); 543 544 // Port processing 545 PVMFStatus ProcessOutgoingMsg(PVMFPortInterface* aPort); 546 bool HandleOutgoingQueueReady(PVMFPortInterface* aPortInterface); 547 548 //Command processing 549 PVMFCommandId QueueCommandL(PVMFMP3FFParserNodeCommand&); 550 void ProcessCommand(); 551 void CommandComplete(PVMFMP3FFParserNodeCmdQ&, PVMFMP3FFParserNodeCommand&, PVMFStatus, PVInterface*extmsg, OsclAny* aData); 552 void CompleteInit(PVMFStatus aStatus); 553 bool FlushPending(); 554 555 //Command handlers. 556 PVMFStatus DoReset(PVMFMP3FFParserNodeCommand&); 557 PVMFStatus DoQueryUuid(PVMFMP3FFParserNodeCommand&); 558 PVMFStatus DoQueryInterface(PVMFMP3FFParserNodeCommand&); 559 PVMFStatus DoRequestPort(PVMFMP3FFParserNodeCommand&, PVMFPortInterface*&); 560 PVMFStatus DoReleasePort(PVMFMP3FFParserNodeCommand&); 561 PVMFStatus DoInit(PVMFMP3FFParserNodeCommand&); 562 PVMFStatus DoPrepare(PVMFMP3FFParserNodeCommand&); 563 PVMFStatus DoStart(PVMFMP3FFParserNodeCommand&); 564 PVMFStatus DoStop(PVMFMP3FFParserNodeCommand&); 565 PVMFStatus DoFlush(PVMFMP3FFParserNodeCommand&); 566 PVMFStatus DoPause(PVMFMP3FFParserNodeCommand&); 567 PVMFStatus DoCancelAllCommands(PVMFMP3FFParserNodeCommand&); 568 PVMFStatus DoCancelCommand(PVMFMP3FFParserNodeCommand&); 569 PVMFStatus DoGetMetadataKeys(PVMFMP3FFParserNodeCommand&); 570 PVMFStatus DoGetMetadataValues(PVMFMP3FFParserNodeCommand&); 571 PVMFStatus DoSetDataSourceRate(PVMFMP3FFParserNodeCommand&); 572 PVMFStatus DoSetDataSourcePosition(PVMFMP3FFParserNodeCommand&); 573 PVMFStatus DoQueryDataSourcePosition(PVMFMP3FFParserNodeCommand&); 574 575 // Event reporting 576 void ReportErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL); 577 void ReportInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, PVInterface*aExtMsg = NULL); 578 void SetState(TPVMFNodeInterfaceState); 579 580 bool HandleTrackState(); 581 bool RetrieveTrackData(PVMP3FFNodeTrackPortInfo& aTrackPortInfo); 582 bool SendTrackData(PVMP3FFNodeTrackPortInfo& aTrackPortInfo); 583 bool SendEndOfTrackCommand(PVMP3FFNodeTrackPortInfo& aTrackPortInfo); 584 bool SendBeginOfMediaStreamCommand(PVMP3FFNodeTrackPortInfo& aTrackPortInfo); 585 int32 FindTrackID(PVMFFormatType aFormatType); 586 PVMFStatus ParseFile(); 587 bool CreateFormatSpecificInfo(uint32 numChannels, uint32 samplingRate); 588 589 void ResetTrack(); 590 void ReleaseTrack(); 591 void RemoveAllCommands(); 592 void CleanupFileSource(); 593 594 //from PVMFPortActivityHandler 595 void HandlePortActivity(const PVMFPortActivity& aActivity); 596 597 // From OsclMemPoolFixedChunkAllocatorObserver 598 void freechunkavailable(OsclAny*); 599 // From OsclMemPoolResizableAllocatorObserver 600 void freeblockavailable(OsclAny*); 601 602 // From PvmiDataStreamObserver 603 void DataStreamCommandCompleted(const PVMFCmdResp& aResponse); 604 void DataStreamInformationalEvent(const PVMFAsyncEvent& aEvent); 605 void DataStreamErrorEvent(const PVMFAsyncEvent& aEvent); 606 PVMFStatus CreateMP3FileObject(MP3ErrorType &aSuccess, PVMFCPMPluginAccessInterfaceFactory*aCPM); 607 PVMFStatus SetupParserObject(); 608 PVMFStatus PushBackCPMMetadataKeys(PVMFMetadataList *&aKeyListPtr, uint32 aLcv); 609 610 protected: 611 void Push(PVMFSubNodeContainerBaseMp3&, PVMFSubNodeContainerBaseMp3::CmdType); 612 PVMFCPMContainerMp3 iCPMContainer; 613 614 // private member variables 615 private: 616 617 #if PV_HAS_SHOUTCAST_SUPPORT_ENABLED 618 // shoutcast related 619 int32 iClipByteRate; 620 int32 iMetadataBufSize; 621 uint32 iMetadataSize; 622 int32 iMetadataInterval; 623 Oscl_Vector<PvmiKvp, OsclMemAllocator> iMetadataVector; 624 625 PVMFShoutcastStreamParserFactory* iSCSPFactory; 626 PVMFShoutcastStreamParser* iSCSP; 627 uint8 *iMetadataBuf; 628 #endif 629 630 // Vector of ports contained in this node 631 PVMFPortVector<PVMFMP3FFParserPort, PVMFMP3FFParserNodeAllocator> iPortVector; 632 633 // command queues 634 PVMFMP3FFParserNodeCmdQ iInputCommands; 635 PVMFMP3FFParserNodeCmdQ iCurrentCommand; 636 PVMFMP3FFParserNodeCmdQ iCancelCommand; 637 638 // stream id 639 uint32 iStreamID; 640 // Parse status 641 bool iParseStatus; 642 643 PVMFNodeCapability iCapability; 644 645 OSCL_wHeapString<OsclMemAllocator> iSourceURL; 646 bool iSourceURLSet; 647 PVMFFormatType iSourceFormat; 648 PVMFSourceContextData iSourceContextData; 649 bool iSourceContextDataValid; 650 OsclFileHandle* iFileHandle; 651 PVMFLocalDataSource iCPMSourceData; 652 Oscl_FileServer iFileServer; 653 IMpeg3File* iMP3File; 654 //MP3Parser* pMP3Parser; 655 uint32 iConfigOk; 656 uint32 iExtensionRefCount; 657 int iMaxFrameSize; 658 PVMP3FFNodeTrackPortInfo iTrack; //The track that this node is streaming. Current assumption is one track supported per node. 659 uint32 iMP3FormatBitrate; 660 bool iFileSizeRecvd; 661 uint32 iFileSize; 662 // Logger 663 PVLogger *iLogger; 664 665 // Channel sample info stored in a OsclRefCounterMemFrag 666 OsclMemAllocDestructDealloc<uint8> iDecodeFormatSpecificInfoAlloc; 667 OsclRefCounterMemFrag iDecodeFormatSpecificInfo; 668 bool iSendDecodeFormatSpecificInfo; 669 670 /* These vars are used for the prog. download to auto pause*/ 671 static const uint32 iTIMESTAMPDELTA; 672 OsclSharedPtr<PVMFMediaClock> iDownloadProgressClock; 673 PVMFDownloadProgressInterface* iDownloadProgressInterface; 674 bool iAutoPaused; 675 bool iDownloadComplete; 676 PvmiDataStreamCommandId iRequestReadCapacityNotificationID; 677 uint32 iMP3MetaDataSize; 678 679 // Data Stream vars 680 PVMIDataStreamSyncInterface* iDataStreamInterface; 681 PVMFDataStreamFactory* iDataStreamFactory; 682 PVMFDataStreamReadCapacityObserver* iDataStreamReadCapacityObserver; 683 PvmiDataStreamSession iDataStreamSessionID; 684 685 //metadata related 686 uint32 iMP3ParserNodeMetadataValueCount; 687 Oscl_Vector<OSCL_HeapString<PVMFMP3FFParserNodeAllocator>, PVMFMP3FFParserNodeAllocator> iCPMMetadataKeys; 688 PVMFStatus CompleteGetMetadataKeys(PVMFMP3FFParserNodeCommand& aCmd); 689 690 //for CPM 691 bool oWaitingOnLicense; 692 PVMFCommandId iCPMGetMetaDataKeysCmdId; 693 PVMFCommandId iCPMGetMetaDataValuesCmdId; 694 class SubNodeCmd 695 { 696 public: 697 PVMFSubNodeContainerBaseMp3* iSubNodeContainer; 698 PVMFSubNodeContainerBaseMp3::CmdType iCmd; 699 }; 700 Oscl_Vector<SubNodeCmd, OsclMemAllocator> iSubNodeCmdVec; 701 702 PVMFStatus DoGetLicense(PVMFMP3FFParserNodeCommand& aCmd, 703 bool aWideCharVersion = false); 704 PVMFStatus DoCancelGetLicense(PVMFMP3FFParserNodeCommand& aCmd); 705 void CompleteGetLicense(); 706 void GetCPMMetaDataKeys(); 707 708 PVMp3DurationCalculator* iDurationCalcAO; 709 friend class PVMFSubNodeContainerBaseMp3; 710 friend class PVMFCPMContainerMp3; 711 friend class PVMFMP3FFParserPort; 712 friend class PVMp3DurationCalculator; 713 714 bool iCheckForMP3HeaderDuringInit; 715 }; 716 717 #endif // PVMF_MP3FFPARSER_NODE_H_INCLUDED 718 719