From c4b8ae62fce61e2ef75ec1d62806c99e01901857 Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Tue, 20 Sep 2022 20:46:32 +0900 Subject: [PATCH] Add new INI fields to use multiple camera plugin - "AltVideosrcElement" : The alternative videosrc element will be used instead of "VideosrcElement" in main configuration file, if exists. - "AltUseZeroCopyFormat" : The alternative value of "UseZeroCopyFormat", it will be used if it's not default value(-1). [Version] 0.10.272 [Issue Type] New feature Change-Id: I6c27b4d2155c692e666e9913f0d2ef7daf999d8d Signed-off-by: Jeongmo Yang --- packaging/libmm-camcorder.spec | 2 +- src/include/mm_camcorder_configure.h | 3 ++- src/mm_camcorder_configure.c | 14 ++++++++++---- src/mm_camcorder_gstcommon.c | 11 +++++++++-- src/mm_camcorder_internal.c | 17 ++++++++++++----- src/mm_camcorder_stillshot.c | 2 +- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/packaging/libmm-camcorder.spec b/packaging/libmm-camcorder.spec index f1c210c..5b969cf 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.271 +Version: 0.10.272 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_camcorder_configure.h b/src/include/mm_camcorder_configure.h index a5fc93a..26c9df6 100644 --- a/src/include/mm_camcorder_configure.h +++ b/src/include/mm_camcorder_configure.h @@ -397,7 +397,8 @@ int _mmcamcorder_conf_get_default_value_int(MMHandleType handle, int type, int c int _mmcamcorder_conf_get_default_value_string(MMHandleType handle, int type, int category, const char *name, const char **value); int _mmcamcorder_conf_get_default_element(MMHandleType handle, int type, int category, const char *name, type_element **element); int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int category, int *size); -void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, int category, const char *name, type_element **element, const char **element_name); +void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, camera_conf *configure_info, int category, + const char *name, type_element **element, const char **element_name); #ifdef __cplusplus } diff --git a/src/mm_camcorder_configure.c b/src/mm_camcorder_configure.c index 3737d04..bf2e84d 100644 --- a/src/mm_camcorder_configure.c +++ b/src/mm_camcorder_configure.c @@ -823,7 +823,9 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure { "FacingDirection", CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_CAMERA_FACING_DIRECTION_REAR} }, { "FrameStabilityCount", CONFIGURE_VALUE_INT, {.value_int = 0} }, { "SupportExtraPreview", CONFIGURE_VALUE_INT, {.value_int = 0} }, - { "ExtraPreviewMode", CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_EXTRA_PREVIEW_MODE_CAMERA_CONTROL} } + { "ExtraPreviewMode", CONFIGURE_VALUE_INT, {.value_int = MM_CAMCORDER_EXTRA_PREVIEW_MODE_CAMERA_CONTROL} }, + { "AltVideosrcElement", CONFIGURE_VALUE_ELEMENT, {NULL} }, /* The alternative of videosrc element, it will be used instead of "VideosrcElement" if exists. */ + { "AltUseZeroCopyFormat", CONFIGURE_VALUE_INT, {.value_int = -1} } /* The alternative of "UseZeroCopyFormat", it will be used if it's not default(-1) value. */ }; /* [Strobe] matching table */ @@ -2090,7 +2092,8 @@ int _mmcamcorder_conf_get_category_size(MMHandleType handle, int type, int categ return TRUE; } -void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, int category, const char *name, type_element **element, const char **element_name) +void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, camera_conf *conf, int category, + const char *name, type_element **element, const char **element_name) { type_element *_element = NULL; mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle); @@ -2100,8 +2103,11 @@ void _mmcamcorder_conf_get_element_and_name(MMHandleType handle, int category, c return; } - _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main, - category, name, &_element); + if (!_mmcamcorder_conf_get_element(handle, conf, + category, name, &_element)) { + MMCAM_LOG_WARNING("get [%s] failed", name); + return; + } if (element) *element = _element; diff --git a/src/mm_camcorder_gstcommon.c b/src/mm_camcorder_gstcommon.c index 362421c..4933e86 100644 --- a/src/mm_camcorder_gstcommon.c +++ b/src/mm_camcorder_gstcommon.c @@ -618,9 +618,16 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle) sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codectype, hcamcorder->use_zero_copy_format); _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder, - CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement", + hcamcorder->conf_ctrl, CONFIGURE_CATEGORY_CTRL_CAMERA, "AltVideosrcElement", &videosrc_element, &videosrc_name); + /* Skip getting "VideosrcElement" if alternative element exists. */ + if (videosrc_name == NULL) { + _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder, + hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement", + &videosrc_element, &videosrc_name); + } + /** * Create child element */ @@ -939,7 +946,7 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle) } _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder, - CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT, cat_name, + hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT, cat_name, &audiosrc_element, &audiosrc_name); free(cat_name); diff --git a/src/mm_camcorder_internal.c b/src/mm_camcorder_internal.c index b473eb7..0069000 100644 --- a/src/mm_camcorder_internal.c +++ b/src/mm_camcorder_internal.c @@ -451,10 +451,17 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord 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, @@ -618,11 +625,11 @@ static gint __mmcamcorder_init_configure_common(mmf_camcorder_t *hcamcorder) &device_count); _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder, - CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement", + hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement", NULL, &videosrc_name); _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder, - CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT, "AudiosrcElement", + hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT, "AudiosrcElement", NULL, &audiosrc_name); MMCAM_LOG_INFO("Device count[%d], Videosrc[%s], Audiosrc[%s]", diff --git a/src/mm_camcorder_stillshot.c b/src/mm_camcorder_stillshot.c index 85a5202..e1ab043 100644 --- a/src/mm_camcorder_stillshot.c +++ b/src/mm_camcorder_stillshot.c @@ -387,7 +387,7 @@ static int __mmcamcorder_extra_preview_mode_init_pipeline(MMHandleType handle, M if (mode == MM_CAMCORDER_EXTRA_PREVIEW_MODE_PIPELINE_ELEMENT) { _mmcamcorder_conf_get_element_and_name(handle, - CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement", + hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement", &videosrc_element, &videosrc_name); _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_EXT_SRC, videosrc_name, "videosrc_ext_src", element_list, err); -- 2.34.1