Commit cd6fd1d8 authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

omxil: split iomx_hwbuffer.cpp

As iomx_hwbuffer.cpp contains mainly call to private native window from
system/window.h:

- move system window calls to modules/video_output/android/nativewindowpriv.c
- move get_hal_format to iomx.cpp
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent b0e5abcd
...@@ -427,6 +427,30 @@ OMX_ERRORTYPE PREFIX(OMXAndroid_GetGraphicBufferUsage)(OMX_HANDLETYPE component, ...@@ -427,6 +427,30 @@ OMX_ERRORTYPE PREFIX(OMXAndroid_GetGraphicBufferUsage)(OMX_HANDLETYPE component,
return OMX_ErrorUndefined; return OMX_ErrorUndefined;
return OMX_ErrorNone; return OMX_ErrorNone;
} }
OMX_ERRORTYPE PREFIX(OMXAndroid_GetHalFormat)( const char *comp_name, int* hal_format )
{
if( !strncmp( comp_name, "OMX.SEC.", 8 ) ) {
switch( *hal_format ) {
case OMX_COLOR_FormatYUV420SemiPlanar:
*hal_format = 0x105; // HAL_PIXEL_FORMAT_YCbCr_420_SP
break;
case OMX_COLOR_FormatYUV420Planar:
*hal_format = 0x101; // HAL_PIXEL_FORMAT_YCbCr_420_P
break;
}
}
else if( !strcmp( comp_name, "OMX.TI.720P.Decoder" ) ||
!strcmp( comp_name, "OMX.TI.Video.Decoder" ) )
*hal_format = 0x14; // HAL_PIXEL_FORMAT_YCbCr_422_I
#if ANDROID_API <= 13 // Required on msm8660 on 3.2, not required on 4.1
else if( !strcmp( comp_name, "OMX.qcom.video.decoder.avc" ))
*hal_format = 0x108;
#endif
return OMX_ErrorNone;
}
#endif #endif
} }
...@@ -2050,12 +2050,7 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2050,12 +2050,7 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port )
msg_Dbg( p_dec, "HwBuffer_Init"); msg_Dbg( p_dec, "HwBuffer_Init");
if( !(pf_enable_graphic_buffers && pf_get_graphic_buffer_usage && if( !(pf_enable_graphic_buffers && pf_get_graphic_buffer_usage &&
pf_omx_hwbuffer_connect && pf_omx_hwbuffer_disconnect && pf_get_hal_format &&
pf_omx_hwbuffer_setup && pf_omx_hwbuffer_get_min_undequeued &&
pf_omx_hwbuffer_set_buffer_count && pf_omx_hwbuffer_setcrop &&
pf_omx_hwbuffer_dequeue && pf_omx_hwbuffer_lock &&
pf_omx_hwbuffer_queue && pf_omx_hwbuffer_cancel &&
pf_omx_hwbuffer_get_hal_format &&
((OMX_COMPONENTTYPE*)p_port->omx_handle)->UseBuffer) ) ((OMX_COMPONENTTYPE*)p_port->omx_handle)->UseBuffer) )
{ {
msg_Warn( p_dec, "direct output port enabled but can't find " msg_Warn( p_dec, "direct output port enabled but can't find "
...@@ -2075,6 +2070,11 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2075,6 +2070,11 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port )
msg_Warn( p_dec, "LoadNativeWindowAPI failed" ); msg_Warn( p_dec, "LoadNativeWindowAPI failed" );
goto error; goto error;
} }
if( LoadNativeWindowPrivAPI( &p_port->p_hwbuf->anwpriv ) != 0 )
{
msg_Warn( p_dec, "LoadNativeWindowPrivAPI failed" );
goto error;
}
surf = jni_LockAndGetAndroidJavaSurface(); surf = jni_LockAndGetAndroidJavaSurface();
if( !surf ) { if( !surf ) {
...@@ -2092,7 +2092,7 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2092,7 +2092,7 @@ static void HwBuffer_Init( decoder_t *p_dec, OmxPort *p_port )
msg_Warn( p_dec, "winFromSurface failed" ); msg_Warn( p_dec, "winFromSurface failed" );
goto error; goto error;
} }
pf_omx_hwbuffer_connect( p_port->p_hwbuf->window ); p_port->p_hwbuf->anwpriv.connect( p_port->p_hwbuf->window );
omx_error = pf_enable_graphic_buffers( p_port->omx_handle, omx_error = pf_enable_graphic_buffers( p_port->omx_handle,
p_port->i_port_index, OMX_TRUE ); p_port->i_port_index, OMX_TRUE );
...@@ -2127,7 +2127,7 @@ static void HwBuffer_Destroy( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2127,7 +2127,7 @@ static void HwBuffer_Destroy( decoder_t *p_dec, OmxPort *p_port )
HwBuffer_Stop( p_dec, p_port ); HwBuffer_Stop( p_dec, p_port );
HwBuffer_FreeBuffers( p_dec, p_port ); HwBuffer_FreeBuffers( p_dec, p_port );
HwBuffer_Join( p_dec, p_port ); HwBuffer_Join( p_dec, p_port );
pf_omx_hwbuffer_disconnect( p_port->p_hwbuf->window ); p_port->p_hwbuf->anwpriv.disconnect( p_port->p_hwbuf->window );
pf_enable_graphic_buffers( p_port->omx_handle, pf_enable_graphic_buffers( p_port->omx_handle,
p_port->i_port_index, OMX_FALSE ); p_port->i_port_index, OMX_FALSE );
p_port->p_hwbuf->native_window.winRelease( p_port->p_hwbuf->window ); p_port->p_hwbuf->native_window.winRelease( p_port->p_hwbuf->window );
...@@ -2158,10 +2158,10 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2158,10 +2158,10 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
if( !p_port->p_hwbuf ) if( !p_port->p_hwbuf )
return 0; return 0;
omx_error = pf_omx_hwbuffer_get_hal_format( p_sys->psz_component, &colorFormat ); omx_error = pf_get_hal_format( p_sys->psz_component, &colorFormat );
if( omx_error != OMX_ErrorNone ) if( omx_error != OMX_ErrorNone )
{ {
msg_Warn( p_dec, "pf_omx_hwbuffer_get_hal_format failed (Not fatal)" ); msg_Warn( p_dec, "pf_get_hal_format failed (Not fatal)" );
} }
omx_error = pf_get_graphic_buffer_usage( p_port->omx_handle, omx_error = pf_get_graphic_buffer_usage( p_port->omx_handle,
...@@ -2173,7 +2173,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2173,7 +2173,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
i_hw_usage = 0; i_hw_usage = 0;
} }
if( pf_omx_hwbuffer_setup( p_port->p_hwbuf->window, if( p_port->p_hwbuf->anwpriv.setup( p_port->p_hwbuf->window,
def->format.video.nFrameWidth, def->format.video.nFrameWidth,
def->format.video.nFrameHeight, def->format.video.nFrameHeight,
colorFormat, colorFormat,
...@@ -2183,7 +2183,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2183,7 +2183,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
goto error; goto error;
} }
if( pf_omx_hwbuffer_get_min_undequeued( p_port->p_hwbuf->window, if( p_port->p_hwbuf->anwpriv.getMinUndequeued( p_port->p_hwbuf->window,
&min_undequeued ) != 0 ) &min_undequeued ) != 0 )
{ {
msg_Err( p_dec, "can't get min_undequeued" ); msg_Err( p_dec, "can't get min_undequeued" );
...@@ -2205,7 +2205,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2205,7 +2205,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
omx_error, ErrorToString(omx_error) ); omx_error, ErrorToString(omx_error) );
} }
if( pf_omx_hwbuffer_set_buffer_count( p_port->p_hwbuf->window, if( p_port->p_hwbuf->anwpriv.setBufferCount( p_port->p_hwbuf->window,
def->nBufferCountActual ) != 0 ) def->nBufferCountActual ) != 0 )
{ {
msg_Err( p_dec, "can't set buffer_count" ); msg_Err( p_dec, "can't set buffer_count" );
...@@ -2240,7 +2240,8 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2240,7 +2240,8 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
{ {
void *p_handle = NULL; void *p_handle = NULL;
if( pf_omx_hwbuffer_dequeue( p_port->p_hwbuf->window, &p_handle ) != 0 ) if( p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window,
&p_handle ) != 0 )
{ {
msg_Err( p_dec, "OMXHWBuffer_dequeue Fail" ); msg_Err( p_dec, "OMXHWBuffer_dequeue Fail" );
goto error; goto error;
...@@ -2252,7 +2253,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2252,7 +2253,7 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
for(; i < p_port->p_hwbuf->i_buffers; i++) for(; i < p_port->p_hwbuf->i_buffers; i++)
{ {
OMX_DBG( "canceling buffer(%d)", i ); OMX_DBG( "canceling buffer(%d)", i );
pf_omx_hwbuffer_cancel( p_port->p_hwbuf->window, p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window,
p_port->p_hwbuf->pp_handles[i] ); p_port->p_hwbuf->pp_handles[i] );
} }
...@@ -2283,7 +2284,7 @@ static int HwBuffer_FreeBuffers( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2283,7 +2284,7 @@ static int HwBuffer_FreeBuffers( decoder_t *p_dec, OmxPort *p_port )
if( p_handle && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED ) if( p_handle && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED )
{ {
pf_omx_hwbuffer_cancel( p_port->p_hwbuf->window, p_handle ); p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window, p_handle );
HwBuffer_ChangeState( p_dec, p_port, i, BUF_STATE_NOT_OWNED ); HwBuffer_ChangeState( p_dec, p_port, i, BUF_STATE_NOT_OWNED );
} }
} }
...@@ -2323,7 +2324,7 @@ static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2323,7 +2324,7 @@ static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port )
if( p_header && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED ) if( p_header && p_port->p_hwbuf->i_states[i] == BUF_STATE_OWNED )
{ {
if( pf_omx_hwbuffer_lock( p_port->p_hwbuf->window, if( p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window,
p_header->pBuffer ) != 0 ) p_header->pBuffer ) != 0 )
{ {
msg_Err( p_dec, "lock failed" ); msg_Err( p_dec, "lock failed" );
...@@ -2351,7 +2352,7 @@ static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2351,7 +2352,7 @@ static int HwBuffer_Start( decoder_t *p_dec, OmxPort *p_port )
/***************************************************************************** /*****************************************************************************
* HwBuffer_Stop: stop DequeueThread and invalidate all pictures that are sent * HwBuffer_Stop: stop DequeueThread and invalidate all pictures that are sent
* to vlc core. The thread can be stuck in pf_omx_hwbuffer_dequeue, so don't * to vlc core. The thread can be stuck in dequeue, so don't
* join it now since it can be unblocked later by HwBuffer_FreeBuffers. * join it now since it can be unblocked later by HwBuffer_FreeBuffers.
*****************************************************************************/ *****************************************************************************/
static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port ) static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port )
...@@ -2373,7 +2374,7 @@ static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port ) ...@@ -2373,7 +2374,7 @@ static int HwBuffer_Stop( decoder_t *p_dec, OmxPort *p_port )
void *p_handle = p_port->pp_buffers[p_picsys->i_index]->pBuffer; void *p_handle = p_port->pp_buffers[p_picsys->i_index]->pBuffer;
if( p_handle ) if( p_handle )
{ {
pf_omx_hwbuffer_cancel( p_port->p_hwbuf->window, p_handle ); p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window, p_handle );
HwBuffer_ChangeState( p_dec, p_port, p_picsys->i_index, HwBuffer_ChangeState( p_dec, p_port, p_picsys->i_index,
BUF_STATE_NOT_OWNED ); BUF_STATE_NOT_OWNED );
} }
...@@ -2468,7 +2469,7 @@ static void HwBuffer_SetCrop( decoder_t *p_dec, OmxPort *p_port, ...@@ -2468,7 +2469,7 @@ static void HwBuffer_SetCrop( decoder_t *p_dec, OmxPort *p_port,
{ {
VLC_UNUSED( p_dec ); VLC_UNUSED( p_dec );
pf_omx_hwbuffer_setcrop( p_port->p_hwbuf->window, p_port->p_hwbuf->anwpriv.setCrop( p_port->p_hwbuf->window,
p_rect->nLeft, p_rect->nTop, p_rect->nLeft, p_rect->nTop,
p_rect->nWidth, p_rect->nHeight ); p_rect->nWidth, p_rect->nHeight );
} }
...@@ -2503,9 +2504,9 @@ static void *DequeueThread( void *data ) ...@@ -2503,9 +2504,9 @@ static void *DequeueThread( void *data )
/* The thread can be stuck here. It shouldn't happen since we make sure /* The thread can be stuck here. It shouldn't happen since we make sure
* we call the dequeue function if there is at least one buffer * we call the dequeue function if there is at least one buffer
* available. */ * available. */
err = pf_omx_hwbuffer_dequeue( p_port->p_hwbuf->window, &p_handle ); err = p_port->p_hwbuf->anwpriv.dequeue( p_port->p_hwbuf->window, &p_handle );
if( err == 0 ) if( err == 0 )
err = pf_omx_hwbuffer_lock( p_port->p_hwbuf->window, p_handle ); err = p_port->p_hwbuf->anwpriv.lock( p_port->p_hwbuf->window, p_handle );
HWBUFFER_LOCK(); HWBUFFER_LOCK();
...@@ -2517,7 +2518,7 @@ static void *DequeueThread( void *data ) ...@@ -2517,7 +2518,7 @@ static void *DequeueThread( void *data )
if( !p_port->p_hwbuf->b_run ) if( !p_port->p_hwbuf->b_run )
{ {
pf_omx_hwbuffer_cancel( p_port->p_hwbuf->window, p_handle ); p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window, p_handle );
continue; continue;
} }
...@@ -2532,7 +2533,7 @@ static void *DequeueThread( void *data ) ...@@ -2532,7 +2533,7 @@ static void *DequeueThread( void *data )
} }
if( i_index == -1 ) if( i_index == -1 )
{ {
msg_Err( p_dec, "pf_omx_hwbuffer_dequeue returned unknown handle" ); msg_Err( p_dec, "p_port->p_hwbuf->anwpriv.dequeue returned unknown handle" );
continue; continue;
} }
...@@ -2581,9 +2582,9 @@ static void DisplayBuffer( picture_sys_t* p_picsys, bool b_render ) ...@@ -2581,9 +2582,9 @@ static void DisplayBuffer( picture_sys_t* p_picsys, bool b_render )
} }
if( b_render ) if( b_render )
pf_omx_hwbuffer_queue( p_port->p_hwbuf->window, p_handle ); p_port->p_hwbuf->anwpriv.queue( p_port->p_hwbuf->window, p_handle );
else else
pf_omx_hwbuffer_cancel( p_port->p_hwbuf->window, p_handle ); p_port->p_hwbuf->anwpriv.cancel( p_port->p_hwbuf->window, p_handle );
HwBuffer_ChangeState( p_dec, p_port, p_picsys->i_index, BUF_STATE_NOT_OWNED ); HwBuffer_ChangeState( p_dec, p_port, p_picsys->i_index, BUF_STATE_NOT_OWNED );
HWBUFFER_BROADCAST( p_port ); HWBUFFER_BROADCAST( p_port );
......
...@@ -78,6 +78,7 @@ typedef struct HwBuffer ...@@ -78,6 +78,7 @@ typedef struct HwBuffer
void *window; void *window;
#if defined(USE_IOMX) #if defined(USE_IOMX)
native_window_api_t native_window; native_window_api_t native_window;
native_window_priv_api_t anwpriv;
#endif #endif
} HwBuffer; } HwBuffer;
......
...@@ -89,18 +89,7 @@ OMX_ERRORTYPE (*pf_component_enum)(OMX_STRING, OMX_U32, OMX_U32); ...@@ -89,18 +89,7 @@ OMX_ERRORTYPE (*pf_component_enum)(OMX_STRING, OMX_U32, OMX_U32);
OMX_ERRORTYPE (*pf_get_roles_of_component)(OMX_STRING, OMX_U32 *, OMX_U8 **); OMX_ERRORTYPE (*pf_get_roles_of_component)(OMX_STRING, OMX_U32 *, OMX_U8 **);
OMX_ERRORTYPE (*pf_enable_graphic_buffers)(OMX_HANDLETYPE, OMX_U32, OMX_BOOL); OMX_ERRORTYPE (*pf_enable_graphic_buffers)(OMX_HANDLETYPE, OMX_U32, OMX_BOOL);
OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*); OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*);
OMX_ERRORTYPE (*pf_get_hal_format) (const char *, int *);
int (*pf_omx_hwbuffer_connect) (void *);
int (*pf_omx_hwbuffer_disconnect) (void *);
int (*pf_omx_hwbuffer_get_hal_format) (const char *, int *);
int (*pf_omx_hwbuffer_setup) (void *, int, int, int, int );
int (*pf_omx_hwbuffer_get_min_undequeued) (void *, unsigned int *);
int (*pf_omx_hwbuffer_set_buffer_count) (void *, unsigned int );
int (*pf_omx_hwbuffer_setcrop) (void *, int, int, int, int);
int (*pf_omx_hwbuffer_dequeue) (void *, void **);
int (*pf_omx_hwbuffer_lock) (void *, void *);
int (*pf_omx_hwbuffer_queue) (void *, void *);
int (*pf_omx_hwbuffer_cancel) (void *, void *);
#ifdef RPI_OMX #ifdef RPI_OMX
static void *extra_dll_handle; static void *extra_dll_handle;
...@@ -177,18 +166,7 @@ int InitOmxCore(vlc_object_t *p_this) ...@@ -177,18 +166,7 @@ int InitOmxCore(vlc_object_t *p_this)
#if defined(USE_IOMX) #if defined(USE_IOMX)
pf_enable_graphic_buffers = dlsym( dll_handle, "OMXAndroid_EnableGraphicBuffers" ); pf_enable_graphic_buffers = dlsym( dll_handle, "OMXAndroid_EnableGraphicBuffers" );
pf_get_graphic_buffer_usage = dlsym( dll_handle, "OMXAndroid_GetGraphicBufferUsage" ); pf_get_graphic_buffer_usage = dlsym( dll_handle, "OMXAndroid_GetGraphicBufferUsage" );
pf_get_hal_format = dlsym( dll_handle, "OMXAndroid_GetHalFormat" );
pf_omx_hwbuffer_connect = dlsym( dll_handle, "OMXHWBuffer_Connect" );
pf_omx_hwbuffer_disconnect = dlsym( dll_handle, "OMXHWBuffer_Disconnect" );
pf_omx_hwbuffer_get_hal_format = dlsym( dll_handle, "OMXHWBuffer_GetHalFormat" );
pf_omx_hwbuffer_setup = dlsym( dll_handle, "OMXHWBuffer_Setup" );
pf_omx_hwbuffer_get_min_undequeued = dlsym( dll_handle, "OMXHWBuffer_GetMinUndequeued" );
pf_omx_hwbuffer_set_buffer_count = dlsym( dll_handle, "OMXHWBuffer_SetBufferCount" );
pf_omx_hwbuffer_setcrop = dlsym( dll_handle, "OMXHWBuffer_Setcrop" );
pf_omx_hwbuffer_dequeue = dlsym( dll_handle, "OMXHWBuffer_Dequeue" );
pf_omx_hwbuffer_lock = dlsym( dll_handle, "OMXHWBuffer_Lock" );
pf_omx_hwbuffer_queue = dlsym( dll_handle, "OMXHWBuffer_Queue" );
pf_omx_hwbuffer_cancel = dlsym( dll_handle, "OMXHWBuffer_Cancel" );
#endif #endif
/* Initialise the OMX core */ /* Initialise the OMX core */
......
...@@ -36,19 +36,7 @@ OMX_ERRORTYPE (*pf_get_roles_of_component)(OMX_STRING, OMX_U32 *, OMX_U8 **); ...@@ -36,19 +36,7 @@ OMX_ERRORTYPE (*pf_get_roles_of_component)(OMX_STRING, OMX_U32 *, OMX_U8 **);
/* Extra IOMX android functions. Can be NULL if we don't link with libiomx */ /* Extra IOMX android functions. Can be NULL if we don't link with libiomx */
OMX_ERRORTYPE (*pf_enable_graphic_buffers)(OMX_HANDLETYPE, OMX_U32, OMX_BOOL); OMX_ERRORTYPE (*pf_enable_graphic_buffers)(OMX_HANDLETYPE, OMX_U32, OMX_BOOL);
OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*); OMX_ERRORTYPE (*pf_get_graphic_buffer_usage)(OMX_HANDLETYPE, OMX_U32, OMX_U32*);
OMX_ERRORTYPE (*pf_get_hal_format) (const char *, int *);
/* OMXHWBuffer functions */
int (*pf_omx_hwbuffer_connect) (void *);
int (*pf_omx_hwbuffer_disconnect) (void *);
int (*pf_omx_hwbuffer_get_hal_format) (const char *, int *);
int (*pf_omx_hwbuffer_setup) (void *, int, int, int, int );
int (*pf_omx_hwbuffer_get_min_undequeued) (void *, unsigned int *);
int (*pf_omx_hwbuffer_set_buffer_count) (void *, unsigned int );
int (*pf_omx_hwbuffer_setcrop) (void *, int, int, int, int);
int (*pf_omx_hwbuffer_dequeue) (void *, void **);
int (*pf_omx_hwbuffer_lock) (void *, void *);
int (*pf_omx_hwbuffer_queue) (void *, void *);
int (*pf_omx_hwbuffer_cancel) (void *, void *);
int InitOmxCore(vlc_object_t *p_this); int InitOmxCore(vlc_object_t *p_this);
void DeinitOmxCore(void); void DeinitOmxCore(void);
......
/***************************************************************************** /*****************************************************************************
* iomx_hwbuffer.c: Wrapper to android native window api used for IOMX * nativewindowpriv.c: Wrapper to android native window private api
***************************************************************************** *****************************************************************************
* Copyright (C) 2011 VLC authors and VideoLAN * Copyright (C) 2011 VLC authors and VideoLAN
* *
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <OMX_Core.h>
#include <OMX_Component.h>
#if ANDROID_API <= 13 #if ANDROID_API <= 13
#include <ui/android_native_buffer.h> #include <ui/android_native_buffer.h>
#include <ui/egl/android_natives.h> #include <ui/egl/android_natives.h>
...@@ -48,14 +45,14 @@ typedef int32_t status_t; ...@@ -48,14 +45,14 @@ typedef int32_t status_t;
typedef android_native_buffer_t ANativeWindowBuffer_t; typedef android_native_buffer_t ANativeWindowBuffer_t;
#endif #endif
#define LOG_TAG "VLC/IOMX" #define LOG_TAG "VLC/ANW"
#define LOGD(...) __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__ ) #define LOGD(...) __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__ )
#define LOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ ) #define LOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
#define CHECK_ERR() do {\ #define CHECK_ERR() do {\
if( err != NO_ERROR ) {\ if( err != NO_ERROR ) {\
LOGE( "IOMXHWBuffer: error %d in %s line %d\n", err, __FUNCTION__, __LINE__ );\ LOGE( "error %d in %s line %d\n", err, __FUNCTION__, __LINE__ );\
return err;\ return err;\
}\ }\
} while (0) } while (0)
...@@ -63,7 +60,7 @@ typedef android_native_buffer_t ANativeWindowBuffer_t; ...@@ -63,7 +60,7 @@ typedef android_native_buffer_t ANativeWindowBuffer_t;
#define CHECK_ANW() do {\ #define CHECK_ANW() do {\
if( anw->common.magic != ANDROID_NATIVE_WINDOW_MAGIC &&\ if( anw->common.magic != ANDROID_NATIVE_WINDOW_MAGIC &&\
anw->common.version != sizeof(ANativeWindow) ) {\ anw->common.version != sizeof(ANativeWindow) ) {\
LOGE( "IOMXHWBuffer: error, window not valid\n" );\ LOGE( "error, window not valid\n" );\
return -EINVAL;\ return -EINVAL;\
}\ }\
} while (0) } while (0)
...@@ -71,12 +68,12 @@ typedef android_native_buffer_t ANativeWindowBuffer_t; ...@@ -71,12 +68,12 @@ typedef android_native_buffer_t ANativeWindowBuffer_t;
#define CHECK_ANB() do {\ #define CHECK_ANB() do {\
if( anb->common.magic != ANDROID_NATIVE_BUFFER_MAGIC &&\ if( anb->common.magic != ANDROID_NATIVE_BUFFER_MAGIC &&\
anb->common.version != sizeof(ANativeWindowBuffer_t) ) {\ anb->common.version != sizeof(ANativeWindowBuffer_t) ) {\
LOGE( "IOMXHWBuffer: error, buffer not valid\n" );\ LOGE( "error, buffer not valid\n" );\
return -EINVAL;\ return -EINVAL;\
}\ }\
} while (0) } while (0)
int IOMXHWBuffer_Connect( void *window ) int ANativeWindowPriv_connect( void *window )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
CHECK_ANW(); CHECK_ANW();
...@@ -89,7 +86,7 @@ int IOMXHWBuffer_Connect( void *window ) ...@@ -89,7 +86,7 @@ int IOMXHWBuffer_Connect( void *window )
#endif #endif
} }
int IOMXHWBuffer_Disconnect( void *window ) int ANativeWindowPriv_disconnect( void *window )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
...@@ -102,31 +99,7 @@ int IOMXHWBuffer_Disconnect( void *window ) ...@@ -102,31 +99,7 @@ int IOMXHWBuffer_Disconnect( void *window )
return 0; return 0;
} }
int ANativeWindowPriv_setup( void *window, int w, int h, int hal_format, int hw_usage )
int IOMXHWBuffer_GetHalFormat( const char *comp_name, int* hal_format )
{
if( !strncmp( comp_name, "OMX.SEC.", 8 ) ) {
switch( *hal_format ) {
case OMX_COLOR_FormatYUV420SemiPlanar:
*hal_format = 0x105; // HAL_PIXEL_FORMAT_YCbCr_420_SP
break;
case OMX_COLOR_FormatYUV420Planar:
*hal_format = 0x101; // HAL_PIXEL_FORMAT_YCbCr_420_P
break;
}
}
else if( !strcmp( comp_name, "OMX.TI.720P.Decoder" ) ||
!strcmp( comp_name, "OMX.TI.Video.Decoder" ) )
*hal_format = 0x14; // HAL_PIXEL_FORMAT_YCbCr_422_I
#if ANDROID_API <= 13 // Required on msm8660 on 3.2, not required on 4.1
else if( !strcmp( comp_name, "OMX.qcom.video.decoder.avc" ))
*hal_format = 0x108;
#endif
return 0;
}
int IOMXHWBuffer_Setup( void *window, int w, int h, int hal_format, int hw_usage )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
int usage = 0; int usage = 0;
...@@ -134,7 +107,7 @@ int IOMXHWBuffer_Setup( void *window, int w, int h, int hal_format, int hw_usage ...@@ -134,7 +107,7 @@ int IOMXHWBuffer_Setup( void *window, int w, int h, int hal_format, int hw_usage
CHECK_ANW(); CHECK_ANW();
LOGD( "IOMXHWBuffer_setup: %p, %d, %d, %X, %X\n", LOGD( "setup: %p, %d, %d, %X, %X\n",
anw, w, h, hal_format, hw_usage ); anw, w, h, hal_format, hw_usage );
usage |= hw_usage | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE; usage |= hw_usage | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
...@@ -162,7 +135,7 @@ int IOMXHWBuffer_Setup( void *window, int w, int h, int hal_format, int hw_usage ...@@ -162,7 +135,7 @@ int IOMXHWBuffer_Setup( void *window, int w, int h, int hal_format, int hw_usage
return 0; return 0;
} }
int IOMXHWBuffer_GetMinUndequeued( void *window, unsigned int *min_undequeued ) int ANativeWindowPriv_getMinUndequeued( void *window, unsigned int *min_undequeued )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
status_t err; status_t err;
...@@ -176,19 +149,19 @@ int IOMXHWBuffer_GetMinUndequeued( void *window, unsigned int *min_undequeued ) ...@@ -176,19 +149,19 @@ int IOMXHWBuffer_GetMinUndequeued( void *window, unsigned int *min_undequeued )
if( *min_undequeued == 0 ) if( *min_undequeued == 0 )
*min_undequeued = 2; *min_undequeued = 2;
LOGD( "IOMXHWBuffer_GetMinUndequeued: %p %u", anw, *min_undequeued ); LOGD( "getMinUndequeued: %p %u", anw, *min_undequeued );
return 0; return 0;
} }
int IOMXHWBuffer_SetBufferCount(void *window, unsigned int count ) int ANativeWindowPriv_setBufferCount(void *window, unsigned int count )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
status_t err; status_t err;
CHECK_ANW(); CHECK_ANW();
LOGD( "IOMXHWBuffer_SetBufferCount: %p %u", anw, count ); LOGD( "setBufferCount: %p %u", anw, count );
err = native_window_set_buffer_count( anw, count ); err = native_window_set_buffer_count( anw, count );
CHECK_ERR(); CHECK_ERR();
...@@ -196,7 +169,7 @@ int IOMXHWBuffer_SetBufferCount(void *window, unsigned int count ) ...@@ -196,7 +169,7 @@ int IOMXHWBuffer_SetBufferCount(void *window, unsigned int count )
return 0; return 0;
} }
int IOMXHWBuffer_Setcrop( void *window, int ofs_x, int ofs_y, int w, int h ) int ANativeWindowPriv_setCrop( void *window, int ofs_x, int ofs_y, int w, int h )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
android_native_rect_t crop; android_native_rect_t crop;
...@@ -210,7 +183,7 @@ int IOMXHWBuffer_Setcrop( void *window, int ofs_x, int ofs_y, int w, int h ) ...@@ -210,7 +183,7 @@ int IOMXHWBuffer_Setcrop( void *window, int ofs_x, int ofs_y, int w, int h )
return native_window_set_crop( anw, &crop ); return native_window_set_crop( anw, &crop );
} }
int IOMXHWBuffer_Dequeue( void *window, void **pp_handle ) int ANativeWindowPriv_dequeue( void *window, void **pp_handle )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
ANativeWindowBuffer_t *anb; ANativeWindowBuffer_t *anb;
...@@ -230,7 +203,7 @@ int IOMXHWBuffer_Dequeue( void *window, void **pp_handle ) ...@@ -230,7 +203,7 @@ int IOMXHWBuffer_Dequeue( void *window, void **pp_handle )
return 0; return 0;
} }
int IOMXHWBuffer_Lock( void *window, void *p_handle ) int ANativeWindowPriv_lock( void *window, void *p_handle )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle; ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
...@@ -249,7 +222,7 @@ int IOMXHWBuffer_Lock( void *window, void *p_handle ) ...@@ -249,7 +222,7 @@ int IOMXHWBuffer_Lock( void *window, void *p_handle )
return 0; return 0;
} }
int IOMXHWBuffer_Queue( void *window, void *p_handle ) int ANativeWindowPriv_queue( void *window, void *p_handle )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle; ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
...@@ -268,7 +241,7 @@ int IOMXHWBuffer_Queue( void *window, void *p_handle ) ...@@ -268,7 +241,7 @@ int IOMXHWBuffer_Queue( void *window, void *p_handle )
return 0; return 0;
} }
int IOMXHWBuffer_Cancel( void *window, void *p_handle ) int ANativeWindowPriv_cancel( void *window, void *p_handle )
{ {
ANativeWindow *anw = (ANativeWindow *)window; ANativeWindow *anw = (ANativeWindow *)window;
ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle; ANativeWindowBuffer_t *anb = (ANativeWindowBuffer_t *)p_handle;
......
...@@ -49,6 +49,25 @@ void *LoadNativeWindowAPI(native_window_api_t *native) ...@@ -49,6 +49,25 @@ void *LoadNativeWindowAPI(native_window_api_t *native)
return NULL; return NULL;
} }
int LoadNativeWindowPrivAPI(native_window_priv_api_t *native)
{
native->connect = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_connect");
native->disconnect = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_disconnect");
native->setup = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_setup");
native->getMinUndequeued = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_getMinUndequeued");
native->setBufferCount = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_setBufferCount");
native->setCrop = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_setCrop");
native->dequeue = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_dequeue");
native->lock = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_lock");
native->queue = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_queue");
native->cancel = dlsym(RTLD_DEFAULT, "ANativeWindowPriv_cancel");
return native->connect && native->disconnect && native->setup &&
native->getMinUndequeued && native->setBufferCount && native->setCrop &&
native->dequeue && native->lock && native->queue && native->cancel
? 0 : -1;
}
extern void jni_getMouseCoordinates(int *, int *, int *, int *); extern void jni_getMouseCoordinates(int *, int *, int *, int *);
void Manage(vout_display_t *vd) void Manage(vout_display_t *vd)
......
...@@ -48,3 +48,31 @@ typedef struct ...@@ -48,3 +48,31 @@ typedef struct
that should be destroyed with dlclose. */ that should be destroyed with dlclose. */
void *LoadNativeWindowAPI(native_window_api_t *native); void *LoadNativeWindowAPI(native_window_api_t *native);
void Manage(vout_display_t *); void Manage(vout_display_t *);
typedef int (*ptr_ANativeWindowPriv_connect) (void *);
typedef int (*ptr_ANativeWindowPriv_disconnect) (void *);
typedef int (*ptr_ANativeWindowPriv_setup) (void *, int, int, int, int );
typedef int (*ptr_ANativeWindowPriv_getMinUndequeued) (void *, unsigned int *);
typedef int (*ptr_ANativeWindowPriv_setBufferCount) (void *, unsigned int );
typedef int (*ptr_ANativeWindowPriv_setCrop) (void *, int, int, int, int);
typedef int (*ptr_ANativeWindowPriv_dequeue) (void *, void **);
typedef int (*ptr_ANativeWindowPriv_lock) (void *, void *);
typedef int (*ptr_ANativeWindowPriv_queue) (void *, void *);
typedef int (*ptr_ANativeWindowPriv_cancel) (void *, void *);
typedef struct
{
ptr_ANativeWindowPriv_connect connect;
ptr_ANativeWindowPriv_disconnect disconnect;
ptr_ANativeWindowPriv_setup setup;
ptr_ANativeWindowPriv_getMinUndequeued getMinUndequeued;
ptr_ANativeWindowPriv_setBufferCount setBufferCount;
ptr_ANativeWindowPriv_setCrop setCrop;
ptr_ANativeWindowPriv_dequeue dequeue;
ptr_ANativeWindowPriv_lock lock;
ptr_ANativeWindowPriv_queue queue;
ptr_ANativeWindowPriv_cancel cancel;
} native_window_priv_api_t;
/* Fill the structure passed as parameter and return 0 if all symbols are
found. Don't need to call dlclose, the lib is already loaded. */
int LoadNativeWindowPrivAPI(native_window_priv_api_t *native);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment