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_PROGRESSIVE_STREAMING_H_INCLUDED 20 #define PVMF_PROTOCOLENGINE_NODE_PROGRESSIVE_STREAMING_H_INCLUDED 21 22 #ifndef PVMF_PROTOCOLENGINE_NODE_PROGRESSIVE_DOWNLOAD_H_INCLUDED 23 #include "pvmf_protocol_engine_node_progressive_download.h" 24 #endif 25 26 27 //////////////////////////////////////////////////////////////////////////////////// 28 ////// ProgressiveStreamingContainer 29 //////////////////////////////////////////////////////////////////////////////////// 30 class ProgressiveStreamingContainer : public ProgressiveDownloadContainer 31 { 32 public: 33 OSCL_IMPORT_REF virtual bool createProtocolObjects(); 34 OSCL_IMPORT_REF PVMFStatus doStop(); 35 OSCL_IMPORT_REF PVMFStatus doSeek(PVMFProtocolEngineNodeCommand& aCmd); 36 OSCL_IMPORT_REF bool completeRepositionRequest(); 37 OSCL_IMPORT_REF bool doInfoUpdate(const uint32 downloadStatus); 38 void enableInfoUpdate(const bool aEnabled = true) 39 { 40 iEnableInfoUpdate = aEnabled; 41 } 42 43 // constructor 44 OSCL_IMPORT_REF ProgressiveStreamingContainer(PVMFProtocolEngineNode *aNode = NULL); 45 46 protected: 47 // called by DoSeek() 48 OSCL_IMPORT_REF uint32 getSeekOffset(PVMFProtocolEngineNodeCommand& aCmd); 49 OSCL_IMPORT_REF PVMFStatus doSeekBody(uint32 aNewOffset); 50 OSCL_IMPORT_REF void updateDownloadControl(const bool isDownloadComplete = false); 51 OSCL_IMPORT_REF bool needToCheckResumeNotificationMaually(); 52 53 protected: 54 bool iEnableInfoUpdate; 55 56 private: 57 void moveToStartedState(); 58 }; 59 60 61 //////////////////////////////////////////////////////////////////////////////////// 62 ////// pvProgressiveStreamingOutput 63 //////////////////////////////////////////////////////////////////////////////////// 64 class pvProgressiveStreamingOutput : public pvHttpDownloadOutput 65 { 66 public: 67 OSCL_IMPORT_REF int32 flushData(const uint32 aOutputType = NodeOutputType_InputPortForData); 68 void discardData(const bool aNeedReopen = false) 69 { 70 OSCL_UNUSED_ARG(aNeedReopen); 71 return; 72 } 73 OSCL_IMPORT_REF bool releaseMemFrag(OsclRefCounterMemFrag* aFrag); 74 // for new data stream APIs 75 OSCL_IMPORT_REF void setContentLength(uint32 aLength); 76 OSCL_IMPORT_REF void dataStreamCommandCompleted(const PVMFCmdResp& aResponse); 77 void setDataStreamSourceRequestObserver(PvmiDataStreamRequestObserver* aObserver) 78 { 79 iSourceRequestObserver = aObserver; 80 } 81 OSCL_IMPORT_REF void flushDataStream(); 82 OSCL_IMPORT_REF bool seekDataStream(const uint32 aSeekOffset); 83 84 // constructor and destructor 85 OSCL_IMPORT_REF pvProgressiveStreamingOutput(PVMFProtocolEngineNodeOutputObserver *aObserver = NULL); 86 virtual ~pvProgressiveStreamingOutput() 87 { 88 flushDataStream(); 89 } 90 91 private: 92 OSCL_IMPORT_REF int32 openDataStream(OsclAny* aInitInfo); 93 // write data to data stream object 94 // return~0=0xffffffff for error. 95 uint32 writeToDataStream(OUTPUT_DATA_QUEUE &aOutputQueue, PENDING_OUTPUT_DATA_QUEUE &aPendingOutputQueue); 96 97 private: 98 PvmiDataStreamRequestObserver* iSourceRequestObserver; 99 }; 100 101 102 //////////////////////////////////////////////////////////////////////////////////// 103 ////// progressiveStreamingControl 104 //////////////////////////////////////////////////////////////////////////////////// 105 class progressiveStreamingControl : public progressiveDownloadControl 106 { 107 public: 108 OSCL_IMPORT_REF void requestResumeNotification(const uint32 currentNPTReadPosition, bool& aDownloadComplete, bool& aNeedSendUnderflowEvent); 109 110 // clear several fields for progressive playback repositioning 111 OSCL_IMPORT_REF void clearPerRequest(); 112 113 // constructor 114 OSCL_IMPORT_REF progressiveStreamingControl(); 115 }; 116 117 //////////////////////////////////////////////////////////////////////////////////// 118 ////// ProgressiveStreamingProgress 119 //////////////////////////////////////////////////////////////////////////////////// 120 class ProgressiveStreamingProgress : public ProgressiveDownloadProgress 121 { 122 public: 123 // constructor 124 ProgressiveStreamingProgress() : ProgressiveDownloadProgress(), iContentLength(0) 125 { 126 ; 127 } 128 129 private: 130 OSCL_IMPORT_REF bool calculateDownloadPercent(uint32 &aDownloadProgressPercent); 131 132 private: 133 uint32 iContentLength; 134 }; 135 136 137 //////////////////////////////////////////////////////////////////////////////////// 138 ////// progressiveStreamingEventReporter 139 //////////////////////////////////////////////////////////////////////////////////// 140 class progressiveStreamingEventReporter : public downloadEventReporter 141 { 142 public: 143 // constructor 144 progressiveStreamingEventReporter(EventReporterObserver *aObserver) : downloadEventReporter(aObserver) 145 { 146 ; 147 } 148 149 private: 150 // in case of progressive streaming, currently do not send PVMFInfoSessionDisconnect event 151 void checkServerDisconnectEvent(const uint32 downloadStatus) 152 { 153 OSCL_UNUSED_ARG(downloadStatus); 154 } 155 // in case of progressive streaming, add buffer fullness information into buffer status report 156 OSCL_IMPORT_REF void reportBufferStatusEvent(int aDownloadPercent); 157 // called by reportBufferStatusEvent 158 uint32 getBufferFullness(); 159 }; 160 161 //////////////////////////////////////////////////////////////////////////////////// 162 ////// PVProgressiveStreamingCfgFileContainer 163 //////////////////////////////////////////////////////////////////////////////////// 164 class PVProgressiveStreamingCfgFileContainer : public PVProgressiveDownloadCfgFileContainer 165 { 166 public: 167 PVProgressiveStreamingCfgFileContainer(PVMFDownloadDataSourceContainer *aDataSource) : PVProgressiveDownloadCfgFileContainer(aDataSource) 168 { 169 ; 170 } 171 172 private: 173 // no need to save data to config file 174 void saveConfig() 175 { 176 ; 177 } 178 }; 179 180 181 #endif 182