[Release version 0.10.24] Support tizenipcsrc and rename some internal APIs
[platform/core/multimedia/libmm-camcorder.git] / src / mm_camcorder_gstcommon.c
index 5d4e253..130d76c 100644 (file)
@@ -234,7 +234,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                                          MMCAM_CAMERA_HDR_CAPTURE, &sc->info_image->hdr_capture_mode,
                                          MMCAM_IMAGE_ENCODER, &codectype,
                                          MMCAM_IMAGE_ENCODER_QUALITY, &capture_jpg_quality,
-                                         MMCAM_DISPLAY_SHM_SOCKET_PATH, &socket_path, &socket_path_len,
+                                         MMCAM_DISPLAY_SOCKET_PATH, &socket_path, &socket_path_len,
                                          MMCAM_DISPLAY_SURFACE, &display_surface_type,
                                          NULL);
        if (err != MM_ERROR_NONE) {
@@ -308,7 +308,7 @@ int _mmcamcorder_create_preview_elements(MMHandleType handle)
                _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_SHM_SOCKET_PATH, &socket_path, &socket_path_len,
+                                                 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);
@@ -1019,11 +1019,6 @@ int _mmcamcorder_create_encodesink_bin(MMHandleType handle, MMCamcorderEncodebin
                element_list = NULL;
        }
 
-       if (video_caps) {
-               gst_caps_unref(video_caps);
-               video_caps = NULL;
-       }
-
        _mmcam_dbg_log("done");
 
        return MM_ERROR_NONE;
@@ -1046,11 +1041,6 @@ pipeline_creation_error :
                element_list = NULL;
        }
 
-       if (video_caps) {
-               gst_caps_unref(video_caps);
-               video_caps = NULL;
-       }
-
        return err;
 }
 
@@ -1495,16 +1485,19 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP
                structure = gst_caps_get_structure( caps, 0 );
                gst_structure_get_int(structure, "width", &(stream.width));
                gst_structure_get_int(structure, "height", &(stream.height));
-               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;
+               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);
                }
-
-               fourcc = _mmcamcorder_convert_fourcc_string_to_value(string_format);
-               stream.format = _mmcamcorder_get_pixtype(fourcc);
                gst_caps_unref(caps);
                caps = NULL;
 
@@ -1612,6 +1605,13 @@ static GstPadProbeReturn __mmcamcorder_video_dataprobe_preview(GstPad *pad, GstP
                                stream.data_type = MM_CAM_STREAM_DATA_YUV422;
                                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;
                                stream.data.yuv420.yuv = mapinfo.data;
@@ -1938,8 +1938,8 @@ int _mmcamcorder_check_audiocodec_fileformat_compatibility(MMHandleType handle)
        }
 
        /* 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);
@@ -1977,8 +1977,8 @@ int _mmcamcorder_check_videocodec_fileformat_compatibility(MMHandleType handle)
        }
 
        /* 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);
@@ -2211,12 +2211,16 @@ bool _mmcamcorder_set_videosrc_caps(MMHandleType handle, unsigned int fourcc, in
 
                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;
 
-                       caps_fourcc = _mmcamcorder_convert_fourcc_string_to_value(gst_structure_get_string(structure, "format"));
+                       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);