static void setup_ports (GstOmxBaseFilter * self) { /* Input port configuration. */ g_omx_port_setup (self->in_port); gst_pad_set_element_private (self->sinkpad, self->in_port); /* Output port configuration. */ g_omx_port_setup (self->out_port); gst_pad_set_element_private (self->srcpad, self->out_port); /* @todo: read from config file: */ if (g_getenv ("OMX_ALLOCATE_ON")) { GST_DEBUG_OBJECT (self, "OMX_ALLOCATE_ON"); self->in_port->omx_allocate = TRUE; self->out_port->omx_allocate = TRUE; self->share_input_buffer = FALSE; self->share_output_buffer = FALSE; } else if (g_getenv ("OMX_SHARE_HACK_ON")) { GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_ON"); self->share_input_buffer = TRUE; self->share_output_buffer = TRUE; } else if (g_getenv ("OMX_SHARE_HACK_OFF")) { GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_OFF"); self->share_input_buffer = FALSE; self->share_output_buffer = FALSE; } else { GST_DEBUG_OBJECT (self, "default sharing and allocation"); } GST_DEBUG_OBJECT (self, "omx_allocate: in: %d, out: %d", self->in_port->omx_allocate, self->out_port->omx_allocate); GST_DEBUG_OBJECT (self, "share_buffer: in: %d, out: %d", self->share_input_buffer, self->share_output_buffer); }
static void setup_ports (GstOmxBaseSink * self) { /* Input port configuration. */ g_omx_port_setup (self->in_port); gst_pad_set_element_private (self->sinkpad, self->in_port); }
static void setup_ports (GstOmxBaseFilter2 *self) { OMX_PARAM_PORTDEFINITIONTYPE param; int i; gboolean omx_allocate, share_buffer; gboolean set_omx_allocate = FALSE, set_share_buffer = FALSE; if (g_getenv ("OMX_ALLOCATE_ON")) { GST_DEBUG_OBJECT (self, "OMX_ALLOCATE_ON"); omx_allocate = TRUE; share_buffer = FALSE; set_omx_allocate = set_share_buffer = TRUE; } else if (g_getenv ("OMX_SHARE_HACK_ON")) { GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_ON"); share_buffer = TRUE; set_share_buffer = TRUE; } else if (g_getenv ("OMX_SHARE_HACK_OFF")) { GST_DEBUG_OBJECT (self, "OMX_SHARE_HACK_OFF"); share_buffer = FALSE; set_share_buffer = TRUE; } /* Input port configuration. */ G_OMX_PORT_GET_DEFINITION (self->in_port, ¶m); g_omx_port_setup (self->in_port, ¶m); gst_pad_set_element_private (self->sinkpad, self->in_port); if (set_omx_allocate) self->in_port->omx_allocate = omx_allocate; if (set_share_buffer) self->in_port->share_buffer = share_buffer; /* Output port configuration. */ for (i = 0; i < NUM_OUTPUTS; i++) { G_OMX_PORT_GET_DEFINITION (self->out_port[i], ¶m); g_omx_port_setup (self->out_port[i], ¶m); gst_pad_set_element_private (self->srcpad[i], self->out_port[i]); if (set_omx_allocate) self->out_port[i]->omx_allocate = omx_allocate; if (set_share_buffer) self->out_port[i]->share_buffer = share_buffer; } }
static void setup_ports (GstOmxBaseSrc *self) { /* Input port configuration. */ g_omx_port_setup (self->out_port); if (self->setup_ports) { self->setup_ports (self); } }
void gst_omx_base_src_setup_ports (GstOmxBaseSrc *self) { OMX_PARAM_PORTDEFINITIONTYPE param; /* Output port configuration. */ G_OMX_PORT_GET_DEFINITION (self->out_port, ¶m); g_omx_port_setup (self->out_port, ¶m); if (self->setup_ports) { self->setup_ports (self); } }
GOmxPort * g_omx_core_setup_port (GOmxCore *core, OMX_PARAM_PORTDEFINITIONTYPE *omx_port) { GOmxPort *port; guint index; index = omx_port->nPortIndex; port = g_omx_core_get_port (core, index); if (!port) { port = g_omx_port_new (core); } g_omx_port_setup (port, omx_port); g_ptr_array_insert (core->ports, index, port); return port; }
static void omx_setup (GstOmxBaseFilter21 *omx_base) { int i; GOmxCore *gomx; OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_PARAM_BUFFER_MEMORYTYPE memTypeCfg; OMX_PARAM_PORTDEFINITIONTYPE paramPort; OMX_CONFIG_VSWMOSAIC_CREATEMOSAICLAYOUT sMosaic; OMX_CONFIG_VSWMOSAIC_SETBACKGROUNDCOLOR sMosaicBg; OMX_PARAM_VSWMOSAIC_MOSAIC_PERIODICITY sMosaicFPS; GstOmxBaseFilter21 *self; gomx = (GOmxCore *) omx_base->gomx; self = GST_OMX_BASE_FILTER21(omx_base); GST_LOG_OBJECT (self, "begin"); /* set the output cap */ gst_pad_set_caps (self->srcpad, create_src_caps (omx_base)); /* Setting Memory type at input port to Raw Memory */ GST_LOG_OBJECT (self, "Setting input port to Raw memory"); _G_OMX_INIT_PARAM (&memTypeCfg); memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT; for ( i = 0; i < NUM_INPUTS; i++) { memTypeCfg.nPortIndex = omx_base->in_port[i]->port_index; eError = OMX_SetParameter (gomx->omx_handle, OMX_TI_IndexParamBuffMemType, &memTypeCfg); if (eError != OMX_ErrorNone) { return; } } /* Setting Memory type at output port to Raw Memory */ GST_LOG_OBJECT (self, "Setting output port to Raw memory"); memTypeCfg.nPortIndex = omx_base->out_port->port_index; memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT; eError = OMX_SetParameter (gomx->omx_handle, OMX_TI_IndexParamBuffMemType, &memTypeCfg); if (eError != OMX_ErrorNone) { return; } GST_LOG_OBJECT (self, "Setting port definition (input)"); for ( i = 0; i < NUM_INPUTS; i++) { /* set input height/width and color format */ G_OMX_PORT_GET_DEFINITION (omx_base->in_port[i], ¶mPort); paramPort.format.video.nFrameWidth = self->in_width[i]; paramPort.format.video.nFrameHeight = self->in_height[i]; /* swmosaic is connceted to scalar, whose stride is different than width*/ paramPort.format.video.nStride = self->in_stride[i]; paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; paramPort.format.video.eColorFormat = OMX_COLOR_FormatYCbYCr; paramPort.nBufferSize = (paramPort.format.video.nStride * paramPort.format.video.nFrameHeight); paramPort.nBufferAlignment = 0; paramPort.bBuffersContiguous = 0; G_OMX_PORT_SET_DEFINITION (omx_base->in_port[i], ¶mPort); g_omx_port_setup (omx_base->in_port[i], ¶mPort); } G_OMX_PORT_GET_DEFINITION (omx_base->out_port, ¶mPort); paramPort.format.video.nFrameWidth = self->out_width; paramPort.format.video.nFrameHeight = self->out_height; paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; paramPort.format.video.eColorFormat = OMX_COLOR_FormatYCbYCr; paramPort.nBufferAlignment = 0; paramPort.bBuffersContiguous = 0; paramPort.nBufferCountActual = 4; paramPort.format.video.nStride = self->out_stride; paramPort.nBufferSize = paramPort.format.video.nStride * paramPort.format.video.nFrameHeight; G_OMX_PORT_SET_DEFINITION (omx_base->out_port, ¶mPort); g_omx_port_setup (omx_base->out_port, ¶mPort); _G_OMX_INIT_PARAM (&sMosaic); sMosaic.nPortIndex = OMX_VSWMOSAIC_OUTPUT_PORT_START_INDEX; sMosaic.nOpWidth = self->out_width; /* Width in pixels */ sMosaic.nOpHeight = self->out_height; /* Height in pixels */ sMosaic.nOpPitch = self->out_stride; /* Pitch in bytes */ sMosaic.nNumWindows = 2; sMosaic.sMosaicWinFmt[0].dataFormat = OMX_COLOR_FormatYCbYCr; sMosaic.sMosaicWinFmt[0].nPortIndex = 0; sMosaic.sMosaicWinFmt[0].pitch[0] = self->in_stride[0]; sMosaic.sMosaicWinFmt[0].winStartX = self->x[0]; sMosaic.sMosaicWinFmt[0].winStartY = self->y[0]; sMosaic.sMosaicWinFmt[0].winWidth = self->in_width[0]; sMosaic.sMosaicWinFmt[0].winHeight = self->in_height[0]; sMosaic.sMosaicWinFmt[1].dataFormat = OMX_COLOR_FormatYCbYCr; sMosaic.sMosaicWinFmt[1].nPortIndex = 1; sMosaic.sMosaicWinFmt[1].pitch[0] = self->in_stride[1]; sMosaic.sMosaicWinFmt[1].winStartX = self->x[1]; sMosaic.sMosaicWinFmt[1].winStartY = self->y[1]; sMosaic.sMosaicWinFmt[1].winWidth = self->in_width[1]; sMosaic.sMosaicWinFmt[1].winHeight = self->in_height[1]; eError = OMX_SetConfig (gomx->omx_handle, OMX_TI_IndexConfigVSWMOSAICCreateMosaicLayout, &sMosaic); if (eError != OMX_ErrorNone) { printf("Error during Layout settings\n"); } _G_OMX_INIT_PARAM(&sMosaicBg); sMosaicBg.nPortIndex = OMX_VSWMOSAIC_OUTPUT_PORT_START_INDEX; sMosaicBg.uColor = BG_COLOR; eError = OMX_SetConfig (gomx->omx_handle, OMX_TI_IndexConfigVSWMOSAICSetBackgroundColor, &sMosaicBg); if (eError != OMX_ErrorNone) { printf("Error during background\n"); } // FPS settings didn't work actually #if 1 _G_OMX_INIT_PARAM(&sMosaicFPS); sMosaicFPS.nPortIndex = OMX_VSWMOSAIC_OUTPUT_PORT_START_INDEX; sMosaicFPS.nFps = 60; eError = OMX_SetConfig (gomx->omx_handle, OMX_TI_IndexParamVSWMOSAICMosaicPeriodicity, &sMosaicFPS); if (eError != OMX_ErrorNone) { printf("Error during FPS settings : %s\n",g_omx_error_to_str (eError)); } #endif }