((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(PLAYER_ERROR_VIDEO_CAPTURE_FAILED, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
break;
case MM_MESSAGE_VIDEO_CAPTURED: /* 0x110 */
+ {
+ MMPlayerVideoCapture *capture = (MMPlayerVideoCapture *)msg->data;
+
if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
- int w;
- int h;
- MMPlayerVideoCapture *capture = (MMPlayerVideoCapture *)msg->data;
- int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &w, MM_PLAYER_VIDEO_HEIGHT, &h, (char *)NULL);
- if (ret != MM_ERROR_NONE && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) {
- LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : Failed to get video size on video captured (0x%x)", __FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED, ret);
+ if (!capture || !capture->data) {
+ LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : Failed to get capture data", PLAYER_ERROR_VIDEO_CAPTURE_FAILED);
err_code = PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
} else {
- switch (msg->captured_frame.orientation) {
- case 0:
- case 180:
- {
- /* use video resolution from above */
- }
- break;
- case 90:
- case 270:
- {
- /* use calculated size during rotation */
- w = msg->captured_frame.width;
- h = msg->captured_frame.height;
- }
- break;
- default:
- break;
- }
-
- LOGI("[%s] captured image width : %d height : %d", __FUNCTION__, w, h);
+ LOGI("captured image ori: %d, width: %d, height: %d, size: %d",
+ capture->orientation, capture->width, capture->height, capture->size);
/* call application callback */
- ((player_video_captured_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])(capture->data, w, h, capture->size, handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
- }
-
- /* capure->data have to be released to avoid mem leak even if _get_attribute got failed. */
- if (capture && capture->data) {
- g_free(capture->data);
- capture->data = NULL;
+ ((player_video_captured_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])
+ (capture->data, capture->width, capture->height, capture->size, handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
}
handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
}
+
+ /* capure->data have to be released to avoid mem leak in all cases. */
+ if (capture && capture->data) {
+ g_free(capture->data);
+ capture->data = NULL;
+ }
break;
+ }
case MM_MESSAGE_FILE_NOT_SUPPORTED: /* 0x10f */
LOGI("[%s] PLAYER_ERROR_NOT_SUPPORTED_FILE (0x%08x) : FILE_NOT_SUPPORTED", __FUNCTION__, PLAYER_ERROR_NOT_SUPPORTED_FILE);
err_code = PLAYER_ERROR_NOT_SUPPORTED_FILE;