From: Jeongmo Yang Date: Wed, 18 Aug 2021 05:21:07 +0000 (+0900) Subject: Check media type first to get pixel format from caps X-Git-Tag: submit/tizen/20210819.005621~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a564e46bb6b34e9a8d990ba7c94dfa9430c44b63;p=platform%2Fcore%2Fmultimedia%2Flibmm-camcorder.git Check media type first to get pixel format from caps [Version] 0.10.242 [Issue Type] Update Change-Id: If7994b5696a1b76030bd97fcaeab0c6c5310385e Signed-off-by: Jeongmo Yang --- diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index de45d6f..f359b9d 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.241 +Version: 0.10.242 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_camcorder_util.c b/src/mm_camcorder_util.c index 23e7f5e..5b83204 100644 --- a/src/mm_camcorder_util.c +++ b/src/mm_camcorder_util.c @@ -1529,44 +1529,47 @@ void _mmcamcorder_remove_message_all(MMHandleType handle) int _mmcamcorder_get_pixel_format(GstCaps *caps) { + gchar *caps_string = NULL; const char *media_type; GstVideoInfo vinfo; - MMPixelFormatType type = MM_PIXEL_FORMAT_INVALID; mmf_return_val_if_fail(caps != NULL, MM_PIXEL_FORMAT_INVALID); - 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; + if (_mmcamcorder_get_log_level() >= MM_CAMCORDER_LOG_LEVEL_DEBUG) { + caps_string = gst_caps_to_string(caps); + MMCAM_LOG_DEBUG("caps[%s]", caps_string); + g_free(caps_string); } - if (!gst_video_info_from_caps(&vinfo, caps)) { - MMCAM_LOG_ERROR("get video info failed[media type:%s]", media_type); + media_type = gst_structure_get_name(gst_caps_get_structure(caps, 0)); + if (!media_type) { + MMCAM_LOG_ERROR("failed to get media_type"); return MM_PIXEL_FORMAT_INVALID; } - 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, "image/jpeg")) - type = MM_PIXEL_FORMAT_ENCODED; + if (!strcmp(media_type, "image/jpeg")) + return MM_PIXEL_FORMAT_ENCODED; else if (!strcmp(media_type, "video/x-h264")) - type = MM_PIXEL_FORMAT_ENCODED_H264; + return MM_PIXEL_FORMAT_ENCODED_H264; else if (!strcmp(media_type, "video/x-jpeg")) - type = MM_PIXEL_FORMAT_ENCODED_MJPEG; + return MM_PIXEL_FORMAT_ENCODED_MJPEG; else if (!strcmp(media_type, "video/x-vp8")) - type = MM_PIXEL_FORMAT_ENCODED_VP8; + return MM_PIXEL_FORMAT_ENCODED_VP8; else if (!strcmp(media_type, "video/x-vp9")) - type = MM_PIXEL_FORMAT_ENCODED_VP9; + return MM_PIXEL_FORMAT_ENCODED_VP9; - 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); + if (gst_video_info_from_caps(&vinfo, caps)) { + if (GST_VIDEO_INFO_IS_YUV(&vinfo)) + return _mmcamcorder_get_pixtype(gst_video_format_to_fourcc(GST_VIDEO_INFO_FORMAT(&vinfo))); + else if (GST_VIDEO_INFO_IS_RGB(&vinfo)) + return MM_PIXEL_FORMAT_RGB888; + } + + caps_string = gst_caps_to_string(caps); + MMCAM_LOG_ERROR("unsupported caps[%s]", caps_string); + g_free(caps_string); - return type; + return MM_PIXEL_FORMAT_INVALID; }