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_BUFFER_DATA_SOURCE_H_INCLUDED 19 #define PVMF_BUFFER_DATA_SOURCE_H_INCLUDED 20 21 #ifndef OSCL_MEM_H_INCLUDED 22 #include "oscl_mem.h" 23 #endif 24 25 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED 26 #include "pvmf_node_interface.h" 27 #endif 28 29 #ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED 30 #include "pvmf_port_base_impl.h" 31 #endif 32 33 #ifndef OSCL_TIMER_H_INCLUDED 34 #include "oscl_timer.h" 35 #endif 36 37 #ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED 38 #include "pvmf_simple_media_buffer.h" 39 #endif 40 41 #ifndef PVMF_MEDIA_DATA_H_INCLUDED 42 #include "pvmf_media_data.h" 43 #endif 44 45 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED 46 #include "pvmi_config_and_capability_utils.h" 47 #endif 48 49 class PVMFBufferDataSource : public PvmfPortBaseImpl, 50 public OsclTimerObserver, 51 public PVMFPortActivityHandler, 52 public PvmiCapabilityAndConfig 53 { 54 public: 55 OSCL_IMPORT_REF PVMFBufferDataSource(int32 aPortTag, 56 unsigned bitrate, 57 unsigned min_sample_sz, 58 unsigned max_sample_sz, 59 uint8* fsi = NULL, 60 unsigned fsi_len = 0); 61 OSCL_IMPORT_REF virtual ~PVMFBufferDataSource(); 62 63 void HandlePortActivity(const PVMFPortActivity &); 64 65 // Start/stop the source 66 OSCL_IMPORT_REF void Start(); 67 OSCL_IMPORT_REF void Stop(); 68 69 // PVMFPortInterface virtuals 70 PVMFStatus PutData(PVMFSharedMediaMsgPtr aMsg); 71 PVMFStatus GetData(PVMFSharedMediaMsgPtr aMsg); 72 73 // timer observer 74 virtual void TimeoutOccurred(int32 timerID, int32 timeoutInfo); 75 76 OSCL_IMPORT_REF void QueryInterface(const PVUuid& aUuid, OsclAny*& aPtr); 77 78 // Implement pure virtuals from PvmiCapabilityAndConfig interface 79 OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver); 80 OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, 81 PvmiKvp*& aParameters, int& num_parameter_elements, 82 PvmiCapabilityContext aContext); 83 OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements); 84 OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext); 85 OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, 86 PvmiKvp* aParameters, int num_parameter_elements); 87 OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext); 88 OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, 89 int num_elements, PvmiKvp * & aRet_kvp); 90 OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, 91 int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL); 92 OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession); 93 OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements); 94 protected: 95 unsigned iBitrate; 96 unsigned iMinSampleSz; 97 unsigned iMaxSampleSz; 98 OsclTimer<OsclMemAllocator> iTimer; 99 unsigned iSampleInterval; 100 PVMFTimestamp iTimestamp; 101 PVMFSimpleMediaBufferCombinedAlloc* iMediaDataAlloc; 102 OsclMemAllocator iMemAlloc; 103 uint8* iFsi; 104 unsigned iFsiLen; 105 }; 106 #endif 107