|
OpenMAXBellagio 0.9.3
|
00001 00026 #include <string.h> 00027 #include <unistd.h> 00028 #include <omxcore.h> 00029 #include <OMX_Core.h> 00030 #include <OMX_Component.h> 00031 00032 #include "omx_base_component.h" 00033 #include "omx_base_audio_port.h" 00034 00051 OMX_ERRORTYPE base_audio_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,omx_base_PortType **openmaxStandPort,OMX_U32 nPortIndex, OMX_BOOL isInput) { 00052 OMX_ERRORTYPE err; 00053 omx_base_audio_PortType *omx_base_audio_Port; 00054 00055 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s of component %p\n", __func__, openmaxStandComp); 00056 if (!(*openmaxStandPort)) { 00057 *openmaxStandPort = calloc(1, sizeof(omx_base_audio_PortType)); 00058 } 00059 00060 if (!(*openmaxStandPort)) { 00061 return OMX_ErrorInsufficientResources; 00062 } 00063 00064 err = base_port_Constructor(openmaxStandComp,openmaxStandPort,nPortIndex, isInput); 00065 if (err != OMX_ErrorNone) { 00066 DEBUG(DEB_LEV_ERR, "In %s base port constructor failed\n", __func__); 00067 return err; 00068 } 00069 00070 omx_base_audio_Port = (omx_base_audio_PortType *)*openmaxStandPort; 00071 00072 setHeader(&omx_base_audio_Port->sAudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE)); 00073 omx_base_audio_Port->sAudioParam.nPortIndex = nPortIndex; 00074 omx_base_audio_Port->sAudioParam.nIndex = 0; 00075 omx_base_audio_Port->sAudioParam.eEncoding = OMX_AUDIO_CodingUnused; 00076 00077 omx_base_audio_Port->sPortParam.eDomain = OMX_PortDomainAudio; 00078 omx_base_audio_Port->sPortParam.format.audio.cMIMEType = malloc(DEFAULT_MIME_STRING_LENGTH); 00079 if (!omx_base_audio_Port->sPortParam.format.audio.cMIMEType) { 00080 DEBUG(DEB_LEV_ERR, "Memory allocation failed in %s\n", __func__); 00081 return OMX_ErrorInsufficientResources; 00082 } 00083 strcpy(omx_base_audio_Port->sPortParam.format.audio.cMIMEType, "raw/audio"); 00084 omx_base_audio_Port->sPortParam.format.audio.pNativeRender = 0; 00085 omx_base_audio_Port->sPortParam.format.audio.bFlagErrorConcealment = OMX_FALSE; 00086 omx_base_audio_Port->sPortParam.format.audio.eEncoding = OMX_AUDIO_CodingUnused; 00087 00088 omx_base_audio_Port->sPortParam.nBufferSize = (isInput == OMX_TRUE)?DEFAULT_IN_BUFFER_SIZE:DEFAULT_OUT_BUFFER_SIZE ; 00089 00090 omx_base_audio_Port->PortDestructor = &base_audio_port_Destructor; 00091 00092 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s of component %p\n", __func__, openmaxStandComp); 00093 return OMX_ErrorNone; 00094 } 00095 00108 OMX_ERRORTYPE base_audio_port_Destructor(omx_base_PortType *openmaxStandPort){ 00109 OMX_ERRORTYPE err; 00110 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s of port %p\n", __func__, openmaxStandPort); 00111 if(openmaxStandPort->sPortParam.format.audio.cMIMEType) { 00112 free(openmaxStandPort->sPortParam.format.audio.cMIMEType); 00113 openmaxStandPort->sPortParam.format.audio.cMIMEType = NULL; 00114 } 00115 err = base_port_Destructor(openmaxStandPort); 00116 if (err != OMX_ErrorNone) { 00117 DEBUG(DEB_LEV_ERR, "In %s base port destructor failed\n", __func__); 00118 return err; 00119 } 00120 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s of port %p\n", __func__, openmaxStandPort); 00121 return OMX_ErrorNone; 00122 }