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;
}