From a5dc6b65b4eb55c005536f4f55d90478be5706c5 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Tue, 1 Jun 2021 19:18:13 +0900 Subject: [PATCH] Revise _mmcamcorder_get_pixel_format() [Version] 0.10.237 [Issue Type] Revise Change-Id: I4e2cdfb02ecdf8df308c22c8ff0cdd5752ebdd16 Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/mm_camcorder_util.c | 45 +++++++++++++++++------------------------- 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index 39dd6d6..0f56702 100755 --- a/packaging/libmm-camcorder.spec +++ b/packaging/libmm-camcorder.spec @@ -1,6 +1,6 @@ Name: libmm-camcorder Summary: Camera and recorder library -Version: 0.10.236 +Version: 0.10.237 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_camcorder_util.c b/src/mm_camcorder_util.c index 24a1230..ab0d4f8 100644 --- a/src/mm_camcorder_util.c +++ b/src/mm_camcorder_util.c @@ -1529,50 +1529,41 @@ void _mmcamcorder_remove_message_all(MMHandleType handle) int _mmcamcorder_get_pixel_format(GstCaps *caps) { - const GstStructure *structure; const char *media_type; - GstVideoInfo media_info; - MMPixelFormatType type = 0; - unsigned int fourcc = 0; + GstVideoInfo vinfo; + MMPixelFormatType type = MM_PIXEL_FORMAT_INVALID; mmf_return_val_if_fail(caps != NULL, MM_PIXEL_FORMAT_INVALID); - structure = gst_caps_get_structure(caps, 0); - media_type = gst_structure_get_name(structure); + media_type = gst_structure_get_name(gst_caps_get_structure(caps, 0)); if (media_type == NULL) { MMCAM_LOG_ERROR("failed to get media_type"); return MM_PIXEL_FORMAT_INVALID; } - gst_video_info_init(&media_info); + if (!gst_video_info_from_caps(&vinfo, caps)) { + MMCAM_LOG_ERROR("get video info failed[media type:%s]", media_type); + return MM_PIXEL_FORMAT_INVALID; + } - if (!strcmp(media_type, "image/jpeg")) { - MMCAM_LOG_INFO("It is jpeg."); - type = MM_PIXEL_FORMAT_ENCODED; - } else if (!strcmp(media_type, "video/x-raw") && - gst_video_info_from_caps(&media_info, caps) && - GST_VIDEO_INFO_IS_YUV(&media_info)) { - MMCAM_LOG_INFO("It is yuv."); - fourcc = gst_video_format_to_fourcc(GST_VIDEO_INFO_FORMAT(&media_info)); - type = _mmcamcorder_get_pixtype(fourcc); - } else if (!strcmp(media_type, "video/x-raw") && - gst_video_info_from_caps(&media_info, caps) && - GST_VIDEO_INFO_IS_RGB(&media_info)) { - MMCAM_LOG_INFO("It is rgb."); + if (GST_VIDEO_INFO_IS_YUV(&vinfo)) + type = _mmcamcorder_get_pixtype(gst_video_format_to_fourcc(GST_VIDEO_INFO_FORMAT(&vinfo))); + else if (GST_VIDEO_INFO_IS_RGB(&vinfo)) type = MM_PIXEL_FORMAT_RGB888; - } else if (!strcmp(media_type, "video/x-h264")) { - MMCAM_LOG_INFO("It is H264"); + else if (!strcmp(media_type, "image/jpeg")) + type = MM_PIXEL_FORMAT_ENCODED; + else if (!strcmp(media_type, "video/x-h264")) type = MM_PIXEL_FORMAT_ENCODED_H264; - } else { - MMCAM_LOG_ERROR("Not supported format [%s]", media_type); - type = MM_PIXEL_FORMAT_INVALID; - } - /*MMCAM_LOG_INFO( "Type [%d]", type );*/ + if (type == MM_PIXEL_FORMAT_INVALID) + MMCAM_LOG_ERROR("Not supported format[%s,GST:%d]", media_type, GST_VIDEO_INFO_FORMAT(&vinfo)); + else + MMCAM_LOG_DEBUG("Type[%d]", type); return type; } + unsigned int _mmcamcorder_get_fourcc(int pixtype, int codectype, int use_zero_copy_format) { unsigned int fourcc = 0; -- 2.7.4