Support new pixel format - VP8, VP9 76/259276/4
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 3 Jun 2021 11:30:55 +0000 (20:30 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 9 Jun 2021 02:02:59 +0000 (11:02 +0900)
[Version] 0.10.238
[Issue Type] New feature

Change-Id: I8bd940fb25f19eb289ab22cc5ce4b58bd118b7ad
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder_internal.h
src/mm_camcorder_attribute.c
src/mm_camcorder_configure.c
src/mm_camcorder_gstcommon.c
src/mm_camcorder_stillshot.c
src/mm_camcorder_util.c
src/mm_camcorder_videorec.c

index 0f56702..ee28361 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.237
+Version:    0.10.238
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 6eef219..0387966 100644 (file)
@@ -716,7 +716,7 @@ typedef struct {
 
        type_element *VideosinkElement;         /**< configure data of videosink element */
        type_element *VideoconvertElement;      /**< configure data of videoconvert element */
-       type_element *VideodecoderElementH264;  /**< configure data of video decoder element for H.264 format */
+       type_element *VideodecoderElement;      /**< configure data of video decoder element */
        gboolean SensorEncodedCapture;          /**< whether camera sensor support encoded image capture */
        gboolean internal_encode;               /**< whether use internal encoding function */
 } _MMCamcorderSubContext;
index cc71487..e9e7637 100644 (file)
@@ -4656,7 +4656,7 @@ bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_i
 
        /* check preview format */
        mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
-       if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
+       if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
                MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
                return FALSE;
        }
@@ -4683,7 +4683,7 @@ bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int a
 
        /* check preview format */
        mm_camcorder_get_attributes(handle, NULL, MMCAM_CAMERA_FORMAT, &preview_format, NULL);
-       if (preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
+       if (!_mmcamcorder_is_encoded_preview_pixel_format(preview_format)) {
                MMCAM_LOG_ERROR("current preview format[%d] is not encoded format", preview_format);
                return FALSE;
        }
index caf7d74..1dbc9f3 100644 (file)
@@ -191,6 +191,36 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                0,
        };
 
+       /* MJPEG decoder element default value */
+       static type_element _videodecoder_element_mjpeg_default = {
+               "VideodecoderElementMJPEG",
+               "jpegdec",
+               NULL,
+               0,
+               NULL,
+               0,
+       };
+
+       /* VP8 decoder element default value */
+       static type_element _videodecoder_element_vp8_default = {
+               "VideodecoderElementVP8",
+               "vp8dec",
+               NULL,
+               0,
+               NULL,
+               0,
+       };
+
+       /* VP9 decoder element default value */
+       static type_element _videodecoder_element_vp9_default = {
+               "VideodecoderElementVP9",
+               "vp9dec",
+               NULL,
+               0,
+               NULL,
+               0,
+       };
+
        /* Record sink element default value */
        static type_element _recordsink_element_default = {
                "RecordsinkElement",
@@ -668,6 +698,9 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
                { "UseVideoconvert",         CONFIGURE_VALUE_INT,       {.value_int = 0} },
                { "VideoconvertElement",     CONFIGURE_VALUE_ELEMENT,   {&_videoconvert_element_default} },
                { "VideodecoderElementH264", CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_h264_default} },
+               { "VideodecoderElementMJPEG",CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_mjpeg_default} },
+               { "VideodecoderElementVP8",  CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_vp8_default} },
+               { "VideodecoderElementVP9",  CONFIGURE_VALUE_ELEMENT,   {&_videodecoder_element_vp9_default} },
                { "RecreateDecoder",         CONFIGURE_VALUE_INT,       {.value_int = 0} }
        };
 
index 288ffe6..d866c1b 100755 (executable)
@@ -225,8 +225,10 @@ static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataT
                stream->num_planes = 1;
                break;
 
-       case MM_PIXEL_FORMAT_ENCODED_H264: /* fall through */
-       case MM_PIXEL_FORMAT_ENCODED_MJPEG:
+       case MM_PIXEL_FORMAT_ENCODED_H264:  /* fall through */
+       case MM_PIXEL_FORMAT_ENCODED_MJPEG: /* fall through */
+       case MM_PIXEL_FORMAT_ENCODED_VP8:   /* fall through */
+       case MM_PIXEL_FORMAT_ENCODED_VP9:   /* fall through */
                stream->data_type = MM_CAM_STREAM_DATA_ENCODED;
                stream->data.encoded.data = map_info->data;
                stream->data.encoded.length_data = stream->length_total;
@@ -436,12 +438,14 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
        const char *videosrc_name = NULL;
        const char *videosink_name = NULL;
        const char *videoconvert_name = NULL;
+       const char *videodecoder_name = NULL;
+       const char *decoder_conf_name = NULL;
+       char videodecoder_name_final[32] = {'\0',};
        char *err_name = NULL;
        char *socket_path = NULL;
        int socket_path_len;
 #ifdef _MMCAMCORDER_RM_SUPPORT
        int decoder_index = 0;
-       char decoder_name[20] = {'\0',};
 #endif /* _MMCAMCORDER_RM_SUPPORT */
        GstElement *sink_element = NULL;
        GstCameraControl *control = NULL;
@@ -599,7 +603,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        &hcamcorder->recreate_decoder);
        }
 
-       if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+       if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
                int preview_bitrate = 0;
                int gop_interval = 0;
                mm_camcorder_get_attributes(handle, NULL,
@@ -612,70 +616,67 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                        MMCAM_LOG_WARNING("_mmcamcorder_set_encoded_preview_bitrate failed");
 
                /* set encoded preview iframe interval */
-               if (!_mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval))
-                       MMCAM_LOG_WARNING("_mmcamcorder_set_encoded_preview_gop_interval failed");
+               if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                       if (!_mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval))
+                               MMCAM_LOG_WARNING("_mmcamcorder_set_encoded_preview_gop_interval failed");
+               }
        }
 
-       if (display_surface_type != MM_DISPLAY_SURFACE_NULL) {
-               const char *videodecoder_name = NULL;
-               /* case of decoder element */
-               if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-                       /* get video decoder element and name for H.264 format */
-                       _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
-                               CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
-                               "VideodecoderElementH264",
-                               &sc->VideodecoderElementH264);
-                       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264,
-                               &videodecoder_name);
-                       if (videodecoder_name) {
+       if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
+               _mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
+               switch (sc->info_image->preview_format) {
+               case MM_PIXEL_FORMAT_ENCODED_H264:
+                       decoder_conf_name = "VideodecoderElementH264";
+                       break;
+               case MM_PIXEL_FORMAT_ENCODED_MJPEG:
+                       decoder_conf_name = "VideodecoderElementMJPEG";
+                       break;
+               case MM_PIXEL_FORMAT_ENCODED_VP8:
+                       decoder_conf_name = "VideodecoderElementVP8";
+                       break;
+               case MM_PIXEL_FORMAT_ENCODED_VP9:
+                       decoder_conf_name = "VideodecoderElementVP9";
+                       break;
+               default:
+                       MMCAM_LOG_ERROR("invalid format[%d]", sc->info_image->preview_format);
+                       goto pipeline_creation_error;
+               }
+
+               /* get video decoder element and name */
+               _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
+                       CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+                       decoder_conf_name,
+                       &sc->VideodecoderElement);
+
+               _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElement,
+                       &videodecoder_name);
+
+               if (!videodecoder_name) {
+                       MMCAM_LOG_ERROR("failed to get video decoder[%d,%s]", sc->info_image->preview_format, decoder_conf_name);
+                       goto pipeline_creation_error;
+               }
+
 #ifdef _MMCAMCORDER_RM_SUPPORT
-                               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
-                                       decoder_index = 1;
-
-                               snprintf(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
-                               MMCAM_LOG_INFO("encoded preview decoder_name [%s], video decoder element [%s]",
-                                       decoder_name, videodecoder_name);
-                               /* create decoder element */
-                               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, decoder_name, "videosrc_decode", element_list, err);
-#else /* _MMCAMCORDER_RM_SUPPORT */
-                               MMCAM_LOG_INFO("video decoder element [%s]", videodecoder_name);
-                               /* create decoder element */
-                               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, videodecoder_name, "videosrc_decode", element_list, err);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
-                               _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
-                       } else {
-                               MMCAM_LOG_ERROR("failed to get video decoder element name from %p", sc->VideodecoderElementH264);
-                               goto pipeline_creation_error;
-                       }
+               MMCAM_LOG_INFO("decoder name from config[%s]", videodecoder_name);
+               if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                       if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
+                               decoder_index = 1;
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s%d", videodecoder_name, decoder_index);
                } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
-#ifdef _MMCAMCORDER_RM_SUPPORT
-                       /* get video decoder element and name for MJPEG format */
-                       _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
-                               CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
-                               "VideodecoderElementH264",
-                               &sc->VideodecoderElementH264);
-                       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264,
-                               &videodecoder_name);
-                       if (videodecoder_name) {
-                               if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER)
-                                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_uhd_mjpegdec");
-                               else
-                                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_mjpegdec");
-                               MMCAM_LOG_INFO("encoded preview decoder_name [%s], video decoder element [%s]",
-                                       decoder_name, videodecoder_name);
-                               /* create decoder element */
-                               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, decoder_name, "videosrc_decode", element_list, err);
-                               _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
-                       } else {
-                               MMCAM_LOG_ERROR("failed to get video decoder element name from %p", sc->VideodecoderElementH264);
-                               goto pipeline_creation_error;
-                       }
-#else /* _MMCAMCORDER_RM_SUPPORT */
-                       MMCAM_LOG_INFO("video decoder element [jpegdec]");
-                       /* create decoder element */
-                       _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, "jpegdec", "videosrc_decode", element_list, err);
+                       if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER)
+                               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_uhd_mjpegdec");
+                       else
+                               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_mjpegdec");
+               } else {
 #endif /* _MMCAMCORDER_RM_SUPPORT */
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", videodecoder_name);
+#ifdef _MMCAMCORDER_RM_SUPPORT
                }
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+
+               _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, videodecoder_name_final, "videosrc_decode", element_list, err);
+
+               _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElement);
        }
 
        MMCAM_LOG_INFO("Current mode[%d]", hcamcorder->type);
@@ -2021,7 +2022,7 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP
 
        /* The first H.264 frame should not be skipped for vstream cb. */
        if (hcamcorder->state < MM_CAMCORDER_STATE_PREPARE &&
-               sc->info_image->preview_format != MM_PIXEL_FORMAT_ENCODED_H264) {
+               !_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
                MMCAM_LOG_WARNING("Not ready for stream callback");
                return GST_PAD_PROBE_OK;
        }
@@ -2528,6 +2529,13 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
        int fps_auto = 0;
        unsigned int caps_fourcc = 0;
        gboolean do_set_caps = FALSE;
+       char fourcc_string[sizeof(fourcc) + 1];
+       gchar *caps_str = NULL;
+#ifdef _MMCAMCORDER_PRODUCT_TV
+       gint maxwidth = 0;
+       gint maxheight = 0;
+       int display_surface_type = MM_DISPLAY_SURFACE_NULL;
+#endif /* _MMCAMCORDER_PRODUCT_TV */
 
        GstCaps *caps = NULL;
 
@@ -2690,83 +2698,92 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
                caps = NULL;
        }
 
-       if (do_set_caps) {
-               if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
-#ifdef _MMCAMCORDER_PRODUCT_TV
-                       gint maxwidth = 0;
-                       gint maxheight = 0;
-                       int display_surface_type = MM_DISPLAY_SURFACE_NULL;
-                       mm_camcorder_get_attributes(handle, NULL,
-                                       MMCAM_DISPLAY_SURFACE, &display_surface_type,
-                                       NULL);
+       if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+               /* assume that it's camera capture mode */
+               MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "csc-range", 1);
+       }
 
-                       if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
-                               __mmcamcorder_find_max_resolution(handle, &maxwidth, &maxheight) == false) {
-                               MMCAM_LOG_ERROR("can not find max resolution limitation");
-                               return false;
-                       } else if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
-                               maxwidth = set_width;
-                               maxheight = set_height;
-                       }
+       if (!do_set_caps)
+               return TRUE;
+
+       switch (sc->info_image->preview_format) {
+       case MM_PIXEL_FORMAT_ENCODED_H264:
+#ifdef _MMCAMCORDER_PRODUCT_TV
+               mm_camcorder_get_attributes(handle, NULL,
+                       MMCAM_DISPLAY_SURFACE, &display_surface_type,
+                       NULL);
+               if (display_surface_type != MM_DISPLAY_SURFACE_NULL &&
+                       __mmcamcorder_find_max_resolution(handle, &maxwidth, &maxheight) == false) {
+                       MMCAM_LOG_ERROR("can not find max resolution limitation");
+                       return false;
+               } else if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
+                       maxwidth = set_width;
+                       maxheight = set_height;
+               }
 #endif /* _MMCAMCORDER_PRODUCT_TV */
-                       caps = gst_caps_new_simple("video/x-h264",
-                               "width", G_TYPE_INT, set_width,
-                               "height", G_TYPE_INT, set_height,
-                               "framerate", GST_TYPE_FRACTION, fps, 1,
-                               "stream-format", G_TYPE_STRING, "byte-stream",
+               caps = gst_caps_new_simple("video/x-h264",
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       "stream-format", G_TYPE_STRING, "byte-stream",
 #ifdef _MMCAMCORDER_PRODUCT_TV
-                               "maxwidth", G_TYPE_INT, maxwidth,
-                               "maxheight", G_TYPE_INT, maxheight,
-                               "alignment", G_TYPE_STRING, "au",
+                       "maxwidth", G_TYPE_INT, maxwidth,
+                       "maxheight", G_TYPE_INT, maxheight,
+                       "alignment", G_TYPE_STRING, "au",
 #endif /* _MMCAMCORDER_PRODUCT_TV */
-                               NULL);
-               } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG){
+                       NULL);
+               break;
+       case MM_PIXEL_FORMAT_ENCODED_MJPEG:
 #ifdef _MMCAMCORDER_PRODUCT_TV
-                       caps = gst_caps_new_simple("video/x-jpeg",
+               caps = gst_caps_new_simple("video/x-jpeg",
 #else
-                       caps = gst_caps_new_simple("image/jpeg",
+               caps = gst_caps_new_simple("image/jpeg",
 #endif
-                               "width", G_TYPE_INT, set_width,
-                               "height", G_TYPE_INT, set_height,
-                               "framerate", GST_TYPE_FRACTION, fps, 1,
-                               NULL);
-               } else {
-                       char fourcc_string[sizeof(fourcc)+1];
-                       memcpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
-                       fourcc_string[sizeof(fourcc)] = '\0';
-                       caps = gst_caps_new_simple("video/x-raw",
-                               "format", G_TYPE_STRING, fourcc_string,
-                               "width", G_TYPE_INT, set_width,
-                               "height", G_TYPE_INT, set_height,
-                               "framerate", GST_TYPE_FRACTION, fps, 1,
-                               "rotate", G_TYPE_INT, set_rotate,
-                               NULL);
-               }
-
-               if (caps) {
-                       gchar *caps_str = gst_caps_to_string(caps);
-
-                       if (caps_str) {
-                               MMCAM_LOG_INFO("vidoesrc new caps set [%s]", caps_str);
-                               g_free(caps_str);
-                               caps_str = NULL;
-                       } else {
-                               MMCAM_LOG_WARNING("caps string failed");
-                       }
-
-                       MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
-                       gst_caps_unref(caps);
-                       caps = NULL;
-               } else {
-                       MMCAM_LOG_ERROR("There are no caps");
-               }
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       NULL);
+               break;
+       case MM_PIXEL_FORMAT_ENCODED_VP8:
+               caps = gst_caps_new_simple("video/x-vp8",
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       NULL);
+               break;
+       case MM_PIXEL_FORMAT_ENCODED_VP9:
+               caps = gst_caps_new_simple("video/x-vp9",
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       NULL);
+               break;
+               break;
+       default:
+               memcpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
+               fourcc_string[sizeof(fourcc)] = '\0';
+               caps = gst_caps_new_simple("video/x-raw",
+                       "format", G_TYPE_STRING, fourcc_string,
+                       "width", G_TYPE_INT, set_width,
+                       "height", G_TYPE_INT, set_height,
+                       "framerate", GST_TYPE_FRACTION, fps, 1,
+                       "rotate", G_TYPE_INT, set_rotate,
+                       NULL);
+               break;
        }
 
-       if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
-               /* assume that it's camera capture mode */
-               MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "csc-range", 1);
+       if (!caps) {
+               MMCAM_LOG_ERROR("There are no caps");
+               return FALSE;
        }
 
+       caps_str = gst_caps_to_string(caps);
+       MMCAM_LOG_INFO("vidoesrc new caps set [%s]", caps_str);
+       g_free(caps_str);
+
+       MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
+       gst_caps_unref(caps);
+
        return TRUE;
 }
 
@@ -3030,9 +3047,9 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
        _MMCamcorderSubContext *sc = NULL;
        mmf_camcorder_t *hcamcorder = NULL;
        const char *videodecoder_name = NULL;
+       char videodecoder_name_final[32] = {'\0',};
        int display_surface_type = MM_DISPLAY_SURFACE_NULL;
 #ifdef _MMCAMCORDER_RM_SUPPORT
-       char decoder_name[20] = {'\0',};
        int decoder_index = 0;
 #endif /* _MMCAMCORDER_RM_SUPPORT */
 
@@ -3073,9 +3090,9 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
 
        MMCAM_LOG_INFO("start");
 
-       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264, &videodecoder_name);
+       _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElement, &videodecoder_name);
        if (videodecoder_name == NULL) {
-               MMCAM_LOG_ERROR("failed to get decoder element name from %p", sc->VideodecoderElementH264);
+               MMCAM_LOG_ERROR("failed to get decoder element name from %p", sc->VideodecoderElement);
                return FALSE;
        }
 
@@ -3105,32 +3122,28 @@ bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
                if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
                        decoder_index = 1;
 
-               snprintf(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
-               MMCAM_LOG_INFO("encoded preview decoder_name %s", decoder_name);
-       } else {
+               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s%d", videodecoder_name, decoder_index);
+       } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
                /* MJPEG */
                if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER)
-                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_uhd_mjpegdec");
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_uhd_mjpegdec");
                else
-                       snprintf(decoder_name, sizeof(decoder_name)-1, "%s", "omx_mjpegdec");
-               MMCAM_LOG_INFO("encoded preview decoder_name %s", decoder_name);
+                       snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", "omx_mjpegdec");
+       } else {
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+               snprintf(videodecoder_name_final, sizeof(videodecoder_name_final), "%s", videodecoder_name);
+#ifdef _MMCAMCORDER_RM_SUPPORT
        }
+#endif /* _MMCAMCORDER_RM_SUPPORT */
 
        /* create decoder */
-       sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(decoder_name, "videosrc_decode");
-       if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
-               MMCAM_LOG_ERROR("Decoder[%s] creation fail", decoder_name);
-               return FALSE;
-       }
-#else /* _MMCAMCORDER_RM_SUPPORT */
-       /* create new decoder */
-       sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(videodecoder_name, "videosrc_decode");
+       sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(videodecoder_name_final, "videosrc_decode");
        if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
-               MMCAM_LOG_ERROR("Decoder [%s] creation fail", videodecoder_name);
+               MMCAM_LOG_ERROR("Decoder[%s] creation fail", videodecoder_name_final);
                return FALSE;
        }
-#endif /* _MMCAMCORDER_RM_SUPPORT */
-       _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
+
+       _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElement);
 
        sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].id = _MMCAMCORDER_VIDEOSRC_DECODE;
        g_object_weak_ref(G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
index 40fa132..5517217 100644 (file)
@@ -823,16 +823,19 @@ int _mmcamcorder_image_cmd_preview_start(MMHandleType handle)
                if (info->type == _MMCamcorder_MULTI_SHOT)
                        _mmcamcorder_sound_finalize(handle);
        } else {
-               if (info->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+               if (_mmcamcorder_is_encoded_preview_pixel_format(info->preview_format)) {
                        ret = mm_camcorder_get_attributes(handle, NULL,
                                MMCAM_ENCODED_PREVIEW_BITRATE, &bitrate,
-                               MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
                                NULL);
-                       if (ret == MM_ERROR_NONE) {
+                       if (ret == MM_ERROR_NONE)
                                _mmcamcorder_set_encoded_preview_bitrate(handle, bitrate);
-                               _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
-                       } else {
-                               MMCAM_LOG_ERROR("failed to get encoded preview setting");
+
+                       if (info->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                               ret = mm_camcorder_get_attributes(handle, NULL,
+                                       MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
+                                       NULL);
+                               if (ret == MM_ERROR_NONE)
+                                       _mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval);
                        }
                }
 
index ab0d4f8..3babfdd 100644 (file)
@@ -1554,6 +1554,12 @@ int _mmcamcorder_get_pixel_format(GstCaps *caps)
                type = MM_PIXEL_FORMAT_ENCODED;
        else if (!strcmp(media_type, "video/x-h264"))
                type = MM_PIXEL_FORMAT_ENCODED_H264;
+       else if (!strcmp(media_type, "video/x-jpeg"))
+               type = MM_PIXEL_FORMAT_ENCODED_MJPEG;
+       else if (!strcmp(media_type, "video/x-vp8"))
+               type = MM_PIXEL_FORMAT_ENCODED_VP8;
+       else if (!strcmp(media_type, "video/x-vp9"))
+               type = 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));
@@ -1644,11 +1650,17 @@ unsigned int _mmcamcorder_get_fourcc(int pixtype, int codectype, int use_zero_co
        case MM_PIXEL_FORMAT_ENCODED_H264:
                fourcc = GST_MAKE_FOURCC('H', '2', '6', '4');
                break;
+       case MM_PIXEL_FORMAT_INVZ:
+               fourcc = GST_MAKE_FOURCC('I', 'N', 'V', 'Z');
+               break;
        case MM_PIXEL_FORMAT_ENCODED_MJPEG:
                fourcc = GST_MAKE_FOURCC ('M', 'J', 'P', 'G');
                break;
-       case MM_PIXEL_FORMAT_INVZ:
-               fourcc = GST_MAKE_FOURCC('I', 'N', 'V', 'Z');
+       case MM_PIXEL_FORMAT_ENCODED_VP8:
+               fourcc = GST_MAKE_FOURCC ('V', 'P', '8', '0');
+               break;
+       case MM_PIXEL_FORMAT_ENCODED_VP9:
+               fourcc = GST_MAKE_FOURCC ('V', 'P', '9', '0');
                break;
        default:
                MMCAM_LOG_INFO("Not proper pixel type[%d]. Set default - I420", pixtype);
@@ -1676,23 +1688,29 @@ int _mmcamcorder_get_pixtype(unsigned int fourcc)
 
        switch (fourcc) {
        case GST_MAKE_FOURCC('S', 'N', '1', '2'):
+               /* fall through */
        case GST_MAKE_FOURCC('N', 'V', '1', '2'):
                pixtype = MM_PIXEL_FORMAT_NV12;
                break;
        case GST_MAKE_FOURCC('S', 'N', '2', '1'):
+               /* fall through */
        case GST_MAKE_FOURCC('N', 'V', '2', '1'):
                pixtype = MM_PIXEL_FORMAT_NV21;
                break;
        case GST_MAKE_FOURCC('S', 'U', 'Y', 'V'):
+               /* fall through */
        case GST_MAKE_FOURCC('Y', 'U', 'Y', 'V'):
+               /* fall through */
        case GST_MAKE_FOURCC('Y', 'U', 'Y', '2'):
                pixtype = MM_PIXEL_FORMAT_YUYV;
                break;
        case GST_MAKE_FOURCC('S', 'Y', 'V', 'Y'):
+               /* fall through */
        case GST_MAKE_FOURCC('U', 'Y', 'V', 'Y'):
                pixtype = MM_PIXEL_FORMAT_UYVY;
                break;
        case GST_MAKE_FOURCC('S', '4', '2', '0'):
+               /* fall through */
        case GST_MAKE_FOURCC('I', '4', '2', '0'):
                pixtype = MM_PIXEL_FORMAT_I420;
                break;
@@ -1709,16 +1727,18 @@ int _mmcamcorder_get_pixtype(unsigned int fourcc)
                pixtype = MM_PIXEL_FORMAT_RGB888;
                break;
        case GST_MAKE_FOURCC('A', 'R', 'G', 'B'):
+               /* fall through */
        case GST_MAKE_FOURCC('x', 'R', 'G', 'B'):
                pixtype = MM_PIXEL_FORMAT_ARGB;
                break;
        case GST_MAKE_FOURCC('B', 'G', 'R', 'A'):
+               /* fall through */
        case GST_MAKE_FOURCC('B', 'G', 'R', 'x'):
+               /* fall through */
        case GST_MAKE_FOURCC('S', 'R', '3', '2'):
                pixtype = MM_PIXEL_FORMAT_RGBA;
                break;
        case GST_MAKE_FOURCC('J', 'P', 'E', 'G'):
-       case GST_MAKE_FOURCC('P', 'N', 'G', ' '):
                pixtype = MM_PIXEL_FORMAT_ENCODED;
                break;
        /*FIXME*/
@@ -1731,6 +1751,16 @@ int _mmcamcorder_get_pixtype(unsigned int fourcc)
        case GST_MAKE_FOURCC ('M', 'J', 'P', 'G'):
                pixtype = MM_PIXEL_FORMAT_ENCODED_MJPEG;
                break;
+       case GST_MAKE_FOURCC ('V', 'P', '8', '0'):
+               /* fall through */
+       case GST_MAKE_FOURCC ('v', 'p', '0', '8'):
+               pixtype = MM_PIXEL_FORMAT_ENCODED_VP8;
+               break;
+       case GST_MAKE_FOURCC ('V', 'P', '9', '0'):
+               /* fall through */
+       case GST_MAKE_FOURCC ('v', 'p', '0', '9'):
+               pixtype = MM_PIXEL_FORMAT_ENCODED_VP9;
+               break;
        case GST_MAKE_FOURCC('I', 'N', 'V', 'Z'):
                pixtype = MM_PIXEL_FORMAT_INVZ;
                break;
@@ -2385,7 +2415,9 @@ int _mmcamcorder_get_audiosrc_blocksize(int samplerate, int format, int channel,
 gboolean _mmcamcorder_is_encoded_preview_pixel_format(int pixel_format)
 {
        return (pixel_format == MM_PIXEL_FORMAT_ENCODED_H264 ||
-               pixel_format == MM_PIXEL_FORMAT_ENCODED_MJPEG);
+               pixel_format == MM_PIXEL_FORMAT_ENCODED_MJPEG ||
+               pixel_format == MM_PIXEL_FORMAT_ENCODED_VP8 ||
+               pixel_format == MM_PIXEL_FORMAT_ENCODED_VP9);
 }
 
 void _mmcamcorder_set_log_level(int level)
index 0f68c16..64b0c99 100644 (file)
@@ -99,12 +99,12 @@ gboolean _mmcamcorder_video_push_buffer(void *handle, GstSample *sample)
 
                if (info_video->is_first_frame) {
                        /* check first I frame for H.264 stream */
-                       if (info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+                       if (_mmcamcorder_is_encoded_preview_pixel_format(info_image->preview_format)) {
                                if (GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
-                                       MMCAM_LOG_WARNING("NOT I frame.. skip this buffer");
+                                       MMCAM_LOG_WARNING("NOT key frame.. skip this buffer");
                                        return TRUE;
                                } else {
-                                       MMCAM_LOG_WARNING("[H.264] first I frame");
+                                       MMCAM_LOG_WARNING("first key frame");
                                }
                        }
 
@@ -733,11 +733,10 @@ int _mmcamcorder_video_command(MMHandleType handle, int command)
 
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-width", info->video_width);
                                MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "video-height", info->video_height);
-                       } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 &&
+                       } else if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format) &&
                                info->preview_width == info->video_width &&
                                info->preview_height == info->video_height) {
-                               MMCAM_LOG_INFO("H264 preview mode and same resolution");
-
+                               MMCAM_LOG_INFO("Encoded[%d] preview mode and same resolution", sc->info_image->preview_format);
                                /* No need to restart preview */
                                info->restart_preview = FALSE;
                        } else if (info->use_videoscale &&