*/
/*=======================================================================================
-| INCLUDE FILES |
+| INCLUDE FILES |
=======================================================================================*/
+#include <gst/allocators/gsttizenmemory.h>
#include <gst/audio/audio-format.h>
#include <gst/video/videooverlay.h>
#include <gst/video/cameracontrol.h>
-#include <gst/wayland/wayland.h>
#include <sys/time.h>
#include <unistd.h>
#include <tbm_bufmgr.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
#include "mm_camcorder_internal.h"
#include "mm_camcorder_gstcommon.h"
/*-----------------------------------------------------------------------
-| GLOBAL VARIABLE DEFINITIONS for internal |
+| GLOBAL VARIABLE DEFINITIONS for internal |
-----------------------------------------------------------------------*/
/* Table for compatibility between audio codec and file format */
-gboolean audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_FORMAT_NUM] =
-{ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
+gboolean audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
+ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
/*AMR*/ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*G723.1*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*MP3*/ { 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1},
};
/* Table for compatibility between video codec and file format */
-gboolean videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM_FILE_FORMAT_NUM] =
-{ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
+gboolean videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
+ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
/*NONE*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*H263*/ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*H264*/ { 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
/*H262*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*H263V2*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*H263V3*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-/*MJPEG*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/*MJPEG*/ { 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*MPEG2*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*MPEG4_SIMPLE*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*MPEG4_ADV*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*-----------------------------------------------------------------------
-| LOCAL VARIABLE DEFINITIONS for internal |
+| LOCAL VARIABLE DEFINITIONS for internal |
-----------------------------------------------------------------------*/
#define USE_AUDIO_CLOCK_TUNE
#define _MMCAMCORDER_WAIT_EOS_TIME 60.0 /* sec */
#define _MMCAMCORDER_CONVERT_OUTPUT_BUFFER_NUM 6
-#define _MMCAMCORDER_MIN_TIME_TO_PASS_FRAME 30000000 /* ns */
-#define _MMCAMCORDER_FRAME_PASS_MIN_FPS 30
#define _MMCAMCORDER_NANOSEC_PER_1SEC 1000000000
#define _MMCAMCORDER_NANOSEC_PER_1MILISEC 1000
/*-----------------------------------------------------------------------
-| LOCAL FUNCTION PROTOTYPES: |
+| LOCAL FUNCTION PROTOTYPES: |
-----------------------------------------------------------------------*/
/* STATIC INTERNAL FUNCTION */
/**
- * These functions are preview video data probing function.
- * If this function is linked with certain pad by gst_pad_add_buffer_probe(),
- * this function will be called when data stream pass through the pad.
+ * These are video data probing functions.
+ * If there are pads which set probe callback by gst_pad_add_probe(),
+ * the functions will be called when data stream pass through the pad.
*
- * @param[in] pad probing pad which calls this function.
- * @param[in] buffer buffer which contains stream data.
- * @param[in] u_data user data.
- * @return This function returns true on success, or false value with error
+ * @param[in] pad probing pad which calls this function.
+ * @param[in] buffer buffer which contains stream data.
+ * @param[in] u_data user data.
+ * @return Refer #GstPadProbeReturn in gstpad.h
* @remarks
- * @see __mmcamcorder_create_preview_pipeline()
+ * @see __mmcamcorder_create_preview_pipeline()
*/
static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
-static GstPadProbeReturn __mmcamcorder_video_dataprobe_push_buffer_to_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data);
+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 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);
/*=======================================================================================
-| FUNCTION DEFINITIONS |
+| FUNCTION DEFINITIONS |
=======================================================================================*/
-/*-----------------------------------------------------------------------
-| GLOBAL FUNCTION DEFINITIONS: |
------------------------------------------------------------------------*/
+static gboolean __mmcamcorder_set_stream_data_normal(MMCamcorderVideoStreamDataType *stream, GstBuffer *buffer, 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);
+
+ 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.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;
+ stream->stride[0] = stream->width;
+ stream->elevation[0] = stream->height;
+ stream->stride[1] = stream->width;
+ stream->elevation[1] = stream->height >> 1;
+ stream->num_planes = 2;
+ break;
+
+ case MM_PIXEL_FORMAT_I420:
+ stream->data_type = MM_CAM_STREAM_DATA_YUV420P;
+ 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;
+ stream->data.yuv420p.v = stream->data.yuv420p.u + stream->data.yuv420p.length_u;
+ stream->data.yuv420p.length_v = stream->data.yuv420p.length_u;
+ stream->stride[0] = stream->width;
+ stream->elevation[0] = stream->height;
+ stream->stride[1] = stream->stride[2] = stream->width >> 1;
+ stream->elevation[1] = stream->elevation[2] = stream->height >> 1;
+ stream->num_planes = 3;
+ break;
+
+ case MM_PIXEL_FORMAT_422P:
+ stream->data_type = MM_CAM_STREAM_DATA_YUV422P;
+ 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;
+ stream->data.yuv422p.v = stream->data.yuv422p.u + stream->data.yuv422p.length_u;
+ stream->data.yuv422p.length_v = stream->data.yuv422p.length_u;
+ stream->stride[0] = stream->width;
+ stream->elevation[0] = stream->height;
+ stream->stride[1] = stream->stride[2] = stream->width;
+ stream->elevation[1] = stream->elevation[2] = stream->height >> 1;
+ stream->num_planes = 3;
+ break;
+
+ case MM_PIXEL_FORMAT_YUYV: /* fall through */
+ 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.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:
+ stream->data_type = MM_CAM_STREAM_DATA_ENCODED;
+ 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;
+ break;
+
+ case MM_PIXEL_FORMAT_INVZ:
+ stream->data_type = MM_CAM_STREAM_DATA_DEPTH;
+ 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;
+ stream->num_planes = 1;
+ break;
+
+ 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.length_data = stream->length_total;
+ stream->stride[0] = stream->width << 2;
+ stream->elevation[0] = stream->height;
+ stream->num_planes = 1;
+ break;
+
+ default:
+ MMCAM_LOG_ERROR("unsupported format[%d]", stream->format);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+static gboolean __mmcamcorder_set_stream_data_tbm(MMCamcorderVideoStreamDataType *stream, tbm_surface_info_s *ts_info)
+{
+ mmf_return_val_if_fail(ts_info, FALSE);
+ mmf_return_val_if_fail(stream, FALSE);
+
+ 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;
+ 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;
+ break;
+
+ default:
+ MMCAM_LOG_ERROR("unsupported format[%d]", stream->format);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+gboolean _mmcamcorder_invoke_video_stream_cb(MMHandleType handle, GstBuffer *buffer, gboolean is_preview)
+{
+ 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;
+
+ GstMemory *memory = NULL;
+ GstMapInfo map_info;
+ GstCaps *caps = NULL;
+ GstPad *pad = NULL;
+ GstStructure *structure = NULL;
+
+ mmf_return_val_if_fail(hcamcorder, FALSE);
+ mmf_return_val_if_fail(buffer, FALSE);
+ mmf_return_val_if_fail(gst_buffer_n_memory(buffer), FALSE);
+
+ 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));
+
+ stream.format = sc->info_image->preview_format;
+ if (is_preview) {
+ /* preview buffer - get resolution from caps */
+ pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "src");
+ mmf_return_val_if_fail(pad, FALSE);
+
+ caps = gst_pad_get_allowed_caps(pad);
+ if (!caps) {
+ MMCAM_LOG_ERROR("failed to get caps from pad %p", pad);
+ gst_object_unref(pad);
+ return FALSE;
+ }
+
+ structure = gst_caps_get_structure(caps, 0);
+ if (!structure) {
+ MMCAM_LOG_ERROR("failed to get structure from caps %p", caps);
+ gst_caps_unref(caps);
+ gst_object_unref(pad);
+ return FALSE;
+ }
+
+ gst_structure_get_int(structure, "width", &stream.width);
+ gst_structure_get_int(structure, "height", &stream.height);
+
+ gst_caps_unref(caps);
+ caps = NULL;
+ gst_object_unref(pad);
+ pad = NULL;
+ } else {
+ /* video recording buffer */
+ stream.width = sc->info_video->video_width;
+ stream.height = sc->info_video->video_height;
+ }
+
+ /* set size and timestamp */
+ if (_mmcamcorder_is_encoded_preview_pixel_format(stream.format))
+ memory = gst_buffer_get_all_memory(buffer);
+ else
+ 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]);
+ }
+
+ stream.length_total = ts_info.size;
+ stream.internal_buffer = buffer;
+
+ if (!__mmcamcorder_set_stream_data_tbm(&stream, &ts_info))
+ 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))
+ goto _INVOKE_VIDEO_STREAM_CB_DONE;
+ }
+
+ MMCAM_LOG_DEBUG("VideoStreamData : resolution[%dx%d], format[%d]",
+ stream.width, stream.height, stream.format);
+
+ stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer) / 1000000); /* nano sec -> milli sec */
+
+ /* invoke application callback */
+ if (is_preview) {
+ _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
+ if (hcamcorder->vstream_cb)
+ hcamcorder->vstream_cb(&stream, hcamcorder->vstream_cb_param);
+ _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(hcamcorder);
+ } else {
+ _MMCAMCORDER_LOCK_VEDECISION_CALLBACK(hcamcorder);
+ if (hcamcorder->vedecision_cb)
+ ret_cb = hcamcorder->vedecision_cb(&stream, hcamcorder->vedecision_cb_param);
+ _MMCAMCORDER_UNLOCK_VEDECISION_CALLBACK(hcamcorder);
+ }
+
+_INVOKE_VIDEO_STREAM_CB_DONE:
+ 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 _mmcamcorder_create_preview_elements(MMHandleType handle)
{
int err = MM_ERROR_NONE;
int i = 0;
- int camera_width = 0;
- int camera_height = 0;
int camera_rotate = 0;
int camera_flip = 0;
int fps = 0;
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;
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/* Check existence */
for (i = _MMCAMCORDER_VIDEOSRC_SRC ; i <= _MMCAMCORDER_VIDEOSINK_SINK ; i++) {
if (sc->element[i].gst) {
- if (((GObject *)sc->element[i].gst)->ref_count > 0) {
+ if (((GObject *)sc->element[i].gst)->ref_count > 0)
gst_object_unref(sc->element[i].gst);
- }
- _mmcam_dbg_log("element[index:%d] is Already existed.", i);
+
+ MMCAM_LOG_INFO("element[index:%d] is Already existed.", i);
}
}
/* Get video device index info */
_mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "InputIndex",
- &input_index);
+ CONFIGURE_CATEGORY_CTRL_CAMERA,
+ "InputIndex",
+ &input_index);
if (input_index == NULL) {
- _mmcam_dbg_err("Failed to get input_index");
+ MMCAM_LOG_ERROR("Failed to get input_index");
return MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
}
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_CAMERA_WIDTH, &camera_width,
- MMCAM_CAMERA_HEIGHT, &camera_height,
- MMCAM_CAMERA_FORMAT, &sc->info_image->preview_format,
- MMCAM_CAMERA_FPS, &fps,
- MMCAM_CAMERA_ROTATION, &camera_rotate,
- MMCAM_CAMERA_FLIP, &camera_flip,
- MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
- MMCAM_CAMERA_ANTI_HANDSHAKE, &anti_shake,
- MMCAM_CAPTURE_WIDTH, &capture_width,
- 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_DISPLAY_SURFACE, &display_surface_type,
- NULL);
+ MMCAM_CAMERA_FORMAT, &sc->info_image->preview_format,
+ MMCAM_CAMERA_FPS, &fps,
+ MMCAM_CAMERA_ROTATION, &camera_rotate,
+ MMCAM_CAMERA_FLIP, &camera_flip,
+ MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
+ MMCAM_CAMERA_ANTI_HANDSHAKE, &anti_shake,
+ MMCAM_CAPTURE_WIDTH, &capture_width,
+ 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_DISPLAY_SURFACE, &display_surface_type,
+ NULL);
if (err != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
+ MMCAM_LOG_WARNING("Get attrs fail. (%s:%x)", err_name, err);
SAFE_FREE(err_name);
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_LOG_ERROR("get user buffer fd failed 0x%x, number %d", err, fd_number);
+ return err;
+ }
+
+ /*
+ for (i = 0 ; i < fd_number ; i++)
+ MMCAM_LOG_INFO("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);
/* Get videosrc element and its name from configure */
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "VideosrcElement",
- &VideosrcElement);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "VideosrcElement",
+ &VideosrcElement);
_mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
/**
*/
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_SRC, videosrc_name, "videosrc_src", element_list, err);
- /* Set video device index */
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "camera-id", input_index->default_value);
-
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_FILT, "capsfilter", "videosrc_filter", element_list, err);
/* init high-speed-fps */
/* set anti handshake mode */
_mmcamcorder_set_videosrc_anti_shake(handle, anti_shake);
- if (sc->is_modified_rate) {
+ if (sc->is_modified_rate)
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", fps);
- }
- /* Set basic infomation of videosrc element */
+ /* Set basic information of videosrc element */
_mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, VideosrcElement);
- /* make demux and decoder for H264 stream from videosrc */
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- int preview_bitrate = 0;
- int gop_interval = 0;
- const char *videodecoder_name = NULL;
+ /* Set video device index */
+#ifdef _MMCAMCORDER_CAMERA_CONF_MGR_SUPPORT
+ MMCAMCORDER_G_OBJECT_SET_POINTER(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "device-name", hcamcorder->conf_device_info.node);
+#else
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "camera-id", input_index->default_value);
+#endif
+ /* 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_LOG_ERROR("set user buffer fd failed");
+ goto pipeline_creation_error;
+ }
+ }
+
+ if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
/* get recreate_decoder flag */
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
"RecreateDecoder",
&hcamcorder->recreate_decoder);
+ }
- /* 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) {
- _mmcam_dbg_log("video decoder element [%s], recreate decoder %d",
- videodecoder_name, hcamcorder->recreate_decoder);
-#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_dbg_log("encoded preview decoder_name %s", decoder_name);
- /* create decoder element */
- _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, decoder_name, "videosrc_decode", element_list, err);
-#else /* _MMCAMCORDER_RM_SUPPORT */
- /* 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_dbg_err("failed to get video decoder element name from %p", sc->VideodecoderElementH264);
- goto pipeline_creation_error;
- }
-
- /* set encoded preview bitrate and iframe interval */
+ 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);
+ /* set encoded preview bitrate */
if (!_mmcamcorder_set_encoded_preview_bitrate(handle, preview_bitrate))
- _mmcam_dbg_warn("_mmcamcorder_set_encoded_preview_bitrate failed");
+ MMCAM_LOG_WARNING("_mmcamcorder_set_encoded_preview_bitrate failed");
+ /* set encoded preview iframe interval */
if (!_mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval))
- _mmcam_dbg_warn("_mmcamcorder_set_encoded_preview_gop_interval failed");
+ MMCAM_LOG_WARNING("_mmcamcorder_set_encoded_preview_gop_interval failed");
+ }
+
+ 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;
+ }
+ } 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);
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ }
}
- _mmcam_dbg_log("Current mode[%d]", hcamcorder->type);
+ MMCAM_LOG_INFO("Current mode[%d]", hcamcorder->type);
/* Get videosink name */
_mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
+ if (!videosink_name) {
+ MMCAM_LOG_ERROR("failed to get videosink name");
+ goto pipeline_creation_error;
+ }
+
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_QUE, "queue", "videosink_queue", element_list, err);
- _mmcam_dbg_log("videosink_name: %s", videosink_name);
+ 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);
MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
NULL);
if (err != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Get socket path failed 0x%x", err);
+ 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, "waylandsink")) {
+ 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_dbg_log("videoconvert element name : %s", 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_dbg_err("failed to get videoconvert element name");
+ MMCAM_LOG_ERROR("failed to get videoconvert element name");
}
/* check sink element in attribute */
if (sink_element) {
int attr_index = 0;
- mmf_attrs_t *attrs = MMF_CAMCORDER_ATTRS(handle);
- mmf_attribute_t *attr_item = NULL;
+ MMHandleType attrs = MMF_CAMCORDER_ATTRS(handle);
- _mmcam_dbg_log("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);
/* reset attribute */
if (attrs) {
mm_attrs_get_index((MMHandleType)attrs, MMCAM_DISPLAY_REUSE_ELEMENT, &attr_index);
- attr_item = &attrs->items[attr_index];
- mmf_attribute_set_data(attr_item, NULL, 0);
- mmf_attribute_commit(attr_item);
+ mm_attrs_set_data(attrs, attr_index, NULL, 0);
+ mm_attrs_commit(attrs, attr_index);
} else {
- _mmcam_dbg_warn("attribute is NULL");
+ MMCAM_LOG_WARNING("attribute is NULL");
err = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
goto pipeline_creation_error;
}
}
if (_mmcamcorder_videosink_window_set(handle, sc->VideosinkElement) != MM_ERROR_NONE) {
- _mmcam_dbg_err("_mmcamcorder_videosink_window_set error");
+ MMCAM_LOG_ERROR("_mmcamcorder_videosink_window_set error");
err = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
goto pipeline_creation_error;
}
/* add elements to main pipeline */
if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst), element_list)) {
- _mmcam_dbg_err("element_list add error.");
+ MMCAM_LOG_ERROR("element_list add error.");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
/* link elements */
if (!_mmcamcorder_link_elements(element_list)) {
- _mmcam_dbg_err( "element link error." );
+ MMCAM_LOG_ERROR("element link error.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
const char *audiosrc_name = NULL;
char *cat_name = NULL;
char *stream_type = NULL;
- char stream_type_len = 0;
+ int stream_type_len = 0;
int stream_index = 0;
+ int buffer_interval = 0;
+ int blocksize = 0;
+ int replay_gain_enable = FALSE;
+ double replay_gain_ref_level = 0.0;
GstCaps *caps = NULL;
GstPad *pad = NULL;
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
err = _mmcamcorder_check_audiocodec_fileformat_compatibility(handle);
- if (err != MM_ERROR_NONE) {
+ if (err != MM_ERROR_NONE)
return err;
- }
err = mm_camcorder_get_attributes(handle, &err_name,
MMCAM_AUDIO_DEVICE, &a_dev,
MMCAM_AUDIO_FORMAT, &format,
MMCAM_AUDIO_CHANNEL, &channel,
MMCAM_AUDIO_VOLUME, &volume,
+ MMCAM_AUDIO_REPLAY_GAIN_ENABLE, &replay_gain_enable,
+ MMCAM_AUDIO_REPLAY_GAIN_REFERENCE_LEVEL, &replay_gain_ref_level,
MMCAM_SOUND_STREAM_TYPE, &stream_type, &stream_type_len,
MMCAM_SOUND_STREAM_INDEX, &stream_index,
NULL);
if (err != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
+ MMCAM_LOG_WARNING("Get attrs fail. (%s:%x)", err_name, err);
SAFE_FREE(err_name);
return err;
}
/* Check existence */
if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst) {
- if (((GObject *)sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst)->ref_count > 0) {
+ if (((GObject *)sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst)->ref_count > 0)
gst_object_unref(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst);
- }
- _mmcam_dbg_log("_MMCAMCORDER_AUDIOSRC_BIN is Already existed. Unref once...");
+
+ MMCAM_LOG_INFO("_MMCAMCORDER_AUDIOSRC_BIN is Already existed. Unref once...");
}
/* Create bin element */
}
if (cat_name == NULL) {
- _mmcam_dbg_err("strdup failed.");
+ MMCAM_LOG_ERROR("strdup failed.");
err = MM_ERROR_CAMCORDER_LOW_MEMORY;
goto pipeline_creation_error;
}
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
- cat_name,
- &AudiosrcElement);
+ CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
+ cat_name,
+ &AudiosrcElement);
_mmcamcorder_conf_get_value_element_name(AudiosrcElement, &audiosrc_name);
free(cat_name);
cat_name = NULL;
- _mmcam_dbg_log("Audio src name : %s", audiosrc_name);
+ MMCAM_LOG_INFO("Audio src name : %s", audiosrc_name);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_SRC, audiosrc_name, "audiosrc_src", element_list, err);
/* set audiosrc properties in ini configuration */
_mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, AudiosrcElement);
+ /* set block size */
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
+ "AudioBufferInterval",
+ &buffer_interval);
+
+ if (_mmcamcorder_get_audiosrc_blocksize(rate, format, channel, buffer_interval, &blocksize)) {
+ MMCAM_LOG_INFO("set audiosrc block size %d", blocksize);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, "blocksize", blocksize);
+ }
+
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_FILT, "capsfilter", "audiosrc_capsfilter", element_list, err);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_QUE, "queue", "audiosrc_queue", element_list, err);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_QUE].gst, "max-size-bytes", 0);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_QUE].gst, "max-size-time", 0);
- if (a_enc != MM_AUDIO_CODEC_VORBIS) {
- _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_VOL, "volume", "audiosrc_volume", element_list, err);
- }
-
- /* Set basic infomation */
+ /* Set basic information */
if (a_enc != MM_AUDIO_CODEC_VORBIS) {
int depth = 0;
const gchar* format_name = NULL;
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_VOL, "volume", "audiosrc_volume", element_list, err);
+
if (volume == 0.0) {
/* Because data probe of audio src do the same job, it doesn't need to set "mute" here. Already null raw data. */
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
}
caps = gst_caps_new_simple("audio/x-raw",
- "rate", G_TYPE_INT, rate,
- "channels", G_TYPE_INT, channel,
- "format", G_TYPE_STRING, format_name,
- NULL);
- _mmcam_dbg_log("caps [x-raw, rate:%d, channel:%d, depth:%d], volume %lf",
- rate, channel, depth, volume);
+ "rate", G_TYPE_INT, rate,
+ "channels", G_TYPE_INT, channel,
+ "format", G_TYPE_STRING, format_name,
+ NULL);
+ MMCAM_LOG_INFO("caps [x-raw, rate:%d, channel:%d, depth:%d], volume %lf",
+ rate, channel, depth, volume);
} else {
/* what are the audio encoder which should get audio/x-raw-float? */
caps = gst_caps_new_simple("audio/x-raw",
- "rate", G_TYPE_INT, rate,
- "channels", G_TYPE_INT, channel,
- "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
- NULL);
- _mmcam_dbg_log("caps [x-raw (F32), rate:%d, channel:%d, endianness:%d, width:32]",
- rate, channel, BYTE_ORDER);
+ "rate", G_TYPE_INT, rate,
+ "channels", G_TYPE_INT, channel,
+ "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
+ NULL);
+ MMCAM_LOG_INFO("caps [x-raw (F32), rate:%d, channel:%d, endianness:%d, width:32]",
+ rate, channel, BYTE_ORDER);
+ }
+
+ /* Replay Gain */
+ MMCAM_LOG_INFO("Replay gain - enable : %d, reference level : %lf",
+ replay_gain_enable, replay_gain_ref_level);
+
+ if (replay_gain_enable) {
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_RGA, "rganalysis", "audiosrc_rga", element_list, err);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_RGA].gst, "reference-level", replay_gain_ref_level);
+ /* If num-tracks is not set, album gain and peak event is not come. */
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_RGA].gst, "num-tracks", 1);
}
if (caps) {
gst_caps_unref(caps);
caps = NULL;
} else {
- _mmcam_dbg_err("create caps error");
+ MMCAM_LOG_ERROR("create caps error");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst), element_list)) {
- _mmcam_dbg_err("element add error.");
+ MMCAM_LOG_ERROR("element add error.");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
if (!_mmcamcorder_link_elements(element_list)) {
- _mmcam_dbg_err("element link error.");
+ MMCAM_LOG_ERROR("element link error.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst, gst_ghost_pad_new("src", pad))) {
gst_object_unref(pad);
pad = NULL;
- _mmcam_dbg_err("failed to create ghost pad on _MMCAMCORDER_AUDIOSRC_BIN.");
+ MMCAM_LOG_ERROR("failed to create ghost pad on _MMCAMCORDER_AUDIOSRC_BIN.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
}
+void _mmcamcorder_set_encoder_bitrate(MMCamcorderEncoderType type, int codec, int bitrate, GstElement *element)
+{
+ int set_value = 0;
+
+ if (!element) {
+ MMCAM_LOG_WARNING("NULL element, will be applied later - type %d, bitrate %d", type, bitrate);
+ return;
+ }
+
+ if (bitrate <= 0) {
+ MMCAM_LOG_WARNING("[type %d, codec %d] too small bitrate[%d], use default",
+ type, codec, bitrate);
+ return;
+ }
+
+ if (type == MM_CAMCORDER_ENCODER_TYPE_AUDIO) {
+ /* audio encoder bitrate setting */
+ switch (codec) {
+ case MM_AUDIO_CODEC_AMR:
+ set_value = __mmcamcorder_get_amrnb_bitrate_mode(bitrate);
+ MMCAM_LOG_INFO("Set AMR encoder mode [%d]", set_value);
+ MMCAMCORDER_G_OBJECT_SET(element, "band-mode", set_value);
+ break;
+ case MM_AUDIO_CODEC_MP3:
+ set_value = bitrate / 1000;
+ MMCAM_LOG_INFO("Set MP3 encoder bitrate [%d] kbps", set_value);
+ MMCAMCORDER_G_OBJECT_SET(element, "bitrate", set_value);
+ break;
+ case MM_AUDIO_CODEC_AAC:
+ MMCAM_LOG_INFO("Set AAC encoder bitrate [%d] bps", bitrate);
+ MMCAMCORDER_G_OBJECT_SET(element, "bitrate", bitrate);
+ break;
+ default:
+ MMCAM_LOG_WARNING("Not AMR, MP3 and AAC codec, need to add code for audio bitrate");
+ break;
+ }
+ } else {
+ /* video encoder bitrate setting */
+ MMCAM_LOG_INFO("Set video encoder bitrate %d", bitrate);
+ MMCAMCORDER_G_OBJECT_SET(element, "bitrate", bitrate);
+ }
+
+ return;
+}
+
+
int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebinProfile profile)
{
int err = MM_ERROR_NONE;
- int result = 0;
int channel = 0;
int audio_enc = 0;
int v_bitrate = 0;
int auto_audio_convert = 0;
int auto_audio_resample = 0;
int auto_color_space = 0;
+ int cap_format = MM_PIXEL_FORMAT_INVALID;
const char *gst_element_venc_name = NULL;
const char *gst_element_aenc_name = NULL;
const char *gst_element_ienc_name = NULL;
const char *gst_element_mux_name = NULL;
const char *gst_element_rsink_name = NULL;
+ const char *gst_element_vscale_name = NULL;
const char *str_profile = NULL;
const char *str_aac = NULL;
const char *str_aar = NULL;
const char *videoconvert_name = NULL;
GstCaps *audio_caps = NULL;
GstCaps *video_caps = NULL;
+ GstCaps *videoscale_caps = NULL;
GstPad *pad = NULL;
GList *element_list = NULL;
type_element *ImageencElement = NULL;
type_element *MuxElement = NULL;
type_element *RecordsinkElement = NULL;
+ type_element *VideoscaleElement = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("start - profile : %d", profile);
+ MMCAM_LOG_INFO("start - profile : %d", profile);
/* Check existence */
if (sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst) {
- if (((GObject *)sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst)->ref_count > 0) {
+ if (((GObject *)sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst)->ref_count > 0)
gst_object_unref(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst);
- }
- _mmcam_dbg_log("_MMCAMCORDER_ENCSINK_BIN is Already existed.");
+
+ MMCAM_LOG_INFO("_MMCAMCORDER_ENCSINK_BIN is Already existed.");
}
/* Create bin element */
/* Create child element */
if (profile != MM_CAMCORDER_ENCBIN_PROFILE_AUDIO) {
GstCaps *caps_from_pad = NULL;
+ char *caps_str = NULL;
/* create appsrc and capsfilter */
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_SRC, "appsrc", "encodesink_src", element_list, err);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_FILT, "capsfilter", "encodesink_filter", element_list, err);
- /* release element_list, they will be placed out of encodesink bin */
- if (element_list) {
- g_list_free(element_list);
- element_list = NULL;
- }
-
/* set appsrc as live source */
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "is-live", TRUE);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "format", 3); /* GST_FORMAT_TIME */
/* set capsfilter */
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- _mmcam_dbg_log("get pad from videosrc_filter");
+ if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
+ MMCAM_LOG_INFO("get pad from videosrc_filter");
pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "src");
} else {
- _mmcam_dbg_log("get pad from videosrc_que");
+ MMCAM_LOG_INFO("get pad from videosrc_que");
pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "src");
}
if (!pad) {
- _mmcam_dbg_err("get videosrc_que src pad failed");
+ MMCAM_LOG_ERROR("get videosrc_que src pad failed");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
caps_from_pad = NULL;
gst_object_unref(pad);
pad = NULL;
+
+ /* fixate caps */
+ video_caps = gst_caps_fixate(video_caps);
} else {
/* Image */
MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", &video_caps);
}
- if (video_caps) {
- char *caps_str = NULL;
+ if (!video_caps) {
+ MMCAM_LOG_ERROR("create recording pipeline caps failed");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto pipeline_creation_error;
+ }
- if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
+ if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
+ if (sc->info_video->use_videoscale) {
gst_caps_set_simple(video_caps,
- "width", G_TYPE_INT, sc->info_video->video_width,
- "height", G_TYPE_INT, sc->info_video->video_height,
- NULL);
+ "width", G_TYPE_INT, sc->info_video->preview_width,
+ "height", G_TYPE_INT, sc->info_video->preview_height,
+ NULL);
+ videoscale_caps = gst_caps_copy(video_caps);
+ } else {
+ gst_caps_set_simple(video_caps,
+ "width", G_TYPE_INT, sc->info_video->video_width,
+ "height", G_TYPE_INT, sc->info_video->video_height,
+ NULL);
}
+ }
+
+ caps_str = gst_caps_to_string(video_caps);
+
+ MMCAM_LOG_INFO("encodebin caps [%s]", caps_str);
+
+ g_free(caps_str);
+ caps_str = NULL;
+
+ MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "caps", video_caps);
+
+ gst_caps_unref(video_caps);
+ video_caps = NULL;
+
+ /* video scale */
+ if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO &&
+ sc->info_video->use_videoscale) {
+ if (!videoscale_caps) {
+ MMCAM_LOG_ERROR("no videoscale caps");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto pipeline_creation_error;
+ }
+
+ gst_caps_set_simple(videoscale_caps,
+ "width", G_TYPE_INT, sc->info_video->video_width,
+ "height", G_TYPE_INT, sc->info_video->video_height,
+ NULL);
+
+ _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "VideoscaleElement",
+ &VideoscaleElement);
+
+ if (!_mmcamcorder_conf_get_value_element_name(VideoscaleElement, &gst_element_vscale_name)) {
+ MMCAM_LOG_ERROR("failed to get videoscale element name");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto pipeline_creation_error;
+ }
+
+ caps_str = gst_caps_to_string(videoscale_caps);
+
+ MMCAM_LOG_INFO("encodebin videocale [%s][%s]", gst_element_vscale_name, caps_str);
- caps_str = gst_caps_to_string(video_caps);
- _mmcam_dbg_log("encodebin caps [%s]", caps_str);
g_free(caps_str);
caps_str = NULL;
- MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "caps", video_caps);
- gst_caps_unref(video_caps);
- video_caps = NULL;
- } else {
- _mmcam_dbg_err("create recording pipeline caps failed");
- err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto pipeline_creation_error;
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_VSCALE, gst_element_vscale_name, "encodesink_vscale", element_list, err);
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_VSCALE_FILT, "capsfilter", "encodesink_vscale_filter", element_list, err);
+
+ MMCAMCORDER_G_OBJECT_SET_POINTER((sc->encode_element[_MMCAMCORDER_ENCSINK_VSCALE_FILT].gst), "caps", videoscale_caps);
+
+ gst_caps_unref(videoscale_caps);
+ videoscale_caps = NULL;
+ }
+
+ /* release element_list, they will be placed out of encodesink bin */
+ if (element_list) {
+ g_list_free(element_list);
+ element_list = NULL;
}
/* connect signal for ready to push buffer */
MMCAMCORDER_SIGNAL_CONNECT(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst,
- _MMCAMCORDER_HANDLER_VIDEOREC,
- "need-data",
- _mmcamcorder_ready_to_encode_callback,
- hcamcorder);
+ _MMCAMCORDER_HANDLER_VIDEOREC,
+ "need-data",
+ _mmcamcorder_ready_to_encode_callback,
+ hcamcorder);
}
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN, "encodebin", "encodesink_encbin", element_list, err);
/* check element availability */
- err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_AUDIO_ENCODER, &audio_enc,
- MMCAM_AUDIO_CHANNEL, &channel,
- MMCAM_VIDEO_ENCODER_BITRATE, &v_bitrate,
- MMCAM_AUDIO_ENCODER_BITRATE, &a_bitrate,
- NULL);
+ if (profile == MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
+ err = mm_camcorder_get_attributes(handle, &err_name,
+ MMCAM_CAPTURE_FORMAT, &cap_format,
+ NULL);
+ } else {
+ err = mm_camcorder_get_attributes(handle, &err_name,
+ MMCAM_AUDIO_ENCODER, &audio_enc,
+ MMCAM_AUDIO_CHANNEL, &channel,
+ MMCAM_VIDEO_ENCODER_BITRATE, &v_bitrate,
+ MMCAM_AUDIO_ENCODER_BITRATE, &a_bitrate,
+ NULL);
+ }
if (err != MM_ERROR_NONE) {
if (err_name) {
- _mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
+ MMCAM_LOG_ERROR("failed to get attributes [%s][0x%x]", err_name, err);
SAFE_FREE(err_name);
} else {
- _mmcam_dbg_err("failed to get attributes [0x%x]", err);
+ MMCAM_LOG_ERROR("failed to get attributes [0x%x]", err);
}
- return err;
+ goto pipeline_creation_error;
}
- _mmcam_dbg_log("Profile[%d]", profile);
+ MMCAM_LOG_INFO("Profile[%d]", profile);
/* Set information */
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_aar, &auto_audio_resample);
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_acs, &auto_color_space);
- _mmcam_dbg_log("Profile:%d, AutoAudioConvert:%d, AutoAudioResample:%d, AutoColorSpace:%d",
- encodebin_profile, auto_audio_convert, auto_audio_resample, auto_color_space);
+ MMCAM_LOG_INFO("Profile:%d, AutoAudioConvert:%d, AutoAudioResample:%d, AutoColorSpace:%d",
+ encodebin_profile, auto_audio_convert, auto_audio_resample, auto_color_space);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "profile", encodebin_profile);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", auto_audio_convert);
VideoencElement = _mmcamcorder_get_type_element(handle, MM_CAM_VIDEO_ENCODER);
if (!VideoencElement) {
- _mmcam_dbg_err("Fail to get type element");
+ MMCAM_LOG_ERROR("Fail to get type element");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- gst_element_venc_name = "capsfilter";
+ if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format)) {
+ /* set dummy element */
+ gst_element_venc_name = "identity";
} else {
_mmcamcorder_conf_get_value_element_name(VideoencElement, &gst_element_venc_name);
}
if (gst_element_venc_name) {
- _mmcam_dbg_log("video encoder name [%s]", gst_element_venc_name);
+ MMCAM_LOG_INFO("video encoder name [%s]", gst_element_venc_name);
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "venc-name", gst_element_venc_name);
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VENC, "video-encode", err);
} else {
- _mmcam_dbg_err("Fail to get video encoder name");
+ MMCAM_LOG_ERROR("Fail to get video encoder name");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
/* set color space converting element */
if (auto_color_space) {
- _mmcam_dbg_log("set video convert element [%s]", videoconvert_name);
+ MMCAM_LOG_INFO("set video convert element [%s]", videoconvert_name);
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vconv-name", videoconvert_name);
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VCONV, "video-convert", err);
/* fourcc type was removed in GST 1.0 */
if (hcamcorder->use_zero_copy_format) {
- if(strstr(gst_element_venc_name, "omx")) {
- video_caps = gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, "SN12",
- NULL);
+ if (strstr(gst_element_venc_name, "omx")) {
+ video_caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "SN12", NULL);
if (video_caps) {
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vcaps", video_caps);
gst_caps_unref(video_caps);
video_caps = NULL;
} else {
- _mmcam_dbg_warn("failed to create caps");
+ MMCAM_LOG_WARNING("failed to create caps");
}
} else {
- _mmcam_dbg_log("current video codec is not openmax but [%s]",gst_element_venc_name);
+ MMCAM_LOG_INFO("current video codec is not openmax but [%s]", gst_element_venc_name);
}
}
}
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_RECORD,
- "UseVideoEncoderQueue",
- &use_venc_queue);
- if (use_venc_queue) {
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "UseVideoEncoderQueue",
+ &use_venc_queue);
+ if (use_venc_queue)
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VENC_QUE, "use-venc-queue", err);
- }
}
if (sc->audio_disable == FALSE &&
profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
- int use_aenc_queue =0;
+ int use_aenc_queue = 0;
AudioencElement = _mmcamcorder_get_type_element(handle, MM_CAM_AUDIO_ENCODER);
if (!AudioencElement) {
- _mmcam_dbg_err("Fail to get type element");
+ MMCAM_LOG_ERROR("Fail to get type element");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
if (audio_enc == MM_AUDIO_CODEC_AMR && channel == 2) {
audio_caps = gst_caps_new_simple("audio/x-raw",
- "channels", G_TYPE_INT, 1,
- NULL);
+ "channels", G_TYPE_INT, 1,
+ NULL);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", TRUE);
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", audio_caps);
gst_caps_unref(audio_caps);
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", audio_caps);
gst_caps_unref(audio_caps);
audio_caps = NULL;
- _mmcam_dbg_log("***** MM_AUDIO_CODEC_OGG : setting audio/x-raw-int ");
+ MMCAM_LOG_INFO("***** MM_AUDIO_CODEC_OGG : setting audio/x-raw-int ");
}
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_RECORD,
- "UseAudioEncoderQueue",
- &use_aenc_queue);
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "UseAudioEncoderQueue",
+ &use_aenc_queue);
if (use_aenc_queue) {
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_AENC_QUE, "use-aenc-queue", err);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst,"max-size-time", 0);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst,"max-size-buffers", 0);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst, "max-size-time", 0);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst, "max-size-buffers", 0);
}
}
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
- ImageencElement = _mmcamcorder_get_type_element(handle, MM_CAM_IMAGE_ENCODER);
- if (!ImageencElement) {
- _mmcam_dbg_err("Fail to get type element");
- err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto pipeline_creation_error;
- }
+ if (cap_format == MM_PIXEL_FORMAT_ENCODED) {
+ ImageencElement = _mmcamcorder_get_type_element(handle, MM_CAM_IMAGE_ENCODER);
+ if (!ImageencElement) {
+ MMCAM_LOG_ERROR("Fail to get type element");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto pipeline_creation_error;
+ }
- _mmcamcorder_conf_get_value_element_name(ImageencElement, &gst_element_ienc_name);
+ _mmcamcorder_conf_get_value_element_name(ImageencElement, &gst_element_ienc_name);
+ } else {
+ /* raw format - set dummy element */
+ gst_element_ienc_name = "identity";
+ }
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "ienc-name", gst_element_ienc_name);
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_IENC, "image-encode", err);
if (profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
MuxElement = _mmcamcorder_get_type_element(handle, MM_CAM_FILE_FORMAT);
if (!MuxElement) {
- _mmcam_dbg_err("Fail to get type element");
+ MMCAM_LOG_ERROR("Fail to get type element");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
if (profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
/* for recording */
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_RECORD,
- "RecordsinkElement",
- &RecordsinkElement );
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "RecordsinkElement",
+ &RecordsinkElement);
_mmcamcorder_conf_get_value_element_name(RecordsinkElement, &gst_element_rsink_name);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_SINK, gst_element_rsink_name, NULL, element_list, err);
}
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
- /* video encoder attribute setting */
- if (v_bitrate > 0) {
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst, "bitrate", v_bitrate);
- } else {
- _mmcam_dbg_warn("video bitrate is too small[%d], so skip setting. Use DEFAULT value.", v_bitrate);
- }
-
+ /* property setting in ini */
_mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst, VideoencElement);
+
+ /* bitrate setting */
+ _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
+ v_bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
}
if (sc->audio_disable == FALSE &&
profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
- /* audio encoder attribute setting */
- if (a_bitrate > 0) {
- switch (audio_enc) {
- case MM_AUDIO_CODEC_AMR:
- result = __mmcamcorder_get_amrnb_bitrate_mode(a_bitrate);
- _mmcam_dbg_log("Set AMR encoder[%s] mode [%d]", gst_element_aenc_name, result);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, "band-mode", result);
- break;
- case MM_AUDIO_CODEC_AAC:
- _mmcam_dbg_log("Set AAC encoder[%s] bitrate [%d]", gst_element_aenc_name, a_bitrate);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, "bitrate", a_bitrate);
- break;
- default:
- _mmcam_dbg_log("Audio codec is not AMR or AAC... you need to implement setting function for audio encoder bit-rate");
- break;
- }
- } else {
- _mmcam_dbg_warn("Setting bitrate is too small, so skip setting. Use DEFAULT value.");
- }
-
+ /* property setting in ini */
_mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, AudioencElement);
+
+ /* bitrate setting */
+ _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
+ a_bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
}
- _mmcam_dbg_log("Element creation complete");
+ MMCAM_LOG_INFO("Element creation complete");
/* Add element to bin */
if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst), element_list)) {
- _mmcam_dbg_err("element add error.");
+ MMCAM_LOG_ERROR("element add error.");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
- _mmcam_dbg_log("Element add complete");
+ 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");
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;
- _mmcam_dbg_err("failed to create ghost video_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+ MMCAM_LOG_ERROR("failed to create ghost video_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
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;
- _mmcam_dbg_err("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+ MMCAM_LOG_ERROR("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
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;
- _mmcam_dbg_err("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+ MMCAM_LOG_ERROR("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
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;
- _mmcam_dbg_err("failed to create ghost image_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
+ MMCAM_LOG_ERROR("failed to create ghost image_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
pad = NULL;
}
- _mmcam_dbg_log("Get pad complete");
+ MMCAM_LOG_INFO("Get pad complete");
/* Link internal element */
if (!_mmcamcorder_link_elements(element_list)) {
- _mmcam_dbg_err("element link error.");
+ MMCAM_LOG_ERROR("element link error.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
- if (element_list) {
+ if (element_list)
g_list_free(element_list);
- element_list = NULL;
- }
- _mmcam_dbg_log("done");
+ MMCAM_LOG_INFO("done");
return MM_ERROR_NONE;
-pipeline_creation_error :
+pipeline_creation_error:
_mmcamcorder_remove_all_handlers(handle, _MMCAMCORDER_HANDLER_VIDEOREC);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_SRC);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_FILT);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_VSCALE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_VSCALE_FILT);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_VENC);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_AENC);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_IENC);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_SINK);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_BIN);
- if (element_list) {
+ if (element_list)
g_list_free(element_list);
- element_list = NULL;
- }
+
+ if (video_caps)
+ gst_caps_unref(video_caps);
+
+ if (videoscale_caps)
+ gst_caps_unref(videoscale_caps);
return err;
}
GstPad *srcpad = NULL;
GstBus *bus = NULL;
- mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
/** Create gstreamer element **/
/* Main pipeline */
/* Sub pipeline */
err = _mmcamcorder_create_preview_elements((MMHandleType)hcamcorder);
- if (err != MM_ERROR_NONE) {
+ if (err != MM_ERROR_NONE)
goto pipeline_creation_error;
- }
/* Set data probe function */
if (sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst) {
- _mmcam_dbg_log("add video dataprobe to videosrc queue");
+ MMCAM_LOG_INFO("add video dataprobe to videosrc queue");
srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "src");
} else {
- _mmcam_dbg_err("there is no queue plugin");
+ MMCAM_LOG_ERROR("there is no queue plugin");
goto pipeline_creation_error;
}
if (srcpad) {
MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_PREVIEW,
- __mmcamcorder_video_dataprobe_preview, hcamcorder);
+ __mmcamcorder_video_dataprobe_preview, hcamcorder);
+
gst_object_unref(srcpad);
srcpad = NULL;
} else {
- _mmcam_dbg_err("failed to get srcpad");
+ MMCAM_LOG_ERROR("failed to get srcpad");
goto pipeline_creation_error;
}
- /* set dataprobe for video recording */
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "src");
- } else {
- srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "src");
+ /* set dataprobe for video recording if it does not support dual stream. */
+ if (sc->info_video->record_dual_stream == FALSE) {
+ if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format))
+ srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "src");
+ else
+ srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst, "src");
+
+ MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_PREVIEW,
+ __mmcamcorder_video_dataprobe_record, hcamcorder);
+ gst_object_unref(srcpad);
+ srcpad = NULL;
}
- MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_PREVIEW,
- __mmcamcorder_video_dataprobe_push_buffer_to_record, hcamcorder);
- gst_object_unref(srcpad);
- srcpad = NULL;
bus = gst_pipeline_get_bus(GST_PIPELINE(sc->element[_MMCAMCORDER_MAIN_PIPE].gst));
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- /*_mmcam_dbg_log("start");*/
+ /*MMCAM_LOG_INFO("start");*/
mmf_return_if_fail(hcamcorder);
mmf_return_if_fail(hcamcorder->sub_context);
/* set flag */
if (sc->info_video->push_encoding_buffer == PUSH_ENCODING_BUFFER_INIT) {
- sc->info_video->get_first_I_frame = FALSE;
sc->info_video->push_encoding_buffer = PUSH_ENCODING_BUFFER_RUN;
- _mmcam_dbg_warn("set push_encoding_buffer RUN");
+ MMCAM_LOG_WARNING("set push_encoding_buffer RUN");
}
}
{
int err = MM_ERROR_NONE;
int size = 0;
- int retx = 0;
- int rety = 0;
- int retwidth = 0;
- int retheight = 0;
+ int rect_x = 0;
+ int rect_y = 0;
+ int rect_width = 0;
+ int rect_height = 0;
int visible = 0;
int rotation = MM_DISPLAY_ROTATION_NONE;
int flip = MM_FLIP_NONE;
int zoom_attr = 0;
int zoom_level = 0;
int do_scaling = FALSE;
-#ifdef _MMCAMCORDER_RM_SUPPORT
- int display_scaler = 0;
-#endif /* _MMCAMCORDER_RM_SUPPORT */
- int *overlay = NULL;
+ int *dp_handle = NULL;
+ MMCamWindowInfo *window_info = NULL;
gulong xid;
char *err_name = NULL;
const char *videosink_name = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
/* Get video display information */
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_DISPLAY_RECT_X, &retx,
- MMCAM_DISPLAY_RECT_Y, &rety,
- MMCAM_DISPLAY_RECT_WIDTH, &retwidth,
- MMCAM_DISPLAY_RECT_HEIGHT, &retheight,
- MMCAM_DISPLAY_ROTATION, &rotation,
- MMCAM_DISPLAY_FLIP, &flip,
- MMCAM_DISPLAY_VISIBLE, &visible,
- MMCAM_DISPLAY_HANDLE, (void**)&overlay, &size,
- MMCAM_DISPLAY_MODE, &display_mode,
- MMCAM_DISPLAY_GEOMETRY_METHOD, &display_geometry_method,
- MMCAM_DISPLAY_SCALE, &zoom_attr,
- MMCAM_DISPLAY_EVAS_DO_SCALING, &do_scaling,
- NULL);
+ MMCAM_DISPLAY_RECT_X, &rect_x,
+ MMCAM_DISPLAY_RECT_Y, &rect_y,
+ MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
+ MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
+ MMCAM_DISPLAY_ROTATION, &rotation,
+ MMCAM_DISPLAY_FLIP, &flip,
+ MMCAM_DISPLAY_VISIBLE, &visible,
+ MMCAM_DISPLAY_HANDLE, (void **)&dp_handle, &size,
+ MMCAM_DISPLAY_MODE, &display_mode,
+ MMCAM_DISPLAY_GEOMETRY_METHOD, &display_geometry_method,
+ MMCAM_DISPLAY_SCALE, &zoom_attr,
+ MMCAM_DISPLAY_EVAS_DO_SCALING, &do_scaling,
+ NULL);
if (err != MM_ERROR_NONE) {
if (err_name) {
- _mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
+ MMCAM_LOG_ERROR("failed to get attributes [%s][0x%x]", err_name, err);
SAFE_FREE(err_name);
} else {
- _mmcam_dbg_err("failed to get attributes [0x%x]", err);
+ MMCAM_LOG_ERROR("failed to get attributes [0x%x]", err);
}
return err;
_mmcamcorder_conf_get_value_element_name(VideosinkElement, &videosink_name);
- _mmcam_dbg_log("(overlay=%p, size=%d)", overlay, size);
+ if (!videosink_name) {
+ MMCAM_LOG_ERROR("failed to get videosink name");
+ return MM_ERROR_CAMCORDER_INTERNAL;
+ }
+
+ MMCAM_LOG_INFO("(dp_handle=%p, size=%d)", dp_handle, size);
/* Set display handle */
- if (!strcmp(videosink_name, "xvimagesink") ||
- !strcmp(videosink_name, "ximagesink")) {
- if (overlay) {
- xid = *overlay;
- _mmcam_dbg_log("xid = %lu )", xid);
+ if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink")) {
+ if (dp_handle) {
+ xid = *dp_handle;
+ MMCAM_LOG_INFO("xid = %lu )", xid);
gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), xid);
} else {
- _mmcam_dbg_warn("Handle is NULL. Set xid as 0.. but, it's not recommended.");
+ MMCAM_LOG_WARNING("Handle is NULL. Set xid as 0.. but, it's not recommended.");
gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), 0);
}
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
- display_scaler = 1;
-
- MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
+ /* set the videosink using the virtual device id instead of the real id (main=0, sub=1) */
+ MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", hcamcorder->returned_devices.device_id[1]);
#endif /* _MMCAMCORDER_RM_SUPPORT */
- } else if (!strcmp(videosink_name, "evasimagesink") ||
- !strcmp(videosink_name, "evaspixmapsink")) {
- _mmcam_dbg_log("videosink : %s, handle : %p", videosink_name, overlay);
- if (overlay) {
- MMCAMCORDER_G_OBJECT_SET_POINTER(vsink, "evas-object", overlay);
+ } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
+ MMCAM_LOG_INFO("videosink : %s, handle : %p", videosink_name, dp_handle);
+
+ if (dp_handle) {
+ MMCAMCORDER_G_OBJECT_SET_POINTER(vsink, "evas-object", dp_handle);
MMCAMCORDER_G_OBJECT_SET(vsink, "origin-size", !do_scaling);
} else {
- _mmcam_dbg_err("display handle(eavs object) is NULL");
+ MMCAM_LOG_ERROR("display handle(eavs object) is NULL");
return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
}
- } else if (!strcmp(videosink_name, "waylandsink")) {
- MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)overlay;
- if (wl_info) {
- _mmcam_dbg_log("wayland global surface id : %d", wl_info->global_surface_id);
- gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(vsink), (guintptr)wl_info->global_surface_id);
+ } else if (!strcmp(videosink_name, "tizenwlsink")) {
+ if (dp_handle) {
+ window_info = (MMCamWindowInfo *)dp_handle;
+ MMCAM_LOG_INFO("wayland global surface id : %d", window_info->surface_id);
+ gst_video_overlay_set_wl_window_wl_surface_id(GST_VIDEO_OVERLAY(vsink), window_info->surface_id);
+ } else {
+ MMCAM_LOG_WARNING("Handle is NULL. skip setting.");
+ }
+ } else if (!strcmp(videosink_name, "directvideosink")) {
+ if (dp_handle) {
+ window_info = (MMCamWindowInfo *)dp_handle;
+ MMCAM_LOG_INFO("wayland global surface id : %d, x,y,w,h (%d,%d,%d,%d)",
+ window_info->surface_id,
+ window_info->rect.x,
+ window_info->rect.y,
+ window_info->rect.width,
+ window_info->rect.height);
+ gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), (guintptr)window_info->surface_id);
gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(vsink),
- wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
-#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
- display_scaler = 1;
-
- MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
-#endif /* _MMCAMCORDER_RM_SUPPORT */
+ window_info->rect.x,
+ window_info->rect.y,
+ window_info->rect.width,
+ window_info->rect.height);
} else {
- _mmcam_dbg_warn("Handle is NULL. skip setting.");
+ MMCAM_LOG_WARNING("dp_handle is null");
}
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ /* set the videosink using the virtual device id instead of the real id (main=0, sub=1) */
+ MMCAM_LOG_INFO("device-scaler : %d", hcamcorder->returned_devices.device_id[1]);
+ MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", hcamcorder->returned_devices.device_id[1]);
+#endif /* _MMCAMCORDER_RM_SUPPORT */
} else {
- _mmcam_dbg_warn("Who are you?? (Videosink: %s)", videosink_name);
+ MMCAM_LOG_WARNING("Who are you?? (Videosink: %s)", videosink_name);
}
- _mmcam_dbg_log("%s set: display_geometry_method[%d],origin-size[%d],visible[%d],rotate[%d],flip[%d]",
- videosink_name, display_geometry_method, origin_size, visible, rotation, flip);
+ MMCAM_LOG_INFO("%s set: display_geometry_method[%d],origin-size[%d],visible[%d],rotate[%d],flip[%d]",
+ videosink_name, display_geometry_method, origin_size, visible, rotation, flip);
/* Set attribute */
- if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
- !strcmp(videosink_name, "evaspixmapsink")) {
+ if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "tizenwlsink") ||
+ !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
/* set rotation */
MMCAMCORDER_G_OBJECT_SET(vsink, "rotate", rotation);
zoom_level = 3;
break;
default:
- _mmcam_dbg_warn("Unsupported zoom value. set as default.");
+ MMCAM_LOG_WARNING("Unsupported zoom value. set as default.");
zoom_level = 1;
break;
}
MMCAMCORDER_G_OBJECT_SET(vsink, "zoom", zoom_level);
if (display_geometry_method == MM_DISPLAY_METHOD_CUSTOM_ROI) {
- g_object_set(vsink,
- "dst-roi-x", retx,
- "dst-roi-y", rety,
- "dst-roi-w", retwidth,
- "dst-roi-h", retheight,
- NULL);
+ if (!strcmp(videosink_name, "tizenwlsink")) {
+ gst_video_overlay_set_display_roi_area(GST_VIDEO_OVERLAY(vsink),
+ rect_x, rect_y, rect_width, rect_height);
+ } else {
+ g_object_set(vsink,
+ "dst-roi-x", rect_x,
+ "dst-roi-y", rect_y,
+ "dst-roi-w", rect_width,
+ "dst-roi-h", rect_height,
+ NULL);
+ }
}
}
}
-int _mmcamcorder_vframe_stablize(MMHandleType handle)
+int _mmcamcorder_video_frame_stabilize(MMHandleType handle, int cmd)
{
- mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
+ int category = 0;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- _mmcam_dbg_log("%d", _MMCAMCORDER_CAMSTABLE_COUNT);
-
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (sc->cam_stability_count != _MMCAMCORDER_CAMSTABLE_COUNT) {
- sc->cam_stability_count = _MMCAMCORDER_CAMSTABLE_COUNT;
+ switch (cmd) {
+ case _MMCamcorder_CMD_PREVIEW_START:
+ category = CONFIGURE_CATEGORY_CTRL_CAMERA;
+ break;
+ case _MMCamcorder_CMD_CAPTURE:
+ category = CONFIGURE_CATEGORY_CTRL_CAPTURE;
+ break;
+ default:
+ MMCAM_LOG_WARNING("unknown command : %d", cmd);
+ return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
}
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_ctrl,
+ category, "FrameStabilityCount", &sc->frame_stability_count);
+
+ MMCAM_LOG_INFO("[cmd %d] frame stability count : %d",
+ cmd, sc->frame_stability_count);
+
return MM_ERROR_NONE;
}
/* Exif related information */
control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control != NULL) {
- gst_camera_control_get_exif_info(control, &exif_info); //get video input device information
+ gst_camera_control_get_exif_info(control, &exif_info); /* get video input device information */
if (exif_info.focal_len_denominator != 0)
focal_len = ((double)exif_info.focal_len_numerator) / ((double) exif_info.focal_len_denominator);
} else {
- _mmcam_dbg_err("Fail to get camera control interface!");
+ MMCAM_LOG_ERROR("Fail to get camera control interface!");
focal_len = 0.0;
}
}
/* Set values to attributes */
err = mm_camcorder_set_attributes(handle, &err_name,
- MMCAM_CAMERA_FOCAL_LENGTH, focal_len,
- NULL);
+ MMCAM_CAMERA_FOCAL_LENGTH, focal_len,
+ NULL);
if (err != MM_ERROR_NONE) {
- _mmcam_dbg_err("Set attributes error(%s:%x)!", err_name, err);
+ MMCAM_LOG_ERROR("Set attributes error(%s:%x)!", err_name, err);
SAFE_FREE(err_name);
return FALSE;
}
} else {
- _mmcam_dbg_warn( "Sub context isn't exist.");
+ MMCAM_LOG_WARNING("Sub context isn't exist.");
return FALSE;
}
static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_name)
{
- return format_name[0] | (format_name[1] << 8) | (format_name[2] << 16) | (format_name[3] << 24);
+ return format_name[0] | (format_name[1] << 8) | (format_name[2] << 16) | (format_name[3] << 24);
}
static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
{
- int current_state = MM_CAMCORDER_STATE_NONE;
- int i = 0;
-
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
_MMCamcorderSubContext *sc = NULL;
_MMCamcorderKPIMeasure *kpi = NULL;
GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
- GstMemory *dataBlock = NULL;
- GstMemory *metaBlock = NULL;
- GstMapInfo mapinfo;
mmf_return_val_if_fail(buffer, GST_PAD_PROBE_DROP);
- mmf_return_val_if_fail(gst_buffer_n_memory(buffer) , GST_PAD_PROBE_DROP);
+ mmf_return_val_if_fail(gst_buffer_n_memory(buffer), GST_PAD_PROBE_DROP);
mmf_return_val_if_fail(hcamcorder, GST_PAD_PROBE_DROP);
sc = MMF_CAMCORDER_SUBCONTEXT(u_data);
mmf_return_val_if_fail(sc, GST_PAD_PROBE_DROP);
- memset(&mapinfo, 0x0, sizeof(GstMapInfo));
-
- current_state = hcamcorder->state;
-
if (sc->drop_vframe > 0) {
if (sc->pass_first_vframe > 0) {
sc->pass_first_vframe--;
- _mmcam_dbg_log("Pass video frame by pass_first_vframe");
+ MMCAM_LOG_INFO("Pass video frame by pass_first_vframe");
} else {
sc->drop_vframe--;
- _mmcam_dbg_log("Drop video frame by drop_vframe");
+ MMCAM_LOG_INFO("Drop video frame by drop_vframe");
return GST_PAD_PROBE_DROP;
}
- } else if (sc->cam_stability_count > 0) {
- sc->cam_stability_count--;
- _mmcam_dbg_log("Drop video frame by cam_stability_count");
+ } else if (sc->frame_stability_count > 0) {
+ sc->frame_stability_count--;
+ MMCAM_LOG_INFO("Drop video frame by frame_stability_count");
return GST_PAD_PROBE_DROP;
}
- if (current_state >= MM_CAMCORDER_STATE_PREPARE) {
+ if (hcamcorder->state >= MM_CAMCORDER_STATE_PREPARE) {
int diff_sec;
int frame_count = 0;
struct timeval current_video_time;
kpi->init_video_time.tv_usec == kpi->last_video_time.tv_usec &&
kpi->init_video_time.tv_usec == 0) {
/*
- _mmcam_dbg_log("START to measure FPS");
+ MMCAM_LOG_INFO("START to measure FPS");
*/
gettimeofday(&(kpi->init_video_time), NULL);
}
kpi->last_video_time.tv_sec = current_video_time.tv_sec;
kpi->last_video_time.tv_usec = current_video_time.tv_usec;
/*
- _mmcam_dbg_log("current fps(%d), average(%d)", kpi->current_fps, kpi->average_fps);
+ MMCAM_LOG_INFO("current fps(%d), average(%d)", kpi->current_fps, kpi->average_fps);
*/
}
}
- /* video stream callback */
- if (hcamcorder->vstream_cb && buffer) {
- GstCaps *caps = NULL;
- GstStructure *structure = NULL;
- int state = MM_CAMCORDER_STATE_NULL;
- unsigned int fourcc = 0;
- MMCamcorderVideoStreamDataType stream;
- MMVideoBuffer *mm_buf = NULL;
- const gchar *string_format = NULL;
+ /* 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) {
+ MMCAM_LOG_WARNING("Not ready for stream callback");
+ return GST_PAD_PROBE_OK;
+ }
- state = _mmcamcorder_get_state((MMHandleType)hcamcorder);
- if (state < MM_CAMCORDER_STATE_PREPARE) {
- _mmcam_dbg_warn("Not ready for stream callback");
- return GST_PAD_PROBE_OK;
- }
+ if (_mmcamcorder_invoke_video_stream_cb((MMHandleType)hcamcorder, buffer, TRUE))
+ return GST_PAD_PROBE_OK;
+ else
+ return GST_PAD_PROBE_DROP;
+}
- caps = gst_pad_get_current_caps(pad);
- if (caps == NULL) {
- _mmcam_dbg_warn( "Caps is NULL." );
- return GST_PAD_PROBE_OK;
- }
- /* clear stream data structure */
- memset(&stream, 0x0, sizeof(MMCamcorderVideoStreamDataType));
+static GstPadProbeReturn __mmcamcorder_video_dataprobe_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+{
+ if (_mmcamcorder_video_push_buffer(u_data, GST_PAD_PROBE_INFO_BUFFER(info)))
+ return GST_PAD_PROBE_OK;
- structure = gst_caps_get_structure( caps, 0 );
- gst_structure_get_int(structure, "width", &(stream.width));
- gst_structure_get_int(structure, "height", &(stream.height));
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- stream.format = MM_PIXEL_FORMAT_ENCODED_H264;
- } else {
- string_format = gst_structure_get_string(structure, "format");
- if (string_format == NULL) {
- gst_caps_unref(caps);
- caps = NULL;
- _mmcam_dbg_warn("get string error!!");
- return GST_PAD_PROBE_OK;
- }
- fourcc = _mmcamcorder_convert_fourcc_string_to_value(string_format);
- stream.format = _mmcamcorder_get_pixtype(fourcc);
- }
- gst_caps_unref(caps);
- caps = NULL;
+ return GST_PAD_PROBE_DROP;
+}
- /*
- _mmcam_dbg_log( "Call video steramCb, data[%p], Width[%d],Height[%d], Format[%d]",
- GST_BUFFER_DATA(buffer), stream.width, stream.height, stream.format );
- */
- if (stream.width == 0 || stream.height == 0) {
- _mmcam_dbg_warn("Wrong condition!!");
- return GST_PAD_PROBE_OK;
- }
-
- /* set size and timestamp */
- dataBlock = gst_buffer_peek_memory(buffer, 0);
- stream.length_total = gst_memory_get_sizes(dataBlock, NULL, NULL);
- stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer)/1000000); /* nano sec -> mili sec */
-
- if (hcamcorder->use_zero_copy_format && gst_buffer_n_memory(buffer) > 1) {
- metaBlock = gst_buffer_peek_memory(buffer, 1);
- gst_memory_map(metaBlock, &mapinfo, GST_MAP_READ);
- mm_buf = (MMVideoBuffer *)mapinfo.data;
- }
-
- /* set data pointers */
- if (stream.format == MM_PIXEL_FORMAT_NV12 ||
- stream.format == MM_PIXEL_FORMAT_NV21 ||
- stream.format == MM_PIXEL_FORMAT_I420) {
- if (mm_buf) {
- if (stream.format == MM_PIXEL_FORMAT_NV12 ||
- stream.format == MM_PIXEL_FORMAT_NV21) {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420SP;
- stream.num_planes = 2;
- stream.data.yuv420sp.y = mm_buf->data[0];
- stream.data.yuv420sp.length_y = stream.width * stream.height;
- stream.data.yuv420sp.uv = mm_buf->data[1];
- stream.data.yuv420sp.length_uv = stream.data.yuv420sp.length_y >> 1;
- /*
- _mmcam_dbg_log("format[%d][num_planes:%d] [Y]p:0x%x,size:%d [UV]p:0x%x,size:%d",
- stream.format, stream.num_planes,
- stream.data.yuv420sp.y, stream.data.yuv420sp.length_y,
- stream.data.yuv420sp.uv, stream.data.yuv420sp.length_uv);
- */
- } else {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420P;
- stream.num_planes = 3;
- stream.data.yuv420p.y = mm_buf->data[0];
- stream.data.yuv420p.length_y = stream.width * stream.height;
- stream.data.yuv420p.u = mm_buf->data[1];
- stream.data.yuv420p.length_u = stream.data.yuv420p.length_y >> 2;
- stream.data.yuv420p.v = mm_buf->data[2];
- stream.data.yuv420p.length_v = stream.data.yuv420p.length_u;
- /*
- _mmcam_dbg_log("S420[num_planes:%d] [Y]p:0x%x,size:%d [U]p:0x%x,size:%d [V]p:0x%x,size:%d",
- stream.num_planes,
- 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);
- */
- }
- } else {
- gst_memory_map(dataBlock, &mapinfo, GST_MAP_READWRITE);
- if (stream.format == MM_PIXEL_FORMAT_NV12 ||
- stream.format == MM_PIXEL_FORMAT_NV21) {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420SP;
- stream.num_planes = 2;
- stream.data.yuv420sp.y = mapinfo.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;
- stream.stride[0] = stream.width;
- stream.elevation[0] = stream.height;
- stream.stride[1] = stream.width;
- stream.elevation[1] = stream.height >> 1;
- /*
- _mmcam_dbg_log("format[%d][num_planes:%d] [Y]p:0x%x,size:%d [UV]p:0x%x,size:%d",
- stream.format, stream.num_planes,
- stream.data.yuv420sp.y, stream.data.yuv420sp.length_y,
- stream.data.yuv420sp.uv, stream.data.yuv420sp.length_uv);
- */
- } else {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420P;
- stream.num_planes = 3;
- stream.data.yuv420p.y = mapinfo.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;
- stream.data.yuv420p.v = stream.data.yuv420p.u + stream.data.yuv420p.length_u;
- stream.data.yuv420p.length_v = stream.data.yuv420p.length_u;
- stream.stride[0] = stream.width;
- stream.elevation[0] = stream.height;
- stream.stride[1] = stream.width >> 1;
- stream.elevation[1] = stream.height >> 1;
- stream.stride[2] = stream.width >> 1;
- stream.elevation[2] = stream.height >> 1;
- /*
- _mmcam_dbg_log("I420[num_planes:%d] [Y]p:0x%x,size:%d [U]p:0x%x,size:%d [V]p:0x%x,size:%d",
- stream.num_planes,
- 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);
- */
- }
- }
- } else {
- if (mm_buf) {
- gst_memory_unmap(metaBlock, &mapinfo);
- metaBlock = NULL;
- }
- gst_memory_map(dataBlock, &mapinfo, GST_MAP_READWRITE);
- if (stream.format == MM_PIXEL_FORMAT_YUYV ||
- stream.format == MM_PIXEL_FORMAT_UYVY ||
- stream.format == MM_PIXEL_FORMAT_422P ||
- stream.format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
- stream.data_type = MM_CAM_STREAM_DATA_YUV422;
- stream.data.yuv422.yuv = mapinfo.data;
- stream.data.yuv422.length_yuv = stream.length_total;
- stream.stride[0] = stream.width << 1;
- stream.elevation[0] = stream.height;
- } else if (stream.format == MM_PIXEL_FORMAT_ENCODED_H264) {
- stream.data_type = MM_CAM_STREAM_DATA_ENCODED;
- stream.data.encoded.data = mapinfo.data;
- stream.data.encoded.length_data = stream.length_total;
- _mmcam_dbg_log("H264[num_planes:%d] [0]p:0x%x,size:%d",
- fourcc, fourcc>>8, fourcc>>16, fourcc>>24, stream.num_planes,
- stream.data.encoded.data, stream.data.encoded.length_data);
- } else {
- stream.data_type = MM_CAM_STREAM_DATA_YUV420;
- stream.data.yuv420.yuv = mapinfo.data;
- stream.data.yuv420.length_yuv = stream.length_total;
- stream.stride[0] = (stream.width * 3) >> 1;
- stream.elevation[0] = stream.height;
- }
+GstPadProbeReturn __mmcamcorder_muxed_dataprobe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+{
+ MMCamcorderMuxedStreamDataType stream;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
+ _MMCamcorderSubContext *sc = NULL;
+ GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
+ GstMapInfo mapinfo;
- stream.num_planes = 1;
- /*
- _mmcam_dbg_log("%c%c%c%c[num_planes:%d] [0]p:0x%x,size:%d",
- fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
- stream.num_planes, stream.data.yuv420.yuv, stream.data.yuv420.length_yuv);
- */
- }
+ mmf_return_val_if_fail(buffer, GST_PAD_PROBE_OK);
+ mmf_return_val_if_fail(gst_buffer_n_memory(buffer), GST_PAD_PROBE_OK);
+ mmf_return_val_if_fail(hcamcorder, GST_PAD_PROBE_OK);
- /* set tbm bo */
- if (mm_buf && mm_buf->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) {
- /* set bo, stride and elevation */
- for (i = 0 ; i < MM_VIDEO_BUFFER_PLANE_MAX ; i++) {
- stream.bo[i] = (void *)mm_buf->handle.bo[i];
- stream.stride[i] = mm_buf->stride_width[i];
- stream.elevation[i] = mm_buf->stride_height[i];
- }
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_val_if_fail(sc, GST_PAD_PROBE_OK);
- /* set gst buffer */
- stream.internal_buffer = buffer;
- }
+ if (!gst_buffer_map(buffer, &mapinfo, GST_MAP_READ)) {
+ MMCAM_LOG_WARNING("map failed : buffer %p", buffer);
+ return GST_PAD_PROBE_OK;
+ }
- /* call application callback */
- _MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
- if (hcamcorder->vstream_cb) {
- hcamcorder->vstream_cb(&stream, hcamcorder->vstream_cb_param);
+ /* call application callback */
+ _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(hcamcorder);
- for (i = 0 ; i < MM_VIDEO_BUFFER_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]);
- }
- }
- _MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(hcamcorder);
- /* Either metaBlock was mapped, or dataBlock, but not both. */
- if (metaBlock) {
- gst_memory_unmap(metaBlock, &mapinfo);
- }else {
- gst_memory_unmap(dataBlock, &mapinfo);
- }
+ if (hcamcorder->mstream_cb) {
+ stream.data = (void *)mapinfo.data;
+ stream.length = mapinfo.size;
+ stream.offset = sc->muxed_stream_offset;
+ hcamcorder->mstream_cb(&stream, hcamcorder->mstream_cb_param);
}
+ _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(hcamcorder);
+
+ /* calculate current offset */
+ sc->muxed_stream_offset += mapinfo.size;
+
+ gst_buffer_unmap(buffer, &mapinfo);
+
return GST_PAD_PROBE_OK;
}
-static GstPadProbeReturn __mmcamcorder_video_dataprobe_push_buffer_to_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+
+GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
{
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
+ GstEvent *event = GST_PAD_PROBE_INFO_EVENT(info);
+ mmf_camcorder_t *hcamcorder = NULL;
_MMCamcorderSubContext *sc = NULL;
- GstClockTime diff = 0; /* nsec */
- GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
+ GstObject *parent = NULL;
+
+ switch (GST_EVENT_TYPE(event)) {
+ case GST_EVENT_UNKNOWN:
+ /* upstream events */
+ case GST_EVENT_QOS:
+ case GST_EVENT_SEEK:
+ case GST_EVENT_NAVIGATION:
+ case GST_EVENT_LATENCY:
+ /* downstream serialized events */
+ case GST_EVENT_BUFFERSIZE:
+ MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
+ case GST_EVENT_TAG:
+ {
+ GstTagList *tag_list = NULL;
+ _MMCamcorderReplayGain *replay_gain = NULL;
+
+ MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+
+ hcamcorder = MMF_CAMCORDER(u_data);
+ if (!hcamcorder || !hcamcorder->sub_context) {
+ MMCAM_LOG_WARNING("NULL handle");
+ break;
+ }
- mmf_return_val_if_fail(buffer, GST_PAD_PROBE_DROP);
- mmf_return_val_if_fail(gst_buffer_n_memory(buffer), GST_PAD_PROBE_DROP);
- mmf_return_val_if_fail(hcamcorder, GST_PAD_PROBE_DROP);
+ replay_gain = &hcamcorder->sub_context->replay_gain;
- sc = MMF_CAMCORDER_SUBCONTEXT(u_data);
- mmf_return_val_if_fail(sc, GST_PAD_PROBE_DROP);
+ gst_event_parse_tag(event, &tag_list);
+ if (!tag_list) {
+ MMCAM_LOG_WARNING("failed to get tag list");
+ break;
+ }
- /* push buffer in appsrc to encode */
- if(!sc->info_video) {
- _mmcam_dbg_warn("sc->info_video is NULL!!");
- return FALSE;
- }
+ if (!gst_tag_list_get_double(tag_list, GST_TAG_TRACK_PEAK, &replay_gain->track_peak)) {
+ MMCAM_LOG_WARNING("failed to get GST_TAG_TRACK_PEAK");
+ break;
+ }
- if (sc->info_video->push_encoding_buffer == PUSH_ENCODING_BUFFER_RUN &&
- sc->info_video->record_dual_stream == FALSE &&
- sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst) {
- int ret = 0;
- GstClock *clock = NULL;
+ if (!gst_tag_list_get_double(tag_list, GST_TAG_TRACK_GAIN, &replay_gain->track_gain)) {
+ MMCAM_LOG_WARNING("failed to get GST_TAG_TRACK_GAIN");
+ break;
+ }
- /*
- _mmcam_dbg_log("GST_BUFFER_FLAG_DELTA_UNIT is set : %d",
- GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT));
- */
+ if (!gst_tag_list_get_double(tag_list, GST_TAG_ALBUM_PEAK, &replay_gain->album_peak)) {
+ MMCAM_LOG_WARNING("failed to get GST_TAG_ALBUM_PEAK");
+ break;
+ }
- /* check first I frame */
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264 &&
- sc->info_video->get_first_I_frame == FALSE) {
- if (!GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT)) {
- _mmcam_dbg_warn("first I frame is come");
- sc->info_video->get_first_I_frame = TRUE;
- } else {
- _mmcam_dbg_warn("NOT I frame.. skip this buffer");
- return GST_PAD_PROBE_OK;
+ if (!gst_tag_list_get_double(tag_list, GST_TAG_ALBUM_GAIN, &replay_gain->album_gain)) {
+ MMCAM_LOG_WARNING("failed to get GST_TAG_ALBUM_PEAK");
+ break;
}
+
+ MMCAM_LOG_INFO("Track [peak %lf, gain %lf], Album [peak %lf, gain %lf]",
+ replay_gain->track_peak, replay_gain->track_gain,
+ replay_gain->album_peak, replay_gain->album_gain);
}
+ break;
+ case GST_EVENT_SEGMENT:
+ MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
- if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
- if (sc->info_video->is_firstframe) {
- sc->info_video->is_firstframe = FALSE;
- clock = GST_ELEMENT_CLOCK(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst);
- if (clock) {
- gst_object_ref(clock);
- sc->info_video->base_video_ts = GST_BUFFER_PTS(buffer) - (gst_clock_get_time(clock) - GST_ELEMENT(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst)->base_time);
- gst_object_unref(clock);
- }
- }
- } else {
- if(sc->info_video->is_firstframe) {
- /* for image capture with encodebin(ex:emulator) */
- if (sc->bencbin_capture && sc->info_image->capturing) {
- g_mutex_lock(&hcamcorder->task_thread_lock);
- _mmcam_dbg_log("send signal for sound play");
- hcamcorder->task_thread_state = _MMCAMCORDER_TASK_THREAD_STATE_SOUND_SOLO_PLAY_START;
- g_cond_signal(&hcamcorder->task_thread_cond);
- g_mutex_unlock(&hcamcorder->task_thread_lock);
- }
- sc->info_video->is_firstframe = FALSE;
- sc->info_video->base_video_ts = GST_BUFFER_PTS(buffer);
- }
+ hcamcorder = MMF_CAMCORDER(u_data);
+ if (!hcamcorder) {
+ MMCAM_LOG_WARNING("NULL handle");
+ break;
}
- GST_BUFFER_PTS(buffer) = GST_BUFFER_PTS(buffer) - sc->info_video->base_video_ts;
- GST_BUFFER_DTS(buffer) = GST_BUFFER_PTS(buffer);
- /*_mmcam_dbg_log("buffer %p, timestamp %"GST_TIME_FORMAT, buffer, GST_TIME_ARGS(GST_BUFFER_PTS(buffer)));*/
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ if (!sc) {
+ MMCAM_LOG_WARNING("NULL sub context");
+ break;
+ }
- if (0) {
- GstCaps *caps = gst_pad_get_current_caps(pad);
- if (caps) {
- char *caps_string = gst_caps_to_string(caps);
- if (caps_string) {
- _mmcam_dbg_log("%s", caps_string);
- g_free(caps_string);
- caps_string = NULL;
- }
- gst_caps_unref(caps);
- caps = NULL;
- } else {
- _mmcam_dbg_warn("failed to get caps from pad");
- }
+ if (!sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
+ MMCAM_LOG_WARNING("no encoder sink");
+ break;
}
- g_signal_emit_by_name(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "push-buffer", buffer, &ret);
+ parent = gst_pad_get_parent(pad);
+ if (!parent) {
+ MMCAM_LOG_WARNING("get parent failed");
+ break;
+ }
- /*_mmcam_dbg_log("push buffer result : 0x%x", ret);*/
- }
+ if (parent == (GstObject *)sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
+ const GstSegment *segment;
+ gst_event_parse_segment(event, &segment);
+ if (segment->format == GST_FORMAT_BYTES) {
+ MMCAM_LOG_INFO("change current offset %llu -> %"G_GUINT64_FORMAT,
+ sc->muxed_stream_offset, segment->start);
- /* skip display if too fast FPS */
- if (sc->info_video && sc->info_video->fps > _MMCAMCORDER_FRAME_PASS_MIN_FPS) {
- if (sc->info_video->prev_preview_ts != 0) {
- diff = GST_BUFFER_PTS(buffer) - sc->info_video->prev_preview_ts;
- if (diff < _MMCAMCORDER_MIN_TIME_TO_PASS_FRAME) {
- _mmcam_dbg_log("it's too fast. drop frame...");
- return GST_PAD_PROBE_DROP;
+ sc->muxed_stream_offset = (unsigned long long)segment->start;
}
}
- /*_mmcam_dbg_log("diff %llu", diff);*/
-
- sc->info_video->prev_preview_ts = GST_BUFFER_PTS(buffer);
+ gst_object_unref(parent);
+ parent = NULL;
+ break;
+ case GST_EVENT_EOS:
+ MMCAM_LOG_WARNING("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
+ /* bidirectional events */
+ case GST_EVENT_FLUSH_START:
+ case GST_EVENT_FLUSH_STOP:
+ MMCAM_LOG_ERROR("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
+ default:
+ MMCAM_LOG_INFO("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
}
return GST_PAD_PROBE_OK;
{
int result = MM_CAMCORDER_MR475;
- if (bitrate< 5150) {
+ if (bitrate < 5150)
result = MM_CAMCORDER_MR475; /*AMR475*/
- } else if (bitrate< 5900) {
+ else if (bitrate < 5900)
result = MM_CAMCORDER_MR515; /*AMR515*/
- } else if (bitrate < 6700) {
+ else if (bitrate < 6700)
result = MM_CAMCORDER_MR59; /*AMR59*/
- } else if (bitrate< 7400) {
+ else if (bitrate < 7400)
result = MM_CAMCORDER_MR67; /*AMR67*/
- } else if (bitrate< 7950) {
+ else if (bitrate < 7950)
result = MM_CAMCORDER_MR74; /*AMR74*/
- } else if (bitrate < 10200) {
+ else if (bitrate < 10200)
result = MM_CAMCORDER_MR795; /*AMR795*/
- } else if (bitrate < 12200) {
+ else if (bitrate < 12200)
result = MM_CAMCORDER_MR102; /*AMR102*/
- } else {
+ else
result = MM_CAMCORDER_MR122; /*AMR122*/
- }
return result;
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- _mmcam_dbg_log("START");
+ MMCAM_LOG_INFO("START");
_MMCAMCORDER_LOCK(handle);
if (sc->bget_eos == FALSE) {
end_time = g_get_monotonic_time() + 3 * G_TIME_SPAN_SECOND;
if (_MMCAMCORDER_WAIT_UNTIL(handle, end_time)) {
- _mmcam_dbg_log("EOS signal received");
+ MMCAM_LOG_INFO("EOS signal received");
} else {
- _mmcam_dbg_err("EOS wait time out");
+ MMCAM_LOG_ERROR("EOS wait time out");
+
+ if (hcamcorder->error_code == MM_ERROR_NONE)
+ hcamcorder->error_code = MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
}
} else {
- _mmcam_dbg_log("already got EOS");
+ MMCAM_LOG_INFO("already got EOS");
}
_MMCAMCORDER_UNLOCK(handle);
if (hcamcorder->error_code == MM_ERROR_NONE) {
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
mmf_return_val_if_fail(sc->info_video, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (sc->info_video->b_commiting) {
+ if (sc->info_video->b_committing)
_mmcamcorder_video_handle_eos((MMHandleType)hcamcorder);
- }
} else {
mmf_return_val_if_fail(sc->info_audio, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (sc->info_audio->b_commiting) {
+ if (sc->info_audio->b_committing)
_mmcamcorder_audio_handle_eos((MMHandleType)hcamcorder);
- }
}
} else {
ret = hcamcorder->error_code;
- _mmcam_dbg_err("error 0x%x", ret);
+ MMCAM_LOG_ERROR("error 0x%x", ret);
}
- _mmcam_dbg_log("END");
+ MMCAM_LOG_INFO("END");
return ret;
}
mmf_return_if_fail(handle && remove_element);
mmf_return_if_fail((first_elem >= 0) && (last_elem > 0) && (last_elem > first_elem));
- _mmcam_dbg_log("");
+ MMCAM_LOG_INFO("");
for (i = first_elem ; i <= last_elem ; i++) {
remove_element[i].gst = NULL;
}
+int _mmcamcorder_check_codec_fileformat_compatibility(const char *codec_type, int codec, int file_format)
+{
+ mmf_return_val_if_fail(codec_type, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ /* Check compatibility between codec and file format */
+ if (!strcmp(codec_type, MMCAM_AUDIO_ENCODER)) {
+ if (codec > MM_AUDIO_CODEC_INVALID && codec < MM_AUDIO_CODEC_NUM &&
+ file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
+ if (audiocodec_fileformat_compatibility_table[codec][file_format] == 0) {
+ MMCAM_LOG_ERROR("Audio codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+
+ MMCAM_LOG_INFO("Audio codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
+ } else {
+ MMCAM_LOG_ERROR("Audio codec[%d] or file format[%d] is INVALID.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+ } else if (!strcmp(codec_type, MMCAM_VIDEO_ENCODER)) {
+ if (codec > MM_VIDEO_CODEC_INVALID && codec < MM_VIDEO_CODEC_NUM &&
+ file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
+ if (videocodec_fileformat_compatibility_table[codec][file_format] == 0) {
+ MMCAM_LOG_ERROR("Video codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+
+ MMCAM_LOG_INFO("Video codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
+ } else {
+ MMCAM_LOG_ERROR("Video codec[%d] or file format[%d] is INVALID.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+ }
+
+ return MM_ERROR_NONE;
+}
+
+
int _mmcamcorder_check_audiocodec_fileformat_compatibility(MMHandleType handle)
{
int err = MM_ERROR_NONE;
char *err_name = NULL;
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_AUDIO_ENCODER, &audio_codec,
- MMCAM_FILE_FORMAT, &file_format,
- NULL);
+ MMCAM_AUDIO_ENCODER, &audio_codec,
+ MMCAM_FILE_FORMAT, &file_format,
+ NULL);
if (err != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
+ MMCAM_LOG_WARNING("Get attrs fail. (%s:%x)", err_name, err);
SAFE_FREE(err_name);
return err;
}
/* Check compatibility between audio codec and file format */
- if (audio_codec > MM_AUDIO_CODEC_INVALID && audio_codec < MM_AUDIO_CODEC_NUM &&
- file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
- if (audiocodec_fileformat_compatibility_table[audio_codec][file_format] == 0) {
- _mmcam_dbg_err("Audio codec[%d] and file format[%d] compatibility FAILED.",
- audio_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
+ err = _mmcamcorder_check_codec_fileformat_compatibility(MMCAM_AUDIO_ENCODER, audio_codec, file_format);
- _mmcam_dbg_log("Audio codec[%d] and file format[%d] compatibility SUCCESS.",
- audio_codec, file_format);
- } else {
- _mmcam_dbg_err("Audio codec[%d] or file format[%d] is INVALID.",
- audio_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
-
- return MM_ERROR_NONE;
+ return err;
}
char *err_name = NULL;
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_VIDEO_ENCODER, &video_codec,
- MMCAM_FILE_FORMAT, &file_format,
- NULL);
+ MMCAM_VIDEO_ENCODER, &video_codec,
+ MMCAM_FILE_FORMAT, &file_format,
+ NULL);
if (err != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
+ MMCAM_LOG_WARNING("Get attrs fail. (%s:%x)", err_name, err);
SAFE_FREE(err_name);
return err;
}
- /* Check compatibility between audio codec and file format */
- if (video_codec > MM_VIDEO_CODEC_INVALID && video_codec < MM_VIDEO_CODEC_NUM &&
- file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
- if (videocodec_fileformat_compatibility_table[video_codec][file_format] == 0) {
- _mmcam_dbg_err("Video codec[%d] and file format[%d] compatibility FAILED.",
- video_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
-
- _mmcam_dbg_log("Video codec[%d] and file format[%d] compatibility SUCCESS.",
- video_codec, file_format);
- } else {
- _mmcam_dbg_err("Video codec[%d] or file format[%d] is INVALID.",
- video_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
+ /* Check compatibility between video codec and file format */
+ err = _mmcamcorder_check_codec_fileformat_compatibility(MMCAM_VIDEO_ENCODER, video_codec, file_format);
- return MM_ERROR_NONE;
+ return err;
}
/* Get videosink name */
_mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
if (videosink_name == NULL) {
- _mmcam_dbg_err("Please check videosink element in configuration file");
+ MMCAM_LOG_ERROR("Please check videosink element in configuration file");
return FALSE;
}
- if (!strcmp(videosink_name, "waylandsink") || !strcmp(videosink_name, "xvimagesink") ||
- !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
+ if (!strcmp(videosink_name, "tizenwlsink") || !strcmp(videosink_name, "xvimagesink") ||
+ !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink") ||
+ !strcmp(videosink_name, "directvideosink")) {
MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "rotate", display_rotate);
- _mmcam_dbg_log("Set display-rotate [%d] done.", display_rotate);
- return TRUE;
+ MMCAM_LOG_INFO("Set display-rotate [%d] done.", display_rotate);
} else {
- _mmcam_dbg_warn("videosink[%s] does not support DISPLAY_ROTATION.", videosink_name);
- return FALSE;
+ MMCAM_LOG_WARNING("[%s] does not support DISPLAY_ROTATION, but no error", videosink_name);
}
+
+ return TRUE;
} else {
- _mmcam_dbg_err("Videosink element is null");
+ MMCAM_LOG_ERROR("Videosink element is null");
return FALSE;
}
}
/* Get videosink name */
_mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
if (videosink_name == NULL) {
- _mmcam_dbg_err("Please check videosink element in configuration file");
+ MMCAM_LOG_ERROR("Please check videosink element in configuration file");
return FALSE;
}
- if (!strcmp(videosink_name, "waylandsink") || !strcmp(videosink_name, "xvimagesink") ||
- !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
+ if (!strcmp(videosink_name, "tizenwlsink") || !strcmp(videosink_name, "xvimagesink") ||
+ !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink") ||
+ !strcmp(videosink_name, "directvideosink")) {
MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "flip", display_flip);
- _mmcam_dbg_log("Set display flip [%d] done.", display_flip);
- return TRUE;
+ MMCAM_LOG_INFO("Set display flip [%d] done.", display_flip);
} else {
- _mmcam_dbg_warn("videosink[%s] does not support DISPLAY_FLIP", videosink_name);
- return FALSE;
+ MMCAM_LOG_WARNING("[%s] does not support DISPLAY_FLIP, but no error", videosink_name);
}
+
+ return TRUE;
} else {
- _mmcam_dbg_err("Videosink element is null");
+ MMCAM_LOG_ERROR("Videosink element is null");
return FALSE;
}
}
bool _mmcamcorder_set_videosrc_rotation(MMHandleType handle, int videosrc_rotate)
{
- int width = 0;
- int height = 0;
int fps = 0;
_MMCamcorderSubContext *sc = NULL;
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
if (!sc) {
- _mmcam_dbg_log("sub context is not initailized");
+ MMCAM_LOG_INFO("sub context is not initialized");
return TRUE;
}
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_WIDTH, &width,
- MMCAM_CAMERA_HEIGHT, &height,
- MMCAM_CAMERA_FPS, &fps,
- NULL);
+ MMCAM_CAMERA_WIDTH, &sc->info_video->preview_width,
+ MMCAM_CAMERA_HEIGHT, &sc->info_video->preview_height,
+ MMCAM_CAMERA_FPS, &fps,
+ NULL);
- _mmcam_dbg_log("set rotate %d", videosrc_rotate);
+ MMCAM_LOG_INFO("set rotate %d", videosrc_rotate);
- return _mmcamcorder_set_videosrc_caps(handle, sc->fourcc, width, height, fps, videosrc_rotate);
+ return _mmcamcorder_set_videosrc_caps(handle, sc->fourcc,
+ sc->info_video->preview_width, sc->info_video->preview_height,
+ fps, videosrc_rotate);
}
gboolean do_set_caps = FALSE;
GstCaps *caps = NULL;
-#ifdef _MMCAMCORDER_PRODUCT_TV
- GstPad *sinkpad;
- GstCaps *decsink_caps = NULL;
- GstStructure *decsink_struct = NULL;
- int maxwidth = 0;
- int maxheight = 0;
-#endif /*_MMCAMCORDER_PRODUCT_TV */
mmf_camcorder_t *hcamcorder = NULL;
_MMCamcorderSubContext *sc = NULL;
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
if (!sc || !(sc->element)) {
- _mmcam_dbg_log("sub context is not initialized");
+ MMCAM_LOG_INFO("sub context is not initialized");
return TRUE;
}
if (!sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
- _mmcam_dbg_err("Video src is NULL!");
+ MMCAM_LOG_ERROR("Video src is NULL!");
return FALSE;
}
if (!sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst) {
- _mmcam_dbg_err("Video filter is NULL!");
+ MMCAM_LOG_ERROR("Video filter is NULL!");
return FALSE;
}
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
- MMCAM_CAMERA_FPS_AUTO, &fps_auto,
- MMCAM_CAPTURE_WIDTH, &capture_width,
- MMCAM_CAPTURE_HEIGHT, &capture_height,
- MMCAM_VIDEO_WIDTH, &sc->info_video->video_width,
- MMCAM_VIDEO_HEIGHT, &sc->info_video->video_height,
- NULL);
- _mmcam_dbg_log("motion rate %f, capture size %dx%d, fps auto %d, video size %dx%d",
- motion_rate, capture_width, capture_height, fps_auto,
- sc->info_video->video_width, sc->info_video->video_height);
-
- if(motion_rate != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", fps);
- } else {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", 0);
- }
+ MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
+ MMCAM_CAMERA_FPS_AUTO, &fps_auto,
+ MMCAM_CAPTURE_WIDTH, &capture_width,
+ MMCAM_CAPTURE_HEIGHT, &capture_height,
+ MMCAM_VIDEO_WIDTH, &sc->info_video->video_width,
+ MMCAM_VIDEO_HEIGHT, &sc->info_video->video_height,
+ NULL);
+ MMCAM_LOG_INFO("motion rate %f, capture size %dx%d, fps auto %d, video size %dx%d",
+ motion_rate, capture_width, capture_height, fps_auto,
+ sc->info_video->video_width, sc->info_video->video_height);
+
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
+ "high-speed-fps", (motion_rate != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE ? 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);
set_width = height;
set_height = width;
if (hcamcorder->device_type == MM_VIDEO_DEVICE_CAMERA1) {
- if (rotate == MM_VIDEO_INPUT_ROTATION_90) {
+ if (rotate == MM_VIDEO_INPUT_ROTATION_90)
set_rotate = 270;
- } else {
+ else
set_rotate = 90;
- }
}
} else {
set_width = width;
set_width = width;
set_height = height;
- _mmcam_dbg_warn("ITLV format doe snot support INPUT ROTATE. Ignore ROTATE[%d]", rotate);
+ MMCAM_LOG_WARNING("ITLV format doe snot support INPUT ROTATE. Ignore ROTATE[%d]", rotate);
}
MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", &caps);
int caps_rotate = 0;
format_string = gst_structure_get_string(structure, "format");
- if (format_string) {
+ 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);
#ifdef _MMCAMCORDER_PRODUCT_TV
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- if (set_width == caps_width && set_height == caps_height && set_rotate == caps_rotate && fps == caps_fps) {
- _mmcam_dbg_log("No need to replace caps.");
+ 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) {
+ MMCAM_LOG_INFO("No need to replace caps.");
} else {
- _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %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,
- fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
- set_width, set_height, fps, set_rotate);
+ 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]",
+ caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
+ caps_width, caps_height, caps_fps, 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) {
- _mmcam_dbg_log("No need to replace caps.");
+ MMCAM_LOG_INFO("No need to replace caps.");
} else {
- _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %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,
- fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
- set_width, set_height, fps, set_rotate);
+ 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]",
+ caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
+ caps_width, caps_height, caps_fps, 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) {
- _mmcam_dbg_log("No need to replace caps.");
+ MMCAM_LOG_INFO("No need to replace caps.");
} else {
- _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %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,
- fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
- set_width, set_height, fps, set_rotate);
+ 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]",
+ caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
+ caps_width, caps_height, caps_fps, caps_rotate,
+ fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
+ set_width, set_height, fps, set_rotate);
do_set_caps = TRUE;
}
#endif /*_MMCAMCORDER_PRODUCT_TV */
} else {
- _mmcam_dbg_log("can not get structure of caps. set new one...");
+ MMCAM_LOG_INFO("can not get structure of caps. set new one...");
do_set_caps = TRUE;
}
} else {
- _mmcam_dbg_log("No caps. set new one...");
+ MMCAM_LOG_INFO("No caps. set new one...");
do_set_caps = TRUE;
}
if (do_set_caps) {
if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
#ifdef _MMCAMCORDER_PRODUCT_TV
- sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, "sink");
- if (!sinkpad) {
- _mmcam_dbg_err("There are no decoder caps");
- return FALSE;
- }
-
- decsink_caps = gst_pad_get_pad_template_caps(sinkpad);
- if (!decsink_caps) {
- gst_object_unref(sinkpad);
- _mmcam_dbg_err("There is no decoder sink caps");
- return FALSE;
- }
-
- decsink_struct = gst_caps_get_structure(decsink_caps,0);
- if (!decsink_struct) {
- _mmcam_dbg_err("There are no structure from caps");
- gst_object_unref(decsink_caps);
- gst_object_unref(sinkpad);
- return FALSE;
- }
+ 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(gst_structure_has_field(decsink_struct, "maxwidth")){
- gst_structure_get_int(decsink_struct, "maxwidth", &maxwidth);
- }
- if(gst_structure_has_field(decsink_struct, "maxheight")){
- gst_structure_get_int(decsink_struct, "maxheight", &maxheight);
+ 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",
+ "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);
-
+ NULL);
+ } else if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_MJPEG){
#ifdef _MMCAMCORDER_PRODUCT_TV
- gst_object_unref(decsink_caps);
- gst_object_unref(sinkpad);
-#endif /* _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);
} else {
char fourcc_string[sizeof(fourcc)+1];
- strncpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
+ 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);
+ "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) {
- _mmcam_dbg_log("vidoesrc new caps set. %"GST_PTR_FORMAT, 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_dbg_err("There are no caps");
+ MMCAM_LOG_ERROR("There are no caps");
}
}
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
- _mmcam_dbg_log("Set FLIP %d", videosrc_flip);
+ MMCAM_LOG_INFO("Set FLIP %d", videosrc_flip);
if (sc->element && sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
int hflip = 0;
hflip = (videosrc_flip & MM_FLIP_HORIZONTAL) == MM_FLIP_HORIZONTAL;
vflip = (videosrc_flip & MM_FLIP_VERTICAL) == MM_FLIP_VERTICAL;
- _mmcam_dbg_log("videosrc flip H:%d, V:%d", hflip, vflip);
+ MMCAM_LOG_INFO("videosrc flip H:%d, V:%d", hflip, vflip);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hflip", hflip);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "vflip", vflip);
} else {
- _mmcam_dbg_warn("ITLV format does not support FLIP. Ignore FLIP[%d]",
- videosrc_flip);
+ MMCAM_LOG_WARNING("ITLV format does not support FLIP. Ignore FLIP[%d]",
+ videosrc_flip);
}
} else {
- _mmcam_dbg_warn("element is NULL");
+ MMCAM_LOG_WARNING("element is NULL");
return FALSE;
}
mmf_return_val_if_fail(handle, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
if (!v_src) {
- _mmcam_dbg_warn("videosrc element is NULL");
+ MMCAM_LOG_WARNING("videosrc element is NULL");
return FALSE;
}
/* set anti-shake with camera control */
if (!GST_IS_CAMERA_CONTROL(v_src)) {
- _mmcam_dbg_warn("Can't cast Video source into camera control.");
+ MMCAM_LOG_WARNING("Can't cast Video source into camera control.");
return FALSE;
}
control = GST_CAMERA_CONTROL(v_src);
if (gst_camera_control_set_ahs(control, set_value)) {
- _mmcam_dbg_log("Succeed in operating anti-handshake. value[%d]", set_value);
+ MMCAM_LOG_INFO("Succeed in operating anti-handshake. value[%d]", set_value);
return TRUE;
} else {
- _mmcam_dbg_warn("Failed to operate anti-handshake. value[%d]", set_value);
+ MMCAM_LOG_WARNING("Failed to operate anti-handshake. value[%d]", set_value);
}
return FALSE;
mmf_return_val_if_fail(handle, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
if (!v_src) {
- _mmcam_dbg_warn("videosrc element is NULL");
+ MMCAM_LOG_WARNING("videosrc element is NULL");
return FALSE;
}
/* check property of videosrc element - support VDIS */
- if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(v_src)), "enable-vdis-mode")) {
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(v_src)), "enable-vdis-mode")) {
int video_width = 0;
int video_height = 0;
if (stabilization == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
- _mmcam_dbg_log("ENABLE video stabilization");
+ MMCAM_LOG_INFO("ENABLE video stabilization");
/* VDIS mode only supports NV12 and [720p or 1080p or 1088 * 1088] */
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_VIDEO_WIDTH, &video_width,
- MMCAM_VIDEO_HEIGHT, &video_height,
- NULL);
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_NV12 &&
- video_width >= 1080 && video_height >= 720) {
- _mmcam_dbg_log("NV12, video size %dx%d, ENABLE video stabilization",
- video_width, video_height, stabilization);
+ MMCAM_VIDEO_WIDTH, &video_width,
+ MMCAM_VIDEO_HEIGHT, &video_height,
+ NULL);
+
+ if (sc->info_image->preview_format == MM_PIXEL_FORMAT_NV12 && video_width >= 1080 && video_height >= 720) {
+ MMCAM_LOG_INFO("NV12, video size %dx%d, ENABLE video stabilization",
+ video_width, video_height);
/* set vdis mode */
g_object_set(G_OBJECT(v_src),
- "enable-vdis-mode", TRUE,
- NULL);
+ "enable-vdis-mode", TRUE,
+ NULL);
} else {
- _mmcam_dbg_warn("invalid preview format %c%c%c%c or video size %dx%d",
- sc->fourcc, sc->fourcc>>8, sc->fourcc>>16, sc->fourcc>>24,
- video_width, video_height);
+ MMCAM_LOG_WARNING("invalid preview format %c%c%c%c or video size %dx%d",
+ sc->fourcc, sc->fourcc>>8, sc->fourcc>>16, sc->fourcc>>24,
+ video_width, video_height);
return FALSE;
}
} else {
/* set vdis mode */
g_object_set(G_OBJECT(v_src),
- "enable-vdis-mode", FALSE,
- NULL);
+ "enable-vdis-mode", FALSE,
+ NULL);
- _mmcam_dbg_log("DISABLE video stabilization");
+ MMCAM_LOG_INFO("DISABLE video stabilization");
}
} else if (stabilization == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
- _mmcam_dbg_err("no property for video stabilization, so can not set ON");
+ MMCAM_LOG_ERROR("no property for video stabilization, so can not set ON");
return FALSE;
} else {
- _mmcam_dbg_warn("no property for video stabilization");
+ MMCAM_LOG_WARNING("no property for video stabilization");
}
return TRUE;
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_FPS, &fps,
- NULL);
+ MMCAM_CAMERA_FPS, &fps,
+ NULL);
- _mmcam_dbg_log("set %dx%d", width, height);
+ MMCAM_LOG_INFO("set %dx%d", width, height);
return _mmcamcorder_set_videosrc_caps(handle, sc->fourcc, width, height, fps, sc->videosrc_rotate);
}
bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate)
{
_MMCamcorderSubContext *sc = NULL;
- GstCameraControl *CameraControl = NULL;
- GstCameraControlChannel *CameraControlChannel = NULL;
- const GList *controls = NULL;
- const GList *item = NULL;
if ((void *)handle == NULL) {
- _mmcam_dbg_warn("handle is NULL");
+ MMCAM_LOG_WARNING("handle is NULL");
return FALSE;
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
if (!sc) {
- _mmcam_dbg_warn("subcontext is NULL");
+ MMCAM_LOG_WARNING("subcontext is NULL");
return FALSE;
}
if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst == NULL) {
- _mmcam_dbg_warn("videosrc plugin is NULL");
+ MMCAM_LOG_WARNING("videosrc plugin is NULL");
return FALSE;
}
- _mmcam_dbg_log("set encoded preview bitrate : %d bps", bitrate);
-
- CameraControl = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
- controls = gst_camera_control_list_channels(CameraControl);
- _mmcam_dbg_log("controls : 0x%x", controls);
- if (controls != NULL) {
- _mmcam_dbg_log("controls : 0x%x", controls);
- for (item = controls ; item && item->data ; item = item->next) {
- CameraControlChannel = item->data;
- _mmcam_dbg_log("label : %d", CameraControlChannel->label);
- if (!strcmp(CameraControlChannel->label, "bitrate")) {
- _mmcam_dbg_log("set encoded preview bitrate %d", bitrate);
- return gst_camera_control_set_value(CameraControl, CameraControlChannel, bitrate);
- }
- }
+ MMCAM_LOG_INFO("set encoded preview bitrate : %d bps", bitrate);
- if (item == NULL) {
- _mmcam_dbg_warn("failed to find \"bitrate\" control channel");
- }
- }
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "bitrate", bitrate);
- return FALSE;
+ return TRUE;
}
-bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int interval)
+bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop_interval)
{
_MMCamcorderSubContext *sc = NULL;
if ((void *)handle == NULL) {
- _mmcam_dbg_warn("handle is NULL");
+ MMCAM_LOG_WARNING("handle is NULL");
return FALSE;
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
if (!sc) {
- _mmcam_dbg_warn("subcontext is NULL");
+ MMCAM_LOG_WARNING("subcontext is NULL");
return FALSE;
}
if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst == NULL) {
- _mmcam_dbg_warn("videosrc plugin is NULL");
+ MMCAM_LOG_WARNING("videosrc plugin is NULL");
return FALSE;
}
- _mmcam_dbg_log("set encoded preview GOP interval : %d ms", interval);
+ MMCAM_LOG_INFO("set encoded preview GOP interval : %d ms", gop_interval);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "newgop-interval", interval);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "gop-interval", gop_interval);
return TRUE;
}
char stream_props[64] = {'\0',};
if (element == NULL || stream_type == NULL || stream_index < 0) {
- _mmcam_dbg_err("invalid argument %p %p %d", element, stream_type, stream_index);
+ MMCAM_LOG_ERROR("invalid argument %p %p %d", element, stream_type, stream_index);
return FALSE;
}
"props,media.role=%s, media.parent_id=%d",
stream_type, stream_index);
- _mmcam_dbg_log("stream type %s, index %d -> [%s]", stream_type, stream_index, stream_props);
+ MMCAM_LOG_WARNING("stream type %s, index %d -> [%s]", stream_type, stream_index, stream_props);
props = gst_structure_from_string(stream_props, NULL);
if (!props) {
- _mmcam_dbg_err("failed to create GstStructure");
+ MMCAM_LOG_ERROR("failed to create GstStructure");
return FALSE;
}
_MMCamcorderSubContext *sc = NULL;
mmf_camcorder_t *hcamcorder = NULL;
const char *videodecoder_name = NULL;
+ 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 */
if ((void *)handle == NULL) {
- _mmcam_dbg_warn("handle is NULL");
+ MMCAM_LOG_WARNING("handle is NULL");
return FALSE;
}
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
if (!sc) {
- _mmcam_dbg_warn("subcontext is NULL");
+ MMCAM_LOG_WARNING("subcontext is NULL");
return FALSE;
}
- if (sc->info_image->preview_format != MM_PIXEL_FORMAT_ENCODED_H264 ||
+ if (_mmcamcorder_is_encoded_preview_pixel_format(sc->info_image->preview_format) == false ||
hcamcorder->recreate_decoder == FALSE) {
- _mmcam_dbg_log("skip this fuction - format %d, recreate decoder %d",
+ MMCAM_LOG_INFO("skip this fuction - format %d, recreate decoder %d",
sc->info_image->preview_format, hcamcorder->recreate_decoder);
return TRUE;
}
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_SURFACE, &display_surface_type,
+ NULL);
+
+ if (display_surface_type == MM_DISPLAY_SURFACE_NULL) {
+ MMCAM_LOG_INFO("no need to control decoder element");
+ return TRUE;
+ }
+
if (sc->element[_MMCAMCORDER_MAIN_PIPE].gst == NULL ||
sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
- _mmcam_dbg_warn("main pipeline or decoder plugin is NULL");
+ MMCAM_LOG_WARNING("main pipeline or decoder plugin is NULL");
return FALSE;
}
- _mmcam_dbg_log("start");
+ MMCAM_LOG_INFO("start");
_mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264, &videodecoder_name);
if (videodecoder_name == NULL) {
- _mmcam_dbg_err("failed to get decoder element name from %p", sc->VideodecoderElementH264);
+ MMCAM_LOG_ERROR("failed to get decoder element name from %p", sc->VideodecoderElementH264);
return FALSE;
}
/* set state as NULL */
ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, GST_STATE_NULL);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to set NULL to decoder");
+ MMCAM_LOG_ERROR("failed to set NULL to decoder");
return FALSE;
}
/* remove decoder - pads will be unlinked automatically in remove function */
if (!gst_bin_remove(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)) {
- _mmcam_dbg_err("failed to remove decoder from pipeline");
+ MMCAM_LOG_ERROR("failed to remove decoder from pipeline");
return FALSE;
}
/* check decoder element */
if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst) {
- _mmcam_dbg_log("decoder[%p] is still alive - ref count %d",
+ MMCAM_LOG_INFO("decoder[%p] is still alive - ref count %d",
G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
((GObject *)sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)->ref_count);
}
#ifdef _MMCAMCORDER_RM_SUPPORT
- if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
- decoder_index = 1;
+ 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(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
+ MMCAM_LOG_INFO("encoded preview decoder_name %s", decoder_name);
+ } else {
+ /* MJPEG */
+ 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", decoder_name);
+ }
- snprintf(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
- _mmcam_dbg_log("encoded preview decoder_name %s", decoder_name);
/* create decoder */
sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(decoder_name, "videosrc_decode");
if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
- _mmcam_dbg_err("Decoder[%s] creation fail", decoder_name);
+ MMCAM_LOG_ERROR("Decoder[%s] creation fail", decoder_name);
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_dbg_err("Decoder [%s] creation fail", videodecoder_name);
+ MMCAM_LOG_ERROR("Decoder [%s] creation fail", videodecoder_name);
return FALSE;
}
#endif /* _MMCAMCORDER_RM_SUPPORT */
/* add to pipeline */
if (!gst_bin_add(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)) {
- _mmcam_dbg_err("failed to add decoder to pipeline");
+ MMCAM_LOG_ERROR("failed to add decoder to pipeline");
gst_object_unref(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst);
return FALSE;
}
/* link */
if (_MM_GST_ELEMENT_LINK(GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst),
GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst))) {
- _mmcam_dbg_log("Link videosrc_queue to decoder OK");
+ MMCAM_LOG_INFO("Link videosrc_queue to decoder OK");
} else {
- _mmcam_dbg_err("Link videosrc_queue to decoder FAILED");
+ MMCAM_LOG_ERROR("Link videosrc_queue to decoder FAILED");
return FALSE;
}
if (_MM_GST_ELEMENT_LINK(GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst))) {
- _mmcam_dbg_log("Link decoder to videosink_queue OK");
+ MMCAM_LOG_INFO("Link decoder to videosink_queue OK");
} else {
- _mmcam_dbg_err("Link decoder to videosink_queue FAILED");
+ MMCAM_LOG_ERROR("Link decoder to videosink_queue FAILED");
return FALSE;
}
/* set state READY */
ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, GST_STATE_READY);
if (ret != MM_ERROR_NONE) {
- _mmcam_dbg_err("failed to set READY to decoder");
+ MMCAM_LOG_ERROR("failed to set READY to decoder");
return FALSE;
}
- _mmcam_dbg_log("done");
+ MMCAM_LOG_INFO("done");
return TRUE;
}
+
+#ifdef _MMCAMCORDER_PRODUCT_TV
+static bool __mmcamcorder_find_max_resolution(MMHandleType handle, gint *max_width, gint *max_height)
+{
+ _MMCamcorderSubContext *sc = NULL;
+ mmf_camcorder_t *hcamcorder = NULL;
+ int index = 0;
+ const gchar *mime = NULL;
+ GstPad *sinkpad;
+ GstCaps *decsink_caps = NULL;
+ GstStructure *decsink_struct = NULL;
+
+ mmf_return_val_if_fail(handle, false);
+ mmf_return_val_if_fail(max_width, false);
+ mmf_return_val_if_fail(max_height, false);
+
+ hcamcorder = MMF_CAMCORDER(handle);
+ mmf_return_val_if_fail(hcamcorder, false);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+
+ sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, "sink");
+ if (!sinkpad) {
+ MMCAM_LOG_ERROR("There are no decoder caps");
+ return false;
+ }
+
+ decsink_caps = gst_pad_get_pad_template_caps(sinkpad);
+ if (!decsink_caps) {
+ gst_object_unref(sinkpad);
+ MMCAM_LOG_ERROR("There is no decoder sink caps");
+ return false;
+ }
+
+ for (index = 0; index < gst_caps_get_size(decsink_caps); index++) {
+ decsink_struct = gst_caps_get_structure(decsink_caps, index);
+ if (!decsink_struct) {
+ MMCAM_LOG_ERROR("There are no structure from caps");
+ gst_object_unref(decsink_caps);
+ gst_object_unref(sinkpad);
+ return false;
+ }
+ mime = gst_structure_get_name(decsink_struct);
+ if (!strcmp(mime, "video/x-h264")) {
+ MMCAM_LOG_INFO("h264 caps structure found");
+ if (gst_structure_has_field(decsink_struct, "maxwidth"))
+ *max_width = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxwidth"));
+ if (gst_structure_has_field(decsink_struct, "maxheight"))
+ *max_height = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxheight"));
+ break;
+ } else if (!strcmp(mime, "video/x-jpeg")) {
+ MMCAM_LOG_INFO("mjpeg caps structure found");
+ if (gst_structure_has_field(decsink_struct, "maxwidth"))
+ *max_width = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxwidth"));
+ if (gst_structure_has_field(decsink_struct, "maxheight"))
+ *max_height = gst_value_get_int_range_max(gst_structure_get_value(decsink_struct, "maxheight"));
+ break;
+ }
+ }
+ MMCAM_LOG_INFO("maxwidth = %d , maxheight = %d", (int)*max_width, (int)*max_height);
+ gst_object_unref(decsink_caps);
+ gst_object_unref(sinkpad);
+
+ if (*max_width <= 0 || *max_height <= 0)
+ return false;
+
+ return true;
+}
+#endif /* _MMCAMCORDER_PRODUCT_TV */