OpenMAX Bellagio 0.9.3
omx_base_clock_port.c
Go to the documentation of this file.
1
26#include <string.h>
27#include <unistd.h>
28#include <omxcore.h>
29#include <OMX_Core.h>
30#include <OMX_Component.h>
31#include "omx_base_component.h"
32#include "omx_base_clock_port.h"
33
50OMX_ERRORTYPE base_clock_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,omx_base_PortType **openmaxStandPort,OMX_U32 nPortIndex, OMX_BOOL isInput) {
52 omx_base_clock_PortType *omx_base_clock_Port;
53
54 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s of component %p\n", __func__, openmaxStandComp);
55 if (!(*openmaxStandPort)) {
56 *openmaxStandPort = calloc(1,sizeof (omx_base_clock_PortType));
57 }
58
59 if (!(*openmaxStandPort)) {
61 }
62
63 err = base_port_Constructor(openmaxStandComp,openmaxStandPort,nPortIndex, isInput);
64 if (err != OMX_ErrorNone) {
65 DEBUG(DEB_LEV_ERR, "Base port constructor failed in %s\n", __func__);
66 return err;
67 }
68 omx_base_clock_Port = (omx_base_clock_PortType *)*openmaxStandPort;
69
70 setHeader(&omx_base_clock_Port->sOtherParam, sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE));
71 omx_base_clock_Port->sOtherParam.nPortIndex = nPortIndex;
72 omx_base_clock_Port->sOtherParam.nIndex = 0;
73 omx_base_clock_Port->sOtherParam.eFormat = OMX_OTHER_FormatTime;
74
75 omx_base_clock_Port->sPortParam.eDomain = OMX_PortDomainOther;
76 omx_base_clock_Port->sPortParam.format.other.eFormat = OMX_OTHER_FormatTime;
77 omx_base_clock_Port->sPortParam.nBufferSize = sizeof(OMX_TIME_MEDIATIMETYPE) ;
78 omx_base_clock_Port->sPortParam.nBufferCountActual = 1;
79 omx_base_clock_Port->sPortParam.nBufferCountMin = 1;
80 omx_base_clock_Port->sPortParam.format.other.eFormat = OMX_OTHER_FormatTime;
81
82 setHeader(&omx_base_clock_Port->sTimeStamp, sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
83 omx_base_clock_Port->sTimeStamp.nPortIndex = nPortIndex;
84 omx_base_clock_Port->sTimeStamp.nTimestamp = 0x00;
85
86
87 setHeader(&omx_base_clock_Port->sMediaTime, sizeof(OMX_TIME_MEDIATIMETYPE));
88 omx_base_clock_Port->sMediaTime.nClientPrivate = 0;
89 omx_base_clock_Port->sMediaTime.nOffset = 0x0;
90 omx_base_clock_Port->sMediaTime.xScale = 1;
91
92 setHeader(&omx_base_clock_Port->sMediaTimeRequest, sizeof(OMX_TIME_MEDIATIMETYPE));
93 omx_base_clock_Port->sMediaTimeRequest.nPortIndex = nPortIndex;
94 omx_base_clock_Port->sMediaTimeRequest.pClientPrivate = NULL;
95 omx_base_clock_Port->sMediaTimeRequest.nOffset = 0x0;
96
98 omx_base_clock_Port->PortDestructor = &base_clock_port_Destructor;
99
100 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s of component %p\n", __func__, openmaxStandComp);
101 return OMX_ErrorNone;
102}
103
118 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s of component %p\n", __func__, openmaxStandPort->standCompContainer);
119 err = base_port_Destructor(openmaxStandPort);
120 if (err != OMX_ErrorNone) {
121 DEBUG(DEB_LEV_ERR, "Base port destructor failed in %s\n", __func__);
122 return err;
123 }
124 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s of component %p\n", __func__, openmaxStandPort->standCompContainer);
125 return OMX_ErrorNone;
126}
127
134 omx_base_PortType *openmaxStandPort,
135 OMX_BUFFERHEADERTYPE* pBuffer) {
136
138 int errQue;
139 OMX_U32 portIndex;
140 OMX_COMPONENTTYPE* omxComponent = openmaxStandPort->standCompContainer;
141 omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)omxComponent->pComponentPrivate;
142 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s of component %p\n", __func__, omxComponent);
143#if NO_GST_OMX_PATCH
144 unsigned int i;
145#endif
146 portIndex = (openmaxStandPort->sPortParam.eDir == OMX_DirInput)?pBuffer->nInputPortIndex:pBuffer->nOutputPortIndex;
147 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s portIndex %lu\n", __func__, portIndex);
148
149 if (portIndex != openmaxStandPort->sPortParam.nPortIndex) {
150 DEBUG(DEB_LEV_ERR, "In %s: wrong port for this operation portIndex=%d port->portIndex=%d\n", __func__, (int)portIndex, (int)openmaxStandPort->sPortParam.nPortIndex);
152 }
153
154 if(omx_base_component_Private->state == OMX_StateInvalid) {
155 DEBUG(DEB_LEV_ERR, "In %s: we are in OMX_StateInvalid\n", __func__);
157 }
158
159 if(omx_base_component_Private->state != OMX_StateExecuting &&
160 omx_base_component_Private->state != OMX_StatePause &&
161 omx_base_component_Private->state != OMX_StateIdle) {
162 DEBUG(DEB_LEV_ERR, "In %s: we are not in executing/paused/idle state, but in %d\n", __func__, omx_base_component_Private->state);
164 }
165 if (!PORT_IS_ENABLED(openmaxStandPort) || (PORT_IS_BEING_DISABLED(openmaxStandPort) && !PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(openmaxStandPort)) ||
166 ((omx_base_component_Private->transientState == OMX_TransStateExecutingToIdle ||
167 omx_base_component_Private->transientState == OMX_TransStatePauseToIdle) &&
168 (PORT_IS_TUNNELED(openmaxStandPort) && !PORT_IS_BUFFER_SUPPLIER(openmaxStandPort)))) {
169 DEBUG(DEB_LEV_ERR, "In %s: Port %d is disabled comp = %s \n", __func__, (int)portIndex,omx_base_component_Private->name);
171 }
172
173 /* Temporarily disable this check for gst-openmax */
174#if NO_GST_OMX_PATCH
175 {
176 OMX_BOOL foundBuffer = OMX_FALSE;
177 if(pBuffer!=NULL && pBuffer->pBuffer!=NULL) {
178 for(i=0; i < openmaxStandPort->sPortParam.nBufferCountActual; i++){
179 if (pBuffer->pBuffer == openmaxStandPort->pInternalBufferStorage[i]->pBuffer) {
180 foundBuffer = OMX_TRUE;
181 break;
182 }
183 }
184 }
185 if (!foundBuffer) {
187 }
188 }
189#endif
190
191 if ((err = checkHeader(pBuffer, sizeof(OMX_BUFFERHEADERTYPE))) != OMX_ErrorNone) {
192 DEBUG(DEB_LEV_ERR, "In %s: received wrong buffer header on input port\n", __func__);
193 return err;
194 }
195 /*If port is not tunneled then simply return the buffer except paused state*/
196 if (!PORT_IS_TUNNELED(openmaxStandPort) && (omx_base_component_Private->state != OMX_StatePause)) {
197 openmaxStandPort->ReturnBufferFunction(openmaxStandPort,pBuffer);
198 return OMX_ErrorNone;
199 }
200
201 /* And notify the buffer management thread we have a fresh new buffer to manage */
202 if(!PORT_IS_BEING_FLUSHED(openmaxStandPort) && !(PORT_IS_BEING_DISABLED(openmaxStandPort) && PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(openmaxStandPort))){
203 errQue = queue(openmaxStandPort->pBufferQueue, pBuffer);
204 if (errQue) {
205 /* /TODO the queue is full. This can be handled in a fine way with
206 * some retrials, or other checking. For the moment this is a critical error
207 * and simply causes the failure of this call
208 */
210 }
211 tsem_up(openmaxStandPort->pBufferSem);
212 DEBUG(DEB_LEV_PARAMS, "In %s Signalling bMgmtSem Port Index=%d\n",__func__, (int)portIndex);
213 tsem_up(omx_base_component_Private->bMgmtSem);
214 } else if(PORT_IS_BUFFER_SUPPLIER(openmaxStandPort)){
215 DEBUG(DEB_LEV_FULL_SEQ, "In %s: Comp %s received io:%d buffer\n",
216 __func__,omx_base_component_Private->name,(int)openmaxStandPort->sPortParam.nPortIndex);
217 errQue = queue(openmaxStandPort->pBufferQueue, pBuffer);
218 if (errQue) {
219 /* /TODO the queue is full. This can be handled in a fine way with
220 * some retrials, or other checking. For the moment this is a critical error
221 * and simply causes the failure of this call
222 */
224 }
225 tsem_up(openmaxStandPort->pBufferSem);
226 }
227 else { // If port being flushed and not tunneled then return error
228 DEBUG(DEB_LEV_ERR, "Port flushed but not tunneled in %s \n", __func__);
230 }
231 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s of component %p\n", __func__, omx_base_component_Private);
232 return OMX_ErrorNone;
233}
OMX_ERRORTYPE
Definition: OMX_Core.h:127
@ OMX_ErrorInvalidState
Definition: OMX_Core.h:162
@ OMX_ErrorInsufficientResources
Definition: OMX_Core.h:131
@ OMX_ErrorBadPortIndex
Definition: OMX_Core.h:224
@ OMX_ErrorNone
Definition: OMX_Core.h:128
@ OMX_ErrorBadParameter
Definition: OMX_Core.h:147
@ OMX_ErrorIncorrectStateOperation
Definition: OMX_Core.h:215
@ OMX_OTHER_FormatTime
Definition: OMX_Other.h:51
struct OMX_TIME_MEDIATIMETYPE OMX_TIME_MEDIATIMETYPE
unsigned long OMX_U32
Definition: OMX_Types.h:145
OMX_BOOL
Definition: OMX_Types.h:189
@ OMX_TRUE
Definition: OMX_Types.h:191
@ OMX_FALSE
Definition: OMX_Types.h:190
@ OMX_DirInput
Definition: OMX_Types.h:226
@ OMX_PortDomainOther
Definition: OMX_Component.h:54
@ OMX_StateExecuting
Definition: OMX_Core.h:105
@ OMX_StateInvalid
Definition: OMX_Core.h:94
@ OMX_StateIdle
Definition: OMX_Core.h:102
@ OMX_StatePause
Definition: OMX_Core.h:107
OMX_ERRORTYPE base_clock_port_Destructor(omx_base_PortType *openmaxStandPort)
the base clock port destructor for the generic OpenMAX ST clock port
OMX_ERRORTYPE base_clock_port_SendBufferFunction(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE *pBuffer)
the entry point for sending buffers to the port
OMX_ERRORTYPE base_clock_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, omx_base_PortType **openmaxStandPort, OMX_U32 nPortIndex, OMX_BOOL isInput)
the base constructor for the generic OpenMAX ST Clock port
void setHeader(OMX_PTR header, OMX_U32 size)
Simply fills the first two fields in any OMX structure with the size and the version.
OMX_ERRORTYPE checkHeader(OMX_PTR header, OMX_U32 size)
Checks the header of a structure for consistency with size and spec version.
@ OMX_TransStateExecutingToIdle
@ OMX_TransStatePauseToIdle
OMX_ERRORTYPE base_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, omx_base_PortType **openmaxStandPort, OMX_U32 nPortIndex, OMX_BOOL isInput)
The base contructor for the generic OpenMAX ST port.
Definition: omx_base_port.c:55
OMX_ERRORTYPE base_port_Destructor(omx_base_PortType *openmaxStandPort)
The base destructor for the generic OpenMAX ST port.
#define PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(pPort)
Definition: omx_base_port.h:46
#define PORT_IS_BUFFER_SUPPLIER(pPort)
Definition: omx_base_port.h:45
#define PORT_IS_TUNNELED(pPort)
Definition: omx_base_port.h:43
#define PORT_IS_BEING_DISABLED(pPort)
Definition: omx_base_port.h:40
#define PORT_IS_ENABLED(pPort)
Definition: omx_base_port.h:41
#define PORT_IS_BEING_FLUSHED(pPort)
Definition: omx_base_port.h:39
#define DEB_LEV_PARAMS
#define DEB_LEV_FUNCTION_NAME
#define DEB_LEV_ERR
#define DEB_LEV_FULL_SEQ
#define DEBUG(n, fmt, args...)
OMX_ERRORTYPE err
int queue(queue_t *queue, void *data)
Definition: queue.c:103
OMX_U32 nOutputPortIndex
Definition: OMX_Core.h:439
OMX_U32 nInputPortIndex
Definition: OMX_Core.h:441
OMX_PTR pComponentPrivate
OMX_OTHER_FORMATTYPE eFormat
Definition: OMX_Other.h:329
OMX_OTHER_FORMATTYPE eFormat
Definition: OMX_Other.h:318
union OMX_PARAM_PORTDEFINITIONTYPE::@0 format
OMX_PORTDOMAINTYPE eDomain
Definition: OMX_Component.h:77
OMX_OTHER_PORTDEFINITIONTYPE other
Definition: OMX_Component.h:82
OMX_PARAM_PORTDEFINITIONTYPE sPortParam
OMX_COMPONENTTYPE * standCompContainer
queue_t * pBufferQueue
OMX_ERRORTYPE(* ReturnBufferFunction)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_BUFFERHEADERTYPE ** pInternalBufferStorage
OMX_TIME_CONFIG_TIMESTAMPTYPE sTimeStamp
OMX_ERRORTYPE(* PortDestructor)(omx_base_PortType *openmaxStandPort)
OMX_OTHER_PARAM_PORTFORMATTYPE sOtherParam
OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE sMediaTimeRequest
OMX_PARAM_PORTDEFINITIONTYPE sPortParam
OMX_ERRORTYPE(* Port_SendBufferFunction)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_TIME_MEDIATIMETYPE sMediaTime
void tsem_up(tsem_t *tsem)
Definition: tsemaphore.c:110

Generated for OpenMAX Bellagio rel. 0.9.3 by  doxygen 1.5.1
SourceForge.net Logo