#include <gst/allocators/gsttizenmemory.h>
#include <gst/audio/audio-format.h>
#include <gst/video/videooverlay.h>
-#include <gst/video/cameracontrol.h>
#include <sys/time.h>
#include <unistd.h>
static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height);
#endif /* _MMCAMCORDER_PRODUCT_TV */
-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, GstMemory *memory);
+static gboolean __mmcamcorder_set_stream_data_zero_copy(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, GstMemory *memory);
/*=======================================================================================
| 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, GstMemory *memory)
{
+ gboolean ret = TRUE;
+ GstMapInfo map_info;
+
mmf_return_val_if_fail(buffer, FALSE);
- mmf_return_val_if_fail(map_info, FALSE);
mmf_return_val_if_fail(stream, FALSE);
+ 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;
+ }
+
+ stream->length_total = gst_memory_get_sizes(memory, NULL, NULL);
+
switch (stream->format) {
case MM_PIXEL_FORMAT_NV12: /* fall through */
case MM_PIXEL_FORMAT_NV21:
stream->data_type = MM_CAM_STREAM_DATA_YUV420SP;
- stream->data.yuv420sp.y = map_info->data;
+ stream->data.yuv420sp.y = map_info.data;
stream->data.yuv420sp.length_y = stream->width * stream->height;
stream->data.yuv420sp.uv = stream->data.yuv420sp.y + stream->data.yuv420sp.length_y;
stream->data.yuv420sp.length_uv = stream->data.yuv420sp.length_y >> 1;
case MM_PIXEL_FORMAT_I420:
stream->data_type = MM_CAM_STREAM_DATA_YUV420P;
- stream->data.yuv420p.y = map_info->data;
+ stream->data.yuv420p.y = map_info.data;
stream->data.yuv420p.length_y = stream->width * stream->height;
stream->data.yuv420p.u = stream->data.yuv420p.y + stream->data.yuv420p.length_y;
stream->data.yuv420p.length_u = stream->data.yuv420p.length_y >> 2;
case MM_PIXEL_FORMAT_422P:
stream->data_type = MM_CAM_STREAM_DATA_YUV422P;
- stream->data.yuv422p.y = map_info->data;
+ stream->data.yuv422p.y = map_info.data;
stream->data.yuv422p.length_y = stream->width * stream->height;
stream->data.yuv422p.u = stream->data.yuv422p.y + stream->data.yuv422p.length_y;
stream->data.yuv422p.length_u = stream->data.yuv422p.length_y >> 1;
case MM_PIXEL_FORMAT_UYVY: /* fall through */
case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
stream->data_type = MM_CAM_STREAM_DATA_YUV422;
- stream->data.yuv422.yuv = map_info->data;
+ stream->data.yuv422.yuv = map_info.data;
stream->data.yuv422.length_yuv = stream->length_total;
stream->stride[0] = stream->width << 1;
stream->elevation[0] = stream->height;
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.data = map_info.data;
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);
stream->num_planes = 1;
case MM_PIXEL_FORMAT_INVZ:
stream->data_type = MM_CAM_STREAM_DATA_DEPTH;
- stream->data.depth.data = map_info->data;
+ stream->data.depth.data = map_info.data;
stream->data.depth.length_data = stream->length_total;
stream->stride[0] = stream->width << 1;
stream->elevation[0] = stream->height;
case MM_PIXEL_FORMAT_RGBA: /* fall through */
case MM_PIXEL_FORMAT_ARGB:
stream->data_type = MM_CAM_STREAM_DATA_RGB;
- stream->data.rgb.data = map_info->data;
+ stream->data.rgb.data = map_info.data;
stream->data.rgb.length_data = stream->length_total;
stream->stride[0] = stream->width << 2;
stream->elevation[0] = stream->height;
default:
MMCAM_LOG_ERROR("unsupported format[%d]", stream->format);
- return FALSE;
+ ret = FALSE;
+ break;
}
- return TRUE;
+ gst_memory_unmap(memory, &map_info);
+
+ 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("[420P] 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;
default:
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;
GstCaps *caps = NULL;
GstStructure *structure = NULL;
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_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);
-
- 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, memory))
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) {
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;
}
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;
*/
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, "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);
&hcamcorder->recreate_decoder);
}
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- int preview_bitrate = 0;
- int gop_interval = 0;
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_ENCODED_PREVIEW_BITRATE, &preview_bitrate,
- MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
- NULL);
+ 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;
+ }
- /* set encoded preview bitrate */
- if (!_mmcamcorder_set_encoded_preview_bitrate(handle, preview_bitrate))
- MMCAM_LOG_WARNING("_mmcamcorder_set_encoded_preview_bitrate failed");
+ /* get video decoder element and name */
+ _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ decoder_conf_name,
+ &sc->VideodecoderElement);
- /* 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");
- }
+ _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;
+ }
- 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) {
#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);
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;
if (element_list)
g_list_free(element_list);
- if (video_caps)
- gst_caps_unref(video_caps);
-
if (videoscale_caps)
gst_caps_unref(videoscale_caps);
/* 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;
}
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;
if (format_string)
caps_fourcc = _mmcamcorder_convert_fourcc_string_to_value(format_string);
- 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,
+ "fps", G_TYPE_INT, &caps_fps,
+ "rotate", G_TYPE_INT, &caps_rotate,
+ NULL);
#ifdef _MMCAMCORDER_PRODUCT_TV
if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
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;
}
_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 */
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;
}
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");
+ 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", decoder_name);
+ MMCAM_LOG_ERROR("Decoder[%s] creation fail", videodecoder_name_final);
return FALSE;
}
-#else /* _MMCAMCORDER_RM_SUPPORT */
- /* create new decoder */
- sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(videodecoder_name, "videosrc_decode");
- if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
- MMCAM_LOG_ERROR("Decoder [%s] creation fail", videodecoder_name);
- 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),