Add "VideoFilterElement" for preview pipeline
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_internal.c
index 1867d85..0069000 100644 (file)
@@ -420,10 +420,15 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                "RecommendDisplayRotation",
                &rcmd_dpy_rotation);
 
-       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_CAPTURE,
-               "PlayCaptureSound",
-               &play_capture_sound);
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_CAMERA,
+               "SupportExtraPreview",
+               (int *)&hcamcorder->extra_preview.is_supported);
+
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_CAMERA,
+               "ExtraPreviewMode",
+               (int *)&hcamcorder->extra_preview.mode);
 
        _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
                CONFIGURE_CATEGORY_CTRL_CAMERA,
@@ -440,15 +445,23 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                "SupportZSL",
                &hcamcorder->support_zsl_capture);
 
-       MMCAM_LOG_INFO("Recommend fmt[cap:%d,rec:%d], dpy rot %d, cap snd %d, cam facing dir %d, step denom %d, support zsl %d",
-               rcmd_fmt_capture, rcmd_fmt_recording, rcmd_dpy_rotation,
-               play_capture_sound, camera_facing_direction,
-               hcamcorder->brightness_step_denominator, hcamcorder->support_zsl_capture);
+       MMCAM_LOG_INFO("Recommend format[capture:%d, recording:%d]", rcmd_fmt_capture, rcmd_fmt_recording);
+       MMCAM_LOG_INFO("Recommend display rotation[%d]", rcmd_dpy_rotation);
+       MMCAM_LOG_INFO("Camera facing direction[%d]", camera_facing_direction);
+       MMCAM_LOG_INFO("Brightness step denominator[%d]", hcamcorder->brightness_step_denominator);
+       MMCAM_LOG_INFO("Support ZSL capture[%d]", hcamcorder->support_zsl_capture);
 
-       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
-               "UseZeroCopyFormat",
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_ctrl,
+               CONFIGURE_CATEGORY_CTRL_CAMERA,
+               "AltUseZeroCopyFormat",
                &hcamcorder->use_zero_copy_format);
+       if (hcamcorder->use_zero_copy_format == -1) {
+               MMCAM_LOG_WARNING("AltUseZeroCopyFormat is not set, so use \"UseZeroCopyFormat\".");
+               _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+                       CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+                       "UseZeroCopyFormat",
+                       &hcamcorder->use_zero_copy_format);
+       }
 
        _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
                CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
@@ -461,11 +474,6 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                &hcamcorder->support_media_packet_preview_cb);
 
        _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
-               "SupportExtraPreview",
-               &hcamcorder->support_extra_preview);
-
-       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
                CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
                "UseVideoconvert",
                &hcamcorder->use_videoconvert);
@@ -480,6 +488,27 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                "DefaultEncodedPreviewBitrate",
                &hcamcorder->default_encoded_preview_bitrate);
 
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+               CONFIGURE_CATEGORY_MAIN_CAPTURE,
+               "CaptureMode",
+               &hcamcorder->capture_mode);
+
+       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+               CONFIGURE_CATEGORY_MAIN_CAPTURE,
+               "PlayCaptureSound",
+               &play_capture_sound);
+
+       MMCAM_LOG_INFO("Support user buffer[%d]", hcamcorder->support_user_buffer);
+       MMCAM_LOG_INFO("Support media packet preview cb[%d]", hcamcorder->support_media_packet_preview_cb);
+       MMCAM_LOG_INFO("Support extra preview[%d]", hcamcorder->extra_preview.is_supported);
+       MMCAM_LOG_INFO("Extra preview mode[%d]", hcamcorder->extra_preview.mode);
+       MMCAM_LOG_INFO("Capture mode[%d]", hcamcorder->capture_mode);
+       MMCAM_LOG_INFO("Use zero copy format[%d]", hcamcorder->use_zero_copy_format);
+       MMCAM_LOG_INFO("Use video convert[%d]", hcamcorder->use_videoconvert);
+       MMCAM_LOG_INFO("Measure preview FPS[%d]", hcamcorder->measure_preview_fps);
+       MMCAM_LOG_INFO("Default encoded preview bitrate[%d]", hcamcorder->default_encoded_preview_bitrate);
+       MMCAM_LOG_INFO("Play capture sound[%d]", play_capture_sound);
+
        ret = mm_camcorder_get_attributes((MMHandleType)hcamcorder, NULL,
                MMCAM_CAMERA_WIDTH, &resolution_width,
                MMCAM_CAMERA_HEIGHT, &resolution_height,
@@ -495,12 +524,6 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                return MM_ERROR_CAMCORDER_INTERNAL;
        }
 
-       MMCAM_LOG_INFO("ZC %d, UB %d, VC %d, MPPC %d, EP %d, MPFPS %d, DEPB %d",
-               hcamcorder->use_zero_copy_format, hcamcorder->support_user_buffer,
-               hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb,
-               hcamcorder->support_extra_preview, hcamcorder->measure_preview_fps,
-               hcamcorder->default_encoded_preview_bitrate);
-
        MMCAM_LOG_INFO("res : %d X %d, Default FPS by resolution : %d",
                resolution_width, resolution_height, fps_info.int_array.def);
 
@@ -536,7 +559,7 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                MMCAM_SUPPORT_ZERO_COPY_FORMAT, hcamcorder->use_zero_copy_format,
                MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB, hcamcorder->support_media_packet_preview_cb,
                MMCAM_SUPPORT_USER_BUFFER, hcamcorder->support_user_buffer,
-               MMCAM_SUPPORT_EXTRA_PREVIEW, hcamcorder->support_extra_preview,
+               MMCAM_SUPPORT_EXTRA_PREVIEW, hcamcorder->extra_preview.is_supported,
                MMCAM_CAMERA_FPS, fps_info.int_array.def,
                MMCAM_DISPLAY_FLIP, camera_default_flip,
                MMCAM_CAPTURE_SOUND_ENABLE, play_capture_sound,
@@ -590,32 +613,24 @@ static gint __mmcamcorder_init_configure_common(mmf_camcorder_t *hcamcorder)
        int device_count = 0;
        const char *videosrc_name = NULL;
        const char *audiosrc_name = NULL;
-       type_element *SrcElement = NULL;
 
        if (!hcamcorder) {
                MMCAM_LOG_ERROR("NULL handle");
                return MM_ERROR_CAMCORDER_NOT_INITIALIZED;
        }
 
-       /* Device count */
        _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
                CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
                "DeviceCount",
                &device_count);
 
-       /* Videosrc element name */
-       _mmcamcorder_conf_get_element((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
-               "VideosrcElement",
-               &SrcElement);
-       _mmcamcorder_conf_get_value_element_name(SrcElement, &videosrc_name);
+       _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder,
+               hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement",
+               NULL, &videosrc_name);
 
-       /* Audiosrc element name */
-       _mmcamcorder_conf_get_element((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
-               "AudiosrcElement",
-               &SrcElement);
-       _mmcamcorder_conf_get_value_element_name(SrcElement, &audiosrc_name);
+       _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder,
+               hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT, "AudiosrcElement",
+               NULL, &audiosrc_name);
 
        MMCAM_LOG_INFO("Device count[%d], Videosrc[%s], Audiosrc[%s]",
                device_count, videosrc_name, audiosrc_name);
@@ -900,8 +915,6 @@ int _mmcamcorder_realize(MMHandleType handle)
        double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
        char *videosink_element_type = NULL;
        const char *videosink_name = NULL;
-       char *socket_path = NULL;
-       int socket_path_len = 0;
        int conn_size = 0;
 
        mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
@@ -958,12 +971,6 @@ int _mmcamcorder_realize(MMHandleType handle)
        if (motion_rate != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE)
                hcamcorder->sub_context->is_modified_rate = TRUE;
 
-       _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_CAPTURE,
-               "UseEncodebin",
-               &(hcamcorder->sub_context->bencbin_capture));
-       MMCAM_LOG_WARNING("UseEncodebin [%d]", hcamcorder->sub_context->bencbin_capture);
-
        if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
                /* get video recording info */
                _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
@@ -992,17 +999,6 @@ int _mmcamcorder_realize(MMHandleType handle)
        case MM_DISPLAY_SURFACE_NULL:
                videosink_element_type = strdup("VideosinkElementNull");
                break;
-       case MM_DISPLAY_SURFACE_REMOTE:
-               mm_camcorder_get_attributes(handle, NULL,
-                       MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
-                       NULL);
-               if (socket_path == NULL) {
-                       MMCAM_LOG_WARNING("REMOTE surface, but socket path is NULL -> to NullSink");
-                       videosink_element_type = strdup("VideosinkElementNull");
-               } else {
-                       videosink_element_type = strdup("VideosinkElementRemote");
-               }
-               break;
        default:
                videosink_element_type = strdup("VideosinkElementOverlay");
                break;
@@ -1017,7 +1013,7 @@ int _mmcamcorder_realize(MMHandleType handle)
                free(videosink_element_type);
                videosink_element_type = NULL;
        } else {
-               MMCAM_LOG_WARNING("strdup failed(display_surface_type %d). Use default X type",
+               MMCAM_LOG_WARNING("strdup failed(display_surface_type %d). Use default Overlay type",
                        display_surface_type);
 
                _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
@@ -3131,16 +3127,6 @@ int _mmcamcorder_create_pipeline(MMHandleType handle, int type)
                ret = _mmcamcorder_create_preview_pipeline(handle);
                if (ret != MM_ERROR_NONE)
                        return ret;
-
-               if (!sc->bencbin_capture) {
-                       ret = _mmcamcorder_connect_capture_signal(handle);
-                       if (ret != MM_ERROR_NONE)
-                               return ret;
-               }
-
-               if (hcamcorder->support_extra_preview &&
-                       _mmcamcorder_initialize_extra_preview_stream(handle) != MM_ERROR_NONE)
-                       MMCAM_LOG_WARNING("connect extra preview stream signal failed");
                break;
        }