static void gst_amc_audio_dec_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); GstAmcAudioDecClass *amcaudiodec_class = GST_AMC_AUDIO_DEC_CLASS (g_class); const GstAmcCodecInfo *codec_info; GstPadTemplate *templ; GstCaps *caps; gchar *longname; codec_info = g_type_get_qdata (G_TYPE_FROM_CLASS (g_class), gst_amc_codec_info_quark); /* This happens for the base class and abstract subclasses */ if (!codec_info) return; amcaudiodec_class->codec_info = codec_info; /* Add pad templates */ caps = create_sink_caps (codec_info); templ = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps); gst_element_class_add_pad_template (element_class, templ); gst_caps_unref (caps); caps = create_src_caps (codec_info); templ = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, caps); gst_element_class_add_pad_template (element_class, templ); gst_caps_unref (caps); longname = g_strdup_printf ("Android MediaCodec %s", codec_info->name); gst_element_class_set_metadata (element_class, codec_info->name, "Codec/Decoder/Audio", longname, "Sebastian Dröge <*****@*****.**>"); g_free (longname); }
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 }