summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongmo Yang <jm80.yang@samsung.com>2019-04-09 06:37:24 +0000
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>2019-04-09 06:37:24 +0000
commit8620b9b49c1b84c5f8fea9492ab2c1b758289c58 (patch)
tree2624f922601e1e3d5f950477b915d91e6b7dac32
parent345c781655d0213dcf09d5fc597c1a24bdc7f6bc (diff)
parent96c1782a7a90b6c6af42aabcfa08d71c475823f6 (diff)
downloadlibmm-camcorder-8620b9b49c1b84c5f8fea9492ab2c1b758289c58.tar.gz
libmm-camcorder-8620b9b49c1b84c5f8fea9492ab2c1b758289c58.tar.bz2
libmm-camcorder-8620b9b49c1b84c5f8fea9492ab2c1b758289c58.zip
Merge "Support user buffer fd" into tizen
-rw-r--r--src/include/mm_camcorder.h10
-rw-r--r--src/include/mm_camcorder_attribute.h2
-rw-r--r--src/include/mm_camcorder_internal.h1
-rw-r--r--src/mm_camcorder_attribute.c22
-rw-r--r--src/mm_camcorder_configure.c1
-rw-r--r--src/mm_camcorder_gstcommon.c27
-rw-r--r--src/mm_camcorder_internal.c17
7 files changed, 76 insertions, 4 deletions
diff --git a/src/include/mm_camcorder.h b/src/include/mm_camcorder.h
index 9ad8416..0eb6492 100644
--- a/src/include/mm_camcorder.h
+++ b/src/include/mm_camcorder.h
@@ -1228,6 +1228,16 @@ extern "C" {
#define MMCAM_SUPPORT_MEDIA_PACKET_PREVIEW_CB "support-media-packet-preview-cb"
/**
+* Support user buffer for zero copy
+*/
+#define MMCAM_SUPPORT_USER_BUFFER "support-user-buffer"
+
+/**
+* Buffer fd from user
+*/
+#define MMCAM_USER_BUFFER_FD "user-buffer-fd"
+
+/**
* Enable to write tags for recorded file
*/
#define MMCAM_RECORDER_TAG_ENABLE "recorder-tag-enable"
diff --git a/src/include/mm_camcorder_attribute.h b/src/include/mm_camcorder_attribute.h
index e0ccc7c..2e8cbad 100644
--- a/src/include/mm_camcorder_attribute.h
+++ b/src/include/mm_camcorder_attribute.h
@@ -188,6 +188,8 @@ typedef enum {
MM_CAM_GDBUS_CONNECTION, /* 130 */
MM_CAM_AUDIO_REPLAY_GAIN_ENABLE,
MM_CAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL,
+ MM_CAM_SUPPORT_USER_BUFFER,
+ MM_CAM_USER_BUFFER_FD,
MM_CAM_ATTRIBUTE_NUM
} MMCamcorderAttrsID;
diff --git a/src/include/mm_camcorder_internal.h b/src/include/mm_camcorder_internal.h
index f8f9ad9..144ae34 100644
--- a/src/include/mm_camcorder_internal.h
+++ b/src/include/mm_camcorder_internal.h
@@ -770,6 +770,7 @@ typedef struct mmf_camcorder {
int use_zero_copy_format; /**< Whether use zero copy format for camera input */
int use_videoconvert; /**< Whether use videoconvert element for display */
int support_media_packet_preview_cb; /**< Whether support zero copy format for camera input */
+ int support_user_buffer; /**< Whether support user allocated buffer for zero copy */
int shutter_sound_policy; /**< shutter sound policy */
int brightness_default; /**< default value of brightness */
int brightness_step_denominator; /**< denominator of brightness bias step */
diff --git a/src/mm_camcorder_attribute.c b/src/mm_camcorder_attribute.c
index 8f162b7..719c0fe 100644
--- a/src/mm_camcorder_attribute.c
+++ b/src/mm_camcorder_attribute.c
@@ -1609,6 +1609,28 @@ _mmcamcorder_alloc_attribute(MMHandleType handle)
{.double_min = 0.0},
{.double_max = 150.0},
_mmcamcorder_commit_audio_replay_gain,
+ },
+ {
+ MM_CAM_SUPPORT_USER_BUFFER,
+ "support-user-buffer",
+ MM_ATTRS_TYPE_INT,
+ MM_ATTRS_FLAG_RW,
+ {(void*)FALSE},
+ MM_ATTRS_VALID_TYPE_INT_RANGE,
+ {.int_min = FALSE},
+ {.int_max = TRUE},
+ NULL,
+ },
+ {
+ MM_CAM_USER_BUFFER_FD,
+ "user-buffer-fd",
+ MM_ATTRS_TYPE_DATA,
+ MM_ATTRS_FLAG_RW,
+ {NULL},
+ MM_ATTRS_VALID_TYPE_NONE,
+ {0},
+ {0},
+ NULL,
}
};
diff --git a/src/mm_camcorder_configure.c b/src/mm_camcorder_configure.c
index 575a073..a245b44 100644
--- a/src/mm_camcorder_configure.c
+++ b/src/mm_camcorder_configure.c
@@ -635,6 +635,7 @@ int _mmcamcorder_conf_init(MMHandleType handle, int type, camera_conf *configure
{ "UseZeroCopyFormat", CONFIGURE_VALUE_INT, {.value_int = 0} },
{ "DeviceCount", CONFIGURE_VALUE_INT, {.value_int = MM_VIDEO_DEVICE_NUM} },
{ "SupportMediaPacketPreviewCb", CONFIGURE_VALUE_INT, {.value_int = 0} },
+ { "SupportUserBuffer", CONFIGURE_VALUE_INT, {.value_int = 0} },
};
/* [AudioInput] matching table */
diff --git a/src/mm_camcorder_gstcommon.c b/src/mm_camcorder_gstcommon.c
index 3bc8440..ccff837 100644
--- a/src/mm_camcorder_gstcommon.c
+++ b/src/mm_camcorder_gstcommon.c
@@ -188,7 +188,10 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
char decoder_name[20] = {'\0',};
#endif /* _MMCAMCORDER_RM_SUPPORT */
GstElement *sink_element = NULL;
+ GstCameraControl *control = NULL;
int sink_element_size = 0;
+ int *fds = NULL;
+ int fd_number = 0;
GList *element_list = NULL;
@@ -248,6 +251,21 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
return err;
}
+ if (hcamcorder->support_user_buffer) {
+ err = mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_USER_BUFFER_FD, &fds, &fd_number,
+ NULL);
+ if (err != MM_ERROR_NONE || fd_number < 1) {
+ _mmcam_dbg_err("get user buffer fd failed 0x%x, number %d", err, fd_number);
+ return err;
+ }
+
+ /*
+ for (i = 0 ; i < fd_number ; i++)
+ _mmcam_dbg_log("fds[%d] %d", i, fds[i]);
+ */
+ }
+
/* Get fourcc from picture format */
sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codectype, hcamcorder->use_zero_copy_format);
@@ -294,6 +312,15 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
/* Set video device index */
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "camera-id", input_index->default_value);
+ /* set user buffer fd to videosrc element */
+ if (hcamcorder->support_user_buffer) {
+ control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ if (!gst_camera_control_set_user_buffer_fd(control, fds, fd_number)) {
+ _mmcam_dbg_err("set user buffer fd failed");
+ goto pipeline_creation_error;
+ }
+ }
+
/* make demux and decoder for H264 stream from videosrc */
if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
int preview_bitrate = 0;
diff --git a/src/mm_camcorder_internal.c b/src/mm_camcorder_internal.c
index eff03e1..a4ab29d 100644
--- a/src/mm_camcorder_internal.c
+++ b/src/mm_camcorder_internal.c
@@ -403,13 +403,19 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
"UseZeroCopyFormat",
- &(hcamcorder->use_zero_copy_format));
+ &hcamcorder->use_zero_copy_format);
+
+ /* Get SupportUserBuffer value from INI */
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "SupportUserBuffer",
+ &hcamcorder->support_user_buffer);
/* Get SupportMediaPacketPreviewCb value from INI */
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
"SupportMediaPacketPreviewCb",
- &(hcamcorder->support_media_packet_preview_cb));
+ &hcamcorder->support_media_packet_preview_cb);
/* Get UseVideoconvert value from INI */
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
@@ -424,8 +430,10 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
mm_camcorder_get_fps_list_by_resolution((MMHandleType)hcamcorder, resolution_width, resolution_height, &fps_info);
- _mmcam_dbg_log("UseZeroCopyFormat %d, UseVideoconvert %d, SupportMediaPacketPreviewCb %d",
- hcamcorder->use_zero_copy_format, hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb);
+ _mmcam_dbg_log("ZeroCopy %d, UserBuffer %d, Videoconvert %d, MPPreviewCb %d",
+ hcamcorder->use_zero_copy_format, hcamcorder->support_user_buffer,
+ hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb);
+
_mmcam_dbg_log("res : %d X %d, Default FPS by resolution : %d",
resolution_width, resolution_height, fps_info.int_array.def);
@@ -447,6 +455,7 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
MMCAM_SUPPORT_ZSL_CAPTURE, hcamcorder->support_zsl_capture,
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_CAMERA_FPS, fps_info.int_array.def,
MMCAM_DISPLAY_FLIP, camera_default_flip,
MMCAM_CAPTURE_SOUND_ENABLE, play_capture_sound,