#include <gst/audio/audio-format.h>
#include <gst/video/videooverlay.h>
#include <gst/video/cameracontrol.h>
+#ifdef HAVE_WAYLAND
+#include <gst/wayland/wayland.h>
+#endif
+
#include <sys/time.h>
#include <unistd.h>
+#include <tbm_bufmgr.h>
#include "mm_camcorder_internal.h"
#include "mm_camcorder_gstcommon.h"
-----------------------------------------------------------------------*/
/* 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 */
-/*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, },
-/*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, },
-/*MP3*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
-/*OGG*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
-/*AAC*/ { 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
-/*WMA*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
-/*MMF*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
-/*ADPCM*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, },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 0, 0, 1, 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 |
-----------------------------------------------------------------------*/
#define USE_AUDIO_CLOCK_TUNE
-#define _MMCAMCORDER_WAIT_EOS_TIME 5.0 /* sec */
-#define _MMCAMCORDER_CONVERT_OUTPUT_BUFFER_NUM 6
+#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
+#define _MMCAMCORDER_VIDEO_DECODER_NAME "avdec_h264"
+
/*-----------------------------------------------------------------------
| LOCAL FUNCTION PROTOTYPES: |
* @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 int __mmcamcorder_get_amrnb_bitrate_mode(int bitrate);
+static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_name);
/*=======================================================================================
| FUNCTION DEFINITIONS |
/*-----------------------------------------------------------------------
| GLOBAL FUNCTION DEFINITIONS: |
-----------------------------------------------------------------------*/
-int _mmcamcorder_create_videosrc_bin(MMHandleType handle)
+int _mmcamcorder_create_preview_elements(MMHandleType handle)
{
int err = MM_ERROR_NONE;
- int rotate = 0;
- int flip = 0;
+ int i = 0;
+ int camera_width = 0;
+ int camera_height = 0;
+ int camera_rotate = 0;
+ int camera_flip = 0;
int fps = 0;
- int hold_af = 0;
- int UseVideoscale = 0;
int codectype = 0;
int capture_width = 0;
int capture_height = 0;
int capture_jpg_quality = 100;
int video_stabilization = 0;
int anti_shake = 0;
- char *videosrc_name = NULL;
+ int display_surface_type = MM_DISPLAY_SURFACE_NULL;
+ const char *videosrc_name = NULL;
+ const char *videosink_name = NULL;
char *err_name = NULL;
- unsigned int pix_fourcc = 0;
+ char *socket_path = NULL;
+ int socket_path_len;
GList *element_list = NULL;
- GstCaps *caps = NULL;
- GstPad *video_tee0 = NULL;
- GstPad *video_tee1 = NULL;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
_mmcam_dbg_log("");
/* Check existence */
- if (sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst) {
- if (((GObject *)sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst)->ref_count > 0) {
- gst_object_unref(sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst);
+ for (i = _MMCAMCORDER_VIDEOSRC_SRC ; i <= _MMCAMCORDER_VIDEOSINK_SINK ; i++) {
+ if (sc->element[i].gst) {
+ 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_dbg_log("_MMCAMCORDER_VIDEOSRC_BIN is Already existed.");
}
/* Get video device index info */
_mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl,
CONFIGURE_CATEGORY_CTRL_CAMERA,
"InputIndex",
- &input_index );
+ &input_index);
if (input_index == NULL) {
_mmcam_dbg_err("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, &rotate,
- MMCAM_CAMERA_FLIP, &flip,
+ 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,
- "camera-hold-af-after-capturing", &hold_af,
+ 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);
}
/* Get fourcc from picture format */
- pix_fourcc= _mmcamcorder_get_fourcc(sc->info_image->preview_format, codectype, hcamcorder->use_zero_copy_format);
- strncpy(sc->format_name, (char*)&pix_fourcc, sizeof(pix_fourcc));
- sc->format_name[sizeof(pix_fourcc)] = '\0';
+ 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(hcamcorder->conf_main,
+ _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
"VideosrcElement",
&VideosrcElement);
_mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
- /* Create bin element */
- __ta__(" videosrc_bin",
- _MMCAMCORDER_BIN_MAKE(sc, _MMCAMCORDER_VIDEOSRC_BIN, "videosrc_bin", err);
- );
+ /**
+ * Create child element
+ */
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_SRC, videosrc_name, "videosrc_src", element_list, err);
- /* Create child element */
- __ta__(" videosrc_src",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSRC_SRC, videosrc_name, "videosrc_src", element_list, err);
- );
- __ta__(" videosrc_capsfilter",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSRC_FILT, "capsfilter", "videosrc_filter", element_list, err);
- );
- __ta__(" videosrc_queue",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSRC_QUE, "queue", "videosrc_queue", 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 */
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", 0);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", capture_width);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", capture_height);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-jpg-quality", capture_jpg_quality);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hdr-capture", sc->info_image->hdr_capture_mode);
- /* set camera flip */
- _mmcamcorder_set_videosrc_flip(handle, flip);
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_QUE, "queue", "videosrc_queue", element_list, err);
- /* set flush cache as FALSE */
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "flush-cache", FALSE);
- }
+ /* set camera flip */
+ _mmcamcorder_set_videosrc_flip(handle, camera_flip);
/* set video stabilization mode */
_mmcamcorder_set_videosrc_stabilization(handle, video_stabilization);
/* set anti handshake mode */
_mmcamcorder_set_videosrc_anti_shake(handle, anti_shake);
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "UseVideoscale",
- &UseVideoscale);
- if (UseVideoscale) {
- int set_width = 0;
- int set_height = 0;
- int scale_width = 0;
- int scale_height = 0;
- int scale_method = 0;
- char *videoscale_name = NULL;
- type_element *VideoscaleElement = NULL;
-
- _mmcamcorder_conf_get_element(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "VideoscaleElement",
- &VideoscaleElement);
- _mmcamcorder_conf_get_value_element_name(VideoscaleElement, &videoscale_name);
- __ta__(" videosrc_scale",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSRC_SCALE, videoscale_name, "videosrc_scale", element_list, err);
- );
- __ta__(" videoscale_capsfilter",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSRC_VSFLT, "capsfilter", "videosrc_scalefilter", element_list, err);
- );
-
- _mmcamcorder_conf_get_value_element_int(VideoscaleElement, "width", &scale_width);
- _mmcamcorder_conf_get_value_element_int(VideoscaleElement, "height", &scale_height);
- _mmcamcorder_conf_get_value_element_int(VideoscaleElement, "method", &scale_method);
-
- if (rotate == MM_VIDEO_INPUT_ROTATION_90 ||
- rotate == MM_VIDEO_INPUT_ROTATION_270) {
- set_width = scale_height;
- set_height = scale_width;
- } else {
- set_width = scale_width;
- set_height = scale_height;
- }
-
- _mmcam_dbg_log("VideoSRC Scale[%dx%d], Method[%d]", set_width, set_height, scale_method);
-
- caps = gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, sc->format_name,
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- NULL);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_VSFLT].gst, "caps", caps);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SCALE].gst, "method", scale_method);
-
- gst_caps_unref(caps);
- caps = NULL;
- }
-
if (sc->is_modified_rate) {
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", fps);
}
- __ta__(" tee",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSRC_TEE, "tee", "videosrc_tee", element_list, err);
- );
-
/* Set basic infomation of videosrc element */
_mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, VideosrcElement);
- /* Set video device index */
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "camera-id", input_index->default_value);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "hold-af-after-capturing", hold_af);
+ /* 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;
- _mmcam_dbg_log("Current mode[%d]", hcamcorder->type);
+ /* set encoded preview bitrate and iframe interval */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_ENCODED_PREVIEW_BITRATE, &preview_bitrate,
+ MMCAM_ENCODED_PREVIEW_GOP_INTERVAL, &gop_interval,
+ NULL);
- /* Set sensor mode as CAMERA */
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "sensor-mode", 0);
+ if (!_mmcamcorder_set_encoded_preview_bitrate(handle, preview_bitrate))
+ _mmcam_dbg_warn("_mmcamcorder_set_encoded_preview_bitrate failed");
- /* Set caps by rotation */
- _mmcamcorder_set_videosrc_rotation(handle, rotate);
+ if (!_mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval))
+ _mmcam_dbg_warn("_mmcamcorder_set_encoded_preview_gop_interval failed");
- if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst), element_list)) {
- _mmcam_dbg_err( "element add error." );
- err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto pipeline_creation_error;
+ /* create decoder element */
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, _MMCAMCORDER_VIDEO_DECODER_NAME, "videosrc_decode", element_list, err);
}
- if (!_mmcamcorder_link_elements(element_list)) {
- _mmcam_dbg_err( "element link error." );
- err = MM_ERROR_CAMCORDER_GST_LINK;
- goto pipeline_creation_error;
+ _mmcam_dbg_log("Current mode[%d]", hcamcorder->type);
+
+ /* Get videosink name */
+ _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
+
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_QUE, "queue", "videosink_queue", element_list, err);
+
+ _mmcam_dbg_log("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);
+
+ err = mm_camcorder_get_attributes(handle, &err_name,
+ 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);
+ 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 {
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, "videosink_sink", element_list, err);
+ if (_mmcamcorder_videosink_window_set(handle, sc->VideosinkElement) != MM_ERROR_NONE) {
+ _mmcam_dbg_err("_mmcamcorder_videosink_window_set error");
+ err = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+ goto pipeline_creation_error;
+ }
}
- video_tee0 = gst_element_get_request_pad(sc->element[_MMCAMCORDER_VIDEOSRC_TEE].gst, "src_%u");
- video_tee1 = gst_element_get_request_pad(sc->element[_MMCAMCORDER_VIDEOSRC_TEE].gst, "src_%u");
+ _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
- MMCAMCORDER_G_OBJECT_SET((sc->element[_MMCAMCORDER_VIDEOSRC_TEE].gst), "alloc-pad", video_tee0);
+ /* Set caps by rotation */
+ _mmcamcorder_set_videosrc_rotation(handle, camera_rotate);
- /* Ghost pad */
- if ((gst_element_add_pad( sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst, gst_ghost_pad_new("src0", video_tee0) )) < 0) {
- _mmcam_dbg_err("failed to create ghost pad1 on _MMCAMCORDER_VIDEOSRC_BIN.");
- gst_object_unref(video_tee0);
- video_tee0 = NULL;
- gst_object_unref(video_tee1);
- video_tee1 = NULL;
- err = MM_ERROR_CAMCORDER_GST_LINK;
+ /* 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.");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
}
- if ((gst_element_add_pad( sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst, gst_ghost_pad_new("src1", video_tee1) )) < 0) {
- _mmcam_dbg_err("failed to create ghost pad2 on _MMCAMCORDER_VIDEOSRC_BIN.");
- gst_object_unref(video_tee0);
- video_tee0 = NULL;
- gst_object_unref(video_tee1);
- video_tee1 = NULL;
+ /* link elements */
+ if (!_mmcamcorder_link_elements(element_list)) {
+ _mmcam_dbg_err( "element link error." );
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
- gst_object_unref(video_tee0);
- video_tee0 = NULL;
- gst_object_unref(video_tee1);
- video_tee1 = NULL;
-
if (element_list) {
g_list_free(element_list);
element_list = NULL;
return MM_ERROR_NONE;
pipeline_creation_error:
- _MMCAMCORDER_ELEMENT_REMOVE( sc, _MMCAMCORDER_VIDEOSRC_SRC );
- _MMCAMCORDER_ELEMENT_REMOVE( sc, _MMCAMCORDER_VIDEOSRC_FILT );
- _MMCAMCORDER_ELEMENT_REMOVE( sc, _MMCAMCORDER_VIDEOSRC_SCALE );
- _MMCAMCORDER_ELEMENT_REMOVE( sc, _MMCAMCORDER_VIDEOSRC_VSFLT );
- _MMCAMCORDER_ELEMENT_REMOVE( sc, _MMCAMCORDER_VIDEOSRC_TEE );
- _MMCAMCORDER_ELEMENT_REMOVE( sc, _MMCAMCORDER_VIDEOSRC_BIN );
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_SRC);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_FILT);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CLS_QUE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CLS);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_CLS_FILT);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_QUE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSRC_DECODE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSINK_QUE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_VIDEOSINK_SINK);
+
if (element_list) {
g_list_free(element_list);
element_list = NULL;
int channel = 0;
int a_enc = MM_AUDIO_CODEC_AMR;
int a_dev = MM_AUDIO_DEVICE_MIC;
- int UseNoiseSuppressor = 0;
double volume = 0.0;
char *err_name = NULL;
- char *audiosrc_name = NULL;
+ const char *audiosrc_name = NULL;
char *cat_name = NULL;
+ char *stream_type = NULL;
+ char stream_type_len = 0;
+ int stream_index = 0;
GstCaps *caps = NULL;
GstPad *pad = NULL;
return err;
}
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_RECORD,
- "UseNoiseSuppressor",
- &UseNoiseSuppressor);
-
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_AUDIO_DEVICE, &a_dev,
- MMCAM_AUDIO_ENCODER, &a_enc,
- MMCAM_AUDIO_ENCODER_BITRATE, &val,
- MMCAM_AUDIO_SAMPLERATE, &rate,
- MMCAM_AUDIO_FORMAT, &format,
- MMCAM_AUDIO_CHANNEL, &channel,
- MMCAM_AUDIO_VOLUME, &volume,
- NULL);
+ MMCAM_AUDIO_DEVICE, &a_dev,
+ MMCAM_AUDIO_ENCODER, &a_enc,
+ MMCAM_AUDIO_ENCODER_BITRATE, &val,
+ MMCAM_AUDIO_SAMPLERATE, &rate,
+ MMCAM_AUDIO_FORMAT, &format,
+ MMCAM_AUDIO_CHANNEL, &channel,
+ MMCAM_AUDIO_VOLUME, &volume,
+ 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);
SAFE_FREE(err_name);
}
/* Check existence */
- if (sc->element[_MMCAMCORDER_AUDIOSRC_BIN].gst) {
- if (((GObject *)sc->element[_MMCAMCORDER_AUDIOSRC_BIN].gst)->ref_count > 0) {
- gst_object_unref(sc->element[_MMCAMCORDER_AUDIOSRC_BIN].gst);
+ if (sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst) {
+ 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...");
}
/* Create bin element */
- __ta__(" audiosource_bin",
- _MMCAMCORDER_BIN_MAKE(sc, _MMCAMCORDER_AUDIOSRC_BIN, "audiosource_bin", err);
- );
+ _MMCAMCORDER_BIN_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_BIN, "audiosource_bin", err);
if (a_dev == MM_AUDIO_DEVICE_MODEM) {
cat_name = strdup("AudiomodemsrcElement");
goto pipeline_creation_error;
}
- _mmcamcorder_conf_get_element(hcamcorder->conf_main,
+ _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
cat_name,
&AudiosrcElement);
_mmcam_dbg_log("Audio src name : %s", audiosrc_name);
- __ta__(" audiosrc",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_AUDIOSRC_SRC, audiosrc_name, NULL, element_list, err);
- );
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_SRC, audiosrc_name, "audiosrc_src", element_list, err);
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_AUDIOSRC_SRC].gst, AudiosrcElement);
+ /* set sound stream info */
+ _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
- __ta__(" audiosource_capsfilter",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_AUDIOSRC_FILT, "capsfilter", NULL, element_list, err);
- );
+ /* set audiosrc properties in ini configuration */
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, AudiosrcElement);
- if (a_enc != MM_AUDIO_CODEC_VORBIS) {
- __ta__(" audiosource_volume",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_AUDIOSRC_VOL, "volume", NULL, element_list, err);
- );
- }
+ _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-buffers", 0);
+ 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 (UseNoiseSuppressor && a_enc != MM_AUDIO_CODEC_AAC) {
- __ta__(" noise_suppressor",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_AUDIOSRC_NS, "noisesuppressor", "audiofilter", element_list, err);
- );
+ 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 */
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->element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", 1.0);
} else {
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", volume);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "mute", FALSE);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_VOL].gst, "volume", volume);
}
if (format == MM_CAMCORDER_AUDIO_FORMAT_PCM_S16_LE) {
depth = 16;
format_name = "S16LE";
} else { /* MM_CAMCORDER_AUDIO_FORMAT_PCM_U8 */
- format_name = "U8";
depth = 8;
+ format_name = "U8";
}
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-int,rate:%d,channel:%d,depth:%d]",
- rate, channel, depth);
+ "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);
} 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-float,rate:%d,channel:%d,endianness:%d,width:32]",
+ "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);
}
- MMCAMCORDER_G_OBJECT_SET((sc->element[_MMCAMCORDER_AUDIOSRC_FILT].gst), "caps", caps);
- gst_caps_unref(caps);
-
- if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->element[_MMCAMCORDER_AUDIOSRC_BIN].gst), element_list)) {
- _mmcam_dbg_err("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." );
- err = MM_ERROR_CAMCORDER_GST_LINK;
- goto pipeline_creation_error;
- }
-
- last_element = (_MMCamcorderGstElement*)(g_list_last(element_list)->data);
- pad = gst_element_get_static_pad(last_element->gst, "src");
- if ((gst_element_add_pad( sc->element[_MMCAMCORDER_AUDIOSRC_BIN].gst, gst_ghost_pad_new("src", pad) )) < 0) {
- gst_object_unref(pad);
- pad = NULL;
- _mmcam_dbg_err("failed to create ghost pad on _MMCAMCORDER_AUDIOSRC_BIN.");
- err = MM_ERROR_CAMCORDER_GST_LINK;
- goto pipeline_creation_error;
- }
-
- gst_object_unref(pad);
- pad = NULL;
-
- if (element_list) {
- g_list_free(element_list);
- element_list = NULL;
- }
-
- return MM_ERROR_NONE;
-
-pipeline_creation_error:
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_AUDIOSRC_SRC);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_AUDIOSRC_FILT);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_AUDIOSRC_VOL);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_AUDIOSRC_QUE);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_AUDIOSRC_CONV);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_AUDIOSRC_ENC);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_AUDIOSRC_BIN);
- if (element_list) {
- g_list_free(element_list);
- element_list = NULL;
- }
-
- return err;
-}
-
-
-int _mmcamcorder_create_videosink_bin(MMHandleType handle)
-{
- int err = MM_ERROR_NONE;
- int rect_width = 0;
- int rect_height = 0;
- int camera_width = 0;
- int camera_height = 0;
- int rotate = 0;
- int flip = 0;
- int UseVideoscale = 0, EnableConvertedSC = 0;
- int scale_method = 0;
- char* videosink_name = NULL;
- char* videoscale_name = NULL;
- char* err_name = NULL;
-
- GstCaps *caps = NULL;
- GstPad *pad = NULL;
- GList *element_list = NULL;
-
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _MMCamcorderSubContext *sc = NULL;
- _MMCamcorderGstElement *first_element = NULL;
- type_element *VideoscaleElement = NULL;
-
- 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);
- mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
-
- _mmcam_dbg_log("START");
-
- /* Get attributes */
- err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_CAMERA_WIDTH, &camera_width,
- MMCAM_CAMERA_HEIGHT, &camera_height,
- MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
- MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
- MMCAM_DISPLAY_ROTATION, &rotate,
- MMCAM_DISPLAY_FLIP, &flip,
- "enable-converted-stream-callback", &EnableConvertedSC,
- NULL);
- if (err != MM_ERROR_NONE) {
- _mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
- SAFE_FREE(err_name);
- return err;
- }
-
- /* Get videosink name */
- _mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
-
- /* Check existence */
- if (sc->element[_MMCAMCORDER_VIDEOSINK_BIN].gst) {
- if (((GObject *)sc->element[_MMCAMCORDER_VIDEOSINK_BIN].gst)->ref_count > 0) {
- gst_object_unref(sc->element[_MMCAMCORDER_VIDEOSINK_BIN].gst);
- }
- _mmcam_dbg_log("_MMCAMCORDER_VIDEOSINK_BIN is Already existed. Unref once...");
- }
-
- /* Create bin element */
- __ta__(" videosink_bin",
- _MMCAMCORDER_BIN_MAKE(sc, _MMCAMCORDER_VIDEOSINK_BIN, "videosink_bin", err);
- );
-
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- "UseVideoscale",
- &UseVideoscale);
-
- /* Create child element */
- if (EnableConvertedSC ||
- !strcmp(videosink_name, "evasimagesink") ||
- !strcmp(videosink_name, "ximagesink")) {
- GstElementFactory *factory = gst_element_factory_find("fimcconvert");
-
- if ((strcmp(sc->format_name, "SN21") == 0 ||
- strcmp(sc->format_name, "SN12") == 0 ||
- strcmp(sc->format_name, "ST12") == 0 ||
- strcmp(sc->format_name, "S420") == 0) &&
- factory) {
- int set_rotate = 0;
- int set_flip = 0;
-
- gst_object_unref(factory);
- factory = NULL;
-
- __ta__(" videosink_fimcconvert",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSINK_CLS, "fimcconvert", NULL, element_list, err);
- );
-
- /* set rotate */
- if (rotate > MM_VIDEO_INPUT_ROTATION_NONE &&
- rotate < MM_VIDEO_INPUT_ROTATION_NUM) {
- set_rotate = rotate * 90;
- } else {
- set_rotate = 0;
- }
-
- if (rect_width == 0 || rect_height == 0) {
- _mmcam_dbg_warn("rect_width or height is 0. set camera width and height.");
-
- if (rotate == MM_DISPLAY_ROTATION_90 ||
- rotate == MM_DISPLAY_ROTATION_270) {
- rect_width = camera_height;
- rect_height = camera_width;
- } else {
- rect_width = camera_width;
- rect_height = camera_height;
- }
- }
-
- /* set flip */
- switch (flip) {
- case MM_FLIP_HORIZONTAL:
- set_flip = FIMCCONVERT_FLIP_HORIZONTAL;
- break;
- case MM_FLIP_VERTICAL:
- set_flip = FIMCCONVERT_FLIP_VERTICAL;
- break;
- case MM_FLIP_BOTH: /* both flip has same effect with 180 rotation */
- set_rotate = (set_rotate + 180) % 360;
- case MM_FLIP_NONE:
- default:
- set_flip = FIMCCONVERT_FLIP_NONE;
- break;
- }
-
- _mmcam_dbg_log("Fimcconvert set values - %dx%d, rotate: %d, flip: %d",
- rect_width, rect_height, set_rotate, set_flip);
-
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_CLS].gst, "src-width", rect_width);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_CLS].gst, "src-height", rect_height);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_CLS].gst, "rotate", set_rotate);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_CLS].gst, "flip", set_flip);
- } else {
- if (factory) {
- gst_object_unref(factory);
- factory = NULL;
- }
-
- __ta__(" videosink_videoconvert",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSINK_CLS, "videoconvert", NULL, element_list, err);
- );
- }
- } else if(UseVideoscale) {
- __ta__(" videosink_queue",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSINK_QUE, "queue", NULL, element_list, err);
- );
-
- _mmcamcorder_conf_get_element(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
- "VideoscaleElement",
- &VideoscaleElement);
- _mmcamcorder_conf_get_value_element_name(VideoscaleElement, &videoscale_name);
-
- __ta__(" videosink_videoscale",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSINK_SCALE, videoscale_name, NULL, element_list, err);
- );
- __ta__(" videosink_capsfilter",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSINK_FILT, "capsfilter", NULL, element_list, err);
- );
-
- _mmcamcorder_conf_get_value_element_int(VideoscaleElement, "method", &scale_method);
- _mmcam_dbg_log("VideoSINK Scale[%dx%d], Method[%d]", rect_width, rect_height, scale_method);
-
- if (rect_width == 0 || rect_height == 0) {
- _mmcam_dbg_warn("rect_width or height is 0. set camera width and height.");
-
- rect_width = camera_width;
- rect_height = camera_height;
- }
-
- caps = gst_caps_new_simple("video/x-raw",
- "width", G_TYPE_INT, rect_width,
- "height", G_TYPE_INT, rect_height,
- NULL);
- MMCAMCORDER_G_OBJECT_SET((sc->element[_MMCAMCORDER_VIDEOSINK_FILT].gst), "caps", caps);
- MMCAMCORDER_G_OBJECT_SET((sc->element[_MMCAMCORDER_VIDEOSINK_SCALE].gst), "method", scale_method);
+ if (caps) {
+ MMCAMCORDER_G_OBJECT_SET_POINTER((sc->encode_element[_MMCAMCORDER_AUDIOSRC_FILT].gst), "caps", caps);
gst_caps_unref(caps);
caps = NULL;
+ } else {
+ _mmcam_dbg_err("create caps error");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto pipeline_creation_error;
}
- if (sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst == NULL) {
- __ta__(" videosink_queue",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSINK_QUE, "queue", "videosink_queue", element_list, err);
- );
- }
-
- __ta__(" videosink",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, NULL, element_list, err);
- );
-
- if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "ximagesink") ||
- !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
- if (_mmcamcorder_videosink_window_set(handle, sc->VideosinkElement) != MM_ERROR_NONE) {
- _mmcam_dbg_err("_mmcamcorder_videosink_window_set error");
- err = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
- goto pipeline_creation_error;
- }
- }
-
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
-
- if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->element[_MMCAMCORDER_VIDEOSINK_BIN].gst), element_list)) {
+ if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst), element_list)) {
_mmcam_dbg_err("element add error.");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
goto pipeline_creation_error;
}
- first_element = (_MMCamcorderGstElement*)(element_list->data);
- __ta__(" gst_element_get_static_pad",
- pad = gst_element_get_static_pad( first_element->gst, "sink");
- );
- if ((gst_element_add_pad( sc->element[_MMCAMCORDER_VIDEOSINK_BIN].gst, gst_ghost_pad_new("sink", pad) )) < 0) {
+ last_element = (_MMCamcorderGstElement*)(g_list_last(element_list)->data);
+ pad = gst_element_get_static_pad(last_element->gst, "src");
+ 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_VIDEOSINK_BIN.");
+ _mmcam_dbg_err("failed to create ghost pad on _MMCAMCORDER_AUDIOSRC_BIN.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
element_list = NULL;
}
- _mmcam_dbg_log("END");
-
return MM_ERROR_NONE;
pipeline_creation_error:
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_VIDEOSINK_QUE);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_VIDEOSINK_SCALE);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_VIDEOSINK_FILT);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_VIDEOSINK_CLS);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_VIDEOSINK_SINK);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_VIDEOSINK_BIN);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_AUDIOSRC_SRC);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_AUDIOSRC_FILT);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_AUDIOSRC_QUE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_AUDIOSRC_VOL);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_AUDIOSRC_BIN);
+
if (element_list) {
g_list_free(element_list);
element_list = NULL;
int auto_audio_convert = 0;
int auto_audio_resample = 0;
int auto_color_space = 0;
- char *gst_element_venc_name = NULL;
- char *gst_element_aenc_name = NULL;
- char *gst_element_ienc_name = NULL;
- char *gst_element_mux_name = NULL;
- char *gst_element_rsink_name = NULL;
- char *str_profile = NULL;
- char *str_aac = NULL;
- char *str_aar = NULL;
- char *str_acs = NULL;
+ 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 *str_profile = NULL;
+ const char *str_aac = NULL;
+ const char *str_aar = NULL;
+ const char *str_acs = NULL;
char *err_name = NULL;
-
- GstCaps *caps = NULL;
+ const char *videoconvert_name = NULL;
+ GstCaps *audio_caps = NULL;
+ GstCaps *video_caps = NULL;
GstPad *pad = NULL;
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_dbg_log("start - profile : %d", profile);
/* Check existence */
- if (sc->element[_MMCAMCORDER_ENCSINK_BIN].gst) {
- if (((GObject *)sc->element[_MMCAMCORDER_ENCSINK_BIN].gst)->ref_count > 0) {
- gst_object_unref(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst);
+ if (sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst) {
+ 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.");
}
/* Create bin element */
- __ta__(" encodesink_bin",
- _MMCAMCORDER_BIN_MAKE(sc, _MMCAMCORDER_ENCSINK_BIN, "encodesink_bin", err);
- );
+ _MMCAMCORDER_BIN_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_BIN, "encodesink_bin", err);
/* Create child element */
- __ta__(" encodebin",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_ENCSINK_ENCBIN, "encodebin", NULL, element_list, err);
- );
+ if (profile != MM_CAMCORDER_ENCBIN_PROFILE_AUDIO) {
+ GstCaps *caps_from_pad = 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 */
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "max-bytes", 0); /* unlimited */
+
+ /* 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");
+ pad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "src");
+ } else {
+ _mmcam_dbg_log("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");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto pipeline_creation_error;
+ }
+
+ caps_from_pad = gst_pad_get_allowed_caps(pad);
+ video_caps = gst_caps_copy(caps_from_pad);
+ gst_caps_unref(caps_from_pad);
+ caps_from_pad = NULL;
+ gst_object_unref(pad);
+ pad = NULL;
+ } else {
+ /* Image */
+ MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", &video_caps);
+ }
+
+ if (video_caps) {
+ char *caps_str = NULL;
+
+ if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
+ 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_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;
+ }
+
+ /* 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_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN, "encodebin", "encodesink_encbin", element_list, err);
/* check element availability */
- mm_camcorder_get_attributes(handle, &err_name,
+ 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);
+ SAFE_FREE(err_name);
+ } else {
+ _mmcam_dbg_err("failed to get attributes [0x%x]", err);
+ }
+
+ return err;
+ }
+
_mmcam_dbg_log("Profile[%d]", profile);
/* Set information */
str_acs = "ImageAutoColorSpace";
}
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_profile, &encodebin_profile);
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_aac, &auto_audio_convert);
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_aar, &auto_audio_resample);
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_acs, &auto_color_space);
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_profile, &encodebin_profile);
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main, CONFIGURE_CATEGORY_MAIN_RECORD, str_aac, &auto_audio_convert);
+ _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);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "profile", encodebin_profile);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", auto_audio_convert);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-resample", auto_audio_resample);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-colorspace", auto_color_space);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "use-video-toggle", FALSE);
+ 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);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-resample", auto_audio_resample);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-colorspace", auto_color_space);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "use-video-toggle", FALSE);
+
+ /* get video convert element name */
+ _mmcamcorder_conf_get_value_element_name(sc->VideoconvertElement, &videoconvert_name);
/* Codec */
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
goto pipeline_creation_error;
}
- _mmcamcorder_conf_get_value_element_name(VideoencElement, &gst_element_venc_name);
+ if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ gst_element_venc_name = "capsfilter";
+ } else {
+ _mmcamcorder_conf_get_value_element_name(VideoencElement, &gst_element_venc_name);
+ }
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "venc-name", gst_element_venc_name);
- _MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VENC, "video-encode", err);
+ if (gst_element_venc_name) {
+ _mmcam_dbg_log("video encoder name [%s]", gst_element_venc_name);
- /* set color convert plugin */
- if (hcamcorder->use_zero_copy_format &&
- strcmp(sc->format_name,"SN12") != 0) {
- int dst_buffer_num = _MMCAMCORDER_CONVERT_OUTPUT_BUFFER_NUM;
+ 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");
+ err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
+ goto pipeline_creation_error;
+ }
- /* set fimcconvert as colorspace element */
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vconv-name", "fimcconvert");
- _MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VCONV, "video-convert", err);
+ /* set color space converting element */
+ if (auto_color_space) {
+ _mmcam_dbg_log("set video convert element [%s]", videoconvert_name);
- caps = gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, "SN12",
- NULL);
- if (caps) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vcaps", caps);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_VCONV].gst, "dst-buffer-num", dst_buffer_num);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-colorspace", TRUE);
+ 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);
- gst_caps_unref (caps);
- caps = NULL;
- } else {
- err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
- goto pipeline_creation_error;
+ /* set colorspace plugin property setting */
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_VCONV].gst, sc->VideoconvertElement);
+
+ /* 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 (video_caps) {
+ MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vcaps", video_caps);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_VCONV].gst, "dst-buffer-num", _MMCAMCORDER_CONVERT_OUTPUT_BUFFER_NUM);
+
+ gst_caps_unref(video_caps);
+ video_caps = NULL;
+ } else {
+ _mmcam_dbg_warn("failed to create caps");
+ }
+ } else {
+ _mmcam_dbg_log("current video codec is not openmax but [%s]",gst_element_venc_name);
+ }
}
-
- _mmcam_dbg_log("fimcconvert dst-buffer-num %d", dst_buffer_num);
}
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main,
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_RECORD,
"UseVideoEncoderQueue",
&use_venc_queue);
if (sc->audio_disable == FALSE &&
profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
int use_aenc_queue =0;
- const gchar* int_formats = "{S8, U8, "
- "S16LE, S16BE, U16LE, U16BE, "
- "S24_32LE, S24_32BE, U24_32LE, U24_32BE, "
- "S32LE, S32BE, U32LE, U32BE, "
- "S24LE, S24BE, U24LE, U24BE, "
- "S20LE, S20BE, U20LE, U20BE, "
- "S18LE, S18BE, U18LE, U18BE}";
AudioencElement = _mmcamcorder_get_type_element(handle, MM_CAM_AUDIO_ENCODER);
if (!AudioencElement) {
_mmcamcorder_conf_get_value_element_name(AudioencElement, &gst_element_aenc_name);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "aenc-name", gst_element_aenc_name);
+ MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "aenc-name", gst_element_aenc_name);
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_AENC, "audio-encode", err);
if (audio_enc == MM_AUDIO_CODEC_AMR && channel == 2) {
- caps = gst_caps_new_simple("audio/x-raw",
+ audio_caps = gst_caps_new_simple("audio/x-raw",
"channels", G_TYPE_INT, 1,
- "format", G_TYPE_STRING, int_formats,
NULL);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", TRUE);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", caps);
- gst_caps_unref (caps);
- caps = 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);
+ audio_caps = NULL;
}
if (audio_enc == MM_AUDIO_CODEC_OGG) {
- caps = gst_caps_new_simple("audio/x-raw", "format", G_TYPE_STRING, int_formats, NULL);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", TRUE);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", caps);
- gst_caps_unref (caps);
- caps = NULL;
+ audio_caps = gst_caps_new_empty_simple("audio/x-raw");
+ 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);
+ audio_caps = NULL;
_mmcam_dbg_log("***** MM_AUDIO_CODEC_OGG : setting audio/x-raw-int ");
}
- //AAC is marked as experimental,
- //so compliance level must be set accordingly
- if (audio_enc == MM_AUDIO_CODEC_AAC)
- {
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_ENCSINK_AENC].gst, "compliance", -2);
- }
-
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main,
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
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->element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst,"max-size-time",G_GUINT64_CONSTANT(0));
- MMCAMCORDER_G_OBJECT_SET(sc->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);
}
}
_mmcamcorder_conf_get_value_element_name(ImageencElement, &gst_element_ienc_name);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "ienc-name", gst_element_ienc_name);
+ 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);
}
_mmcamcorder_conf_get_value_element_name(MuxElement, &gst_element_mux_name);
- __ta__(" mux",
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "mux-name", gst_element_mux_name);
- );
+ MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "mux-name", gst_element_mux_name);
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_MUX, "mux", err);
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_ENCSINK_MUX].gst, MuxElement);
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_MUX].gst, MuxElement);
}
/* Sink */
if (profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
/* for recording */
- _mmcamcorder_conf_get_element(hcamcorder->conf_main,
+ _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
CONFIGURE_CATEGORY_MAIN_RECORD,
"RecordsinkElement",
&RecordsinkElement );
_mmcamcorder_conf_get_value_element_name(RecordsinkElement, &gst_element_rsink_name);
- __ta__(" Recordsink_sink",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_ENCSINK_SINK, gst_element_rsink_name, NULL, element_list, err);
- );
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_SINK, gst_element_rsink_name, NULL, element_list, err);
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_ENCSINK_SINK].gst, RecordsinkElement);
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, RecordsinkElement);
} else {
/* for stillshot */
- __ta__(" fakesink",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_ENCSINK_SINK, "fakesink", NULL, element_list, err);
- );
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_SINK, "fakesink", NULL, element_list, err);
}
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
/* video encoder attribute setting */
if (v_bitrate > 0) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_ENCSINK_VENC].gst, "bitrate", v_bitrate);
+ 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);
}
- /*MMCAMCORDER_G_OBJECT_SET ((sc->element[_MMCAMCORDER_ENCSINK_VENC].gst),"hw-accel", v_hw);*/
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_ENCSINK_VENC].gst, VideoencElement);
+
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst, VideoencElement);
}
if (sc->audio_disable == FALSE &&
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->element[_MMCAMCORDER_ENCSINK_AENC].gst, "band-mode", 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->element[_MMCAMCORDER_ENCSINK_AENC].gst, "bitrate", 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");
_mmcam_dbg_warn("Setting bitrate is too small, so skip setting. Use DEFAULT value.");
}
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_ENCSINK_AENC].gst, AudioencElement);
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, AudioencElement);
}
_mmcam_dbg_log("Element creation complete");
/* Add element to bin */
- if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst), element_list)) {
+ if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst), element_list)) {
_mmcam_dbg_err("element add error.");
err = MM_ERROR_CAMCORDER_RESOURCE_CREATION;
goto pipeline_creation_error;
_mmcam_dbg_log("Element add complete");
if (profile == MM_CAMCORDER_ENCBIN_PROFILE_VIDEO) {
- pad = gst_element_get_request_pad(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "video");
- if (gst_element_add_pad(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("video_sink0", pad)) < 0) {
+ 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.");
pad = NULL;
if (sc->audio_disable == FALSE) {
- pad = gst_element_get_request_pad(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
- if (gst_element_add_pad(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad)) < 0) {
+ pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
+ if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
gst_object_unref(pad);
pad = NULL;
_mmcam_dbg_err("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
pad = NULL;
}
} else if (profile == MM_CAMCORDER_ENCBIN_PROFILE_AUDIO) {
- pad = gst_element_get_request_pad(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
- if (gst_element_add_pad(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad)) < 0) {
+ pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "audio");
+ if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("audio_sink0", pad))) {
gst_object_unref(pad);
pad = NULL;
_mmcam_dbg_err("failed to create ghost audio_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
pad = NULL;
} else {
/* for stillshot */
- pad = gst_element_get_request_pad(sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
- if (gst_element_add_pad(sc->element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("image_sink0", pad)) < 0) {
+ pad = gst_element_get_request_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "image");
+ if (!gst_element_add_pad(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst, gst_ghost_pad_new("image_sink0", pad))) {
gst_object_unref(pad);
pad = NULL;
_mmcam_dbg_err("failed to create ghost image_sink0 on _MMCAMCORDER_ENCSINK_BIN.");
element_list = NULL;
}
- return MM_ERROR_NONE;
-
-pipeline_creation_error :
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_ENCSINK_ENCBIN);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_ENCSINK_VENC);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_ENCSINK_AENC);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_ENCSINK_IENC);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_ENCSINK_MUX);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_ENCSINK_SINK);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_ENCSINK_BIN);
- if (element_list) {
- g_list_free(element_list);
- element_list = NULL;
- }
-
- return err;
-}
-
-
-int _mmcamcorder_create_stillshotsink_bin(MMHandleType handle)
-{
- int err = MM_ERROR_NONE;
- int capture_width = 0;
- int capture_height = 0;
- int UseCaptureMode = 0;
- char *gst_element_ienc_name = NULL;
- char *gst_element_videoscale_name = NULL;
-
- GList *element_list = NULL;
- GstPad *pad = NULL;
-
- mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
- _MMCamcorderSubContext *sc = NULL;
- _MMCamcorderGstElement *first_element = NULL;
- type_element* ImageencElement = NULL;
- type_element* VideoscaleElement = NULL;
-
- 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);
- mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
-
- _mmcam_dbg_log("");
-
- /* Check existence */
- if (sc->element[_MMCAMCORDER_STILLSHOTSINK_BIN].gst) {
- if (((GObject *)sc->element[_MMCAMCORDER_STILLSHOTSINK_BIN].gst)->ref_count > 0) {
- gst_object_unref(sc->element[_MMCAMCORDER_STILLSHOTSINK_BIN].gst);
- }
- _mmcam_dbg_log("_MMCAMCORDER_STILLSHOTSINK_BIN is Already existed. Unref once...");
- }
-
- /* Check element availability */
- 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;
- }
-
- _mmcamcorder_conf_get_value_element_name(ImageencElement, &gst_element_ienc_name);
-
- _mmcamcorder_conf_get_value_int(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_CAPTURE,
- "UseCaptureMode",
- &UseCaptureMode);
-
- /* Create bin element */
- __ta__(" stillshotsink_bin",
- _MMCAMCORDER_BIN_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_BIN, "stillshotsink_bin", err);
- );
-
- /* Create child element */
- __ta__(" stillshotsink_queue",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_QUE, "queue", NULL, element_list, err);
- );
- __ta__(" stillshotsink_toggle",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_TOGGLE, "toggle", NULL, element_list, err);
- );
-
- if (UseCaptureMode) {
- _mmcamcorder_conf_get_element(hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_CAPTURE,
- "VideoscaleElement",
- &VideoscaleElement);
- _mmcamcorder_conf_get_value_element_name(VideoscaleElement, &gst_element_videoscale_name);
-
- __ta__(" stillshotsink_videoscale",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_SCALE, "gst_element_videoscale_name", NULL, element_list, err);
- );
- __ta__(" stillshotsink_videocrop",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_CROP, "videocrop", NULL, element_list, err);
- );
- __ta__(" stillshotsink_capsfiltern",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_FILT, "capsfilter", NULL, element_list, err);
- );
- }
-
- __ta__(" image encoder",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_ENC, gst_element_ienc_name, NULL, element_list, err);
- );
-
- __ta__(" fakesink",
- _MMCAMCORDER_ELEMENT_MAKE(sc, _MMCAMCORDER_STILLSHOTSINK_SINK, "fakesink", NULL, element_list, err);
- );
-
- if (UseCaptureMode) {
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_STILLSHOTSINK_SCALE].gst, VideoscaleElement);
-
- /* Set property */
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAPTURE_WIDTH, &capture_width,
- MMCAM_CAPTURE_HEIGHT, &capture_height,
- NULL);
-
- __ta__(" _mmcamcorder_set_resize_property",
- err = _mmcamcorder_set_resize_property(handle, capture_width, capture_height);
- );
- if (err != MM_ERROR_NONE) {
- //unref??
- _mmcam_dbg_log("Set resize property failed.");
- goto pipeline_creation_error;
- }
- }
-
- if (!_mmcamcorder_add_elements_to_bin(GST_BIN(sc->element[_MMCAMCORDER_STILLSHOTSINK_BIN].gst), element_list)) {
- _mmcam_dbg_err( "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." );
- err = MM_ERROR_CAMCORDER_GST_LINK;
- goto pipeline_creation_error;
- }
-
- first_element = (_MMCamcorderGstElement*)(element_list->data);
-
- pad = gst_element_get_static_pad(first_element->gst, "sink");
- if (gst_element_add_pad( sc->element[_MMCAMCORDER_STILLSHOTSINK_BIN].gst, gst_ghost_pad_new("sink", pad)) < 0) {
- gst_object_unref(pad);
- pad = NULL;
- _mmcam_dbg_err("failed to create ghost pad on _MMCAMCORDER_STILLSHOTSINK_BIN.");
- err = MM_ERROR_CAMCORDER_GST_LINK;
- goto pipeline_creation_error;
- }
- gst_object_unref(pad);
- pad = NULL;
-
- if (element_list) {
- g_list_free(element_list);
- element_list = NULL;
- }
+ _mmcam_dbg_log("done");
return MM_ERROR_NONE;
pipeline_creation_error :
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_QUE);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_TOGGLE);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_CROP);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_FILT);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_SCALE);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_ENC);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_SINK);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_STILLSHOTSINK_BIN);
+ _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_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_MUX);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_SINK);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_BIN);
+
if (element_list) {
g_list_free(element_list);
element_list = NULL;
int err = MM_ERROR_NONE;
GstPad *srcpad = NULL;
- GstPad *sinkpad = NULL;
GstBus *bus = NULL;
mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
/** Create gstreamer element **/
/* Main pipeline */
- _MMCAMCORDER_PIPELINE_MAKE(sc, _MMCAMCORDER_MAIN_PIPE, "camcorder_pipeline", err);
+ _MMCAMCORDER_PIPELINE_MAKE(sc, sc->element, _MMCAMCORDER_MAIN_PIPE, "camera_pipeline", err);
/* Sub pipeline */
- __ta__(" __mmcamcorder_create_videosrc_bin",
- err = _mmcamcorder_create_videosrc_bin((MMHandleType)hcamcorder);
- );
- if (err != MM_ERROR_NONE ) {
+ err = _mmcamcorder_create_preview_elements((MMHandleType)hcamcorder);
+ if (err != MM_ERROR_NONE) {
goto pipeline_creation_error;
}
- __ta__(" _mmcamcorder_create_videosink_bin",
- err = _mmcamcorder_create_videosink_bin((MMHandleType)hcamcorder);
- );
- if (err != MM_ERROR_NONE ) {
+ /* Set data probe function */
+ if (sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst) {
+ _mmcam_dbg_log("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");
goto pipeline_creation_error;
}
- gst_bin_add_many(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
- sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst,
- sc->element[_MMCAMCORDER_VIDEOSINK_BIN].gst,
- NULL);
-
- /* Link each element */
- srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_BIN].gst, "src0");
- sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSINK_BIN].gst, "sink");
- _MM_GST_PAD_LINK_UNREF(srcpad, sinkpad, err, pipeline_creation_error);
+ if (srcpad) {
+ MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_PREVIEW,
+ __mmcamcorder_video_dataprobe_preview, hcamcorder);
+ gst_object_unref(srcpad);
+ srcpad = NULL;
+ } else {
+ _mmcam_dbg_err("failed to get srcpad");
+ goto pipeline_creation_error;
+ }
- /* Set data probe function */
- srcpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst, "src");
+ /* 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");
+ }
MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_PREVIEW,
- __mmcamcorder_video_dataprobe_preview, hcamcorder);
+ __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));
- /* Register message callback */
+ /* Register pipeline message callback */
hcamcorder->pipeline_cb_event_id = gst_bus_add_watch(bus, _mmcamcorder_pipeline_cb_message, (gpointer)hcamcorder);
/* set sync handler */
- gst_bus_set_sync_handler(bus, _mmcamcorder_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
+ gst_bus_set_sync_handler(bus, _mmcamcorder_pipeline_bus_sync_callback, (gpointer)hcamcorder, NULL);
gst_object_unref(bus);
bus = NULL;
- /* Below signals are meaningfull only when video source is using. */
- MMCAMCORDER_SIGNAL_CONNECT(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst,
- _MMCAMCORDER_HANDLER_PREVIEW,
- "nego-complete",
- _mmcamcorder_negosig_handler,
- hcamcorder);
-
return MM_ERROR_NONE;
pipeline_creation_error:
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_VIDEOSRC_BIN);
- _MMCAMCORDER_ELEMENT_REMOVE(sc, _MMCAMCORDER_MAIN_PIPE);
+ _MMCAMCORDER_ELEMENT_REMOVE(sc->element, _MMCAMCORDER_MAIN_PIPE);
return err;
}
-void _mmcamcorder_negosig_handler(GstElement *videosrc, MMHandleType handle)
+void _mmcamcorder_ready_to_encode_callback(GstElement *element, guint size, gpointer handle)
{
- mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- _mmcam_dbg_log("");
+ /*_mmcam_dbg_log("start");*/
mmf_return_if_fail(hcamcorder);
mmf_return_if_fail(hcamcorder->sub_context);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- /* kernel was modified. No need to set.
- _mmcamcorder_set_attribute_to_camsensor(handle);
- */
-
- if (sc->cam_stability_count != _MMCAMCORDER_CAMSTABLE_COUNT) {
- sc->cam_stability_count = _MMCAMCORDER_CAMSTABLE_COUNT;
- }
-
- if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
- _MMCamcorderImageInfo *info = NULL;
- info = sc->info_image;
- if (info->resolution_change == TRUE) {
- _mmcam_dbg_log("open toggle of stillshot sink.");
- MMCAMCORDER_G_OBJECT_SET( sc->element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "block", FALSE);
- info->resolution_change = FALSE;
- }
+ /* 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");
}
}
int retheight = 0;
int visible = 0;
int rotation = MM_DISPLAY_ROTATION_NONE;
- int rotation_degree = 0;
int flip = MM_FLIP_NONE;
int display_mode = MM_DISPLAY_MODE_DEFAULT;
int display_geometry_method = MM_DISPLAY_METHOD_LETTER_BOX;
int origin_size = 0;
int zoom_attr = 0;
- float zoom_level = 0;
+ int zoom_level = 0;
int do_scaling = FALSE;
int *overlay = NULL;
gulong xid;
char *err_name = NULL;
- char *videosink_name = NULL;
+ const char *videosink_name = NULL;
GstElement *vsink = NULL;
vsink = sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst;
/* Get video display information */
- __ta__(" videosink get attributes",
err = mm_camcorder_get_attributes(handle, &err_name,
MMCAM_DISPLAY_RECT_X, &retx,
MMCAM_DISPLAY_RECT_Y, &rety,
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);
+ SAFE_FREE(err_name);
+ } else {
+ _mmcam_dbg_err("failed to get attributes [0x%x]", err);
+ }
- _mmcam_dbg_log("(overlay=%p, size=%d)", overlay, size);
+ return err;
+ }
_mmcamcorder_conf_get_value_element_name(VideosinkElement, &videosink_name);
+ _mmcam_dbg_log("(overlay=%p, size=%d)", overlay, size);
+
/* Set display handle */
if (!strcmp(videosink_name, "xvimagesink") ||
!strcmp(videosink_name, "ximagesink")) {
if (overlay) {
xid = *overlay;
_mmcam_dbg_log("xid = %lu )", xid);
- gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), 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.");
- gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), 0);
+ gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), 0);
}
-
- _mmcam_dbg_log("%s set: display_geometry_method[%d],origin-size[%d],visible[%d],rotate[enum:%d]",
- videosink_name, display_geometry_method, origin_size, visible, rotation);
} 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(vsink, "evas-object", overlay);
+ MMCAMCORDER_G_OBJECT_SET_POINTER(vsink, "evas-object", overlay);
MMCAMCORDER_G_OBJECT_SET(vsink, "origin-size", !do_scaling);
} else {
_mmcam_dbg_err("display handle(eavs object) is NULL");
return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
}
+#ifdef HAVE_WAYLAND
+ } 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);
+ 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);
+ } else {
+ _mmcam_dbg_warn("Handle is NULL. skip setting.");
+ }
+#endif /* HAVE_WAYLAND */
} else {
_mmcam_dbg_warn("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);
+
/* Set attribute */
- if (!strcmp(videosink_name, "xvimagesink") ||
+ if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
!strcmp(videosink_name, "evaspixmapsink")) {
+ /* set rotation */
+ MMCAMCORDER_G_OBJECT_SET(vsink, "rotate", rotation);
- if (!strcmp(videosink_name, "xvimagesink")) {
- /* set rotation */
- switch (rotation) {
- case MM_DISPLAY_ROTATION_NONE :
- rotation_degree = 0;
- break;
- case MM_DISPLAY_ROTATION_90 :
- rotation_degree = 1;
- break;
- case MM_DISPLAY_ROTATION_180 :
- rotation_degree = 2;
- break;
- case MM_DISPLAY_ROTATION_270 :
- rotation_degree = 3;
- break;
- default:
- _mmcam_dbg_warn("Unsupported rotation value. set as default(0).");
- rotation_degree = 0;
- break;
- }
- MMCAMCORDER_G_OBJECT_SET(vsink, "rotate", rotation_degree);
-
- /* set flip */
- MMCAMCORDER_G_OBJECT_SET(vsink, "flip", flip);
-
- _mmcam_dbg_log("set videosink[%s] rotate %d, flip %d",
- videosink_name, rotation_degree, flip);
- }
+ /* set flip */
+ MMCAMCORDER_G_OBJECT_SET(vsink, "flip", flip);
switch (zoom_attr) {
case MM_DISPLAY_SCALE_DEFAULT:
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ memset(&exif_info, 0x0, sizeof(GstCameraControlExifInfo));
+
if (sc && sc->element) {
int err = MM_ERROR_NONE;
char *err_name = NULL;
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
- focal_len = ((double)exif_info.focal_len_numerator) / ((double) exif_info.focal_len_denominator);
+ 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!");
focal_len = 0.0;
NULL);
if (err != MM_ERROR_NONE) {
_mmcam_dbg_err("Set attributes error(%s:%x)!", err_name, err);
- if (err_name) {
- free(err_name);
- err_name = NULL;
- }
+ SAFE_FREE(err_name);
return FALSE;
}
} else {
return TRUE;
}
-static guint32 _mmcamcorder_convert_fourcc_to_string(const gchar* format_name)
+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);
}
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 = GST_MAP_INFO_INIT;
+ GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
+ GstMemory *dataBlock = NULL;
+ GstMemory *metaBlock = NULL;
+ GstMapInfo mapinfo;
- mmf_return_val_if_fail(buffer, FALSE);
- mmf_return_val_if_fail(gst_buffer_n_memory(buffer) , FALSE);
- mmf_return_val_if_fail(hcamcorder, TRUE);
+ 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);
sc = MMF_CAMCORDER_SUBCONTEXT(u_data);
- mmf_return_val_if_fail(sc, TRUE);
+ mmf_return_val_if_fail(sc, GST_PAD_PROBE_DROP);
+
+ memset(&mapinfo, 0x0, sizeof(GstMapInfo));
current_state = hcamcorder->state;
} else {
sc->drop_vframe--;
_mmcam_dbg_log("Drop video frame by drop_vframe");
- return GST_PAD_PROBE_DROP;
+ 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");
- return GST_PAD_PROBE_DROP;
+ return GST_PAD_PROBE_DROP;
}
if (current_state >= MM_CAMCORDER_STATE_PREPARE) {
if (kpi->init_video_time.tv_sec == kpi->last_video_time.tv_sec &&
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");
+ */
gettimeofday(&(kpi->init_video_time), NULL);
}
int state = MM_CAMCORDER_STATE_NULL;
unsigned int fourcc = 0;
MMCamcorderVideoStreamDataType stream;
+ MMVideoBuffer *mm_buf = NULL;
+ const gchar *string_format = NULL;
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;
+ return GST_PAD_PROBE_OK;
}
- caps = gst_pad_get_current_caps(pad);
+ caps = gst_pad_get_current_caps(pad);
if (caps == NULL) {
_mmcam_dbg_warn( "Caps is NULL." );
- return GST_PAD_PROBE_OK;
+ return GST_PAD_PROBE_OK;
}
/* clear stream data structure */
structure = gst_caps_get_structure( caps, 0 );
gst_structure_get_int(structure, "width", &(stream.width));
gst_structure_get_int(structure, "height", &(stream.height));
- fourcc = _mmcamcorder_convert_fourcc_to_string(gst_structure_get_string(structure, "format"));
- stream.format = _mmcamcorder_get_pixtype(fourcc);
- gst_caps_unref( caps );
+ 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;
/*
if (stream.width == 0 || stream.height == 0) {
_mmcam_dbg_warn("Wrong condition!!");
- return GST_PAD_PROBE_OK;
+ 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_TIMESTAMP(buffer)/1000000); /* nano sec -> mili sec */
+ stream.length_total = gst_memory_get_sizes(dataBlock, NULL, NULL);
+ stream.timestamp = (unsigned int)(GST_BUFFER_PTS(buffer)/1000000); /* nano sec -> mili sec */
- /* set data pointers */
- if (stream.format == MM_PIXEL_FORMAT_NV12 || stream.format == MM_PIXEL_FORMAT_I420) {
- 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);
- SCMN_IMGB *scmn_imgb = (SCMN_IMGB *)mapinfo.data;
+ 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;
+ }
- if (stream.format == MM_PIXEL_FORMAT_NV12) {
+ /* 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 = scmn_imgb->a[0];
+ stream.data.yuv420sp.y = mm_buf->data[0];
stream.data.yuv420sp.length_y = stream.width * stream.height;
- stream.data.yuv420sp.uv = scmn_imgb->a[1];
+ stream.data.yuv420sp.uv = mm_buf->data[1];
stream.data.yuv420sp.length_uv = stream.data.yuv420sp.length_y >> 1;
-
- _mmcam_dbg_log("SN12[num_planes:%d] [Y]p:0x%x,size:%d [UV]p:0x%x,size:%d",
- stream.num_planes,
+ /*
+ _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 = scmn_imgb->a[0];
+ stream.data.yuv420p.y = mm_buf->data[0];
stream.data.yuv420p.length_y = stream.width * stream.height;
- stream.data.yuv420p.u = scmn_imgb->a[1];
+ stream.data.yuv420p.u = mm_buf->data[1];
stream.data.yuv420p.length_u = stream.data.yuv420p.length_y >> 2;
- stream.data.yuv420p.v = scmn_imgb->a[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 {
- if (stream.format == MM_PIXEL_FORMAT_NV12) {
+ 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;
- gst_memory_map(dataBlock, &mapinfo, GST_MAP_READ);
- stream.data.yuv420sp.y = mapinfo.data;
+ 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;
-
- _mmcam_dbg_log("NV12[num_planes:%d] [Y]p:0x%x,size:%d [UV]p:0x%x,size:%d",
- stream.num_planes,
+ /*
+ _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;
- gst_memory_map(dataBlock, &mapinfo, GST_MAP_READ);
- stream.data.yuv420p.y = mapinfo.data;
+ 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;
-
+ /*
_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;
- gst_memory_map(dataBlock, &mapinfo, GST_MAP_READ);
- stream.data.yuv422.yuv = mapinfo.data;
+ stream.data.yuv422.yuv = mapinfo.data;
stream.data.yuv422.length_yuv = stream.length_total;
+ } 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;
- gst_memory_map(dataBlock, &mapinfo, GST_MAP_READ);
- stream.data.yuv420.yuv = mapinfo.data;
+ stream.data.yuv420.yuv = mapinfo.data;
stream.data.yuv420.length_yuv = stream.length_total;
}
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);
+ */
+ }
+
+ /* 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];
+ }
+
+ /* set gst buffer */
+ stream.internal_buffer = buffer;
}
/* call application callback */
_MMCAMCORDER_LOCK_VSTREAM_CALLBACK(hcamcorder);
if (hcamcorder->vstream_cb) {
hcamcorder->vstream_cb(&stream, hcamcorder->vstream_cb_param);
+
+ 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);
+ gst_memory_unmap(metaBlock, &mapinfo);
+ }else {
+ gst_memory_unmap(dataBlock, &mapinfo);
+ }
+ }
+
+ return GST_PAD_PROBE_OK;
+}
+
+static GstPadProbeReturn __mmcamcorder_video_dataprobe_push_buffer_to_record(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+{
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
+ _MMCamcorderSubContext *sc = NULL;
+ GstClockTime diff = 0; /* nsec */
+ GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
+
+ 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);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(u_data);
+ mmf_return_val_if_fail(sc, GST_PAD_PROBE_DROP);
+
+ /* push buffer in appsrc to encode */
+ if(!sc->info_video) {
+ _mmcam_dbg_warn("sc->info_video is NULL!!");
+ return FALSE;
+ }
+
+ 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;
+
+ /*
+ _mmcam_dbg_log("GST_BUFFER_FLAG_DELTA_UNIT is set : %d",
+ GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT));
+ */
+
+ /* 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 (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 {
- gst_memory_unmap(dataBlock, &mapinfo);
+ 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);
+ }
+ }
+ 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)));*/
+
+ 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");
+ }
}
+
+ g_signal_emit_by_name(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "push-buffer", buffer, &ret);
+
+ /*_mmcam_dbg_log("push buffer result : 0x%x", ret);*/
}
- /* Do force flush cache */
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "force-flush-cache", FALSE);
+ /* 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;
+ }
+ }
+
+ /*_mmcam_dbg_log("diff %llu", diff);*/
+
+ sc->info_video->prev_preview_ts = GST_BUFFER_PTS(buffer);
}
- return GST_PAD_PROBE_OK;
+ return GST_PAD_PROBE_OK;
}
return result;
}
+
int _mmcamcorder_get_eos_message(MMHandleType handle)
{
- double elapsed = 0.0;
+ double elapsed = 0.0;
GstMessage *gMessage = NULL;
GstBus *bus = NULL;
GstClockTime timeout = 1 * GST_SECOND; /* maximum waiting time */
GTimer *timer = NULL;
+ int ret = MM_ERROR_NONE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
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);
_mmcam_dbg_log("");
- bus = gst_pipeline_get_bus(GST_PIPELINE(sc->element[_MMCAMCORDER_MAIN_PIPE].gst));
+ bus = gst_pipeline_get_bus(GST_PIPELINE(sc->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
timer = g_timer_new();
if (sc && !(sc->bget_eos)) {
- while (1) {
- elapsed = g_timer_elapsed(timer, NULL);
+ while (TRUE) {
+ elapsed = g_timer_elapsed(timer, NULL);
/*_mmcam_dbg_log("elapsed:%f sec", elapsed);*/
if (elapsed > _MMCAMCORDER_WAIT_EOS_TIME) {
_mmcam_dbg_warn("Timeout. EOS isn't received.");
- g_timer_destroy(timer);
- gst_object_unref(bus);
- return MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
+ ret = MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
+ break;
}
- gMessage = gst_bus_timed_pop (bus, timeout);
+ gMessage = gst_bus_timed_pop(bus, timeout);
if (gMessage != NULL) {
_mmcam_dbg_log("Get message(%x).", GST_MESSAGE_TYPE(gMessage));
+
+ if (GST_MESSAGE_TYPE(gMessage) == GST_MESSAGE_ERROR) {
+ GError *err;
+ gchar *debug;
+ gst_message_parse_error(gMessage, &err, &debug);
+
+ switch (err->code) {
+ case GST_RESOURCE_ERROR_WRITE:
+ _mmcam_dbg_err("File write error");
+ ret = MM_ERROR_FILE_WRITE;
+ break;
+ case GST_RESOURCE_ERROR_NO_SPACE_LEFT:
+ _mmcam_dbg_err("No left space");
+ ret = MM_MESSAGE_CAMCORDER_NO_FREE_SPACE;
+ break;
+ case GST_RESOURCE_ERROR_OPEN_WRITE:
+ _mmcam_dbg_err("Out of storage");
+ ret = MM_ERROR_OUT_OF_STORAGE;
+ break;
+ case GST_RESOURCE_ERROR_SEEK:
+ _mmcam_dbg_err("File read(seek)");
+ ret = MM_ERROR_FILE_READ;
+ break;
+ default:
+ _mmcam_dbg_err("Resource error(%d)", err->code);
+ ret = MM_ERROR_CAMCORDER_GST_RESOURCE;
+ break;
+ }
+
+ g_error_free (err);
+ g_free (debug);
+
+ gst_message_unref(gMessage);
+ break;
+ }
+
_mmcamcorder_pipeline_cb_message(bus, gMessage, (void*)hcamcorder);
if (GST_MESSAGE_TYPE(gMessage) == GST_MESSAGE_EOS || sc->bget_eos) {
}
}
- g_timer_destroy(timer);
- gst_object_unref(bus);
+ g_timer_destroy(timer);
+ timer = NULL;
+ gst_object_unref(bus);
+ bus = NULL;
_mmcam_dbg_log("END");
- return MM_ERROR_NONE;
+ return ret;
}
-void _mmcamcorder_remove_element_handle(MMHandleType handle, int first_elem, int last_elem)
+void _mmcamcorder_remove_element_handle(MMHandleType handle, void *element, int first_elem, int last_elem)
{
int i = 0;
- _MMCamcorderSubContext *sc = NULL;
+ _MMCamcorderGstElement *remove_element = (_MMCamcorderGstElement *)element;
- mmf_return_if_fail(handle);
-
- sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- mmf_return_if_fail(sc);
- mmf_return_if_fail(sc->element);
- mmf_return_if_fail((first_elem > 0) && (last_elem > 0) && (last_elem > first_elem));
+ mmf_return_if_fail(handle && remove_element);
+ mmf_return_if_fail((first_elem >= 0) && (last_elem > 0) && (last_elem > first_elem));
_mmcam_dbg_log("");
for (i = first_elem ; i <= last_elem ; i++) {
- sc->element[i].gst = NULL;
- sc->element[i].id = _MMCAMCORDER_NONE;
+ remove_element[i].gst = NULL;
+ remove_element[i].id = _MMCAMCORDER_NONE;
}
return;
}
/* 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 (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);
}
/* 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 (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);
}
-bool _mmcamcorder_set_display_rotation(MMHandleType handle, int display_rotate)
+bool _mmcamcorder_set_display_rotation(MMHandleType handle, int display_rotate, int videosink_index)
{
- char* videosink_name = NULL;
+ const char* videosink_name = NULL;
mmf_camcorder_t *hcamcorder = NULL;
_MMCamcorderSubContext *sc = NULL;
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst) {
+ if (sc->element[videosink_index].gst) {
/* Get videosink name */
_mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
- if (!strcmp(videosink_name, "xvimagesink")) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
- "rotate", display_rotate);
+ if (videosink_name == NULL) {
+ _mmcam_dbg_err("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")) {
+ MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "rotate", display_rotate);
_mmcam_dbg_log("Set display-rotate [%d] done.", display_rotate);
return TRUE;
} else {
}
-bool _mmcamcorder_set_display_flip(MMHandleType handle, int display_flip)
+bool _mmcamcorder_set_display_flip(MMHandleType handle, int display_flip, int videosink_index)
{
- char* videosink_name = NULL;
+ const char* videosink_name = NULL;
mmf_camcorder_t *hcamcorder = NULL;
_MMCamcorderSubContext *sc = NULL;
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst) {
+ if (sc->element[videosink_index].gst) {
/* Get videosink name */
_mmcamcorder_conf_get_value_element_name(sc->VideosinkElement, &videosink_name);
- if (!strcmp(videosink_name, "xvimagesink")) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
- "flip", display_flip);
+ if (videosink_name == NULL) {
+ _mmcam_dbg_err("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")) {
+ MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "flip", display_flip);
_mmcam_dbg_log("Set display flip [%d] done.", display_flip);
return TRUE;
} else {
{
int width = 0;
int height = 0;
+ int fps = 0;
+ _MMCamcorderSubContext *sc = NULL;
+
+ mmf_camcorder_t *hcamcorder = NULL;
+
+ hcamcorder = MMF_CAMCORDER(handle);
+ mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ if (!sc) {
+ _mmcam_dbg_log("sub context is not initailized");
+ return TRUE;
+ }
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_CAMERA_WIDTH, &width,
+ MMCAM_CAMERA_HEIGHT, &height,
+ MMCAM_CAMERA_FPS, &fps,
+ NULL);
+
+ _mmcam_dbg_log("set rotate %d", videosrc_rotate);
+
+ return _mmcamcorder_set_videosrc_caps(handle, sc->fourcc, width, height, fps, videosrc_rotate);
+}
+
+
+bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, int width, int height, int fps, int rotate)
+{
int set_width = 0;
int set_height = 0;
int set_rotate = 0;
- int fps = 0;
+ int fps_auto = 0;
+ unsigned int caps_fourcc = 0;
gboolean do_set_caps = FALSE;
GstCaps *caps = NULL;
- type_int_array *input_index = NULL;
mmf_camcorder_t *hcamcorder = NULL;
_MMCamcorderSubContext *sc = NULL;
hcamcorder = MMF_CAMCORDER(handle);
- mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- mmf_return_val_if_fail(sc->element, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+
+ if (!sc || !(sc->element)) {
+ _mmcam_dbg_log("sub context is not initialized");
+ return TRUE;
+ }
if (!sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst) {
_mmcam_dbg_err("Video src is NULL!");
return FALSE;
}
- mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_WIDTH, &width,
- MMCAM_CAMERA_HEIGHT, &height,
- MMCAM_CAMERA_FPS, &fps,
- NULL);
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ int capture_width = 0;
+ int capture_height = 0;
+ double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
- _mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "InputIndex",
- &input_index );
- if (input_index == NULL) {
- _mmcam_dbg_err("Failed to get input_index");
- return FALSE;
+ 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);
+ }
+
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", capture_width);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", capture_height);
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "fps-auto", fps_auto);
+
+ /* set fps */
+ sc->info_video->fps = fps;
}
/* Interleaved format does not support rotation */
if (sc->info_image->preview_format != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
/* store videosrc rotation */
- sc->videosrc_rotate = videosrc_rotate;
+ sc->videosrc_rotate = rotate;
/* Define width, height and rotate in caps */
/* This will be applied when rotate is 0, 90, 180, 270 if rear camera.
This will be applied when rotate is 0, 180 if front camera. */
- set_rotate = videosrc_rotate * 90;
+ set_rotate = rotate * 90;
- if (videosrc_rotate == MM_VIDEO_INPUT_ROTATION_90 ||
- videosrc_rotate == MM_VIDEO_INPUT_ROTATION_270) {
+ if (rotate == MM_VIDEO_INPUT_ROTATION_90 ||
+ rotate == MM_VIDEO_INPUT_ROTATION_270) {
set_width = height;
set_height = width;
- if (input_index->default_value == MM_VIDEO_DEVICE_CAMERA1) {
- if (videosrc_rotate == MM_VIDEO_INPUT_ROTATION_90) {
+ if (hcamcorder->device_type == MM_VIDEO_DEVICE_CAMERA1) {
+ if (rotate == MM_VIDEO_INPUT_ROTATION_90) {
set_rotate = 270;
} else {
set_rotate = 90;
set_width = width;
set_height = height;
- _mmcam_dbg_warn("ITLV format doe snot support INPUT ROTATE. Ignore ROTATE[%d]",
- videosrc_rotate);
- }
-
- /* correct size because ITLV does not support QCIF */
- if (input_index->default_value == MM_VIDEO_DEVICE_CAMERA0 &&
- strcmp(sc->format_name, "ITLV") == 0) {
- if ((set_width == 176 && set_height == 144) ||
- (set_width == 144 && set_height == 176)) {
- set_width = set_width << 1;
- set_height = set_height << 1;
- _mmcam_dbg_log("ITLV format is not supported QCIF, so we set CIF(%dx%d)",
- set_width, set_height);
- }
+ _mmcam_dbg_warn("ITLV format doe snot support INPUT ROTATE. Ignore ROTATE[%d]", rotate);
}
MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", &caps);
- if (caps) {
+ if (caps && !gst_caps_is_any(caps)) {
GstStructure *structure = NULL;
structure = gst_caps_get_structure(caps, 0);
if (structure) {
+ const gchar *format_string = NULL;
int caps_width = 0;
int caps_height = 0;
int caps_fps = 0;
int caps_rotate = 0;
+ format_string = gst_structure_get_string(structure, "format");
+ 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);
+
if (set_width == caps_width && set_height == caps_height &&
- set_rotate == caps_rotate && fps == caps_fps) {
+ fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps) {
_mmcam_dbg_log("No need to replace caps.");
} else {
- _mmcam_dbg_log("something is different. set new one...");
+ _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);
do_set_caps = TRUE;
}
} else {
_mmcam_dbg_log("can not get structure of caps. set new one...");
do_set_caps = TRUE;
}
-
- gst_caps_unref(caps);
- caps = NULL;
} else {
_mmcam_dbg_log("No caps. set new one...");
do_set_caps = TRUE;
}
- if (do_set_caps) {
- caps = gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, sc->format_name,
- "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);
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", caps);
+ if (caps) {
gst_caps_unref(caps);
caps = NULL;
- _mmcam_dbg_log("vidoesrc new caps set. format[%s],width[%d],height[%d],fps[%d],rotate[%d]",
- sc->format_name, set_width, set_height, fps, set_rotate);
+ }
+
+ if (do_set_caps) {
+ if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ 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",
+ NULL);
+ } else {
+ char fourcc_string[sizeof(fourcc)+1];
+ strncpy(fourcc_string, (char*)&fourcc, sizeof(fourcc));
+ fourcc_string[sizeof(fourcc)] = '\0';
+ caps = gst_caps_new_simple("video/x-raw",
+ "format", G_TYPE_STRING, fourcc_string,
+ "width", G_TYPE_INT, set_width,
+ "height", G_TYPE_INT, set_height,
+ "framerate", GST_TYPE_FRACTION, fps, 1,
+ "rotate", G_TYPE_INT, set_rotate,
+ NULL);
+ }
+
+ if (caps) {
+ _mmcam_dbg_log("vidoesrc new caps set. %"GST_PTR_FORMAT, caps);
+ 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");
+ }
+ }
+
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ /* assume that it's camera capture mode */
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, "csc-range", 1);
}
return TRUE;
{
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
- type_int_array *input_index = NULL;
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- mmf_return_val_if_fail(sc, TRUE);
+ if (!sc) {
+ return TRUE;
+ }
_mmcam_dbg_log("Set FLIP %d", videosrc_flip);
/* Interleaved format does not support FLIP */
if (sc->info_image->preview_format != MM_PIXEL_FORMAT_ITLV_JPEG_UYVY) {
- _mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "InputIndex",
- &input_index );
-
hflip = (videosrc_flip & MM_FLIP_HORIZONTAL) == MM_FLIP_HORIZONTAL;
vflip = (videosrc_flip & MM_FLIP_VERTICAL) == MM_FLIP_VERTICAL;
mmf_return_val_if_fail(handle, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- mmf_return_val_if_fail(sc, TRUE);
+ if (!sc) {
+ return TRUE;
+ }
v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
mmf_return_val_if_fail(handle, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- mmf_return_val_if_fail(sc, TRUE);
+ if (!sc) {
+ return TRUE;
+ }
v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
-
if (!v_src) {
_mmcam_dbg_warn("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")) {
- int camera_format =MM_PIXEL_FORMAT_INVALID;
- int camera_width = 0;
- int camera_height = 0;
+ int video_width = 0;
+ int video_height = 0;
if (stabilization == MM_CAMCORDER_VIDEO_STABILIZATION_ON) {
_mmcam_dbg_log("ENABLE video stabilization");
- /* VDIS mode only supports NV12 and [720p or 1080p] */
+ /* VDIS mode only supports NV12 and [720p or 1080p or 1088 * 1088] */
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_FORMAT, &camera_format,
- MMCAM_CAMERA_WIDTH, &camera_width,
- MMCAM_CAMERA_HEIGHT, &camera_height,
+ MMCAM_VIDEO_WIDTH, &video_width,
+ MMCAM_VIDEO_HEIGHT, &video_height,
NULL);
- if (camera_format == MM_PIXEL_FORMAT_NV12 &&
- camera_width >= 1280 &&
- camera_height >= 720) {
- _mmcam_dbg_log("preview format %d, size %dx%d, ENABLE video stabilization",
- camera_format, camera_width, camera_height, stabilization);
+ 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);
/* set vdis mode */
g_object_set(G_OBJECT(v_src),
"enable-vdis-mode", TRUE,
NULL);
} else {
- _mmcam_dbg_warn("invalid preview format %d or size %dx%d",
- camera_format, camera_width, camera_height);
+ _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);
return FALSE;
}
} else {
return TRUE;
}
+
+bool _mmcamcorder_set_camera_resolution(MMHandleType handle, int width, int height)
+{
+ int fps = 0;
+
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
+ _MMCamcorderSubContext *sc = NULL;
+
+ mmf_return_val_if_fail(hcamcorder, FALSE);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ if (!sc) {
+ return TRUE;
+ }
+
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_CAMERA_FPS, &fps,
+ NULL);
+
+ _mmcam_dbg_log("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");
+ return FALSE;
+ }
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ if (!sc) {
+ _mmcam_dbg_warn("subcontext is NULL");
+ return FALSE;
+ }
+
+ if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst == NULL) {
+ _mmcam_dbg_warn("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);
+ }
+ }
+
+ if (item == NULL) {
+ _mmcam_dbg_warn("failed to find \"bitrate\" control channel");
+ }
+ }
+
+ return FALSE;
+}
+
+
+bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int interval)
+{
+ _MMCamcorderSubContext *sc = NULL;
+
+ if ((void *)handle == NULL) {
+ _mmcam_dbg_warn("handle is NULL");
+ return FALSE;
+ }
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ if (!sc) {
+ _mmcam_dbg_warn("subcontext is NULL");
+ return FALSE;
+ }
+
+ if (sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst == NULL) {
+ _mmcam_dbg_warn("videosrc plugin is NULL");
+ return FALSE;
+ }
+
+ _mmcam_dbg_log("set encoded preview GOP interval : %d ms", interval);
+
+ MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "newgop-interval", interval);
+
+ return TRUE;
+}
+
+
+bool _mmcamcorder_set_sound_stream_info(GstElement *element, char *stream_type, int stream_index)
+{
+ GstStructure *props = NULL;
+ 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);
+ return FALSE;
+ }
+
+ snprintf(stream_props, sizeof(stream_props) - 1,
+ "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);
+
+ props = gst_structure_from_string(stream_props, NULL);
+ if (!props) {
+ _mmcam_dbg_err("failed to create GstStructure");
+ return FALSE;
+ }
+
+ MMCAMCORDER_G_OBJECT_SET_POINTER(element, "stream-properties", props);
+
+ gst_structure_free(props);
+ props = NULL;
+
+ return TRUE;
+}
+