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 19 #ifndef PVMF_PROTOCOLENGINE_NODE_DOWNLOAD_COMMON_H_INCLUDED 20 #define PVMF_PROTOCOLENGINE_NODE_DOWNLOAD_COMMON_H_INCLUDED 21 22 #ifndef PVMF_PROTOCOLENGINE_NODE_COMMON_H_INCLUDED 23 #include "pvmf_protocol_engine_node_common.h" 24 #endif 25 26 #ifndef PVMF_FORMAT_PROGDOWNLOAD_SUPPORT_EXTENSION_H_INCLUDED 27 #include "pvmf_format_progdownload_support_extension.h" 28 #endif 29 30 #ifndef PVDL_CONFIG_FILE_H_INCLUDED 31 #include "pvdl_config_file.h" 32 #endif 33 34 35 //////////////////////////////////////////////////////////////////////////////////// 36 ////// DownloadContainer 37 //////////////////////////////////////////////////////////////////////////////////// 38 class DownloadContainer : public ProtocolContainer 39 { 40 public: 41 // constructor 42 OSCL_IMPORT_REF DownloadContainer(PVMFProtocolEngineNode *aNode = NULL); ~DownloadContainer()43 virtual ~DownloadContainer() 44 { 45 ; 46 } 47 48 OSCL_IMPORT_REF virtual void deleteProtocolObjects(); 49 OSCL_IMPORT_REF virtual int32 doPreStart(); 50 OSCL_IMPORT_REF virtual bool doPause(); 51 OSCL_IMPORT_REF virtual PVMFStatus doStop(); 52 OSCL_IMPORT_REF virtual void doClear(const bool aNeedDelete = false); 53 OSCL_IMPORT_REF virtual void doCancelClear(); 54 OSCL_IMPORT_REF virtual bool doInfoUpdate(const uint32 downloadStatus); 55 OSCL_IMPORT_REF virtual bool addSourceData(OsclAny* aSourceData); 56 OSCL_IMPORT_REF virtual bool createCfgFile(OSCL_String& aUri); 57 OSCL_IMPORT_REF virtual bool getProxy(OSCL_String& aProxyName, uint32 &aProxyPort); 58 OSCL_IMPORT_REF virtual void setHttpVersion(const uint32 aHttpVersion); 59 OSCL_IMPORT_REF virtual void setHttpExtensionHeaderField(OSCL_String &aFieldKey, 60 OSCL_String &aFieldValue, 61 const HttpMethod aMethod, 62 const bool aPurgeOnRedirect); 63 64 OSCL_IMPORT_REF virtual bool handleContentRangeUnmatch(); 65 OSCL_IMPORT_REF virtual bool downloadUpdateForHttpHeaderAvailable(); 66 OSCL_IMPORT_REF virtual bool isStreamingPlayback(); 67 OSCL_IMPORT_REF virtual bool handleProtocolStateComplete(PVProtocolEngineNodeInternalEvent &aEvent, PVProtocolEngineNodeInternalEventHandler *aEventHandler); 68 OSCL_IMPORT_REF virtual void checkSendResumeNotification(); 69 70 protected: 71 OSCL_IMPORT_REF virtual int32 initNodeOutput(); 72 OSCL_IMPORT_REF virtual bool initProtocol_SetConfigInfo(); 73 OSCL_IMPORT_REF virtual void initDownloadControl(); 74 OSCL_IMPORT_REF virtual void updateDownloadControl(const bool isDownloadComplete = false); isDownloadComplete(const uint32 downloadStatus)75 virtual bool isDownloadComplete(const uint32 downloadStatus) const 76 { 77 return (downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE || 78 downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_TRUNCATED || 79 downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA || 80 downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_BY_SERVER_DISCONNECT); 81 } 82 OSCL_IMPORT_REF virtual bool ignoreThisTimeout(const int32 timerID); needToCheckResumeNotificationMaually()83 virtual bool needToCheckResumeNotificationMaually() 84 { 85 return iNeedCheckResumeNotificationManually; 86 } 87 OSCL_IMPORT_REF void setEventReporterSupportObjects(); 88 89 protected: 90 bool iForceSocketReconnect; 91 bool iNeedCheckResumeNotificationManually; 92 }; 93 94 //////////////////////////////////////////////////////////////////////////////////// 95 ////// pvHttpDownloadOutput 96 //////////////////////////////////////////////////////////////////////////////////// 97 98 // This derived class adds data stream output 99 struct DownloadOutputConfig 100 { 101 bool isResumeDownload; 102 bool isRangeSupport; 103 bool isNeedOpenDataStream; 104 105 // constructor DownloadOutputConfigDownloadOutputConfig106 DownloadOutputConfig() : isResumeDownload(false), 107 isRangeSupport(true), 108 isNeedOpenDataStream(true) 109 { 110 ; 111 } 112 }; 113 114 class pvHttpDownloadOutput : public PVMFProtocolEngineNodeOutput 115 { 116 public: 117 OSCL_IMPORT_REF void setOutputObject(OsclAny* aOutputObject, const uint32 aObjectType = NodeOutputType_InputPortForData); 118 OSCL_IMPORT_REF int32 initialize(OsclAny* aInitInfo = NULL); 119 OSCL_IMPORT_REF virtual int32 flushData(const uint32 aOutputType = NodeOutputType_InputPortForData); 120 OSCL_IMPORT_REF virtual void discardData(const bool aNeedReopen = false); 121 OSCL_IMPORT_REF uint32 getAvailableOutputSize(); 122 OSCL_IMPORT_REF uint32 getMaxAvailableOutputSize(); 123 124 // constructor and destructor 125 OSCL_IMPORT_REF pvHttpDownloadOutput(PVMFProtocolEngineNodeOutputObserver *aObserver = NULL); 126 OSCL_IMPORT_REF virtual ~pvHttpDownloadOutput(); 127 128 protected: 129 // write data to data stream object 130 // return~0=0xffffffff for error. 131 OSCL_IMPORT_REF uint32 writeToDataStream(OUTPUT_DATA_QUEUE &aOutputQueue); 132 OSCL_IMPORT_REF bool writeToDataStream(uint8 *aBuffer, uint32 aBufferLen); 133 OSCL_IMPORT_REF virtual int32 openDataStream(OsclAny* aInitInfo); 134 // reset 135 OSCL_IMPORT_REF virtual void reset(); 136 137 protected: 138 PVMFDataStreamFactory *iDataStreamFactory; 139 PVMIDataStreamSyncInterface *iDataStream; 140 PvmiDataStreamSession iSessionID; // PvmiDataStreamSession = int32 141 bool isOpenDataStream; 142 uint32 iCounter; // for debugging purpose 143 }; 144 145 //////////////////////////////////////////////////////////////////////////////////// 146 ////// pvDownloadControl 147 //////////////////////////////////////////////////////////////////////////////////// 148 149 // This class does auto-resume control and download progress update for event report 150 class DownloadProgressInterface; 151 class pvDownloadControl : public DownloadControlInterface 152 { 153 public: 154 // constructor, may leave for creating download clock 155 OSCL_IMPORT_REF pvDownloadControl(); ~pvDownloadControl()156 virtual ~pvDownloadControl() 157 { 158 clearBody(); 159 } 160 161 162 // set download control supporting objects: 163 // PVMFFormatProgDownloadSupportInterface object, 164 // PVMFDownloadProgressInterface object, 165 // engine playback clock object, 166 // protocol engine object, 167 // DownloadProgressInterface object, (to get the clip duraton) 168 // PVMFProtocolEngineNodeOutput object 169 OSCL_IMPORT_REF void setSupportObject(OsclAny *aDLSupportObject, DownloadControlSupportObjectType aType); 170 171 // From PVMFDownloadProgressInterface API pass down 172 OSCL_IMPORT_REF virtual void requestResumeNotification(const uint32 currentNPTReadPosition, bool& aDownloadComplete, bool& aNeedSendUnderflowEvent); 173 OSCL_IMPORT_REF void cancelResumeNotification(); 174 175 // check whether to make resume notification; if needed, then make resume notification 176 // Return value: 1 means making resume notification normally (underflow->auto resume), 177 // 2 means making resume notification for download complete 178 // 0 means anything else 179 OSCL_IMPORT_REF virtual int32 checkResumeNotification(const bool aDownloadComplete = true); 180 181 // From PVMFDownloadProgressInterface API getDownloadClock(OsclSharedPtr<PVMFMediaClock> & aClock)182 virtual void getDownloadClock(OsclSharedPtr<PVMFMediaClock> &aClock) 183 { 184 OSCL_UNUSED_ARG(aClock); 185 } 186 // From PVMFDownloadProgressInterface API setClipDuration(const uint32 aClipDurationMsec)187 void setClipDuration(const uint32 aClipDurationMsec) 188 { 189 iClipDurationMsec = aClipDurationMsec; 190 } 191 192 void setPrevDownloadSize(uint32 aPrevDownloadSize = 0) 193 { 194 iPrevDownloadSize = aPrevDownloadSize; 195 } 196 197 OSCL_IMPORT_REF void clear(); 198 199 // clear several fields for progressive playback repositioning clearPerRequest()200 virtual void clearPerRequest() 201 { 202 ; 203 } 204 // checks if download has completed isDownloadCompletedPerRequest()205 bool isDownloadCompletedPerRequest() 206 { 207 return iDownloadComplete; 208 } 209 210 protected: 211 212 // simple routine to focus on sending resume notification only 213 OSCL_IMPORT_REF virtual void sendResumeNotification(const bool aDownloadComplete); 214 OSCL_IMPORT_REF void sendDownloadCompleteNotification(); 215 216 // auto-resume playback decision 217 OSCL_IMPORT_REF bool isResumePlayback(const uint32 aDownloadRate, const uint32 aCurrDownloadSize, const uint32 aFileSize); 218 219 // create iDlProgressClock, will leave when memory allocation fails 220 OSCL_IMPORT_REF void createDownloadClock(); 221 virtual bool updateDownloadClock() = 0; 222 223 // ready means, download clock has been created, and all the objects have passed down isInfoReady()224 bool isInfoReady() 225 { 226 return !(iDlProgressClock.GetRep() == NULL || 227 iProtocol == NULL || 228 iDownloadProgress == NULL || 229 iNodeOutput == NULL); 230 }; 231 232 // called by isResumePlayback() 233 OSCL_IMPORT_REF virtual bool isDlAlgoPreConditionMet(const uint32 aDownloadRate, 234 const uint32 aDurationMsec, 235 const uint32 aCurrDownloadSize, 236 const uint32 aFileSize); 237 238 // update duration by new playback rate, called by checkAutoResumeAlgoWithConstraint checkNewDuration(const uint32 aCurrDurationMsec,uint32 & aNewDurationMsec)239 virtual bool checkNewDuration(const uint32 aCurrDurationMsec, uint32 &aNewDurationMsec) 240 { 241 aNewDurationMsec = aCurrDurationMsec; 242 return true; 243 } 244 245 // called by checkAutoResumeAlgoWithConstraint() approveAutoResumeDecisionShortCut(const uint32 aCurrDownloadSize,const uint32 aDurationMsec,const uint32 aPlaybackTimeMsec,uint32 & aPlaybackRemainingTimeMsec)246 virtual bool approveAutoResumeDecisionShortCut(const uint32 aCurrDownloadSize, 247 const uint32 aDurationMsec, 248 const uint32 aPlaybackTimeMsec, 249 uint32 &aPlaybackRemainingTimeMsec) 250 { 251 OSCL_UNUSED_ARG(aCurrDownloadSize); 252 OSCL_UNUSED_ARG(aDurationMsec); 253 OSCL_UNUSED_ARG(aPlaybackTimeMsec); 254 OSCL_UNUSED_ARG(aPlaybackRemainingTimeMsec); 255 return false; 256 } 257 258 // No constraint: for file size/clip duration/clip bitrate(i.e. playback rate), one of them must be unavailable, except 259 // file size and clip duration are available, but clip bitrate is unavailable. This only applies on PDL checkAutoResumeAlgoNoConstraint(const uint32 aCurrDownloadSize,const uint32 aFileSize,uint32 & aDurationMsec)260 virtual bool checkAutoResumeAlgoNoConstraint(const uint32 aCurrDownloadSize, 261 const uint32 aFileSize, 262 uint32 &aDurationMsec) 263 { 264 OSCL_UNUSED_ARG(aCurrDownloadSize); 265 OSCL_UNUSED_ARG(aFileSize); 266 OSCL_UNUSED_ARG(aDurationMsec); 267 return false; 268 } 269 270 // adding buffer constraint for the algo, i.e. if buffer constraint meets (or buffer overflows), auto-resume should kick off. isOutputBufferOverflow()271 virtual bool isOutputBufferOverflow() 272 { 273 return false; 274 } 275 276 // handle overflow issue: // result = x*1000/y 277 OSCL_IMPORT_REF uint32 divisionInMilliSec(const uint32 x, const uint32 y); 278 279 protected: 280 // called by checkResumeNotification() 281 OSCL_IMPORT_REF bool checkSendingNotification(const bool aDownloadComplete = false); 282 283 // called by isResumePlayback() 284 // with contraint: file size and clip duration are both available 285 OSCL_IMPORT_REF bool checkAutoResumeAlgoWithConstraint(const uint32 aDownloadRate, 286 const uint32 aRemainingDownloadSize, 287 const uint32 aDurationMsec, 288 const uint32 aFileSize); 289 290 // use fixed-point calculation to replace the float-point calculation: aRemainingDLSize<0.0009*aDownloadRate*aRemainingPlaybackTime 291 OSCL_IMPORT_REF bool approveAutoResumeDecision(const uint32 aRemainingDLSize, 292 const uint32 aDownloadRate, 293 const uint32 aRemainingPlaybackTime); 294 295 // old algorithm 296 OSCL_IMPORT_REF bool isResumePlaybackWithOldAlg(const uint32 aDownloadRate, 297 const uint32 aRemainingDownloadSize); 298 299 // set file size to parser node for the new API, setFileSize() 300 OSCL_IMPORT_REF void setFileSize(const uint32 aFileSize); 301 OSCL_IMPORT_REF bool getPlaybackTimeFromEngineClock(uint32 &aPlaybackTime); setProtocolInfo()302 virtual void setProtocolInfo() 303 { 304 ; 305 } 306 307 private: 308 void updateFileSize(); 309 OSCL_IMPORT_REF void clearBody(); 310 311 312 protected: 313 // download control 314 PVMFTimebase_Tickcount iEstimatedServerClockTimeBase; 315 OsclSharedPtr<PVMFMediaClock> iDlProgressClock; 316 PVMFMediaClock* iCurrentPlaybackClock; 317 PVMFFormatProgDownloadSupportInterface *iProgDownloadSI; 318 HttpBasedProtocol *iProtocol; 319 DownloadProgressInterface *iDownloadProgress; 320 PVMFProtocolEngineNodeOutput *iNodeOutput; 321 PVDlCfgFileContainer *iCfgFileContainer; 322 323 bool iPlaybackUnderflow; 324 bool iDownloadComplete; 325 bool iRequestResumeNotification; 326 bool iFirstResumeNotificationSent; 327 uint32 iCurrentNPTReadPosition; 328 uint32 iClipDurationMsec; 329 uint32 iPlaybackByteRate; 330 uint32 iPrevDownloadSize; 331 uint32 iFileSize; 332 333 bool iDlAlgoPreConditionMet; 334 bool iSetFileSize; 335 bool iSendDownloadCompleteNotification; 336 uint32 iClipByterate; 337 338 PVLogger* iDataPathLogger; 339 }; 340 341 //////////////////////////////////////////////////////////////////////////////////// 342 ////// DownloadProgress 343 //////////////////////////////////////////////////////////////////////////////////// 344 class DownloadProgress : public DownloadProgressInterface 345 { 346 public: 347 348 // cosntructor and destructor 349 OSCL_IMPORT_REF DownloadProgress(); ~DownloadProgress()350 virtual ~DownloadProgress() 351 { 352 reset(); 353 } 354 355 // set download progress supporting objects: 356 // PVMFFormatProgDownloadSupportInterface object, 357 // protocol engine object, 358 // config file object, (for progressive download only) 359 // track selction container (for fastrack download only) 360 // PVMFProtocolEngineNodeOutput object (for fasttrack download only) 361 OSCL_IMPORT_REF virtual void setSupportObject(OsclAny *aDLSupportObject, DownloadControlSupportObjectType aType); 362 363 // updata download progress 364 OSCL_IMPORT_REF bool update(const bool aDownloadComplete = false); 365 366 // return true for the new download progress 367 OSCL_IMPORT_REF bool getNewProgressPercent(uint32 &aProgressPercent); 368 369 // return duration regardless of the difference between progressive download and fasttrack download setClipDuration(const uint32 aClipDurationMsec)370 void setClipDuration(const uint32 aClipDurationMsec) 371 { 372 iDurationMsec = aClipDurationMsec; 373 } 374 375 virtual void setDownloadProgressMode(DownloadProgressMode aMode = DownloadProgressMode_TimeBased) 376 { 377 OSCL_UNUSED_ARG(aMode); 378 } 379 380 381 protected: 382 OSCL_IMPORT_REF virtual uint32 getClipDuration(); 383 OSCL_IMPORT_REF virtual bool updateDownloadClock(const bool aDownloadComplete) = 0; 384 OSCL_IMPORT_REF virtual bool calculateDownloadPercent(uint32 &aDownloadProgressPercent); 385 OSCL_IMPORT_REF virtual void reset(); 386 387 protected: 388 HttpBasedProtocol *iProtocol; 389 PVMFFormatProgDownloadSupportInterface *iProgDownloadSI; 390 PVMFProtocolEngineNodeOutput *iNodeOutput; 391 392 //for progress reports 393 uint32 iCurrProgressPercent; 394 uint32 iPrevProgressPercent; 395 uint32 iDownloadNPTTime; 396 uint32 iDurationMsec; 397 }; 398 399 400 401 //////////////////////////////////////////////////////////////////////////////////// 402 ////// PVMFDownloadDataSourceContainer 403 //////////////////////////////////////////////////////////////////////////////////// 404 405 // This container class wraps the data from all the download source data classes, i.e., 406 // PVMFDownloadDataSourceHTTP, PVMFDownloadDataSourcePVX, PVMFSourceContextDataDownloadHTTP and PVMFSourceContextDataDownloadPVX 407 408 class CPVXInfo; 409 class PVMFDownloadDataSourceContainer 410 { 411 public: 412 bool iHasDataSource; // true means the constainer is already filled in the data source 413 bool iIsNewSession; // true if the downloading a new file, false if keep downloading a partial downloading file 414 uint32 iMaxFileSize; // the max size of the file. 415 uint32 iPlaybackControl; // correspond to PVMFDownloadDataSourceHTTP::TPVPlaybackControl, PVMFSourceContextDataDownloadHTTP::TPVPlaybackControl 416 OSCL_wHeapString<OsclMemAllocator> iConfigFileName; // download config file 417 OSCL_wHeapString<OsclMemAllocator> iDownloadFileName; // local file name of the downloaded clip 418 OSCL_HeapString<OsclMemAllocator> iProxyName; // HTTP proxy name, either ip or dns 419 uint32 iProxyPort; // HTTP proxy port 420 OSCL_HeapString<OsclMemAllocator> iUserID; // UserID string used for HTTP basic/digest authentication 421 OSCL_HeapString<OsclMemAllocator> iUserPasswd; // password string used for HTTP basic/digest authentication 422 423 424 CPVXInfo *iPvxInfo; // Fasttrack only, contains all the info in the .pvx file except the URL 425 426 public: 427 // default constructor PVMFDownloadDataSourceContainer()428 PVMFDownloadDataSourceContainer() 429 { 430 clear(); 431 } 432 isEmpty()433 bool isEmpty() 434 { 435 return !iHasDataSource; 436 } 437 438 // major copy constructor to do type conversion 439 PVMFDownloadDataSourceContainer(OsclAny* aSourceData); 440 441 // add source data 442 bool addSource(OsclAny* aSourceData); 443 clear()444 void clear() 445 { 446 iHasDataSource = false; 447 iIsNewSession = true; 448 iMaxFileSize = 0; 449 iPlaybackControl = 0; 450 iProxyPort = 0; 451 iPvxInfo = NULL; 452 } 453 454 private: 455 // type conversion routine for each download source data class 456 void copy(const PVMFDownloadDataSourceHTTP& aSourceData); 457 void copy(const PVMFDownloadDataSourcePVX& aSourceData); 458 void copy(const PVMFSourceContextDataDownloadHTTP& aSourceData); 459 void copy(const PVMFSourceContextDataDownloadPVX& aSourceData); 460 PVMFSourceContextDataDownloadHTTP::TPVPlaybackControl convert(const PVMFDownloadDataSourceHTTP::TPVPlaybackControl aPlaybackControl); 461 }; 462 463 464 465 //////////////////////////////////////////////////////////////////////////////////// 466 ////// PVDlCfgFileContainer and its derived class definition 467 //////////////////////////////////////////////////////////////////////////////////// 468 class PVDlCfgFileContainer 469 { 470 public: ~PVDlCfgFileContainer()471 virtual ~PVDlCfgFileContainer() {} 472 PVDlCfgFileContainer(PVMFDownloadDataSourceContainer * aDataSource)473 PVDlCfgFileContainer(PVMFDownloadDataSourceContainer *aDataSource) : 474 iPlaybackMode(PVMFDownloadDataSourceHTTP::EAsap), 475 iDataSource(aDataSource) 476 { 477 iDataPathLogger = PVLogger::GetLoggerObject("datapath.sourcenode.protocolenginenode"); 478 } 479 480 OSCL_IMPORT_REF virtual PVMFStatus createCfgFile(OSCL_String &aUrl); setDataSource(PVMFDownloadDataSourceContainer * aDataSource)481 void setDataSource(PVMFDownloadDataSourceContainer *aDataSource) 482 { 483 iDataSource = aDataSource; 484 } 485 486 // get API getCfgFile()487 OsclSharedPtr<PVDlCfgFile> &getCfgFile() 488 { 489 return iCfgFileObj; 490 } getPlaybackMode()491 PVMFDownloadDataSourceHTTP::TPVPlaybackControl getPlaybackMode() 492 { 493 return iPlaybackMode; 494 } isEmpty()495 bool isEmpty() 496 { 497 return (iCfgFileObj.GetRep() == NULL); 498 } saveConfig()499 virtual void saveConfig() 500 { 501 if (!isEmpty()) iCfgFileObj->SaveConfig(); 502 } 503 504 protected: 505 OSCL_IMPORT_REF virtual PVMFStatus configCfgFile(OSCL_String &aUrl); 506 OSCL_IMPORT_REF PVMFStatus loadOldConfig(); // utility function for configCfgFile() 507 508 protected: 509 OsclSharedPtr<PVDlCfgFile> iCfgFileObj; 510 PVMFDownloadDataSourceHTTP::TPVPlaybackControl iPlaybackMode; 511 PVMFDownloadDataSourceContainer *iDataSource; 512 PVLogger* iDataPathLogger; 513 }; 514 515 //////////////////////////////////////////////////////////////////////////////////// 516 ////// downloadEventReporter 517 //////////////////////////////////////////////////////////////////////////////////// 518 519 class downloadEventReporter : public EventReporter 520 { 521 public: 522 // constructor 523 OSCL_IMPORT_REF downloadEventReporter(EventReporterObserver *aObserver); 524 525 OSCL_IMPORT_REF virtual void setSupportObject(OsclAny *aSupportObject, EventReporterSupportObjectType aType); 526 OSCL_IMPORT_REF virtual bool checkReportEvent(const uint32 downloadStatus); 527 OSCL_IMPORT_REF virtual void clear(); 528 OSCL_IMPORT_REF bool checkContentInfoEvent(const uint32 downloadStatus); 529 530 // enable some specific events 531 OSCL_IMPORT_REF void sendDataReadyEvent(); 532 OSCL_IMPORT_REF void enableBufferingCompleteEvent(); 533 OSCL_IMPORT_REF void sendBufferStatusEvent(); 534 535 protected: needToCheckContentInfoEvent()536 virtual bool needToCheckContentInfoEvent() 537 { 538 return true; 539 } 540 OSCL_IMPORT_REF virtual void checkUnexpectedDataAndServerDisconnectEvent(const uint32 downloadStatus); 541 542 // supporting function for checkReportEvent() 543 OSCL_IMPORT_REF bool checkBufferInfoEvent(const uint32 downloadStatus); 544 // check and send buffer complete, data ready and unexpected data events 545 OSCL_IMPORT_REF void checkBufferCompleteEvent(const uint32 downloadStatus); 546 OSCL_IMPORT_REF void checkUnexpectedDataEvent(const uint32 downloadStatus); 547 OSCL_IMPORT_REF virtual void checkServerDisconnectEvent(const uint32 downloadStatus); 548 // for checkContentInfoEvent() 549 OSCL_IMPORT_REF bool checkContentLengthOrTooLarge(); 550 OSCL_IMPORT_REF bool checkContentTruncated(const uint32 downloadStatus); 551 OSCL_IMPORT_REF int32 isDownloadFileTruncated(const uint32 downloadStatus); isDownloadComplete(const uint32 downloadStatus)552 bool isDownloadComplete(const uint32 downloadStatus) const 553 { 554 return (downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE || 555 downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_TRUNCATED || 556 downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_WITH_EXTRA_DATA || 557 downloadStatus == PROCESS_SUCCESS_END_OF_MESSAGE_BY_SERVER_DISCONNECT); 558 } 559 // will be overriden in case of PS 560 // called by sendBufferStatusEventBody() 561 OSCL_IMPORT_REF virtual void reportBufferStatusEvent(const uint32 aDownloadPercent); 562 563 protected: 564 bool iSendBufferStartInfoEvent; 565 bool iSendBufferCompleteInfoEvent; 566 bool iSendMovieAtomCompleteInfoEvent; 567 bool iSendInitialDataReadyEvent; 568 bool iSendContentLengthEvent; 569 bool iSendContentTruncateEvent; 570 bool iSendContentTypeEvent; 571 bool iSendUnexpectedDataEvent; 572 bool iSendServerDisconnectEvent; 573 574 // supporting objects 575 DownloadProgressInterface *iDownloadProgress; 576 HttpBasedProtocol *iProtocol; 577 PVDlCfgFileContainer *iCfgFileContainer; 578 PVMFProtocolEngineNodeTimer *iNodeTimer; 579 InterfacingObjectContainer *iInterfacingObjectContainer; 580 PVMFProtocolEngineNodeOutput *iNodeOutput; 581 582 private: 583 void sendBufferStatusEventBody(const bool aForceToSend = false); 584 585 private: 586 uint32 iPrevDownloadProgress; 587 }; 588 589 #endif 590 591