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_SOCKET_PORT_H_INCLUDED 19 #define PVMF_SOCKET_PORT_H_INCLUDED 20 21 #ifndef OSCL_BASE_H_INCLUDED 22 #include "oscl_base.h" 23 #endif 24 #ifndef PVLOGGER_H_INCLUDED 25 #include "pvlogger.h" 26 #endif 27 #ifndef OSCL_SOCKET_TYPES_H_INCLUDED 28 #include "oscl_socket_types.h" 29 #endif 30 #ifndef OSCL_SOCKET_H_INCLUDED 31 #include "oscl_socket.h" 32 #endif 33 #ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED 34 #include "pvmf_port_base_impl.h" 35 #endif 36 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED 37 #include "pvmi_config_and_capability.h" 38 #endif 39 #include "pvmf_node_interface.h" 40 41 #ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED 42 #include "pvmi_config_and_capability_utils.h" 43 #endif 44 #ifndef PVMI_PORT_CONFIG_KVP_H_INCLUDED 45 #include "pvmi_port_config_kvp.h" 46 #endif 47 #ifndef PVMI_PORT_CONFIG_KVP_H_INCLUDED 48 #include "pvmi_port_config_kvp.h" 49 #endif 50 51 //Default vector reserve size 52 #define PVMF_SOCKET_NODE_PORT_VECTOR_RESERVE 10 53 54 // Capability mime strings 55 // Capability mime strings 56 #define PVMF_SOCKET_PORT_SPECIFIC_ALLOCATOR "x-pvmf/pvmfstreaming/socketmemallocator" 57 #define PVMF_SOCKET_PORT_SPECIFIC_ALLOCATOR_VALTYPE "x-pvmf/pvmfstreaming/socketmemallocator;valtype=ksv" 58 59 /** Enumerated list of port tags supported by this port */ 60 typedef enum 61 { 62 PVMF_SOCKET_NODE_PORT_TYPE_UNKNOWN, 63 PVMF_SOCKET_NODE_PORT_TYPE_SOURCE, 64 PVMF_SOCKET_NODE_PORT_TYPE_SINK, 65 PVMF_SOCKET_NODE_PORT_TYPE_PASSTHRU 66 } PVMFSocketNodePortTag; 67 68 class PVMFSocketNode; 69 class SocketPortConfig; 70 71 class PVMFSocketPort : public PvmfPortBaseImpl, 72 public PvmiCapabilityAndConfigPortFormatImpl 73 { 74 public: 75 /** 76 * Default constructor. Default settings will be used for the data queues. 77 * @param aId ID assigned to this port 78 * @param aTag Port tag 79 * @param aNode Container node 80 */ 81 PVMFSocketPort(int32 aTag, PVMFNodeInterface* aNode); 82 83 /** 84 * Constructor that allows the node to configure the data queues of this port. 85 * @param aTag Port tag 86 * @param aNode Container node 87 * @param aSize Data queue capacity. The data queue size will not grow beyond this capacity. 88 * @param aReserve Size of data queue for which memory is reserved. This must be 89 * less than or equal to the capacity. If this is less than capacity, memory will be 90 * allocated when the queue grows beyond the reserve size, but will stop growing at 91 * capacity. 92 * @param aThreshold Ready-to-receive threshold, in terms of percentage of the data queue capacity. 93 * This value should be between 0 - 100. 94 */ 95 PVMFSocketPort(int32 aTag 96 , PVMFNodeInterface* aNode 97 , uint32 aInCapacity 98 , uint32 aInReserve 99 , uint32 aInThreshold 100 , uint32 aOutCapacity 101 , uint32 aOutReserve 102 , uint32 aOutThreshold); 103 104 /** Destructor */ 105 ~PVMFSocketPort(); 106 107 // Implement pure virtuals from PvmiCapabilityAndConfigPortFormatImpl interface 108 bool IsFormatSupported(PVMFFormatType); 109 void FormatUpdated(); 110 111 // this port supports config interface QueryInterface(const PVUuid & aUuid,OsclAny * & aPtr)112 void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr) 113 { 114 if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID) 115 aPtr = (PvmiCapabilityAndConfig*)this; 116 else 117 aPtr = NULL; 118 } 119 120 PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, 121 PvmiKvp*& aParameters, int& num_parameter_elements, PvmiCapabilityContext aContext); 122 void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, 123 int num_elements, PvmiKvp * & aRet_kvp); 124 PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements); 125 126 PVMFStatus PeekIncomingMsg(PVMFSharedMediaMsgPtr& aMsg); 127 128 SocketPortConfig* iConfig; 129 PVMFSocketNodePortTag iPortTag; 130 131 //overrides from PVMFPortInterface so we can skip the outgoing port queue. 132 PVMFStatus QueueOutgoingMsg(PVMFSharedMediaMsgPtr aMsg); 133 bool IsOutgoingQueueBusy(); 134 135 private: 136 void Construct(); 137 bool pvmiGetPortInPlaceDataProcessingInfoSync(const char* aFormatValType, 138 PvmiKvp*& aKvp); 139 PVLogger *iLogger; 140 141 uint32 iNumFramesConsumed; //number of frames consumed & discarded. 142 143 friend class PVMFSocketNode; 144 friend class Oscl_TAlloc<PVMFSocketPort, OsclMemAllocator>; 145 friend class PVMFSocketNodeCustomInterface1Impl; 146 }; 147 148 #endif 149 150