#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 "mm_camcorder_internal.h"
#include "mm_camcorder_gstcommon.h"
-#include "mm_camcorder_client.h"
/*-----------------------------------------------------------------------
| GLOBAL VARIABLE DEFINITIONS for internal |
-----------------------------------------------------------------------*/
/* Table for compatibility between audio codec and file format */
-gboolean audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_FORMAT_NUM] =
-{ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
+gboolean audiocodec_fileformat_compatibility_table[MM_AUDIO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
+ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
/*AMR*/ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*G723.1*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
-/*MP3*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+/*MP3*/ { 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1},
/*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, 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, 0, 1},
/*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, 0, 0},
};
/* Table for compatibility between video codec and file format */
-gboolean videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM_FILE_FORMAT_NUM] =
-{ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
+gboolean videocodec_fileformat_compatibility_table[MM_VIDEO_CODEC_NUM][MM_FILE_FORMAT_NUM] = {
+ /* 3GP ASF AVI MATROSKA MP4 OGG NUT QT REAL AMR AAC MP3 AIFF AU WAV MID MMF DIVX FLV VOB IMELODY WMA WMV JPG FLAC M2TS*/
/*NONE*/ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*H263*/ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
/*H264*/ { 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
#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"
/*-----------------------------------------------------------------------
int display_surface_type = MM_DISPLAY_SURFACE_NULL;
const char *videosrc_name = NULL;
const char *videosink_name = NULL;
+ const char *videoconvert_name = NULL;
char *err_name = NULL;
char *socket_path = NULL;
int socket_path_len;
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ int decoder_index = 0;
+ char decoder_name[20] = {'\0',};
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ GstElement *sink_element = NULL;
+ int sink_element_size = 0;
GList *element_list = NULL;
/* Check existence */
for (i = _MMCAMCORDER_VIDEOSRC_SRC ; i <= _MMCAMCORDER_VIDEOSINK_SINK ; i++) {
if (sc->element[i].gst) {
- if (((GObject *)sc->element[i].gst)->ref_count > 0) {
+ if (((GObject *)sc->element[i].gst)->ref_count > 0)
gst_object_unref(sc->element[i].gst);
- }
+
_mmcam_dbg_log("element[index:%d] is Already existed.", i);
}
}
/* Get video device index info */
_mmcamcorder_conf_get_value_int_array(hcamcorder->conf_ctrl,
- CONFIGURE_CATEGORY_CTRL_CAMERA,
- "InputIndex",
- &input_index);
+ CONFIGURE_CATEGORY_CTRL_CAMERA,
+ "InputIndex",
+ &input_index);
if (input_index == NULL) {
_mmcam_dbg_err("Failed to get input_index");
return MM_ERROR_CAMCORDER_CREATE_CONFIGURE;
}
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_CAMERA_WIDTH, &camera_width,
- MMCAM_CAMERA_HEIGHT, &camera_height,
- MMCAM_CAMERA_FORMAT, &sc->info_image->preview_format,
- MMCAM_CAMERA_FPS, &fps,
- MMCAM_CAMERA_ROTATION, &camera_rotate,
- MMCAM_CAMERA_FLIP, &camera_flip,
- MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
- MMCAM_CAMERA_ANTI_HANDSHAKE, &anti_shake,
- MMCAM_CAPTURE_WIDTH, &capture_width,
- MMCAM_CAPTURE_HEIGHT, &capture_height,
- MMCAM_CAMERA_HDR_CAPTURE, &sc->info_image->hdr_capture_mode,
- MMCAM_IMAGE_ENCODER, &codectype,
- MMCAM_IMAGE_ENCODER_QUALITY, &capture_jpg_quality,
- MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
- MMCAM_DISPLAY_SURFACE, &display_surface_type,
- NULL);
+ MMCAM_CAMERA_WIDTH, &camera_width,
+ MMCAM_CAMERA_HEIGHT, &camera_height,
+ MMCAM_CAMERA_FORMAT, &sc->info_image->preview_format,
+ MMCAM_CAMERA_FPS, &fps,
+ MMCAM_CAMERA_ROTATION, &camera_rotate,
+ MMCAM_CAMERA_FLIP, &camera_flip,
+ MMCAM_CAMERA_VIDEO_STABILIZATION, &video_stabilization,
+ MMCAM_CAMERA_ANTI_HANDSHAKE, &anti_shake,
+ MMCAM_CAPTURE_WIDTH, &capture_width,
+ MMCAM_CAPTURE_HEIGHT, &capture_height,
+ MMCAM_CAMERA_HDR_CAPTURE, &sc->info_image->hdr_capture_mode,
+ MMCAM_IMAGE_ENCODER, &codectype,
+ MMCAM_IMAGE_ENCODER_QUALITY, &capture_jpg_quality,
+ MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
+ MMCAM_DISPLAY_SURFACE, &display_surface_type,
+ NULL);
if (err != MM_ERROR_NONE) {
_mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
SAFE_FREE(err_name);
/* Get videosrc element and its name from configure */
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
- "VideosrcElement",
- &VideosrcElement);
+ CONFIGURE_CATEGORY_MAIN_VIDEO_INPUT,
+ "VideosrcElement",
+ &VideosrcElement);
_mmcamcorder_conf_get_value_element_name(VideosrcElement, &videosrc_name);
/**
/* set anti handshake mode */
_mmcamcorder_set_videosrc_anti_shake(handle, anti_shake);
- if (sc->is_modified_rate) {
+ if (sc->is_modified_rate)
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "high-speed-fps", fps);
- }
/* Set basic infomation of videosrc element */
_mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, VideosrcElement);
if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
int preview_bitrate = 0;
int gop_interval = 0;
+ const char *videodecoder_name = NULL;
+
+ /* get recreate_decoder flag */
+ _mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ "RecreateDecoder",
+ &hcamcorder->recreate_decoder);
+
+ /* get video decoder element and name for H.264 format */
+ _mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_VIDEO_OUTPUT,
+ "VideodecoderElementH264",
+ &sc->VideodecoderElementH264);
+
+ _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264, &videodecoder_name);
+
+ if (videodecoder_name) {
+ _mmcam_dbg_log("video decoder element [%s], recreate decoder %d",
+ videodecoder_name, hcamcorder->recreate_decoder);
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
+ decoder_index = 1;
+
+ snprintf(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
+ _mmcam_dbg_log("encoded preview decoder_name %s", decoder_name);
+ /* create decoder element */
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, decoder_name, "videosrc_decode", element_list, err);
+#else /* _MMCAMCORDER_RM_SUPPORT */
+ /* create decoder element */
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, videodecoder_name, "videosrc_decode", element_list, err);
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
+ } else {
+ _mmcam_dbg_err("failed to get video decoder element name from %p", sc->VideodecoderElementH264);
+ goto pipeline_creation_error;
+ }
/* set encoded preview bitrate and iframe interval */
mm_camcorder_get_attributes(handle, NULL,
if (!_mmcamcorder_set_encoded_preview_gop_interval(handle, gop_interval))
_mmcam_dbg_warn("_mmcamcorder_set_encoded_preview_gop_interval failed");
-
- /* create decoder element */
- _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSRC_DECODE, _MMCAMCORDER_VIDEO_DECODER_NAME, "videosrc_decode", element_list, err);
}
_mmcam_dbg_log("Current mode[%d]", hcamcorder->type);
if (display_surface_type == MM_DISPLAY_SURFACE_REMOTE) {
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, "ipc_sink", element_list, err);
+ _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
+
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
- NULL);
+ 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);
- return err;
+ 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 (hcamcorder->use_videoconvert && (!strcmp(videosink_name, "waylandsink") || !strcmp(videosink_name, "directvideosink"))) {
+ /* get video convert name */
+ _mmcamcorder_conf_get_value_element_name(sc->VideoconvertElement, &videoconvert_name);
+
+ if (videoconvert_name) {
+ _mmcam_dbg_log("videoconvert element name : %s", videoconvert_name);
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_CLS, videoconvert_name, "videosink_cls", element_list, err);
+ } else
+ _mmcam_dbg_err("failed to get videoconvert element name");
+ }
+
+ /* check sink element in attribute */
+ mm_camcorder_get_attributes(handle, NULL,
+ MMCAM_DISPLAY_REUSE_ELEMENT, &sink_element, &sink_element_size,
+ NULL);
+
+ if (sink_element) {
+ int attr_index = 0;
+ mmf_attrs_t *attrs = MMF_CAMCORDER_ATTRS(handle);
+ mmf_attribute_t *attr_item = NULL;
+
+ _mmcam_dbg_log("reuse sink element %p in attribute", sink_element);
+
+ _MMCAMCORDER_ELEMENT_ADD(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, sink_element, element_list, err);
- _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
+ /* reset attribute */
+ if (attrs) {
+ mm_attrs_get_index((MMHandleType)attrs, MMCAM_DISPLAY_REUSE_ELEMENT, &attr_index);
+ attr_item = &attrs->items[attr_index];
+ mmf_attribute_set_data(attr_item, NULL, 0);
+ mmf_attribute_commit(attr_item);
+ } else {
+ _mmcam_dbg_warn("attribute is NULL");
+ err = MM_ERROR_CAMCORDER_NOT_INITIALIZED;
+ goto pipeline_creation_error;
+ }
+ } else {
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->element, _MMCAMCORDER_VIDEOSINK_SINK, videosink_name, "videosink_sink", element_list, err);
+
+ _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst, sc->VideosinkElement);
+ }
+
+ if (_mmcamcorder_videosink_window_set(handle, sc->VideosinkElement) != MM_ERROR_NONE) {
+ _mmcam_dbg_err("_mmcamcorder_videosink_window_set error");
+ err = MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
+ goto pipeline_creation_error;
+ }
+ }
/* Set caps by rotation */
_mmcamcorder_set_videosrc_rotation(handle, camera_rotate);
/* link elements */
if (!_mmcamcorder_link_elements(element_list)) {
- _mmcam_dbg_err( "element link error." );
+ _mmcam_dbg_err("element link error.");
err = MM_ERROR_CAMCORDER_GST_LINK;
goto pipeline_creation_error;
}
char *err_name = NULL;
const char *audiosrc_name = NULL;
char *cat_name = NULL;
+ char *stream_type = NULL;
+ char stream_type_len = 0;
+ int stream_index = 0;
+ int buffer_interval = 0;
+ int blocksize = 0;
GstCaps *caps = NULL;
GstPad *pad = NULL;
_mmcam_dbg_log("");
err = _mmcamcorder_check_audiocodec_fileformat_compatibility(handle);
- if (err != MM_ERROR_NONE) {
+ if (err != MM_ERROR_NONE)
return err;
- }
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_AUDIO_DEVICE, &a_dev,
- MMCAM_AUDIO_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->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst) {
- if (((GObject *)sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst)->ref_count > 0) {
+ if (((GObject *)sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst)->ref_count > 0)
gst_object_unref(sc->encode_element[_MMCAMCORDER_AUDIOSRC_BIN].gst);
- }
+
_mmcam_dbg_log("_MMCAMCORDER_AUDIOSRC_BIN is Already existed. Unref once...");
}
}
_mmcamcorder_conf_get_element(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
- cat_name,
- &AudiosrcElement);
+ CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
+ cat_name,
+ &AudiosrcElement);
_mmcamcorder_conf_get_value_element_name(AudiosrcElement, &audiosrc_name);
free(cat_name);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_SRC, audiosrc_name, "audiosrc_src", element_list, err);
+ /* set sound stream info */
+ _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, stream_index);
+
+ /* set audiosrc properties in ini configuration */
_mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, AudiosrcElement);
+ /* set block size */
+ _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
+ CONFIGURE_CATEGORY_MAIN_AUDIO_INPUT,
+ "AudioBufferInterval",
+ &buffer_interval);
+
+ if (_mmcamcorder_get_audiosrc_blocksize(rate, format, channel, buffer_interval, &blocksize)) {
+ _mmcam_dbg_log("set audiosrc block size %d", blocksize);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, "blocksize", blocksize);
+ }
+
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_FILT, "capsfilter", "audiosrc_capsfilter", element_list, err);
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_QUE, "queue", "audiosrc_queue", element_list, err);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_QUE].gst, "max-size-bytes", 0);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_AUDIOSRC_QUE].gst, "max-size-time", 0);
- if (a_enc != MM_AUDIO_CODEC_VORBIS) {
+ 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 (a_enc != MM_AUDIO_CODEC_VORBIS) {
}
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);
+ "rate", G_TYPE_INT, rate,
+ "channels", G_TYPE_INT, channel,
+ "format", G_TYPE_STRING, format_name,
+ NULL);
_mmcam_dbg_log("caps [x-raw, rate:%d, channel:%d, depth:%d], volume %lf",
- rate, channel, depth, volume);
+ rate, 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);
+ "rate", G_TYPE_INT, rate,
+ "channels", G_TYPE_INT, channel,
+ "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
+ NULL);
_mmcam_dbg_log("caps [x-raw (F32), rate:%d, channel:%d, endianness:%d, width:32]",
- rate, channel, BYTE_ORDER);
+ rate, channel, BYTE_ORDER);
}
if (caps) {
}
+void _mmcamcorder_set_encoder_bitrate(MMCamcorderEncoderType type, int codec, int bitrate, GstElement *element)
+{
+ int set_value = 0;
+
+ if (!element) {
+ _mmcam_dbg_warn("NULL element, will be applied later - type %d, bitrate %d", type, bitrate);
+ return;
+ }
+
+ if (bitrate <= 0) {
+ _mmcam_dbg_warn("[type %d, codec %d] too small bitrate[%d], use default",
+ type, codec, bitrate);
+ return;
+ }
+
+ if (type == MM_CAMCORDER_ENCODER_TYPE_AUDIO) {
+ /* audio encoder bitrate setting */
+ switch (codec) {
+ case MM_AUDIO_CODEC_AMR:
+ set_value = __mmcamcorder_get_amrnb_bitrate_mode(bitrate);
+ _mmcam_dbg_log("Set AMR encoder mode [%d]", set_value);
+ MMCAMCORDER_G_OBJECT_SET(element, "band-mode", set_value);
+ break;
+ case MM_AUDIO_CODEC_MP3:
+ set_value = bitrate / 1000;
+ _mmcam_dbg_log("Set MP3 encoder bitrate [%d] kbps", set_value);
+ MMCAMCORDER_G_OBJECT_SET(element, "bitrate", set_value);
+ break;
+ case MM_AUDIO_CODEC_AAC:
+ _mmcam_dbg_log("Set AAC encoder bitrate [%d] bps", bitrate);
+ MMCAMCORDER_G_OBJECT_SET(element, "bitrate", bitrate);
+ break;
+ default:
+ _mmcam_dbg_warn("Not AMR, MP3 and AAC codec, need to add code for audio bitrate");
+ break;
+ }
+ } else {
+ /* video encoder bitrate setting */
+ _mmcam_dbg_log("Set video encoder bitrate %d", bitrate);
+ MMCAMCORDER_G_OBJECT_SET(element, "bitrate", bitrate);
+ }
+
+ return;
+}
+
+
int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebinProfile profile)
{
int err = MM_ERROR_NONE;
- int result = 0;
+ int file_name_len = 0;
int channel = 0;
int audio_enc = 0;
int v_bitrate = 0;
const char *str_aar = NULL;
const char *str_acs = NULL;
char *err_name = NULL;
+ char *file_name = NULL;
const char *videoconvert_name = NULL;
GstCaps *audio_caps = NULL;
GstCaps *video_caps = NULL;
/* Check existence */
if (sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst) {
- if (((GObject *)sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst)->ref_count > 0) {
+ if (((GObject *)sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst)->ref_count > 0)
gst_object_unref(sc->encode_element[_MMCAMCORDER_ENCSINK_BIN].gst);
- }
+
_mmcam_dbg_log("_MMCAMCORDER_ENCSINK_BIN is Already existed.");
}
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst, "max-bytes", 0); /* unlimited */
/* set capsfilter */
- 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");
+ 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 {
- _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;
+ /* Image */
+ MMCAMCORDER_G_OBJECT_GET(sc->element[_MMCAMCORDER_VIDEOSRC_FILT].gst, "caps", &video_caps);
}
- 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;
-
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);
+ "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);
- free(caps_str);
+ g_free(caps_str);
caps_str = NULL;
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_FILT].gst, "caps", video_caps);
/* connect signal for ready to push buffer */
MMCAMCORDER_SIGNAL_CONNECT(sc->encode_element[_MMCAMCORDER_ENCSINK_SRC].gst,
- _MMCAMCORDER_HANDLER_VIDEOREC,
- "need-data",
- _mmcamcorder_ready_to_encode_callback,
- hcamcorder);
+ _MMCAMCORDER_HANDLER_VIDEOREC,
+ "need-data",
+ _mmcamcorder_ready_to_encode_callback,
+ hcamcorder);
}
_MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN, "encodebin", "encodesink_encbin", element_list, err);
/* check element availability */
- 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);
+ 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,
+ MMCAM_TARGET_FILENAME, &file_name, &file_name_len,
+ 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);
_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);
+ encodebin_profile, auto_audio_convert, auto_audio_resample, auto_color_space);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "profile", encodebin_profile);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", auto_audio_convert);
goto pipeline_creation_error;
}
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- gst_element_venc_name = strdup("capsfilter");
- } else {
+ 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);
- }
if (gst_element_venc_name) {
_mmcam_dbg_log("video encoder name [%s]", gst_element_venc_name);
/* fourcc type was removed in GST 1.0 */
if (hcamcorder->use_zero_copy_format) {
- if(strstr(gst_element_venc_name, "omx")) {
- video_caps = gst_caps_new_simple("video/x-raw",
- "format", G_TYPE_STRING, "SN12",
- NULL);
+ if (strstr(gst_element_venc_name, "omx")) {
+ video_caps = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, "SN12", NULL);
if (video_caps) {
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "vcaps", video_caps);
_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("current video codec is not openmax but [%s]", gst_element_venc_name);
}
}
}
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_RECORD,
- "UseVideoEncoderQueue",
- &use_venc_queue);
- if (use_venc_queue) {
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "UseVideoEncoderQueue",
+ &use_venc_queue);
+ if (use_venc_queue)
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_VENC_QUE, "use-venc-queue", err);
- }
-
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
- free(gst_element_venc_name);
- gst_element_venc_name = NULL;
- }
}
if (sc->audio_disable == FALSE &&
profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
- int use_aenc_queue =0;
+ int use_aenc_queue = 0;
AudioencElement = _mmcamcorder_get_type_element(handle, MM_CAM_AUDIO_ENCODER);
if (!AudioencElement) {
if (audio_enc == MM_AUDIO_CODEC_AMR && channel == 2) {
audio_caps = gst_caps_new_simple("audio/x-raw",
- "channels", G_TYPE_INT, 1,
- NULL);
+ "channels", G_TYPE_INT, 1,
+ NULL);
MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "auto-audio-convert", TRUE);
MMCAMCORDER_G_OBJECT_SET_POINTER(sc->encode_element[_MMCAMCORDER_ENCSINK_ENCBIN].gst, "acaps", audio_caps);
gst_caps_unref(audio_caps);
}
_mmcamcorder_conf_get_value_int(handle, hcamcorder->conf_main,
- CONFIGURE_CATEGORY_MAIN_RECORD,
- "UseAudioEncoderQueue",
- &use_aenc_queue);
+ CONFIGURE_CATEGORY_MAIN_RECORD,
+ "UseAudioEncoderQueue",
+ &use_aenc_queue);
if (use_aenc_queue) {
_MMCAMCORDER_ENCODEBIN_ELMGET(sc, _MMCAMCORDER_ENCSINK_AENC_QUE, "use-aenc-queue", err);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst,"max-size-time", 0);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst,"max-size-buffers", 0);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst, "max-size-time", 0);
+ MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC_QUE].gst, "max-size-buffers", 0);
}
}
/* Sink */
if (profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
/* for recording */
- _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);
+ if (file_name) {
+ _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);
- _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _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->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, RecordsinkElement);
+ _mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst, RecordsinkElement);
+ } else {
+ /* if file_name is not set, add fakesink for muxed stream callback */
+ _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_ENCSINK_SINK, "fakesink", NULL, element_list, err);
+ }
} else {
/* for stillshot */
_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->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst, "bitrate", v_bitrate);
- } else {
- _mmcam_dbg_warn("video bitrate is too small[%d], so skip setting. Use DEFAULT value.", v_bitrate);
- }
-
+ /* property setting in ini */
_mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst, VideoencElement);
+
+ /* bitrate setting */
+ _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_VIDEO, 0,
+ v_bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_VENC].gst);
}
if (sc->audio_disable == FALSE &&
profile != MM_CAMCORDER_ENCBIN_PROFILE_IMAGE) {
- /* audio encoder attribute setting */
- if (a_bitrate > 0) {
- switch (audio_enc) {
- case MM_AUDIO_CODEC_AMR:
- result = __mmcamcorder_get_amrnb_bitrate_mode(a_bitrate);
- _mmcam_dbg_log("Set AMR encoder[%s] mode [%d]", gst_element_aenc_name, result);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, "band-mode", result);
- break;
- case MM_AUDIO_CODEC_AAC:
- _mmcam_dbg_log("Set AAC encoder[%s] bitrate [%d]", gst_element_aenc_name, a_bitrate);
- MMCAMCORDER_G_OBJECT_SET(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, "bitrate", a_bitrate);
- break;
- default:
- _mmcam_dbg_log("Audio codec is not AMR or AAC... you need to implement setting function for audio encoder bit-rate");
- break;
- }
- } else {
- _mmcam_dbg_warn("Setting bitrate is too small, so skip setting. Use DEFAULT value.");
- }
-
+ /* property setting in ini */
_mmcamcorder_conf_set_value_element_property(sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst, AudioencElement);
+
+ /* bitrate setting */
+ _mmcamcorder_set_encoder_bitrate(MM_CAMCORDER_ENCODER_TYPE_AUDIO, audio_enc,
+ a_bitrate, sc->encode_element[_MMCAMCORDER_ENCSINK_AENC].gst);
}
_mmcam_dbg_log("Element creation complete");
return MM_ERROR_NONE;
-pipeline_creation_error :
+pipeline_creation_error:
_mmcamcorder_remove_all_handlers(handle, _MMCAMCORDER_HANDLER_VIDEOREC);
_MMCAMCORDER_ELEMENT_REMOVE(sc->encode_element, _MMCAMCORDER_ENCSINK_ENCBIN);
GstPad *srcpad = NULL;
GstBus *bus = NULL;
- mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
mmf_return_val_if_fail(hcamcorder, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
/* Sub pipeline */
err = _mmcamcorder_create_preview_elements((MMHandleType)hcamcorder);
- if (err != MM_ERROR_NONE) {
+ if (err != MM_ERROR_NONE)
goto pipeline_creation_error;
- }
/* Set data probe function */
if (sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst) {
if (srcpad) {
MMCAMCORDER_ADD_BUFFER_PROBE(srcpad, _MMCAMCORDER_HANDLER_PREVIEW,
- __mmcamcorder_video_dataprobe_preview, hcamcorder);
+ __mmcamcorder_video_dataprobe_preview, hcamcorder);
+
gst_object_unref(srcpad);
srcpad = NULL;
} else {
}
/* set dataprobe for video recording */
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ 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 {
+ 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_push_buffer_to_record, hcamcorder);
+ __mmcamcorder_video_dataprobe_push_buffer_to_record, hcamcorder);
gst_object_unref(srcpad);
srcpad = NULL;
{
int err = MM_ERROR_NONE;
int size = 0;
- int retx = 0;
- int rety = 0;
- int retwidth = 0;
- int retheight = 0;
+ int rect_x = 0;
+ int rect_y = 0;
+ int rect_width = 0;
+ int rect_height = 0;
int visible = 0;
int rotation = MM_DISPLAY_ROTATION_NONE;
int flip = MM_FLIP_NONE;
int zoom_attr = 0;
int zoom_level = 0;
int do_scaling = FALSE;
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ int display_scaler = 0;
+#endif /* _MMCAMCORDER_RM_SUPPORT */
int *overlay = NULL;
gulong xid;
char *err_name = NULL;
/* Get video display information */
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_DISPLAY_RECT_X, &retx,
- MMCAM_DISPLAY_RECT_Y, &rety,
- MMCAM_DISPLAY_RECT_WIDTH, &retwidth,
- MMCAM_DISPLAY_RECT_HEIGHT, &retheight,
- MMCAM_DISPLAY_ROTATION, &rotation,
- MMCAM_DISPLAY_FLIP, &flip,
- MMCAM_DISPLAY_VISIBLE, &visible,
- MMCAM_DISPLAY_HANDLE, (void**)&overlay, &size,
- MMCAM_DISPLAY_MODE, &display_mode,
- MMCAM_DISPLAY_GEOMETRY_METHOD, &display_geometry_method,
- MMCAM_DISPLAY_SCALE, &zoom_attr,
- MMCAM_DISPLAY_EVAS_DO_SCALING, &do_scaling,
- NULL);
+ MMCAM_DISPLAY_RECT_X, &rect_x,
+ MMCAM_DISPLAY_RECT_Y, &rect_y,
+ MMCAM_DISPLAY_RECT_WIDTH, &rect_width,
+ MMCAM_DISPLAY_RECT_HEIGHT, &rect_height,
+ MMCAM_DISPLAY_ROTATION, &rotation,
+ MMCAM_DISPLAY_FLIP, &flip,
+ MMCAM_DISPLAY_VISIBLE, &visible,
+ MMCAM_DISPLAY_HANDLE, (void**)&overlay, &size,
+ MMCAM_DISPLAY_MODE, &display_mode,
+ MMCAM_DISPLAY_GEOMETRY_METHOD, &display_geometry_method,
+ MMCAM_DISPLAY_SCALE, &zoom_attr,
+ MMCAM_DISPLAY_EVAS_DO_SCALING, &do_scaling,
+ NULL);
if (err != MM_ERROR_NONE) {
if (err_name) {
_mmcam_dbg_err("failed to get attributes [%s][0x%x]", err_name, err);
- free(err_name);
- err_name = NULL;
+ SAFE_FREE(err_name);
} else {
_mmcam_dbg_err("failed to get attributes [0x%x]", err);
}
_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);
}
- } else if (!strcmp(videosink_name, "evasimagesink") ||
- !strcmp(videosink_name, "evaspixmapsink")) {
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
+ display_scaler = 1;
+
+ MMCAMCORDER_G_OBJECT_SET(vsink, "device-scaler", display_scaler);
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ } else if (!strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink")) {
_mmcam_dbg_log("videosink : %s, handle : %p", videosink_name, overlay);
+
if (overlay) {
MMCAMCORDER_G_OBJECT_SET_POINTER(vsink, "evas-object", overlay);
MMCAMCORDER_G_OBJECT_SET(vsink, "origin-size", !do_scaling);
_mmcam_dbg_err("display handle(eavs object) is NULL");
return MM_ERROR_CAMCORDER_INVALID_ARGUMENT;
}
-#ifdef HAVE_WAYLAND
- } else if (!strcmp(videosink_name, "waylandsink")) {
+ } else if (!strcmp(videosink_name, "waylandsink") || !strcmp(videosink_name, "directvideosink")) {
MMCamWaylandInfo *wl_info = (MMCamWaylandInfo *)overlay;
- if (wl_info) {
- GstContext *context = NULL;
-
- context = gst_wayland_display_handle_context_new((struct wl_display *)wl_info->display);
- if (context) {
- gst_element_set_context(vsink, context);
- } else {
- _mmcam_dbg_warn("gst_wayland_display_handle_context_new failed");
- }
- gst_video_overlay_set_window_handle(GST_VIDEO_OVERLAY(vsink), (guintptr)wl_info->surface);
+ 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);
+ 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);
+ videosink_name, display_geometry_method, origin_size, visible, rotation, flip);
/* Set attribute */
- if (!strcmp(videosink_name, "xvimagesink") ||
- !strcmp(videosink_name, "evaspixmapsink")) {
+ if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "waylandsink") ||
+ !strcmp(videosink_name, "evaspixmapsink") || !strcmp(videosink_name, "directvideosink")) {
/* set rotation */
MMCAMCORDER_G_OBJECT_SET(vsink, "rotate", rotation);
MMCAMCORDER_G_OBJECT_SET(vsink, "zoom", zoom_level);
if (display_geometry_method == MM_DISPLAY_METHOD_CUSTOM_ROI) {
- g_object_set(vsink,
- "dst-roi-x", retx,
- "dst-roi-y", rety,
- "dst-roi-w", retwidth,
- "dst-roi-h", retheight,
- NULL);
+ if (!strcmp(videosink_name, "waylandsink")) {
+ gst_video_overlay_set_render_rectangle(GST_VIDEO_OVERLAY(vsink),
+ rect_x, rect_y, rect_width, rect_height);
+ } else {
+ g_object_set(vsink,
+ "dst-roi-x", rect_x,
+ "dst-roi-y", rect_y,
+ "dst-roi-w", rect_width,
+ "dst-roi-h", rect_height,
+ NULL);
+ }
}
}
int _mmcamcorder_vframe_stablize(MMHandleType handle)
{
- mmf_camcorder_t *hcamcorder= MMF_CAMCORDER(handle);
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
_mmcam_dbg_log("%d", _MMCAMCORDER_CAMSTABLE_COUNT);
mmf_return_val_if_fail(sc, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
- if (sc->cam_stability_count != _MMCAMCORDER_CAMSTABLE_COUNT) {
+ if (sc->cam_stability_count != _MMCAMCORDER_CAMSTABLE_COUNT)
sc->cam_stability_count = _MMCAMCORDER_CAMSTABLE_COUNT;
- }
return MM_ERROR_NONE;
}
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
_MMCamcorderSubContext *sc = NULL;
GstCameraControl *control = NULL;
- GstCameraControlExifInfo exif_info;
+ GstCameraControlExifInfo exif_info = {0,};
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
/* Exif related information */
control = GST_CAMERA_CONTROL(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst);
if (control != NULL) {
- gst_camera_control_get_exif_info(control, &exif_info); //get video input device information
- focal_len = ((double)exif_info.focal_len_numerator) / ((double) exif_info.focal_len_denominator);
+ gst_camera_control_get_exif_info(control, &exif_info); /* get video input device information */
+ if (exif_info.focal_len_denominator != 0)
+ focal_len = ((double)exif_info.focal_len_numerator) / ((double) exif_info.focal_len_denominator);
} else {
_mmcam_dbg_err("Fail to get camera control interface!");
focal_len = 0.0;
/* Set values to attributes */
err = mm_camcorder_set_attributes(handle, &err_name,
- MMCAM_CAMERA_FOCAL_LENGTH, focal_len,
- NULL);
+ MMCAM_CAMERA_FOCAL_LENGTH, focal_len,
+ NULL);
if (err != MM_ERROR_NONE) {
_mmcam_dbg_err("Set attributes error(%s:%x)!", err_name, err);
- if (err_name) {
- free(err_name);
- err_name = NULL;
- }
+ SAFE_FREE(err_name);
return FALSE;
}
} else {
- _mmcam_dbg_warn( "Sub context isn't exist.");
+ _mmcam_dbg_warn("Sub context isn't exist.");
return FALSE;
}
static guint32 _mmcamcorder_convert_fourcc_string_to_value(const gchar* format_name)
{
- return format_name[0] | (format_name[1] << 8) | (format_name[2] << 16) | (format_name[3] << 24);
+ return format_name[0] | (format_name[1] << 8) | (format_name[2] << 16) | (format_name[3] << 24);
}
static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
GstMapInfo mapinfo;
mmf_return_val_if_fail(buffer, GST_PAD_PROBE_DROP);
- mmf_return_val_if_fail(gst_buffer_n_memory(buffer) , GST_PAD_PROBE_DROP);
+ mmf_return_val_if_fail(gst_buffer_n_memory(buffer), GST_PAD_PROBE_DROP);
mmf_return_val_if_fail(hcamcorder, GST_PAD_PROBE_DROP);
sc = MMF_CAMCORDER_SUBCONTEXT(u_data);
caps = gst_pad_get_current_caps(pad);
if (caps == NULL) {
- _mmcam_dbg_warn( "Caps is NULL." );
+ _mmcam_dbg_warn("Caps is NULL.");
return GST_PAD_PROBE_OK;
}
/* clear stream data structure */
memset(&stream, 0x0, sizeof(MMCamcorderVideoStreamDataType));
- structure = gst_caps_get_structure( caps, 0 );
+ structure = gst_caps_get_structure(caps, 0);
gst_structure_get_int(structure, "width", &(stream.width));
gst_structure_get_int(structure, "height", &(stream.height));
+
if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
stream.format = MM_PIXEL_FORMAT_ENCODED_H264;
} else {
_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;
/*
- _mmcam_dbg_log( "Call video steramCb, data[%p], Width[%d],Height[%d], Format[%d]",
- GST_BUFFER_DATA(buffer), stream.width, stream.height, stream.format );
+ _mmcam_dbg_log("Call video steramCb, data[%p], Width[%d],Height[%d], Format[%d]",
+ GST_BUFFER_DATA(buffer), stream.width, stream.height, stream.format);
*/
if (stream.width == 0 || stream.height == 0) {
stream.data.yuv420sp.length_uv = stream.data.yuv420sp.length_y >> 1;
/*
_mmcam_dbg_log("format[%d][num_planes:%d] [Y]p:0x%x,size:%d [UV]p:0x%x,size:%d",
- stream.format, stream.num_planes,
- stream.data.yuv420sp.y, stream.data.yuv420sp.length_y,
- stream.data.yuv420sp.uv, stream.data.yuv420sp.length_uv);
+ 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.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);
+ 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 {
stream.data.yuv420sp.length_y = stream.width * stream.height;
stream.data.yuv420sp.uv = stream.data.yuv420sp.y + stream.data.yuv420sp.length_y;
stream.data.yuv420sp.length_uv = stream.data.yuv420sp.length_y >> 1;
+ stream.stride[0] = stream.width;
+ stream.elevation[0] = stream.height;
+ stream.stride[1] = stream.width;
+ stream.elevation[1] = stream.height >> 1;
/*
_mmcam_dbg_log("format[%d][num_planes:%d] [Y]p:0x%x,size:%d [UV]p:0x%x,size:%d",
- stream.format, stream.num_planes,
- stream.data.yuv420sp.y, stream.data.yuv420sp.length_y,
- stream.data.yuv420sp.uv, stream.data.yuv420sp.length_uv);
+ 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.data.yuv420p.length_u = stream.data.yuv420p.length_y >> 2;
stream.data.yuv420p.v = stream.data.yuv420p.u + stream.data.yuv420p.length_u;
stream.data.yuv420p.length_v = stream.data.yuv420p.length_u;
+ stream.stride[0] = stream.width;
+ stream.elevation[0] = stream.height;
+ stream.stride[1] = stream.width >> 1;
+ stream.elevation[1] = stream.height >> 1;
+ stream.stride[2] = stream.width >> 1;
+ stream.elevation[2] = stream.height >> 1;
/*
_mmcam_dbg_log("I420[num_planes:%d] [Y]p:0x%x,size:%d [U]p:0x%x,size:%d [V]p:0x%x,size:%d",
- stream.num_planes,
- stream.data.yuv420p.y, stream.data.yuv420p.length_y,
- stream.data.yuv420p.u, stream.data.yuv420p.length_u,
- stream.data.yuv420p.v, stream.data.yuv420p.length_v);
+ 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);
*/
}
}
stream.data_type = MM_CAM_STREAM_DATA_YUV422;
stream.data.yuv422.yuv = mapinfo.data;
stream.data.yuv422.length_yuv = stream.length_total;
+ stream.stride[0] = stream.width << 1;
+ stream.elevation[0] = stream.height;
} else if (stream.format == MM_PIXEL_FORMAT_ENCODED_H264) {
stream.data_type = MM_CAM_STREAM_DATA_ENCODED;
stream.data.encoded.data = mapinfo.data;
stream.data_type = MM_CAM_STREAM_DATA_YUV420;
stream.data.yuv420.yuv = mapinfo.data;
stream.data.yuv420.length_yuv = stream.length_total;
+ stream.stride[0] = (stream.width * 3) >> 1;
+ stream.elevation[0] = stream.height;
}
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);
+ fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
+ stream.num_planes, stream.data.yuv420.yuv, stream.data.yuv420.length_yuv);
*/
}
tbm_bo_unmap(stream.bo[i]);
}
}
+
_MMCAMCORDER_UNLOCK_VSTREAM_CALLBACK(hcamcorder);
/* Either metaBlock was mapped, or dataBlock, but not both. */
- if (metaBlock) {
+ if (metaBlock)
gst_memory_unmap(metaBlock, &mapinfo);
- }else {
+ else
gst_memory_unmap(dataBlock, &mapinfo);
- }
}
return GST_PAD_PROBE_OK;
mmf_return_val_if_fail(sc, GST_PAD_PROBE_DROP);
/* push buffer in appsrc to encode */
- if(!sc->info_video) {
+ if (!sc->info_video) {
_mmcam_dbg_warn("sc->info_video is NULL!!");
- return FALSE;
+ return GST_PAD_PROBE_DROP;
}
if (sc->info_video->push_encoding_buffer == PUSH_ENCODING_BUFFER_RUN &&
/*
_mmcam_dbg_log("GST_BUFFER_FLAG_DELTA_UNIT is set : %d",
- GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT));
+ GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT));
*/
/* check first I frame */
}
}
} else {
- if(sc->info_video->is_firstframe) {
+ if (sc->info_video->is_firstframe) {
/* for image capture with encodebin(ex:emulator) */
if (sc->bencbin_capture && sc->info_image->capturing) {
- pthread_mutex_lock(&(hcamcorder->task_thread_lock));
+ 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;
- pthread_cond_signal(&(hcamcorder->task_thread_cond));
- pthread_mutex_unlock(&(hcamcorder->task_thread_lock));
+ 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);
char *caps_string = gst_caps_to_string(caps);
if (caps_string) {
_mmcam_dbg_log("%s", caps_string);
- free(caps_string);
+ g_free(caps_string);
caps_string = NULL;
}
gst_caps_unref(caps);
}
+GstPadProbeReturn __mmcamcorder_muxed_dataprobe(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+{
+ MMCamcorderMuxedStreamDataType stream;
+ mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(u_data);
+ _MMCamcorderSubContext *sc = NULL;
+ GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info);
+ GstMapInfo mapinfo;
+
+ mmf_return_val_if_fail(buffer, GST_PAD_PROBE_OK);
+ mmf_return_val_if_fail(gst_buffer_n_memory(buffer), GST_PAD_PROBE_OK);
+ mmf_return_val_if_fail(hcamcorder, GST_PAD_PROBE_OK);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ mmf_return_val_if_fail(sc, GST_PAD_PROBE_OK);
+
+ if (!gst_buffer_map(buffer, &mapinfo, GST_MAP_READ)) {
+ _mmcam_dbg_warn("map failed : buffer %p", buffer);
+ return GST_PAD_PROBE_OK;
+ }
+
+ /* call application callback */
+ _MMCAMCORDER_LOCK_MSTREAM_CALLBACK(hcamcorder);
+
+ if (hcamcorder->mstream_cb) {
+ stream.data = (void *)mapinfo.data;
+ stream.length = mapinfo.size;
+ stream.offset = sc->muxed_stream_offset;
+ hcamcorder->mstream_cb(&stream, hcamcorder->mstream_cb_param);
+ }
+
+ _MMCAMCORDER_UNLOCK_MSTREAM_CALLBACK(hcamcorder);
+
+ /* calculate current offset */
+ sc->muxed_stream_offset += mapinfo.size;
+
+ gst_buffer_unmap(buffer, &mapinfo);
+
+ return GST_PAD_PROBE_OK;
+}
+
+
+GstPadProbeReturn __mmcamcorder_eventprobe_monitor(GstPad *pad, GstPadProbeInfo *info, gpointer u_data)
+{
+ GstEvent *event = GST_PAD_PROBE_INFO_EVENT(info);
+ mmf_camcorder_t *hcamcorder = NULL;
+ _MMCamcorderSubContext *sc = NULL;
+ GstObject *parent = NULL;
+
+ switch (GST_EVENT_TYPE(event)) {
+ case GST_EVENT_UNKNOWN:
+ /* upstream events */
+ case GST_EVENT_QOS:
+ case GST_EVENT_SEEK:
+ case GST_EVENT_NAVIGATION:
+ case GST_EVENT_LATENCY:
+ /* downstream serialized events */
+ case GST_EVENT_TAG:
+ case GST_EVENT_BUFFERSIZE:
+ _mmcam_dbg_log("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
+ case GST_EVENT_SEGMENT:
+ _mmcam_dbg_log("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+
+ hcamcorder = MMF_CAMCORDER(u_data);
+ if (!hcamcorder) {
+ _mmcam_dbg_warn("NULL handle");
+ break;
+ }
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(hcamcorder);
+ if (!sc) {
+ _mmcam_dbg_warn("NULL sub context");
+ break;
+ }
+
+ if (!sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
+ _mmcam_dbg_warn("no encoder sink");
+ break;
+ }
+
+ parent = gst_pad_get_parent(pad);
+ if (!parent) {
+ _mmcam_dbg_warn("get parent failed");
+ break;
+ }
+
+ if (parent == (GstObject *)sc->encode_element[_MMCAMCORDER_ENCSINK_SINK].gst) {
+ const GstSegment *segment;
+ gst_event_parse_segment(event, &segment);
+ if (segment->format == GST_FORMAT_BYTES) {
+ _mmcam_dbg_log("change current offset %llu -> %llu",
+ sc->muxed_stream_offset, segment->start);
+
+ sc->muxed_stream_offset = (unsigned long long)segment->start;
+ }
+ }
+
+ gst_object_unref(parent);
+ parent = NULL;
+ break;
+ case GST_EVENT_EOS:
+ _mmcam_dbg_warn("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
+ /* bidirectional events */
+ case GST_EVENT_FLUSH_START:
+ case GST_EVENT_FLUSH_STOP:
+ _mmcam_dbg_err("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
+ default:
+ _mmcam_dbg_log("[%s:%s] gots %s", GST_DEBUG_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event));
+ break;
+ }
+
+ return GST_PAD_PROBE_OK;
+}
+
+
int __mmcamcorder_get_amrnb_bitrate_mode(int bitrate)
{
int result = MM_CAMCORDER_MR475;
- if (bitrate< 5150) {
+ if (bitrate < 5150)
result = MM_CAMCORDER_MR475; /*AMR475*/
- } else if (bitrate< 5900) {
+ else if (bitrate < 5900)
result = MM_CAMCORDER_MR515; /*AMR515*/
- } else if (bitrate < 6700) {
+ else if (bitrate < 6700)
result = MM_CAMCORDER_MR59; /*AMR59*/
- } else if (bitrate< 7400) {
+ else if (bitrate < 7400)
result = MM_CAMCORDER_MR67; /*AMR67*/
- } else if (bitrate< 7950) {
+ else if (bitrate < 7950)
result = MM_CAMCORDER_MR74; /*AMR74*/
- } else if (bitrate < 10200) {
+ else if (bitrate < 10200)
result = MM_CAMCORDER_MR795; /*AMR795*/
- } else if (bitrate < 12200) {
+ else if (bitrate < 12200)
result = MM_CAMCORDER_MR102; /*AMR102*/
- } else {
+ else
result = MM_CAMCORDER_MR122; /*AMR122*/
- }
return result;
}
int _mmcamcorder_get_eos_message(MMHandleType handle)
{
- double elapsed = 0.0;
-
- GstMessage *gMessage = NULL;
- GstBus *bus = NULL;
- GstClockTime timeout = 1 * GST_SECOND; /* maximum waiting time */
- GTimer *timer = NULL;
+ int64_t end_time;
int ret = MM_ERROR_NONE;
mmf_camcorder_t *hcamcorder = MMF_CAMCORDER(handle);
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->encode_element[_MMCAMCORDER_ENCODE_MAIN_PIPE].gst));
- timer = g_timer_new();
+ _mmcam_dbg_log("START");
- if (sc && !(sc->bget_eos)) {
- while (TRUE) {
- elapsed = g_timer_elapsed(timer, NULL);
+ _MMCAMCORDER_LOCK(handle);
- /*_mmcam_dbg_log("elapsed:%f sec", elapsed);*/
-
- if (elapsed > _MMCAMCORDER_WAIT_EOS_TIME) {
- _mmcam_dbg_warn("Timeout. EOS isn't received.");
- ret = MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT;
- break;
- }
-
- 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;
- }
+ if (sc->bget_eos == FALSE) {
+ end_time = g_get_monotonic_time() + 3 * G_TIME_SPAN_SECOND;
+ if (_MMCAMCORDER_WAIT_UNTIL(handle, end_time)) {
+ _mmcam_dbg_log("EOS signal received");
+ } else {
+ _mmcam_dbg_err("EOS wait time out");
+ }
+ } else {
+ _mmcam_dbg_log("already got EOS");
+ }
- _mmcamcorder_pipeline_cb_message(bus, gMessage, (void*)hcamcorder);
+ _MMCAMCORDER_UNLOCK(handle);
- if (GST_MESSAGE_TYPE(gMessage) == GST_MESSAGE_EOS || sc->bget_eos) {
- gst_message_unref(gMessage);
- break;
- }
- gst_message_unref(gMessage);
- } else {
- _mmcam_dbg_log("timeout of gst_bus_timed_pop()");
- if (sc->bget_eos) {
- _mmcam_dbg_log("Get EOS in another thread.");
- break;
- }
- }
+ if (hcamcorder->error_code == MM_ERROR_NONE) {
+ if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
+ mmf_return_val_if_fail(sc->info_video, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ if (sc->info_video->b_commiting)
+ _mmcamcorder_video_handle_eos((MMHandleType)hcamcorder);
+ } else {
+ mmf_return_val_if_fail(sc->info_audio, MM_ERROR_CAMCORDER_NOT_INITIALIZED);
+ if (sc->info_audio->b_commiting)
+ _mmcamcorder_audio_handle_eos((MMHandleType)hcamcorder);
}
+ } else {
+ ret = hcamcorder->error_code;
+ _mmcam_dbg_err("error 0x%x", ret);
}
- g_timer_destroy(timer);
- timer = NULL;
- gst_object_unref(bus);
- bus = NULL;
-
_mmcam_dbg_log("END");
return ret;
}
+int _mmcamcorder_check_codec_fileformat_compatibility(const char *codec_type, int codec, int file_format)
+{
+ mmf_return_val_if_fail(codec_type, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
+
+ /* Check compatibility between codec and file format */
+ if (!strcmp(codec_type, MMCAM_AUDIO_ENCODER)) {
+ if (codec > MM_AUDIO_CODEC_INVALID && codec < MM_AUDIO_CODEC_NUM &&
+ file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
+ if (audiocodec_fileformat_compatibility_table[codec][file_format] == 0) {
+ _mmcam_dbg_err("Audio codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+
+ _mmcam_dbg_log("Audio codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
+ } else {
+ _mmcam_dbg_err("Audio codec[%d] or file format[%d] is INVALID.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+ } else if (!strcmp(codec_type, MMCAM_VIDEO_ENCODER)) {
+ if (codec > MM_VIDEO_CODEC_INVALID && codec < MM_VIDEO_CODEC_NUM &&
+ file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
+ if (videocodec_fileformat_compatibility_table[codec][file_format] == 0) {
+ _mmcam_dbg_err("Video codec[%d] and file format[%d] compatibility FAILED.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+
+ _mmcam_dbg_log("Video codec[%d] and file format[%d] compatibility SUCCESS.", codec, file_format);
+ } else {
+ _mmcam_dbg_err("Video codec[%d] or file format[%d] is INVALID.", codec, file_format);
+ return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
+ }
+ }
+
+ return MM_ERROR_NONE;
+}
+
+
int _mmcamcorder_check_audiocodec_fileformat_compatibility(MMHandleType handle)
{
int err = MM_ERROR_NONE;
char *err_name = NULL;
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_AUDIO_ENCODER, &audio_codec,
- MMCAM_FILE_FORMAT, &file_format,
- NULL);
+ MMCAM_AUDIO_ENCODER, &audio_codec,
+ MMCAM_FILE_FORMAT, &file_format,
+ NULL);
if (err != MM_ERROR_NONE) {
_mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
SAFE_FREE(err_name);
}
/* Check compatibility between audio codec and file format */
- if (audio_codec > MM_AUDIO_CODEC_INVALID && audio_codec < MM_AUDIO_CODEC_NUM &&
- file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
- if (audiocodec_fileformat_compatibility_table[audio_codec][file_format] == 0) {
- _mmcam_dbg_err("Audio codec[%d] and file format[%d] compatibility FAILED.",
- audio_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
-
- _mmcam_dbg_log("Audio codec[%d] and file format[%d] compatibility SUCCESS.",
- audio_codec, file_format);
- } else {
- _mmcam_dbg_err("Audio codec[%d] or file format[%d] is INVALID.",
- audio_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
+ err = _mmcamcorder_check_codec_fileformat_compatibility(MMCAM_AUDIO_ENCODER, audio_codec, file_format);
- return MM_ERROR_NONE;
+ return err;
}
char *err_name = NULL;
err = mm_camcorder_get_attributes(handle, &err_name,
- MMCAM_VIDEO_ENCODER, &video_codec,
- MMCAM_FILE_FORMAT, &file_format,
- NULL);
+ MMCAM_VIDEO_ENCODER, &video_codec,
+ MMCAM_FILE_FORMAT, &file_format,
+ NULL);
if (err != MM_ERROR_NONE) {
_mmcam_dbg_warn("Get attrs fail. (%s:%x)", err_name, err);
SAFE_FREE(err_name);
return err;
}
- /* Check compatibility between audio codec and file format */
- if (video_codec > MM_VIDEO_CODEC_INVALID && video_codec < MM_VIDEO_CODEC_NUM &&
- file_format > MM_FILE_FORMAT_INVALID && file_format < MM_FILE_FORMAT_NUM) {
- if (videocodec_fileformat_compatibility_table[video_codec][file_format] == 0) {
- _mmcam_dbg_err("Video codec[%d] and file format[%d] compatibility FAILED.",
- video_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
-
- _mmcam_dbg_log("Video codec[%d] and file format[%d] compatibility SUCCESS.",
- video_codec, file_format);
- } else {
- _mmcam_dbg_err("Video codec[%d] or file format[%d] is INVALID.",
- video_codec, file_format);
- return MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE;
- }
+ /* Check compatibility between video codec and file format */
+ err = _mmcamcorder_check_codec_fileformat_compatibility(MMCAM_VIDEO_ENCODER, video_codec, file_format);
- return MM_ERROR_NONE;
+ return err;
}
-bool _mmcamcorder_set_display_rotation(MMHandleType handle, int display_rotate)
+bool _mmcamcorder_set_display_rotation(MMHandleType handle, int display_rotate, int videosink_index)
{
const char* videosink_name = 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 (videosink_name == NULL) {
return FALSE;
}
- if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "evasimagesink") ||
- !strcmp(videosink_name, "evaspixmapsink")) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
- "rotate", display_rotate);
+ if (!strcmp(videosink_name, "waylandsink") || !strcmp(videosink_name, "xvimagesink") ||
+ !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink") ||
+ !strcmp(videosink_name, "directvideosink")) {
+ MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "rotate", display_rotate);
_mmcam_dbg_log("Set display-rotate [%d] done.", display_rotate);
- return TRUE;
} else {
- _mmcam_dbg_warn("videosink[%s] does not support DISPLAY_ROTATION.", videosink_name);
- return FALSE;
+ _mmcam_dbg_warn("[%s] does not support DISPLAY_ROTATION, but no error", videosink_name);
}
+
+ return TRUE;
} else {
_mmcam_dbg_err("Videosink element is null");
return FALSE;
}
-bool _mmcamcorder_set_display_flip(MMHandleType handle, int display_flip)
+bool _mmcamcorder_set_display_flip(MMHandleType handle, int display_flip, int videosink_index)
{
const char* videosink_name = 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 (videosink_name == NULL) {
return FALSE;
}
- if (!strcmp(videosink_name, "xvimagesink") || !strcmp(videosink_name, "evasimagesink") ||
- !strcmp(videosink_name, "evaspixmapsink")) {
- MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSINK_SINK].gst,
- "flip", display_flip);
+ if (!strcmp(videosink_name, "waylandsink") || !strcmp(videosink_name, "xvimagesink") ||
+ !strcmp(videosink_name, "evasimagesink") || !strcmp(videosink_name, "evaspixmapsink") ||
+ !strcmp(videosink_name, "directvideosink")) {
+ MMCAMCORDER_G_OBJECT_SET(sc->element[videosink_index].gst, "flip", display_flip);
_mmcam_dbg_log("Set display flip [%d] done.", display_flip);
- return TRUE;
} else {
- _mmcam_dbg_warn("videosink[%s] does not support DISPLAY_FLIP", videosink_name);
- return FALSE;
+ _mmcam_dbg_warn("[%s] does not support DISPLAY_FLIP, but no error", videosink_name);
}
+
+ return TRUE;
} else {
_mmcam_dbg_err("Videosink element is null");
return FALSE;
}
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_WIDTH, &width,
- MMCAM_CAMERA_HEIGHT, &height,
- MMCAM_CAMERA_FPS, &fps,
- NULL);
+ MMCAM_CAMERA_WIDTH, &width,
+ MMCAM_CAMERA_HEIGHT, &height,
+ MMCAM_CAMERA_FPS, &fps,
+ NULL);
_mmcam_dbg_log("set rotate %d", videosrc_rotate);
gboolean do_set_caps = FALSE;
GstCaps *caps = NULL;
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ GstPad *sinkpad;
+ GstCaps *decsink_caps = NULL;
+ GstStructure *decsink_struct = NULL;
+ int maxwidth = 0;
+ int maxheight = 0;
+#endif /*_MMCAMCORDER_PRODUCT_TV */
mmf_camcorder_t *hcamcorder = NULL;
_MMCamcorderSubContext *sc = NULL;
double motion_rate = _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE;
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_RECORDING_MOTION_RATE, &motion_rate,
- MMCAM_CAMERA_FPS_AUTO, &fps_auto,
- MMCAM_CAPTURE_WIDTH, &capture_width,
- MMCAM_CAPTURE_HEIGHT, &capture_height,
- MMCAM_VIDEO_WIDTH, &sc->info_video->video_width,
- MMCAM_VIDEO_HEIGHT, &sc->info_video->video_height,
- NULL);
+ MMCAM_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);
+ 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,
+ "high-speed-fps", (motion_rate != _MMCAMCORDER_DEFAULT_RECORDING_MOTION_RATE ? fps : 0));
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-width", capture_width);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "capture-height", capture_height);
set_width = height;
set_height = width;
if (hcamcorder->device_type == MM_VIDEO_DEVICE_CAMERA1) {
- if (rotate == MM_VIDEO_INPUT_ROTATION_90) {
+ if (rotate == MM_VIDEO_INPUT_ROTATION_90)
set_rotate = 270;
- } else {
+ else
set_rotate = 90;
- }
}
} else {
set_width = width;
int caps_rotate = 0;
format_string = gst_structure_get_string(structure, "format");
- if (format_string) {
+ if (format_string)
caps_fourcc = _mmcamcorder_convert_fourcc_string_to_value(format_string);
- }
+
gst_structure_get_int(structure, "width", &caps_width);
gst_structure_get_int(structure, "height", &caps_height);
gst_structure_get_int(structure, "fps", &caps_fps);
gst_structure_get_int(structure, "rotate", &caps_rotate);
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+ if (set_width == caps_width && set_height == caps_height && set_rotate == caps_rotate && fps == caps_fps) {
+ _mmcam_dbg_log("No need to replace caps.");
+ } else {
+ _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+ caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
+ caps_width, caps_height, caps_fps, caps_rotate,
+ fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
+ set_width, set_height, fps, set_rotate);
+ do_set_caps = TRUE;
+ }
+ } else {
+ if (set_width == caps_width && set_height == caps_height &&
+ fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps) {
+ _mmcam_dbg_log("No need to replace caps.");
+ } else {
+ _mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
+ caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
+ caps_width, caps_height, caps_fps, caps_rotate,
+ fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
+ set_width, set_height, fps, set_rotate);
+ do_set_caps = TRUE;
+ }
+ }
+#else /*_MMCAMCORDER_PRODUCT_TV */
if (set_width == caps_width && set_height == caps_height &&
fourcc == caps_fourcc && set_rotate == caps_rotate && fps == caps_fps) {
_mmcam_dbg_log("No need to replace caps.");
} else {
_mmcam_dbg_log("current [%c%c%c%c %dx%d, fps %d, rot %d], new [%c%c%c%c %dx%d, fps %d, rot %d]",
- caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
- caps_width, caps_height, caps_fps, caps_rotate,
- fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
- set_width, set_height, fps, set_rotate);
+ caps_fourcc, caps_fourcc>>8, caps_fourcc>>16, caps_fourcc>>24,
+ caps_width, caps_height, caps_fps, caps_rotate,
+ fourcc, fourcc>>8, fourcc>>16, fourcc>>24,
+ set_width, set_height, fps, set_rotate);
do_set_caps = TRUE;
}
+#endif /*_MMCAMCORDER_PRODUCT_TV */
} else {
_mmcam_dbg_log("can not get structure of caps. set new one...");
do_set_caps = TRUE;
if (do_set_caps) {
if (sc->info_image->preview_format == MM_PIXEL_FORMAT_ENCODED_H264) {
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ sinkpad = gst_element_get_static_pad(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, "sink");
+ if (!sinkpad) {
+ _mmcam_dbg_err("There are no decoder caps");
+ return FALSE;
+ }
+
+ decsink_caps = gst_pad_get_pad_template_caps(sinkpad);
+ if (!decsink_caps) {
+ gst_object_unref(sinkpad);
+ _mmcam_dbg_err("There is no decoder sink caps");
+ return FALSE;
+ }
+
+ decsink_struct = gst_caps_get_structure(decsink_caps, 0);
+ if (!decsink_struct) {
+ _mmcam_dbg_err("There are no structure from caps");
+ gst_object_unref(decsink_caps);
+ gst_object_unref(sinkpad);
+ return FALSE;
+ }
+
+ if (gst_structure_has_field(decsink_struct, "maxwidth"))
+ gst_structure_get_int(decsink_struct, "maxwidth", &maxwidth);
+
+ if (gst_structure_has_field(decsink_struct, "maxheight"))
+ gst_structure_get_int(decsink_struct, "maxheight", &maxheight);
+#endif /* _MMCAMCORDER_PRODUCT_TV */
+
caps = gst_caps_new_simple("video/x-h264",
- "width", G_TYPE_INT, set_width,
- "height", G_TYPE_INT, set_height,
- "framerate", GST_TYPE_FRACTION, fps, 1,
- "stream-format", G_TYPE_STRING, "byte-stream",
- NULL);
+ "width", G_TYPE_INT, set_width,
+ "height", G_TYPE_INT, set_height,
+ "framerate", GST_TYPE_FRACTION, fps, 1,
+ "stream-format", G_TYPE_STRING, "byte-stream",
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ "maxwidth", G_TYPE_INT, maxwidth,
+ "maxheight", G_TYPE_INT, maxheight,
+ "alignment", G_TYPE_STRING, "au",
+#endif /* _MMCAMCORDER_PRODUCT_TV */
+ NULL);
+
+#ifdef _MMCAMCORDER_PRODUCT_TV
+ gst_object_unref(decsink_caps);
+ gst_object_unref(sinkpad);
+#endif /* _MMCAMCORDER_PRODUCT_TV */
} 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);
+ "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");
}
-
- _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;
}
if (hcamcorder->type != MM_CAMCORDER_MODE_AUDIO) {
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
_mmcam_dbg_log("Set FLIP %d", videosrc_flip);
MMCAMCORDER_G_OBJECT_SET(sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst, "vflip", vflip);
} else {
_mmcam_dbg_warn("ITLV format does not support FLIP. Ignore FLIP[%d]",
- videosrc_flip);
+ videosrc_flip);
}
} else {
_mmcam_dbg_warn("element is NULL");
mmf_return_val_if_fail(handle, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
mmf_return_val_if_fail(handle, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
v_src = sc->element[_MMCAMCORDER_VIDEOSRC_SRC].gst;
if (!v_src) {
}
/* check property of videosrc element - support VDIS */
- if(g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(v_src)), "enable-vdis-mode")) {
+ if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(v_src)), "enable-vdis-mode")) {
int video_width = 0;
int video_height = 0;
/* VDIS mode only supports NV12 and [720p or 1080p or 1088 * 1088] */
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_VIDEO_WIDTH, &video_width,
- MMCAM_VIDEO_HEIGHT, &video_height,
- NULL);
- if (sc->info_image->preview_format == MM_PIXEL_FORMAT_NV12 &&
- video_width >= 1080 && video_height >= 720) {
+ MMCAM_VIDEO_WIDTH, &video_width,
+ MMCAM_VIDEO_HEIGHT, &video_height,
+ NULL);
+
+ if (sc->info_image->preview_format == MM_PIXEL_FORMAT_NV12 && video_width >= 1080 && video_height >= 720) {
_mmcam_dbg_log("NV12, video size %dx%d, ENABLE video stabilization",
- video_width, video_height, stabilization);
+ video_width, video_height, stabilization);
/* set vdis mode */
g_object_set(G_OBJECT(v_src),
- "enable-vdis-mode", TRUE,
- NULL);
+ "enable-vdis-mode", TRUE,
+ NULL);
} else {
_mmcam_dbg_warn("invalid preview format %c%c%c%c or video size %dx%d",
- sc->fourcc, sc->fourcc>>8, sc->fourcc>>16, sc->fourcc>>24,
- video_width, video_height);
+ sc->fourcc, sc->fourcc>>8, sc->fourcc>>16, sc->fourcc>>24,
+ video_width, video_height);
return FALSE;
}
} else {
/* set vdis mode */
g_object_set(G_OBJECT(v_src),
- "enable-vdis-mode", FALSE,
- NULL);
+ "enable-vdis-mode", FALSE,
+ NULL);
_mmcam_dbg_log("DISABLE video stabilization");
}
mmf_return_val_if_fail(hcamcorder, FALSE);
sc = MMF_CAMCORDER_SUBCONTEXT(handle);
- if (!sc) {
+ if (!sc)
return TRUE;
- }
mm_camcorder_get_attributes(handle, NULL,
- MMCAM_CAMERA_FPS, &fps,
- NULL);
+ MMCAM_CAMERA_FPS, &fps,
+ NULL);
_mmcam_dbg_log("set %dx%d", width, height);
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;
+}
+
+
+bool _mmcamcorder_recreate_decoder_for_encoded_preview(MMHandleType handle)
+{
+ int ret = MM_ERROR_NONE;
+ _MMCamcorderSubContext *sc = NULL;
+ mmf_camcorder_t *hcamcorder = NULL;
+ const char *videodecoder_name = NULL;
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ char decoder_name[20] = {'\0',};
+ int decoder_index = 0;
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+
+ if ((void *)handle == NULL) {
+ _mmcam_dbg_warn("handle is NULL");
+ return FALSE;
+ }
+
+ hcamcorder = MMF_CAMCORDER(handle);
+
+ sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+ if (!sc) {
+ _mmcam_dbg_warn("subcontext is NULL");
+ return FALSE;
+ }
+
+ if (sc->info_image->preview_format != MM_PIXEL_FORMAT_ENCODED_H264 ||
+ hcamcorder->recreate_decoder == FALSE) {
+ _mmcam_dbg_log("skip this fuction - format %d, recreate decoder %d",
+ sc->info_image->preview_format, hcamcorder->recreate_decoder);
+ return TRUE;
+ }
+
+ if (sc->element[_MMCAMCORDER_MAIN_PIPE].gst == NULL ||
+ sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
+ _mmcam_dbg_warn("main pipeline or decoder plugin is NULL");
+ return FALSE;
+ }
+
+ _mmcam_dbg_log("start");
+
+ _mmcamcorder_conf_get_value_element_name(sc->VideodecoderElementH264, &videodecoder_name);
+ if (videodecoder_name == NULL) {
+ _mmcam_dbg_err("failed to get decoder element name from %p", sc->VideodecoderElementH264);
+ return FALSE;
+ }
+
+ /* set state as NULL */
+ ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, GST_STATE_NULL);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to set NULL to decoder");
+ return FALSE;
+ }
+
+ /* remove decoder - pads will be unlinked automatically in remove function */
+ if (!gst_bin_remove(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
+ sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)) {
+ _mmcam_dbg_err("failed to remove decoder from pipeline");
+ return FALSE;
+ }
+
+ /* check decoder element */
+ if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst) {
+ _mmcam_dbg_log("decoder[%p] is still alive - ref count %d",
+ G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
+ ((GObject *)sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)->ref_count);
+ }
+
+#ifdef _MMCAMCORDER_RM_SUPPORT
+ if (hcamcorder->request_resources.category_id[0] == RM_CATEGORY_VIDEO_DECODER_SUB)
+ decoder_index = 1;
+
+ snprintf(decoder_name, sizeof(decoder_name)-1, "%s%d", videodecoder_name, decoder_index);
+ _mmcam_dbg_log("encoded preview decoder_name %s", decoder_name);
+ /* create decoder */
+ sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(decoder_name, "videosrc_decode");
+ if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
+ _mmcam_dbg_err("Decoder[%s] creation fail", decoder_name);
+ return FALSE;
+ }
+#else /* _MMCAMCORDER_RM_SUPPORT */
+ /* create new decoder */
+ sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst = gst_element_factory_make(videodecoder_name, "videosrc_decode");
+ if (sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst == NULL) {
+ _mmcam_dbg_err("Decoder [%s] creation fail", videodecoder_name);
+ return FALSE;
+ }
+#endif /* _MMCAMCORDER_RM_SUPPORT */
+ _mmcamcorder_conf_set_value_element_property(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, sc->VideodecoderElementH264);
+
+ sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].id = _MMCAMCORDER_VIDEOSRC_DECODE;
+ g_object_weak_ref(G_OBJECT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
+ (GWeakNotify)_mmcamcorder_element_release_noti, sc);
+
+ /* add to pipeline */
+ if (!gst_bin_add(GST_BIN(sc->element[_MMCAMCORDER_MAIN_PIPE].gst),
+ sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst)) {
+ _mmcam_dbg_err("failed to add decoder to pipeline");
+ gst_object_unref(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst);
+ return FALSE;
+ }
+
+ /* link */
+ if (_MM_GST_ELEMENT_LINK(GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_QUE].gst),
+ GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst))) {
+ _mmcam_dbg_log("Link videosrc_queue to decoder OK");
+ } else {
+ _mmcam_dbg_err("Link videosrc_queue to decoder FAILED");
+ return FALSE;
+ }
+
+ if (_MM_GST_ELEMENT_LINK(GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst),
+ GST_ELEMENT(sc->element[_MMCAMCORDER_VIDEOSINK_QUE].gst))) {
+ _mmcam_dbg_log("Link decoder to videosink_queue OK");
+ } else {
+ _mmcam_dbg_err("Link decoder to videosink_queue FAILED");
+ return FALSE;
+ }
+
+ /* set state READY */
+ ret = _mmcamcorder_gst_set_state(handle, sc->element[_MMCAMCORDER_VIDEOSRC_DECODE].gst, GST_STATE_READY);
+ if (ret != MM_ERROR_NONE) {
+ _mmcam_dbg_err("failed to set READY to decoder");
+ return FALSE;
+ }
+
+ _mmcam_dbg_log("done");
+
+ return TRUE;
+}