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