#define _MMCAMCORDER_CONVERT_OUTPUT_BUFFER_NUM 6
#define _MMCAMCORDER_NANOSEC_PER_1SEC 1000000000
#define _MMCAMCORDER_NANOSEC_PER_1MILISEC 1000
+#define _MMCAMCORDER_SIGNAL_REQUEST_CODEC_CONFIG "request-codec-config"
/*-----------------------------------------------------------------------
static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
static int __mmcamcorder_get_amrnb_bitrate_mode(int bitrate);
-static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_name);
-#ifdef _MMCAMCORDER_PRODUCT_TV
-static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height);
-#endif /* _MMCAMCORDER_PRODUCT_TV */
+static guint32 _mmcamcorder_get_structure_fourcc(const GstStructure *structure);
-static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType *stream, tbm_surface_info_s *ts_info);
-static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info);
+static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info);
+static gboolean __mmcamcorder_set_stream_data_zero_copy(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory);
+static const char *__mmcamcorder_get_parser_name(MMPixelFormatType format);
+static void __mmcamcorder_request_codec_config(GstElement *videosrc_element);
/*=======================================================================================
| FUNCTION DEFINITIONS |
=======================================================================================*/
-static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info)
+static gboolean __mmcamcorder_set_stream_data(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMapInfo *map_info)
{
+ gboolean ret = TRUE;
+
mmf_return_val_if_fail(buffer, FALSE);
- mmf_return_val_if_fail(map_info, FALSE);
mmf_return_val_if_fail(stream, FALSE);
+ mmf_return_val_if_fail(map_info, FALSE);
+
+ stream->length_total = map_info->size;
switch (stream->format) {
case MM_PIXEL_FORMAT_NV12: /* fall through */
default:
MMCAM_LOG_ERROR("unsupported format[%d]", stream->format);
- return FALSE;
+ ret = FALSE;
+ break;
}
- return TRUE;
+ return ret;
}
-static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType *stream, tbm_surface_info_s *ts_info)
+static gboolean __mmcamcorder_set_stream_data_zero_copy(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory)
{
- mmf_return_val_if_fail(ts_info, FALSE);
+ int i = 0;
+ int num_bos = 0;
+ int tbm_ret = TBM_SURFACE_ERROR_NONE;
+ tbm_bo_handle bo_handle = {NULL, };
+ tbm_surface_info_s ts_info;
+
mmf_return_val_if_fail(stream, FALSE);
+ mmf_return_val_if_fail(buffer, FALSE);
+ mmf_return_val_if_fail(memory, FALSE);
+
+ if (_mmcamcorder_is_encoded_preview_pixel_format(stream->format)) {
+ stream->bo[0] = gst_tizen_memory_get_bos(memory, 0);
+
+ bo_handle = tbm_bo_get_handle(stream->bo[0], TBM_DEVICE_CPU);
+ if (!bo_handle.ptr) {
+ MMCAM_LOG_ERROR("tbm_bo_get_handle failed[bo:%p,memory:%p]", stream->bo[0], memory);
+ return FALSE;
+ }
+
+ stream->data_type = MM_CAM_STREAM_DATA_ENCODED;
+ stream->num_planes = 1;
+ stream->stride[0] = stream->width;
+ stream->elevation[0] = stream->height;
+ stream->data.encoded.data = bo_handle.ptr;
+ stream->length_total = gst_memory_get_sizes(memory, NULL, NULL);
+ stream->data.encoded.length_data = stream->length_total;
+ stream->data.encoded.is_delta_frame = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
+
+ MMCAM_LOG_VERBOSE("[ENCODED] length[%u], is_delta[%d]",
+ stream->data.encoded.length_data, stream->data.encoded.is_delta_frame);
+
+ return TRUE;
+ }
+
+ memset(&ts_info, 0x0, sizeof(tbm_surface_info_s));
+
+ tbm_ret = tbm_surface_get_info((tbm_surface_h)gst_tizen_memory_get_surface(memory), &ts_info);
+ if (tbm_ret != TBM_SURFACE_ERROR_NONE) {
+ MMCAM_LOG_ERROR("get tbm surface info failed[0x%x]", tbm_ret);
+ return FALSE;
+ }
+
+ stream->length_total = ts_info.size;
+ for (i = 0 ; i < ts_info.num_planes ; i++) {
+ stream->stride[i] = ts_info.planes[i].stride;
+ stream->elevation[i] = ts_info.planes[i].size / ts_info.planes[i].stride;
+ MMCAM_LOG_VERBOSE(" plane[%d] %dx%d", i, stream->stride[i], stream->elevation[i]);
+ }
+
+ num_bos = gst_tizen_memory_get_num_bos(memory);
+ for (i = 0 ; i < num_bos ; i++)
+ stream->bo[i] = gst_tizen_memory_get_bos(memory, i);
+
switch (stream->format) {
case MM_PIXEL_FORMAT_NV12: /* fall through */
case MM_PIXEL_FORMAT_NV21:
stream->data_type = MM_CAM_STREAM_DATA_YUV420SP;
stream->num_planes = 2;
- stream->data.yuv420sp.y = ts_info->planes[0].ptr;
- stream->data.yuv420sp.length_y = ts_info->planes[0].size;
- stream->data.yuv420sp.uv = ts_info->planes[1].ptr;
- stream->data.yuv420sp.length_uv = ts_info->planes[1].size;
+ stream->data.yuv420sp.y = ts_info.planes[0].ptr;
+ stream->data.yuv420sp.length_y = ts_info.planes[0].size;
+ stream->data.yuv420sp.uv = ts_info.planes[1].ptr;
+ stream->data.yuv420sp.length_uv = ts_info.planes[1].size;
+
+ MMCAM_LOG_VERBOSE("[420SP] 0[%p,%u], 1[%p,%u]",
+ stream->data.yuv420sp.y, stream->data.yuv420sp.length_y,
+ stream->data.yuv420sp.uv, stream->data.yuv420sp.length_uv);
break;
case MM_PIXEL_FORMAT_I420:
stream->data_type = MM_CAM_STREAM_DATA_YUV420P;
stream->num_planes = 3;
- stream->data.yuv420p.y = ts_info->planes[0].ptr;
- stream->data.yuv420p.length_y = ts_info->planes[0].size;
- stream->data.yuv420p.u = ts_info->planes[1].ptr;
- stream->data.yuv420p.length_u = ts_info->planes[1].size;
- stream->data.yuv420p.v = ts_info->planes[2].ptr;
- stream->data.yuv420p.length_v = ts_info->planes[2].size;
+ stream->data.yuv420p.y = ts_info.planes[0].ptr;
+ stream->data.yuv420p.length_y = ts_info.planes[0].size;
+ stream->data.yuv420p.u = ts_info.planes[1].ptr;
+ stream->data.yuv420p.length_u = ts_info.planes[1].size;
+ stream->data.yuv420p.v = ts_info.planes[2].ptr;
+ stream->data.yuv420p.length_v = ts_info.planes[2].size;
+
+ MMCAM_LOG_VERBOSE("[I420] 0[%p,%u], 1[%p,%u], 2[%p,%u]",
+ stream->data.yuv420p.y, stream->data.yuv420p.length_y,
+ stream->data.yuv420p.u, stream->data.yuv420p.length_u,
+ stream->data.yuv420p.v, stream->data.yuv420p.length_v);
+ break;
+
+ case MM_PIXEL_FORMAT_YUYV:
+ stream->data_type = MM_CAM_STREAM_DATA_YUV422;
+ stream->num_planes = 1;
+ stream->data.yuv422.yuv = ts_info.planes[0].ptr;
+ stream->data.yuv422.length_yuv = ts_info.planes[0].size;
+
+ MMCAM_LOG_VERBOSE("[YUYV] 0[%p,%u]",
+ stream->data.yuv422.yuv, stream->data.yuv422.length_yuv);
break;
default:
}
+static const char *__mmcamcorder_get_parser_name(MMPixelFormatType format)
+{
+ switch (format) {
+ case MM_PIXEL_FORMAT_ENCODED_H264:
+ return "h264parse";
+ case MM_PIXEL_FORMAT_ENCODED_VP9:
+ return "vp9parse";
+ default:
+ MMCAM_LOG_WARNING("unsupported format[%d]", format);
+ return NULL;
+ }
+}
+
+
+static void __mmcamcorder_request_codec_config(GstElement *videosrc_element)
+{
+ if (!videosrc_element || !G_TYPE_CHECK_INSTANCE(videosrc_element)) {
+ MMCAM_LOG_WARNING("invalid videosrc element[%p]", videosrc_element);
+ return;
+ }
+
+ if (!g_signal_parse_name(_MMCAMCORDER_SIGNAL_REQUEST_CODEC_CONFIG,
+ G_TYPE_FROM_INSTANCE(videosrc_element), NULL, NULL, FALSE)) {
+ MMCAM_LOG_WARNING("no signal[%s]", _MMCAMCORDER_SIGNAL_REQUEST_CODEC_CONFIG);
+ return;
+ }
+
+ MMCAM_LOG_INFO("emit signal[%s]", _MMCAMCORDER_SIGNAL_REQUEST_CODEC_CONFIG);
+
+ g_signal_emit_by_name(videosrc_element, _MMCAMCORDER_SIGNAL_REQUEST_CODEC_CONFIG);
+}
+
+
gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstSample *sample, gboolean is_preview, int stream_id)
{
int i = 0;
- int num_bos = 0;
gboolean ret_cb = TRUE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
MMCamcorderVideoStreamDataType stream;
- tbm_surface_h t_surface = NULL;
- tbm_surface_info_s ts_info;
-
GstBuffer *buffer = NULL;
GstMemory *memory = NULL;
GstMapInfo map_info;
sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
mmf_return_val_if_fail(sc, FALSE);
- /* clear data structure */
- memset(&map_info, 0x0, sizeof(GstMapInfo));
memset(&stream, 0x0, sizeof(MMCamcorderVideoStreamDataType));
caps = gst_sample_get_caps(sample);
structure = gst_caps_get_structure(caps, 0);
mmf_return_val_if_fail(structure, FALSE);
- /* set format and resolution */
- gst_structure_get_int(structure, "width", &stream.width);
- gst_structure_get_int(structure, "height", &stream.height);
- stream.format = _mmcamcorder_get_pixel_format(caps);
+ stream.format = _mmcamcorder_get_pixel_format(caps, TRUE);
+ gst_structure_get(structure,
+ "width", G_TYPE_INT, &stream.width,
+ "height", G_TYPE_INT, &stream.height,
+ NULL);
- if (_mmcamcorder_is_encoded_preview_pixel_format(stream.format)) {
- memory = gst_buffer_get_all_memory(buffer);
- stream.internal_buffer = buffer;
- } else {
- memory = gst_buffer_peek_memory(buffer, 0);
- }
+ memory = gst_buffer_peek_memory(buffer, 0);
if (!memory) {
MMCAM_LOG_ERROR("GstMemory get failed from buffer %p", buffer);
return FALSE;
}
- /* set zero-copy related information */
- if (hcamcorder->use_zero_copy_format) {
- t_surface = (tbm_surface_h)gst_tizen_memory_get_surface(memory);
-
- if (tbm_surface_get_info(t_surface, &ts_info) != TBM_SURFACE_ERROR_NONE) {
- MMCAM_LOG_ERROR("failed to get tbm surface[%p] info", t_surface);
- goto _INVOKE_VIDEO_STREAM_CB_DONE;
- }
-
- /* set bo, stride and elevation */
- num_bos = gst_tizen_memory_get_num_bos(memory);
- for (i = 0 ; i < num_bos ; i++)
- stream.bo[i] = gst_tizen_memory_get_bos(memory, i);
-
- for (i = 0 ; i < ts_info.num_planes ; i++) {
- stream.stride[i] = ts_info.planes[i].stride;
- stream.elevation[i] = ts_info.planes[i].size / ts_info.planes[i].stride;
- MMCAM_LOG_VERBOSE(" plane[%d] %dx%d", i, stream.stride[i], stream.elevation[i]);
- }
+ structure = gst_mini_object_get_qdata(GST_MINI_OBJECT_CAST(buffer), hcamcorder->buffer_quark);
+ if (structure && gst_structure_has_field(structure, "focus-state")) {
+ gst_structure_get(structure,
+ "focus-state", G_TYPE_INT, &stream.focus_state,
+ "facing-direction", G_TYPE_INT, &stream.facing_direction,
+ "flip", G_TYPE_INT, &stream.flip,
+ "rotation", G_TYPE_INT, &stream.rotation,
+ NULL);
- stream.length_total = ts_info.size;
- stream.internal_buffer = buffer;
+ MMCAM_LOG_VERBOSE("structure[%p], [fs:%d,fd:%d,f:%d,r:%d]", structure,
+ stream.focus_state, stream.facing_direction, stream.flip, stream.rotation);
+ }
- if (!__mmcamcorder_set_stream_data_tbm(&stream, &ts_info))
+ if (gst_is_tizen_memory(memory)) {
+ if (!__mmcamcorder_set_stream_data_zero_copy(&stream, buffer, memory))
goto _INVOKE_VIDEO_STREAM_CB_DONE;
} else {
- stream.length_total = gst_memory_get_sizes(memory, NULL, NULL);
+ memset(&map_info, 0x0, sizeof(GstMapInfo));
+
+ if (!gst_memory_map(memory, &map_info, GST_MAP_READWRITE)) {
+ MMCAM_LOG_ERROR("map failed for memory[%p]", memory);
+ return FALSE;
+ }
- if (!gst_memory_map(memory, &map_info, GST_MAP_READWRITE) ||
- !__mmcamcorder_set_stream_data_normal(&stream, buffer, &map_info))
+ if (!__mmcamcorder_set_stream_data(&stream, buffer, &map_info))
goto _INVOKE_VIDEO_STREAM_CB_DONE;
}
stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer) / 1000000); /* nano sec -> milli sec */
stream.extra_stream_id = stream_id;
+ stream.internal_buffer = buffer;
/* invoke application callback */
if (is_preview) {
}
_INVOKE_VIDEO_STREAM_CB_DONE:
+ if (!gst_is_tizen_memory(memory))
+ gst_memory_unmap(memory, &map_info);
+
for (i = 0 ; i < TBM_SURF_PLANE_MAX && stream.bo[i] ; i++) {
tbm_bo_map(stream.bo[i], TBM_DEVICE_CPU, TBM_OPTION_READ|TBM_OPTION_WRITE);
tbm_bo_unmap(stream.bo[i]);
}
- if (map_info.data)
- gst_memory_unmap(memory, &map_info);
-
- if (_mmcamcorder_is_encoded_preview_pixel_format(stream.format))
- gst_memory_unref(memory);
-
return ret_cb;
}
int codectype = 0;
int capture_width = 0;
int capture_height = 0;
- int capture_jpg_quality = 100;
+ int capture_quality = 0;
int video_stabilization = 0;
int anti_shake = 0;
int display_surface_type = MM_DISPLAY_SURFACE_NULL;
const char *videosink_name = NULL;
const char *videoconvert_name = NULL;
const char *videodecoder_name = NULL;
+ const char *videoparse_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;
#endif /* _MMCAMCORDER_RM_SUPPORT */
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- type_element *VideosrcElement = NULL;
+ type_element *videosrc_element = NULL;
type_int_array *input_index = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
MMCAM_CAPTURE_HEIGHT, &capture_height,
MMCAM_CAMERA_HDR_CAPTURE, &sc->info_image->hdr_capture_mode,
MMCAM_IMAGE_ENCODER, &codectype,
- MMCAM_IMAGE_ENCODER_QUALITY, &capture_jpg_quality,
- MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
+ MMCAM_IMAGE_ENCODER_QUALITY, &capture_quality,
MMCAM_DISPLAY_SURFACE, &display_surface_type,
MMCAM_EXTRA_PREVIEW_ENABLE, &extra_preview_enable,
NULL);
/* Get fourcc from picture format */
sc->fourcc = _mmcamcorder_get_fourcc(sc->info_image->preview_format, codectype, hcamcorder->use_zero_copy_format);
- /* Get videosrc element and its name from configure */
- _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "VideosrcElement",
- &VideosrcElement);
- _mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
+ _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT, "VideosrcElement",
+ &videosrc_element, &videosrc_name);
/**
* Create child element
*/
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hal-name", hcamcorder->network_hal_name);
- /* set camera properties */
+ /* camera properties */
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", 0);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", capture_width);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", capture_height);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", capture_jpg_quality);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-quality", capture_quality);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", sc->info_image->hdr_capture_mode);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "extra-preview", extra_preview_enable);
+ MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "buffer-quark", &hcamcorder->buffer_quark);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_QUE, "queue", "videosrc_queue", element_list, err);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", fps);
/* Set basic information of videosrc element */
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, VideosrcElement);
+ _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, videosrc_element);
/* Set video device index */
if (hcamcorder->is_network) {
}
#endif /* _MMCAMCORDER_RM_SUPPORT */
+ videoparse_name = __mmcamcorder_get_parser_name(sc->info_image->preview_format);
+ if (videoparse_name)
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_PARSE, videoparse_name, "videosrc_parse", element_list, err);
+
_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("videosink_name: %s", videosink_name);
- if (display_surface_type == MM_DISPLAY_SURFACE_REMOTE) {
- _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, "ipc_sink", element_list, err);
+ if (hcamcorder->use_videoconvert && (!strcmp(videosink_name, "tizenwlsink") || !strcmp(videosink_name, "directvideosink"))) {
+ /* get video convert name */
+ _mmcamcorder_conf_get_value_element_name(sc->VideoconvertElement, &videoconvert_name);
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
-
- err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
- NULL);
- if (err != MM_ERROR_NONE) {
- MMCAM_LOG_WARNING("Get socket path failed 0x%x", err);
- SAFE_FREE(err_name);
- goto pipeline_creation_error;
- }
-
- g_object_set(G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst), "socket-path", socket_path, NULL);
- } else {
- if (hcamcorder->use_videoconvert && (!strcmp(videosink_name, "tizenwlsink") || !strcmp(videosink_name, "directvideosink"))) {
- /* get video convert name */
- _mmcamcorder_conf_get_value_element_name(sc->VideoconvertElement, &videoconvert_name);
-
- if (videoconvert_name) {
- MMCAM_LOG_INFO("videoconvert element name : %s", videoconvert_name);
- _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_CLS, videoconvert_name, "videosink_cls", element_list, err);
- } else
- MMCAM_LOG_ERROR("failed to get videoconvert element name");
- }
+ if (videoconvert_name) {
+ MMCAM_LOG_INFO("videoconvert element name : %s", videoconvert_name);
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_CLS, videoconvert_name, "videosink_cls", element_list, err);
+ } else
+ MMCAM_LOG_ERROR("failed to get videoconvert element name");
+ }
- /* check sink element in attribute */
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_DISPLAY_REUSE_ELEMENT, &sink_element, &sink_element_size,
- NULL);
+ /* check sink element in attribute */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_REUSE_ELEMENT, &sink_element, &sink_element_size,
+ NULL);
- if (sink_element) {
- int attr_index = 0;
- MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
+ if (sink_element) {
+ int attr_index = 0;
+ MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
- MMCAM_LOG_INFO("reuse sink element %p in attribute", sink_element);
+ MMCAM_LOG_INFO("reuse sink element %p in attribute", sink_element);
- _MMCAMCORDER_ELEMENT_ADD(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, sink_element, element_list, err);
+ _MMCAMCORDER_ELEMENT_ADD(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, sink_element, element_list, err);
- /* reset attribute */
- if (attrs) {
- mm_attrs_get_index((MMHandleType)attrs, MMCAM_DISPLAY_REUSE_ELEMENT, &attr_index);
- mm_attrs_set_data(attrs, attr_index, NULL, 0);
- mm_attrs_commit(attrs, attr_index);
- } else {
- MMCAM_LOG_WARNING("attribute is NULL");
- err = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
- goto pipeline_creation_error;
- }
+ /* reset attribute */
+ if (attrs) {
+ mm_attrs_get_index((MMHandleType)attrs, MMCAM_DISPLAY_REUSE_ELEMENT, &attr_index);
+ mm_attrs_set_data(attrs, attr_index, NULL, 0);
+ mm_attrs_commit(attrs, attr_index);
} else {
- _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, "videosink_sink", element_list, err);
-
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
- }
-
- if (_mmcamcorder_videosink_window_set(handle, sc->VideosinkElement) != MM_ERROR_NONE) {
- MMCAM_LOG_ERROR("_mmcamcorder_videosink_window_set error");
- err = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+ MMCAM_LOG_WARNING("attribute is NULL");
+ err = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
goto pipeline_creation_error;
}
+ } else {
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, "videosink_sink", element_list, err);
+
+ _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
+ }
+
+ if (_mmcamcorder_videosink_window_set(handle, sc->VideosinkElement) != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("_mmcamcorder_videosink_window_set error");
+ err = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+ goto pipeline_creation_error;
}
/* Set caps by rotation */
pipeline_creation_error:
_MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_SRC);
_MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_FILT);
- _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CLS_QUE);
- _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CLS);
- _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CLS_FILT);
_MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_QUE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CAP_FILT);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CAP_SINK);
_MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_DECODE);
_MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSINK_QUE);
_MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSINK_SINK);
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
_MMCamcorderGstElement *last_element = NULL;
- type_element *AudiosrcElement = NULL;
+ type_element *audiosrc_element = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
goto pipeline_creation_error;
}
- _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
- cat_name,
- &AudiosrcElement);
- _mmcamcorder_conf_get_value_element_name(AudiosrcElement, &audiosrc_name);
+ _mmcamcorder_conf_get_element_and_name((MMHandleType)hcamcorder,
+ CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT, cat_name,
+ &audiosrc_element, &audiosrc_name);
free(cat_name);
cat_name = NULL;
_mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
/* set audiosrc properties in ini configuration */
- _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, AudiosrcElement);
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, audiosrc_element);
/* set block size */
_mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
}
if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
- /* set dummy element */
- gst_element_venc_name = "identity";
+ /* set parse element */
+ gst_element_venc_name = __mmcamcorder_get_parser_name(sc->info_image->preview_format);
+ if (!gst_element_venc_name)
+ gst_element_venc_name = "identity";
} else {
_mmcamcorder_conf_get_value_element_name(VideoencElement, &gst_element_venc_name);
}
MMCAM_LOG_INFO("Element add complete");
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
- pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "video");
+ pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "video");
if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("video_sink0", pad))) {
gst_object_unref(pad);
pad = NULL;
pad = NULL;
if (sc->audio_disable == FALSE) {
- pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
+ pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
gst_object_unref(pad);
pad = NULL;
pad = NULL;
}
} else if (profile == MM_CAMCORDER_ENCBIN_PROFILE_AUDIO) {
- pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
+ pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
gst_object_unref(pad);
pad = NULL;
pad = NULL;
} else {
/* for stillshot */
- pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
+ pad = gst_element_request_pad_simple(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("image_sink0", pad))) {
gst_object_unref(pad);
pad = NULL;
gst_object_unref(bus);
bus = NULL;
+ /* capture mode */
+ err = _mmcamcorder_initialize_capture_mode(handle);
+ if (err != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("initialize capture mode[%d] failed", hcamcorder->capture_mode);
+ goto pipeline_creation_error;
+ }
+
+ /* extra preview mode */
+ err = _mmcamcorder_initialize_extra_preview_mode(handle);
+ if (err != MM_ERROR_NONE) {
+ MMCAM_LOG_ERROR("initialize extra preview mode[%d] failed", hcamcorder->extra_preview.mode);
+ goto pipeline_creation_error;
+ }
+
return MM_ERROR_NONE;
pipeline_creation_error:
/* set flag */
if (sc->info_video->push_encoding_buffer == PUSH_ENCODING_BUFFER_INIT) {
sc->info_video->push_encoding_buffer = PUSH_ENCODING_BUFFER_RUN;
- MMCAM_LOG_WARNING("set push_encoding_buffer RUN");
+ __mmcamcorder_request_codec_config(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
+ MMCAM_LOG_WARNING("start to push buffer to encoding pipeline");
}
}
return TRUE;
}
-static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_name)
+static guint32 _mmcamcorder_get_structure_fourcc(const GstStructure *structure)
{
- return format_name[0] | (format_name[1] << 8) | (format_name[2] << 16) | (format_name[3] << 24);
+ const gchar *format_string = NULL;
+
+ if (!structure) {
+ MMCAM_LOG_WARNING("NULL structure");
+ return GST_MAKE_FOURCC('N', 'U', 'L', 'L');
+ }
+
+ if (gst_structure_has_name(structure, "video/x-h264"))
+ return GST_MAKE_FOURCC('H', '2', '6', '4');
+
+ if (gst_structure_has_name(structure, "video/x-h265"))
+ return GST_MAKE_FOURCC('H', '2', '6', '5');
+
+ if (gst_structure_has_name(structure, "video/x-vp8"))
+ return GST_MAKE_FOURCC('V', 'P', '8', '0');
+
+ if (gst_structure_has_name(structure, "video/x-vp9"))
+ return GST_MAKE_FOURCC('V', 'P', '9', '0');
+
+ if (gst_structure_has_name(structure, "video/x-jpeg") ||
+ gst_structure_has_name(structure, "image/jpeg"))
+ return GST_MAKE_FOURCC('M', 'J', 'P', 'G');
+
+ format_string = gst_structure_get_string(structure, "format");
+
+ if (format_string)
+ return GST_STR_FOURCC(format_string);
+
+ return GST_MAKE_FOURCC('N', 'O', 'N', 'E');
}
static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
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;
mmf_camcorder_t *hcamcorder = NULL;
structure = gst_caps_get_structure(caps, 0);
if (structure) {
- const gchar *format_string = NULL;
int caps_width = 0;
int caps_height = 0;
- int caps_fps = 0;
+ int caps_fps_n = 0;
+ int caps_fps_d = 0;
int caps_rotate = 0;
- format_string = gst_structure_get_string(structure, "format");
- if (format_string)
- caps_fourcc = _mmcamcorder_convert_fourcc_string_to_value(format_string);
+ caps_fourcc = _mmcamcorder_get_structure_fourcc(structure);
- gst_structure_get_int(structure, "width", &caps_width);
- gst_structure_get_int(structure, "height", &caps_height);
- gst_structure_get_int(structure, "fps", &caps_fps);
- gst_structure_get_int(structure, "rotate", &caps_rotate);
+ gst_structure_get(structure,
+ "width", G_TYPE_INT, &caps_width,
+ "height", G_TYPE_INT, &caps_height,
+ "framerate", GST_TYPE_FRACTION, &caps_fps_n, &caps_fps_d,
+ "rotate", G_TYPE_INT, &caps_rotate,
+ NULL);
#ifdef _MMCAMCORDER_PRODUCT_TV
if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
if (set_width == caps_width && set_height == caps_height &&
- set_rotate == caps_rotate && fps == caps_fps) {
+ set_rotate == caps_rotate && fps == caps_fps_n) {
MMCAM_LOG_INFO("No need to replace caps.");
} else {
- MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+ MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d/%d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
- caps_width, caps_height, caps_fps, caps_rotate,
+ caps_width, caps_height, caps_fps_n, caps_fps_d, caps_rotate,
fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
set_width, set_height, fps, set_rotate);
do_set_caps = TRUE;
}
} else {
if (set_width == caps_width && set_height == caps_height &&
- fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps) {
+ fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps_n) {
MMCAM_LOG_INFO("No need to replace caps.");
} else {
- MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+ MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d/%d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
- caps_width, caps_height, caps_fps, caps_rotate,
+ caps_width, caps_height, caps_fps_n, caps_fps_d, caps_rotate,
fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
set_width, set_height, fps, set_rotate);
do_set_caps = TRUE;
}
#else /*_MMCAMCORDER_PRODUCT_TV */
if (set_width == caps_width && set_height == caps_height &&
- fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps) {
+ fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps_n) {
MMCAM_LOG_INFO("No need to replace caps.");
} else {
- MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+ MMCAM_LOG_INFO("current [%c%c%c%c %dx%d, fps %d/%d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
- caps_width, caps_height, caps_fps, caps_rotate,
+ caps_width, caps_height, caps_fps_n, caps_fps_d, caps_rotate,
fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
set_width, set_height, fps, set_rotate);
do_set_caps = TRUE;
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",
-#ifdef _MMCAMCORDER_PRODUCT_TV
- "maxwidth", G_TYPE_INT, maxwidth,
- "maxheight", G_TYPE_INT, maxheight,
- "alignment", G_TYPE_STRING, "au",
-#endif /* _MMCAMCORDER_PRODUCT_TV */
- NULL);
- break;
- case MM_PIXEL_FORMAT_ENCODED_MJPEG:
-#ifdef _MMCAMCORDER_PRODUCT_TV
- caps = gst_caps_new_simple("video/x-jpeg",
-#else
- 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);
- 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;
- }
-
+ caps = _mmcamcorder_get_video_caps(handle,
+ sc->info_image->preview_format, set_width, set_height, fps, set_rotate);
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);
}
#ifdef _MMCAMCORDER_PRODUCT_TV
-static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height)
+bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height)
{
_MMCamcorderSubContext *sc = NULL;
mmf_camcorder_t *hcamcorder = NULL;