本文整理汇总了C++中OMX_INIT_STRUCTURE函数的典型用法代码示例。如果您正苦于以下问题:C++ OMX_INIT_STRUCTURE函数的具体用法?C++ OMX_INIT_STRUCTURE怎么用?C++ OMX_INIT_STRUCTURE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OMX_INIT_STRUCTURE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Lock
OMX_ERRORTYPE COMXCoreComponent::EnablePort(unsigned int port, bool wait)
{
Lock();
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
OMX_PARAM_PORTDEFINITIONTYPE portFormat;
OMX_INIT_STRUCTURE(portFormat);
portFormat.nPortIndex = port;
omx_err = OMX_GetParameter(m_handle, OMX_IndexParamPortDefinition, &portFormat);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXCoreComponent::EnablePort - Error get port %d status on component %s omx_err(0x%08x)",
port, m_componentName.c_str(), (int)omx_err);
}
if(portFormat.bEnabled == OMX_FALSE)
{
omx_err = OMX_SendCommand(m_handle, OMX_CommandPortEnable, port, NULL);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXCoreComponent::EnablePort - Error enable port %d on component %s omx_err(0x%08x)",
port, m_componentName.c_str(), (int)omx_err);
{
UnLock();
return omx_err;
}
}
else
{
if(wait)
omx_err = WaitForCommand(OMX_CommandPortEnable, port);
}
}
UnLock();
return omx_err;
}
示例2: Lock
double OMXClock::OMXClockAdjustment(bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
{
return 0;
}
if(lock)
{
Lock();
}
OMX_ERRORTYPE error = OMX_ErrorNone;
double pts = 0;
OMX_TIME_CONFIG_TIMESTAMPTYPE timeStamp;
OMX_INIT_STRUCTURE(timeStamp);
timeStamp.nPortIndex = m_omx_clock.GetInputPort();
error = m_omx_clock.GetConfig(OMX_IndexConfigClockAdjustment, &timeStamp);
if(error != OMX_ErrorNone)
{
ofLogError(__func__) << "GetConfig OMX_IndexConfigClockAdjustment FAIL: " << COMXCore::getOMXError(error);
if(lock)
{
UnLock();
}
return 0;
}
pts = (double)FromOMXTime(timeStamp.nTimestamp);
//ofLogVerbose(__func__) << "nTimestamp: " << (double)FromOMXTime(timeStamp.nTimestamp) << " pts " << pts;
if(lock)
{
UnLock();
}
return pts;
}
示例3: Lock
// Set the media time, so calls to get media time use the updated value,
// useful after a seek so mediatime is updated immediately (rather than waiting for first decoded packet)
bool OMXClock::OMXMediaTime(double pts, bool lock /* = true*/)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
if(lock)
Lock();
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
OMX_INDEXTYPE index;
OMX_TIME_CONFIG_TIMESTAMPTYPE timeStamp;
OMX_INIT_STRUCTURE(timeStamp);
timeStamp.nPortIndex = m_omx_clock.GetInputPort();
if(m_eClock == OMX_TIME_RefClockAudio)
index = OMX_IndexConfigTimeCurrentAudioReference;
else
index = OMX_IndexConfigTimeCurrentVideoReference;
timeStamp.nTimestamp = ToOMXTime(pts);
omx_err = m_omx_clock.SetConfig(index, &timeStamp);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "OMXClock::OMXMediaTime error setting %s", index == OMX_IndexConfigTimeCurrentAudioReference ?
"OMX_IndexConfigTimeCurrentAudioReference":"OMX_IndexConfigTimeCurrentVideoReference");
if(lock)
UnLock();
return false;
}
CLog::Log(LOGDEBUG, "OMXClock::OMXMediaTime set config %s = %.2f", index == OMX_IndexConfigTimeCurrentAudioReference ?
"OMX_IndexConfigTimeCurrentAudioReference":"OMX_IndexConfigTimeCurrentVideoReference", pts);
m_last_media_time = 0.0f;
if(lock)
UnLock();
return true;
}
示例4: Lock
bool OMXClock::OMXSetSpeed(int speed, bool lock /* = true */, bool pause_resume /* = false */)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
if(lock)
Lock();
sprintf(g_log_buf, "OMXClock::OMXSetSpeed(%.2f) pause_resume:%d",
(float)speed / (float)DVD_PLAYSPEED_NORMAL, pause_resume);
LOG_TRACE_2 << g_log_buf;
if (pause_resume)
{
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
OMX_TIME_CONFIG_SCALETYPE scaleType;
OMX_INIT_STRUCTURE(scaleType);
if (TP(speed))
scaleType.xScale = 0; // for trickplay we just pause, and single step
else
scaleType.xScale = (speed << 16) / DVD_PLAYSPEED_NORMAL;
omx_err = m_omx_clock.SetConfig(OMX_IndexConfigTimeScale, &scaleType);
if(omx_err != OMX_ErrorNone)
{
LOG_ERROR << "OMXClock::OMXSetSpeed error setting OMX_IndexConfigTimeClockState";
if(lock)
UnLock();
return false;
}
}
if (!pause_resume)
m_omx_speed = speed;
m_last_media_time = 0.0f;
if(lock)
UnLock();
return true;
}
示例5: ilctts_set_dest
int32_t ilctts_set_dest(TTSRENDER_STATE_T *st, const char *name) {
OMX_ERRORTYPE omx_err;
OMX_CONFIG_BRCMAUDIODESTINATIONTYPE dest;
char device[8];
if ( (strcmp(name, "local") != 0) && (strcmp(name, "hdmi") != 0) )
strcpy(device, "local");
else
strcpy(device, name);
OMX_INIT_STRUCTURE(dest);
strcpy((char *)dest.sName, device);
omx_err = OMX_SetConfig(ILC_GET_HANDLE(st->audio_render), OMX_IndexConfigBrcmAudioDestination, &dest);
if (omx_err != OMX_ErrorNone) {
ERROR("OMX_SetConfig returned error in ilctts_set_dest: %d", omx_err);
return -1;
}
SHOW(LOGLEVEL_3, "Audio device set to: %s", device);
return 0;
} // end ilctts_set_dest
示例6: OMX_INIT_STRUCTURE
bool OMXClock::OMXSpeed(int speed)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
OMX_TIME_CONFIG_SCALETYPE scaleType;
OMX_INIT_STRUCTURE(scaleType);
scaleType.xScale = (speed << 16);
m_play_speed = speed;
omx_err = OMX_SetConfig(m_omx_clock.GetComponent(), OMX_IndexConfigTimeScale, &scaleType);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "OMXClock::Speed error setting OMX_IndexConfigTimeClockState\n");
return false;
}
return true;
}
示例7: lock
bool COMXVideo::GetPlayerInfo(double &match, double &phase, double &pll)
{
CSingleLock lock (m_critSection);
OMX_ERRORTYPE omx_err;
OMX_CONFIG_BRCMRENDERSTATSTYPE renderstats;
if (!m_hdmi_clock_sync || !m_omx_render.IsInitialized())
return false;
OMX_INIT_STRUCTURE(renderstats);
renderstats.nPortIndex = m_omx_render.GetInputPort();
omx_err = m_omx_render.GetParameter(OMX_IndexConfigBrcmRenderStats, &renderstats);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXVideo::GetPlayerInfo error GetParameter OMX_IndexParamPortDefinition omx_err(0x%08x)\n", omx_err);
return false;
}
match = renderstats.nMatch * 1e-6;
phase = (double)renderstats.nPhase / (double)renderstats.nPeriod;
pll = (double)renderstats.nPixelClock / (double)renderstats.nPixelClockNominal;
return true;
}
示例8: Lock
bool OMXClock::SetSpeed(int speed, bool lock, bool pause_resume)
{
if (!GetComponent())
return false;
if (lock)
Lock();
if (pause_resume)
{
OMX_ERRORTYPE omxErr = OMX_ErrorNone;
OMX_TIME_CONFIG_SCALETYPE scaleType;
OMX_INIT_STRUCTURE(scaleType);
if (TP(speed))
scaleType.xScale = 0;
else
scaleType.xScale = (speed << 16) / CLOCK_PLAYSPEED_NORMAL;
omxErr = SetConfig(OMX_IndexConfigTimeScale, &scaleType);
if (omxErr != OMX_ErrorNone)
{
if (lock)
Unlock();
return false;
}
}
else
m_omxSpeed = speed;
m_lastMediaTime = 0.0f;
if (lock)
Unlock();
return true;
}
示例9: OMX_INIT_STRUCTURE
OMX_ERRORTYPE COpenMaxVideo::AllocOMXInputBuffers(void)
{
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
// Obtain the information about the decoder input port.
OMX_PARAM_PORTDEFINITIONTYPE port_format;
OMX_INIT_STRUCTURE(port_format);
port_format.nPortIndex = m_omx_input_port;
OMX_GetParameter(m_omx_decoder, OMX_IndexParamPortDefinition, &port_format);
#if defined(OMX_DEBUG_VERBOSE)
CLog::Log(LOGDEBUG,
"%s::%s - iport(%d), nBufferCountMin(%lu), nBufferSize(%lu)\n",
CLASSNAME, __func__, m_omx_input_port, port_format.nBufferCountMin, port_format.nBufferSize);
#endif
for (size_t i = 0; i < port_format.nBufferCountMin; i++)
{
OMX_BUFFERHEADERTYPE *buffer = NULL;
// use an external buffer that's sized according to actual demux
// packet size, start at internal's buffer size, will get deleted when
// we start pulling demuxer packets and using demux packet sized buffers.
OMX_U8* data = new OMX_U8[port_format.nBufferSize];
omx_err = OMX_UseBuffer(m_omx_decoder, &buffer, m_omx_input_port, NULL, port_format.nBufferSize, data);
if (omx_err)
{
CLog::Log(LOGERROR, "%s::%s - OMX_UseBuffer failed with omx_err(0x%x)\n",
CLASSNAME, __func__, omx_err);
return(omx_err);
}
m_omx_input_buffers.push_back(buffer);
// don't have to lock/unlock here, we are not decoding
m_omx_input_avaliable.push(buffer);
}
m_omx_input_eos = false;
return(omx_err);
}
示例10: OMX_INIT_STRUCTURE
bool OMXClock::OMXInitialize(bool has_video, bool has_audio)
{
OMX_ERRORTYPE error = OMX_ErrorNone;
const std::string componentName = "OMX.broadcom.clock";
m_has_video = has_video;
m_has_audio = has_audio;
m_pause = false;
if(!m_omx_clock.Initialize(componentName, OMX_IndexParamOtherInit))
{
return false;
}
OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE refClock;
OMX_INIT_STRUCTURE(refClock);
if(m_has_audio)
{
refClock.eClock = OMX_TIME_RefClockAudio;
}
else
{
refClock.eClock = OMX_TIME_RefClockVideo;
}
error = m_omx_clock.SetConfig(OMX_IndexConfigTimeActiveRefClock, &refClock);
if(error != OMX_ErrorNone)
{
ofLogError(__func__) << " setting OMX_IndexConfigTimeCurrentAudioReference";
return false;
}
return true;
}
示例11: lock
OMX_ERRORTYPE Component::enablePort(unsigned int port)//default: wait=false
{
lock();
OMX_ERRORTYPE error;
error = OMX_SendCommand(handle, OMX_CommandPortEnable, port, NULL);
OMX_TRACE(error);
unlock();
return error;
#if 0
OMX_PARAM_PORTDEFINITIONTYPE portFormat;
OMX_INIT_STRUCTURE(portFormat);
portFormat.nPortIndex = port;
OMX_ERRORTYPE error = OMX_GetParameter(handle, OMX_IndexParamPortDefinition, &portFormat);
OMX_TRACE(error);
#ifdef DEBUG_PORTS
ofLogVerbose(__func__) << componentName << " port: " << port;
#endif
if(portFormat.bEnabled == OMX_FALSE)
{
error = OMX_SendCommand(handle, OMX_CommandPortEnable, port, NULL);
OMX_TRACE(error);
if(error != OMX_ErrorNone)
{
unlock();
return error;
}
}
unlock();
return error;
#endif
}
示例12: Lock
bool OMXClock::OMXSpeed(int speed, bool lock /* = true */)
{
if(m_omx_clock.GetComponent() == NULL)
return false;
if(lock)
Lock();
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
OMX_TIME_CONFIG_SCALETYPE scaleType;
OMX_INIT_STRUCTURE(scaleType);
// Modification to adjust the scale accordingly, depending on video playback speed range being in normal or slow motion speed range.
if (speed > OMX_SLOMO_MULTIPLIER) // Normal speed range
scaleType.xScale = ((speed / OMX_SLOMO_MULTIPLIER) << 16); // The number 16 here has nothing to do with OMX_SLOMO_MULTIPLIER
else if (speed >= 1) // Slow Motion range
scaleType.xScale = (1 << (int64_t)(12 + log2(speed))); // This avoids "switch/case" statements but only works well for multiples of 2
else
scaleType.xScale = (speed << 16); // Kept like this for history. Same as "sacleType.xScale = 0;"
m_play_speed = speed;
omx_err = OMX_SetConfig(m_omx_clock.GetComponent(), OMX_IndexConfigTimeScale, &scaleType);
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "OMXClock::Speed error setting OMX_IndexConfigTimeClockState\n");
if(lock)
UnLock();
return false;
}
if(lock)
UnLock();
return true;
}
示例13: setup_tunnel
static void
setup_tunnel(rpi_pixmap_decoder_t *rpd)
{
int dst_width, dst_height;
OMX_PARAM_PORTDEFINITIONTYPE portdef;
if(rpd->rpd_tunnel != NULL)
return;
OMX_INIT_STRUCTURE(portdef);
portdef.nPortIndex = rpd->rpd_decoder->oc_outport;
omxchk(OMX_GetParameter(rpd->rpd_decoder->oc_handle,
OMX_IndexParamPortDefinition, &portdef));
pixmap_compute_rescale_dim(rpd->rpd_im,
portdef.format.image.nFrameWidth,
portdef.format.image.nFrameHeight,
&dst_width, &dst_height);
portdef.nPortIndex = rpd->rpd_resizer->oc_inport;
omxchk(OMX_SetParameter(rpd->rpd_resizer->oc_handle,
OMX_IndexParamPortDefinition, &portdef));
rpd->rpd_tunnel = omx_tunnel_create(rpd->rpd_decoder,
rpd->rpd_decoder->oc_outport,
rpd->rpd_resizer,
rpd->rpd_resizer->oc_inport,
"decoder -> resizer");
OMX_INIT_STRUCTURE(portdef);
portdef.nPortIndex = rpd->rpd_resizer->oc_outport;
omxchk(OMX_GetParameter(rpd->rpd_resizer->oc_handle,
OMX_IndexParamPortDefinition, &portdef));
int stride = (dst_width * 4 + PIXMAP_ROW_ALIGN - 1) & ~(PIXMAP_ROW_ALIGN - 1);
portdef.format.image.eCompressionFormat = OMX_IMAGE_CodingUnused;
portdef.format.image.eColorFormat = OMX_COLOR_Format32bitABGR8888;
portdef.format.image.nFrameWidth = dst_width;
portdef.format.image.nFrameHeight = dst_height;
portdef.format.image.nStride = stride;
portdef.format.image.nSliceHeight = 0;
portdef.format.image.bFlagErrorConcealment = OMX_FALSE;
omxchk(OMX_SetParameter(rpd->rpd_resizer->oc_handle,
OMX_IndexParamPortDefinition, &portdef));
omxchk(OMX_GetParameter(rpd->rpd_resizer->oc_handle,
OMX_IndexParamPortDefinition, &portdef));
omx_set_state(rpd->rpd_resizer, OMX_StateExecuting);
omx_port_enable(rpd->rpd_resizer, rpd->rpd_resizer->oc_outport);
pixmap_t *pm = rpd->rpd_pm = calloc(1, sizeof(pixmap_t));
pm->pm_refcount = 1;
pm->pm_width = portdef.format.image.nFrameWidth;
pm->pm_height = portdef.format.image.nFrameHeight;
pm->pm_linesize = portdef.format.image.nStride;
pm->pm_type = PIXMAP_BGR32;
pm->pm_data = mymemalign(portdef.nBufferAlignment, portdef.nBufferSize);
pm->pm_aspect = (float)pm->pm_width / (float)pm->pm_height;
omxchk(OMX_UseBuffer(rpd->rpd_resizer->oc_handle, &rpd->rpd_buf,
rpd->rpd_resizer->oc_outport,
NULL, portdef.nBufferSize, pm->pm_data));
omx_wait_command(rpd->rpd_resizer);
omxchk(OMX_FillThisBuffer(rpd->rpd_resizer->oc_handle, rpd->rpd_buf));
}
示例14: OMX_INIT_STRUCTURE
OMX_ERRORTYPE COMXCoreComponent::AllocOutputBuffers(bool use_buffers /* = false */)
{
OMX_ERRORTYPE omx_err = OMX_ErrorNone;
if(!m_handle)
return OMX_ErrorUndefined;
m_omx_output_use_buffers = use_buffers;
OMX_PARAM_PORTDEFINITIONTYPE portFormat;
OMX_INIT_STRUCTURE(portFormat);
portFormat.nPortIndex = m_output_port;
omx_err = OMX_GetParameter(m_handle, OMX_IndexParamPortDefinition, &portFormat);
if(omx_err != OMX_ErrorNone)
return omx_err;
if(GetState() != OMX_StateIdle)
{
if(GetState() != OMX_StateLoaded)
SetStateForComponent(OMX_StateLoaded);
SetStateForComponent(OMX_StateIdle);
}
omx_err = EnablePort(m_output_port, false);
if(omx_err != OMX_ErrorNone)
return omx_err;
m_output_alignment = portFormat.nBufferAlignment;
m_output_buffer_count = portFormat.nBufferCountActual;
m_output_buffer_size = portFormat.nBufferSize;
CLog::Log(LOGDEBUG, "COMXCoreComponent::AllocOutputBuffers component(%s) - port(%d), nBufferCountMin(%lu), nBufferCountActual(%lu), nBufferSize(%lu) nBufferAlignmen(%lu)\n",
m_componentName.c_str(), m_output_port, portFormat.nBufferCountMin,
portFormat.nBufferCountActual, portFormat.nBufferSize, portFormat.nBufferAlignment);
for (size_t i = 0; i < portFormat.nBufferCountActual; i++)
{
OMX_BUFFERHEADERTYPE *buffer = NULL;
OMX_U8* data = NULL;
if(m_omx_output_use_buffers)
{
data = (OMX_U8*)_aligned_malloc(portFormat.nBufferSize, m_output_alignment);
omx_err = OMX_UseBuffer(m_handle, &buffer, m_output_port, NULL, portFormat.nBufferSize, data);
}
else
{
omx_err = OMX_AllocateBuffer(m_handle, &buffer, m_output_port, NULL, portFormat.nBufferSize);
}
if(omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXCoreComponent::AllocOutputBuffers component(%s) - OMX_UseBuffer failed with omx_err(0x%x)\n",
m_componentName.c_str(), omx_err);
if(m_omx_output_use_buffers && data)
_aligned_free(data);
return omx_err;
}
buffer->nOutputPortIndex = m_output_port;
buffer->nFilledLen = 0;
buffer->nOffset = 0;
buffer->pAppPrivate = (void*)i;
m_omx_output_buffers.push_back(buffer);
m_omx_output_available.push(buffer);
}
omx_err = WaitForCommand(OMX_CommandPortEnable, m_output_port);
m_flush_output = false;
return omx_err;
}
示例15: omx_err
bool COMXCoreComponent::Initialize( const std::string &component_name, OMX_INDEXTYPE index)
{
OMX_ERRORTYPE omx_err;
if(!m_DllOMX->Load())
return false;
m_DllOMXOpen = true;
m_componentName = component_name;
m_callbacks.EventHandler = &COMXCoreComponent::DecoderEventHandlerCallback;
m_callbacks.EmptyBufferDone = &COMXCoreComponent::DecoderEmptyBufferDoneCallback;
m_callbacks.FillBufferDone = &COMXCoreComponent::DecoderFillBufferDoneCallback;
// Get video component handle setting up callbacks, component is in loaded state on return.
omx_err = m_DllOMX->OMX_GetHandle(&m_handle, (char*)component_name.c_str(), this, &m_callbacks);
if (omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXCoreComponent::Initialize - could not get component handle for %s omx_err(0x%08x)\n",
component_name.c_str(), (int)omx_err);
Deinitialize();
return false;
}
OMX_PORT_PARAM_TYPE port_param;
OMX_INIT_STRUCTURE(port_param);
omx_err = OMX_GetParameter(m_handle, index, &port_param);
if (omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXCoreComponent::Initialize - could not get port_param for component %s omx_err(0x%08x)\n",
component_name.c_str(), (int)omx_err);
}
omx_err = DisableAllPorts();
if (omx_err != OMX_ErrorNone)
{
CLog::Log(LOGERROR, "COMXCoreComponent::Initialize - error disable ports on component %s omx_err(0x%08x)\n",
component_name.c_str(), (int)omx_err);
}
m_input_port = port_param.nStartPortNumber;
m_output_port = m_input_port + 1;
if(m_componentName == "OMX.broadcom.audio_mixer")
{
m_input_port = port_param.nStartPortNumber + 1;
m_output_port = port_param.nStartPortNumber;
}
if (m_output_port > port_param.nStartPortNumber+port_param.nPorts-1)
m_output_port = port_param.nStartPortNumber+port_param.nPorts-1;
CLog::Log(LOGDEBUG, "COMXCoreComponent::Initialize %s input port %d output port %d\n",
m_componentName.c_str(), m_input_port, m_output_port);
m_exit = false;
m_flush_input = false;
m_flush_output = false;
return true;
}