📄 jam_msg_util.c
字号:
*errThrowClassName = NULL;
j2me_lcd_mutex_lock();
gdi_image_jpeg_get_dimension((U8*) buffer, length, (S32*) & width, (S32*) & height);
if (width <= 0 || height <= 0)
{
*errThrowClassName = "java/lang/IllegalArgumentException";
j2me_lcd_mutex_unlock();
#if defined (SUPPORT_MMAPI) && !defined (J2ME_SHARE_MED_EXT_MEM) && defined(__MMI_CAMERA__)
/* Resume camera preview */
if (is_pause_camera)
{
jma_cam_player_preview_start(MMA_TYPE_CAM, video_player.id);
}
#endif
return NULL;
}
orgwidth = width;
orgheight = height;
width += 16;
height += 16;
tempBuffer = jvm_malloc(width * height * 2);
if (tempBuffer == NULL)
{
*errThrowClassName = "java/lang/OutOfMemoryError";
j2me_lcd_mutex_unlock();
#if defined (SUPPORT_MMAPI) && !defined (J2ME_SHARE_MED_EXT_MEM) && defined(__MMI_CAMERA__)
/* Resume camera preview */
if (is_pause_camera)
{
jma_cam_player_preview_start(MMA_TYPE_CAM, video_player.id);
}
#endif
return NULL;
}
if (gdi_image_jpeg_draw_to_buffer(
orgwidth,
orgheight,
(U8*) buffer,
length,
(U8*) tempBuffer,
(S32) (width * height * 2),
(S32*) & width) != GDI_JPEG_SUCCEED)
{
*errThrowClassName = "java/lang/IllegalArgumentException";
j2me_lcd_mutex_unlock();
/* Resume camera preview */
#if defined (SUPPORT_MMAPI) && !defined (J2ME_SHARE_MED_EXT_MEM) && defined(__MMI_CAMERA__)
if (is_pause_camera)
{
jma_cam_player_preview_start(MMA_TYPE_CAM, video_player.id);
}
#endif
return NULL;
}
j2me_lcd_mutex_unlock();
if (get_image(orgwidth, orgheight, &dst) < 0)
{
jvm_free(tempBuffer);
*errThrowClassName = "java/lang/OutOfMemoryError";
#if defined (SUPPORT_MMAPI) && !defined (J2ME_SHARE_MED_EXT_MEM) && defined(__MMI_CAMERA__)
/* Resume camera preview */
if (is_pause_camera)
{
jma_cam_player_preview_start(MMA_TYPE_CAM, video_player.id);
}
#endif
return NULL;
}
srcBuffer = tempBuffer;
dstBuffer = (char*)dst;
for (i = 0; i < orgheight; i++)
{
memcpy(dstBuffer, srcBuffer, orgwidth << 1);
srcBuffer += width << 1;
dstBuffer += orgwidth << 1;
}
jvm_free(tempBuffer);
#if defined (SUPPORT_MMAPI) && !defined (J2ME_SHARE_MED_EXT_MEM) && defined(__MMI_CAMERA__)
if (is_pause_camera)
{
jma_cam_player_preview_start(MMA_TYPE_CAM, video_player.id);
}
#endif
return dst;
#else /* defined(GDI_USING_HW_JPEG) || defined(GDI_USING_HW_JPEG_V2) */
*errThrowClassName = "java/lang/IllegalArgumentException";
return NULL;
#endif /* defined(GDI_USING_HW_JPEG) || defined(GDI_USING_HW_JPEG_V2) */
}
/*****************************************************************************
* FUNCTION
* GIFdecodeImage
* DESCRIPTION
* The API is used to decode a GIF image data.
* PARAMETERS
* buffer [IN] The JPEG raw data to be decoded
* length [IN] The length of the raw data in buffer
* is_transparent [OUT] The function pointer to get a new Java image for
* drawing GIF decoded image (must be 565 format).
* get_image [IN] The function pointer to get a new Java
* image for drawing JPEG decoded image (must be 565 format).
* errThrowClassName [OUT] The class name to be thrown to Java level. If the pointer
* of the variable is modified as non-NULL pointer, it represents error.
* RETURNS
* Return a non-NULL the image buffer if the decoding is successful.
* Return NULL if decoding is failed.
*
*****************************************************************************/
kal_char*
GIFdecodeImage(
char *buffer,
int length,
kal_bool *is_transparent,
kal_int32(*get_image) (kal_int32 width, kal_int32 height, kal_char **dst),
char **errThrowClassName)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
int width, height;
GDI_RESULT gdi_result;
gdi_handle gif_handle;
char *dst = NULL;
kal_bool use_sw_gif_decoder = KAL_FALSE;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
*is_transparent = KAL_FALSE;
*errThrowClassName = NULL;
/* errorMsg = NULL; */
#if DATACACHE_FBBR_ON
/* this function is only workable when DATACACHE_FBBR_ON is 1 */
buffer = (char*)FBBR_invalid_l1_cache(buffer, length);
#endif /* DATACACHE_FBBR_ON */
j2me_lcd_mutex_lock();
gdi_image_gif_get_dimension((unsigned char*)buffer, (S32*) & width, (S32*) & height);
if (width <= 0 || height <= 0)
{
*errThrowClassName = "java/lang/IllegalArgumentException";
j2me_lcd_mutex_unlock();
return NULL;
}
if (get_image(width, height, &dst) < 0)
{
*errThrowClassName = "java/lang/OutOfMemoryError";
j2me_lcd_mutex_unlock();
return NULL;
}
#if DATACACHE_FBBR_ON
/* this function is only workable when DATACACHE_FBBR_ON is 1 */
dst = (char*)FBBR_invalid_l1_cache_img(dst, 0, 0, width, height, width);
#endif /* DATACACHE_FBBR_ON */
gdi_layer_create_using_outside_memory(
0,
0,
width,
height,
&gif_handle,
(U8*) dst,
(S32) (width * height * 2));
gdi_layer_push_and_set_active(gif_handle);
if(width > jui_widget_get_display_width() || height > jui_widget_get_display_height())
{
gdi_image_codec_set_flag_begin(GDI_IMAGE_CODEC_FLAG_USE_SW_DECODE);
use_sw_gif_decoder = KAL_TRUE;
}
gdi_result = gdi_image_gif_draw_java((U8 *)buffer, length, 0, j2me_get_transparent_color_key(), (BOOL *)is_transparent);
if(use_sw_gif_decoder)
{
gdi_image_codec_set_flag_end();
}
gdi_layer_pop_and_restore_active();
gdi_layer_free(gif_handle);
j2me_lcd_mutex_unlock();
if (gdi_result != GDI_GIF_SUCCEED && gdi_result != GDI_GIF_LAST_FRAME)
{
*errThrowClassName = "java/lang/IllegalArgumentException";
return NULL;
}
return dst;
}
#define JAVA_DRM_DEBUG_INFO
#ifdef JAVA_DRM_DEBUG_INFO
#define JAVA_DRM_DEBUG( msg_to_print ) \
do{ \
sprintf msg_to_print; \
Kprintf();\
}while(0);
#else
#define JAVA_DRM_DEBUG( msg_to_print )
#endif
/*****************************************************************************
* FUNCTION
* jam_drm_is_drm_file
* DESCRIPTION
* to check if it is a drm file
* PARAMETERS
* storage_name [IN] the filename in UCS2 format
* RETURNS
* KAL_TRUE or KAL_FALSE
*****************************************************************************/
kal_bool jam_drm_is_drm_file(kal_wchar *storage_name)
{
#ifdef __DRM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if (DRM_get_object_method(0, storage_name) != DRM_METHOD_NONE)
{
return KAL_TRUE;
}
return KAL_FALSE;
#else
return KAL_FALSE;
#endif
}
/*****************************************************************************
* FUNCTION
* jam_drm_check_right
* DESCRIPTION
* to check if this file have suitable permission.
* PARAMETERS
* storage_name [IN] the filename in UCS2 format
* permission [IN] permission
* RETURNS
* KAL_TRUE or KAL_FALSE
*****************************************************************************/
kal_bool jam_drm_check_right(kal_wchar *storage_name, kal_uint8 permission)
{
#ifdef __DRM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return DRM_validate_permission(0, storage_name, permission);
#else
return KAL_TRUE;
#endif
}
/*****************************************************************************
* FUNCTION
* jam_drm_consume_right
* DESCRIPTION
* Use thie function to consume right.
* PARAMETERS
* storage_name [IN] filename
* permissione [IN] permission
* callback [IN] this callback will be invoke when the right is invalid
* RETURNS
* > 0 sucess, return consume_id
* = 0 not drm file
* < 0 fail
*****************************************************************************/
kal_int32 jam_drm_start_consume(kal_wchar *storage_name, kal_uint8 permission, void (*callback)(kal_int32 result, kal_int32 id))
{
#ifdef __DRM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
FS_HANDLE handle;
kal_int32 consume_id;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
if( !jam_drm_is_drm_file(storage_name) )
{
/* not drm file */
return -1;
}
handle = DRM_open_file(storage_name, FS_READ_ONLY | FS_OPEN_SHARED, permission);
if (handle >= 0)
{
consume_id = DRM_consume_rights(handle, permission, callback);
JAVA_DRM_DEBUG((_kvmLogStr,"[JAVA DRM PROCESS] file start consume %d", consume_id ));
DRM_close_file(handle);
return consume_id;
}
else
{
DRM_close_file(handle);
return -1;
}
#else /* __DRM_SUPPORT__ */
return 0;
#endif /* __DRM_SUPPORT__ */
}
/*****************************************************************************
* FUNCTION
* jam_drm_stop_consume
* DESCRIPTION
* Use this function to stop consume
* PARAMETERS
* drm_id [IN] consume id
* RETURNS
* J2ME_NO_ERROR
*****************************************************************************/
kal_int32 jam_drm_stop_consume(kal_int32 consume_id)
{
#ifdef __DRM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JAVA_DRM_DEBUG((_kvmLogStr,"[JAVA DRM PROCESS] file stop consume %d", consume_id ));
DRM_stop_consume(consume_id);
return J2ME_NO_ERROR;
#else /* __DRM_SUPPORT__ */
return J2ME_NO_ERROR;
#endif /* __DRM_SUPPORT__ */
}
/*****************************************************************************
* FUNCTION
* jam_drm_pause_consume
* DESCRIPTION
* Use this function to pause consume
* PARAMETERS
* drm_id [IN] drm_id
* RETURNS
* Void
*****************************************************************************/
kal_int32 jam_drm_pause_consume(kal_int32 consume_id)
{
#ifdef __DRM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JAVA_DRM_DEBUG((_kvmLogStr,"[JAVA DRM PROCESS] file pause consume %d", consume_id ));
DRM_pause_consume(consume_id);
return J2ME_NO_ERROR;
#else /* __DRM_SUPPORT__ */
return J2ME_NO_ERROR;
#endif /* __DRM_SUPPORT__ */
}
/*****************************************************************************
* FUNCTION
* jam_drm_resume_consume
* DESCRIPTION
* Use this function to resume consume
* PARAMETERS
* drm_id [IN] drm_id
* RETURNS
* void
*****************************************************************************/
kal_int32 jam_drm_resume_consume(kal_int32 consume_id)
{
#ifdef __DRM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
JAVA_DRM_DEBUG((_kvmLogStr,"[JAVA DRM PROCESS] file resume consume %d", consume_id ));
DRM_resume_consume(consume_id);
return J2ME_NO_ERROR;
#else /* __DRM_SUPPORT__ */
return J2ME_NO_ERROR;
#endif /* __DRM_SUPPORT__ */
}
/*****************************************************************************
* FUNCTION
* jam_drm_get_content_ext
* DESCRIPTION
* Use this function to get extension name of odf file.
* Caller should prepare the memory space for ext
* PARAMETERS
* drm_id [IN] drm_id
* RETURNS
* void
*****************************************************************************/
void jam_drm_get_content_ext(kal_wchar *storage_name, kal_wchar *ext)
{
#ifdef __DRM_SUPPORT__
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_char *ansii_ext;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -