• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_fileinput_port.h
20  */
21 
22 #ifndef PVMF_FILEINPUT_PORT_H_INCLUDED
23 #define PVMF_FILEINPUT_PORT_H_INCLUDED
24 
25 #ifndef OSCL_BASE_H_INCLUDED
26 #include "oscl_base.h"
27 #endif
28 #ifndef PVLOGGER_H_INCLUDED
29 #include "pvlogger.h"
30 #endif
31 #ifndef PVMF_PORT_BASE_IMPL_H_INCLUDED
32 #include "pvmf_port_base_impl.h"
33 #endif
34 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
35 #include "pvmi_config_and_capability.h"
36 #endif
37 
38 //Default vector reserve size
39 #define PVMF_FILEINPUT_NODE_PORT_VECTOR_RESERVE 10
40 
41 // Capability mime strings
42 #define PVMF_FILEINPUT_PORT_INPUT_FORMATS OUTPUT_FORMATS_CUR_QUERY
43 #define PVMF_FILEINPUT_PORT_INPUT_FORMATS_VALTYPE OUTPUT_FORMATS_VALTYPE
44 #define INPORT_CAPACITY 0
45 #define INPORT_RESERVE 0
46 #define INPORT_THRESOLD 0
47 #define OUTPORT_CAPACITY 10
48 #define OUTPORT_RESERVE 0
49 #define OUTPORT_THRESOLD 70
50 /**
51  * An example of a PVMF port implementation.
52  *
53  * Input (sink) ports have a simple flow control scheme.
54  * Ports report "busy" when their queue is full, then when the
55  * queue goes to half-empty they issue a "get data" to the connected
56  * port.  The media message in the "get data" is empty and is
57  * meant to be discarded.
58  * Output (source) ports assume the connected port uses the
59  * same flow-control scheme.
60  */
61 class PVMFFileDummyInputPort : public PvmfPortBaseImpl,
62         public PvmiCapabilityAndConfig
63 {
64     public:
65         /**
66          * Default constructor. Default settings will be used for the data queues.
67          * @param aId ID assigned to this port
68          * @param aTag Port tag
69          * @param aNode Container node
70          */
71         PVMFFileDummyInputPort(int32 aTag
72                                , PVMFNodeInterface* aNode);
73 
74         /**
75          * Constructor that allows the node to configure the data queues of this port.
76          * @param aTag Port tag
77          * @param aNode Container node
78          * @param aSize Data queue capacity. The data queue size will not grow beyond this capacity.
79          * @param aReserve Size of data queue for which memory is reserved. This must be
80          * less than or equal to the capacity. If this is less than capacity, memory will be
81          * allocated when the queue grows beyond the reserve size, but will stop growing at
82          * capacity.
83          * @param aThreshold Ready-to-receive threshold, in terms of percentage of the data queue capacity.
84          * This value should be between 0 - 100.
85          */
86         PVMFFileDummyInputPort(int32 aTag
87                                , PVMFNodeInterface* aNode
88                                , uint32 aInCapacity
89                                , uint32 aInReserve
90                                , uint32 aInThreshold
91                                , uint32 aOutCapacity
92                                , uint32 aOutReserve
93                                , uint32 aOutThreshold);
94 
95         /** Destructor */
96         ~PVMFFileDummyInputPort();
97 
98         // Implement pure virtuals from PvmiCapabilityAndConfig interface
99         OSCL_IMPORT_REF void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
100         OSCL_IMPORT_REF PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
101                 PvmiKvp*& aParameters, int& num_parameter_elements,
102                 PvmiCapabilityContext aContext);
103         OSCL_IMPORT_REF PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
104         OSCL_IMPORT_REF void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
105         OSCL_IMPORT_REF void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
106                 PvmiKvp* aParameters, int num_parameter_elements);
107         OSCL_IMPORT_REF void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
108         OSCL_IMPORT_REF void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
109                                                int num_elements, PvmiKvp * & aRet_kvp);
110         OSCL_IMPORT_REF PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters,
111                 int num_elements, PvmiKvp*& aRet_kvp, OsclAny* context = NULL);
112         OSCL_IMPORT_REF uint32 getCapabilityMetric(PvmiMIOSession aSession);
113         OSCL_IMPORT_REF PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
114 
115         // Implement virtuals from PVMFPortBaseImpl
116         OSCL_IMPORT_REF PVMFStatus Connect(PVMFPortInterface* aPort);
QueryInterface(const PVUuid & aUuid,OsclAny * & aPtr)117         void QueryInterface(const PVUuid &aUuid, OsclAny*&aPtr)
118         {
119             if (aUuid == PVMI_CAPABILITY_AND_CONFIG_PVUUID)
120                 aPtr = OSCL_STATIC_CAST(PvmiCapabilityAndConfig*, this);
121             else
122                 aPtr = NULL;
123         }
124         bool IsFormatSupported(PVMFFormatType aFmt);
125         void FormatUpdated();
126 
127     private:
128         void Construct();
129         /**
130          * Allocate a specified number of key-value pairs and set the keys
131          *
132          * @param aKvp Output parameter to hold the allocated key-value pairs
133          * @param aKey Key for the allocated key-value pairs
134          * @param aNumParams Number of key-value pairs to be allocated
135          * @return Completion status
136          */
137         PVMFStatus AllocateKvp(PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
138 
139         /**
140          * Verify one key-value pair parameter against capability of the port and
141          * if the aSetParam flag is set, set the value of the parameter corresponding to
142          * the key.
143          *
144          * @param aKvp Key-value pair parameter to be verified
145          * @param aSetParam If true, set the value of parameter corresponding to the key.
146          * @return PVMFSuccess if parameter is supported, else PVMFFailure
147          */
148         PVMFStatus VerifyAndSetParameter(PvmiKvp* aKvp, bool aSetParam = false);
149 
150         bool pvmiGetPortFormatSpecificInfoSync(const char* aFormatValType, PvmiKvp*& aKvp);
151         bool pvmiSetPortFormatSpecificInfoSync(PvmiCapabilityAndConfig *aPort, const char* aFormatValType);
152 
153         uint32 iNumFramesGenerated; //number of source frames generated.
154         PVMFFormatType iFormat;
155         OsclMemAllocator iAlloc;
156         PVLogger *iLogger;
157         uint32 iTrackConfigSizeFI;
158         uint8* iTrackConfigFI;
159         friend class PVMFDummyFileInputNode;
160 };
161 
162 #endif // PVMF_FILEINPUT_PORT_H_INCLUDED
163 
164 
165 
166