[Release version 0.10.39] Support sound stream information to select audio device 12/60312/1
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 25 Feb 2016 03:37:51 +0000 (12:37 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 25 Feb 2016 03:37:51 +0000 (12:37 +0900)
Change-Id: I800817abb741620e5d5b37dd99ceea8c089dce3e
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/include/mm_camcorder.h
src/include/mm_camcorder_attribute.h
src/include/mm_camcorder_gstcommon.h
src/mm_camcorder_attribute.c
src/mm_camcorder_gstcommon.c

index 8b44bdb..73108cd 100644 (file)
@@ -2,7 +2,7 @@
 
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.38
+Version:    0.10.39
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 10f589c..15b6911 100644 (file)
@@ -1250,7 +1250,13 @@ extern "C" {
 /**
  * GOP interval for encoded preview stream
  */
-#define MMCAM_ENCODED_PREVIEW_GOP_INTERVAL   "encoded-preview-gop-interval"
+#define MMCAM_ENCODED_PREVIEW_GOP_INTERVAL      "encoded-preview-gop-interval"
+
+/**
+ * Stream type and index for sound route
+ */
+#define MMCAM_SOUND_STREAM_TYPE                 "sound-stream-type"
+#define MMCAM_SOUND_STREAM_INDEX                "sound-stream-index"
 
 /*=======================================================================================
 | ENUM DEFINITIONS                                                                     |
index b7b5aac..a03e3d7 100644 (file)
@@ -177,6 +177,8 @@ typedef enum
        MM_CAM_DISPLAY_SOCKET_PATH,
        MM_CAM_PID_FOR_SOUND_FOCUS,
        MM_CAM_ROOT_DIRECTORY,          /* 120 */
+       MM_CAM_SOUND_STREAM_TYPE,
+       MM_CAM_SOUND_STREAM_INDEX,
        MM_CAM_ATTRIBUTE_NUM
 }MMCamcorderAttrsID;
 
@@ -371,6 +373,8 @@ bool _mmcamcorder_commit_camera_hdr_capture(MMHandleType handle, int attr_idx, c
 bool _mmcamcorder_commit_encoded_preview_bitrate(MMHandleType handle, int attr_idx, const mmf_value_t *value);
 bool _mmcamcorder_commit_encoded_preview_gop_interval(MMHandleType handle, int attr_idx, const mmf_value_t *value);
 bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx, const mmf_value_t *value);
+bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const mmf_value_t *value);
+
 
 /**
  * This function initialize effect setting.
index 3724cb5..bb74829 100644 (file)
@@ -169,6 +169,7 @@ bool _mmcamcorder_set_videosrc_stabilization(MMHandleType handle, int stabilizat
 bool _mmcamcorder_set_camera_resolution(MMHandleType handle, int width, int height);
 bool _mmcamcorder_set_encoded_preview_bitrate(MMHandleType handle, int bitrate);
 bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int gop);
+bool _mmcamcorder_set_sound_stream_info(GstElement *element, char *stream_type, int stream_index);
 #ifdef __cplusplus
 }
 #endif
index fbec727..59db9a8 100644 (file)
@@ -1479,6 +1479,28 @@ _mmcamcorder_alloc_attribute( MMHandleType handle, MMCamPreset *info )
                        {0},
                        {0},
                        NULL,
+               },
+               {
+                       MM_CAM_SOUND_STREAM_TYPE,
+                       "sound-stream-type",
+                       MMF_VALUE_TYPE_STRING,
+                       MM_ATTRS_FLAG_RW,
+                       {(void*)NULL},
+                       MM_ATTRS_VALID_TYPE_NONE,
+                       {0},
+                       {0},
+                       NULL,
+               },
+               {
+                       MM_CAM_SOUND_STREAM_INDEX,
+                       "sound-stream-index",
+                       MMF_VALUE_TYPE_INT,
+                       MM_ATTRS_FLAG_RW,
+                       {(void*)-1},
+                       MM_ATTRS_VALID_TYPE_INT_RANGE,
+                       {.int_min = -1},
+                       {.int_max = _MMCAMCORDER_MAX_INT},
+                       _mmcamcorder_commit_sound_stream_info,
                }
        };
 
@@ -4104,6 +4126,39 @@ bool _mmcamcorder_commit_pid_for_sound_focus(MMHandleType handle, int attr_idx,
 }
 
 
+bool _mmcamcorder_commit_sound_stream_info(MMHandleType handle, int attr_idx, const mmf_value_t *value)
+{
+       char *stream_type = NULL;
+       int stream_type_len = 0;
+       _MMCamcorderSubContext *sc = NULL;
+
+       if ((void *)handle == NULL) {
+               _mmcam_dbg_warn("handle is NULL");
+               return FALSE;
+       }
+
+       sc = MMF_CAMCORDER_SUBCONTEXT(handle);
+       if (!sc || !sc->encode_element ||
+           !sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst) {
+               _mmcam_dbg_log("audiosrc element is not initialized, it will be set later");
+               return TRUE;
+       }
+
+       mm_camcorder_get_attributes(handle, NULL,
+               MMCAM_SOUND_STREAM_TYPE, &stream_type, &stream_type_len,
+               NULL);
+
+       if (stream_type == NULL) {
+               _mmcam_dbg_err("stream type is not set");
+               return FALSE;
+       }
+
+       _mmcam_dbg_log("Commit : sound stream info - type %s", stream_type);
+
+       return _mmcamcorder_set_sound_stream_info(sc->encode_element[_MMCAMCORDER_AUDIOSRC_SRC].gst, stream_type, value->value.i_val);
+}
+
+
 static bool
 __mmcamcorder_attrs_is_supported(MMHandleType handle, int idx)
 {
index 3ad6ec2..556ffc6 100644 (file)
@@ -400,6 +400,9 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
        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;
 
        GstCaps *caps = NULL;
        GstPad *pad = NULL;
@@ -424,14 +427,16 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
        }
 
        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);
@@ -475,6 +480,10 @@ int _mmcamcorder_create_audiosrc_bin(MMHandleType handle)
 
        _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);
 
        _MMCAMCORDER_ELEMENT_MAKE(sc, sc->encode_element, _MMCAMCORDER_AUDIOSRC_FILT, "capsfilter", "audiosrc_capsfilter", element_list, err);
@@ -2551,3 +2560,35 @@ bool _mmcamcorder_set_encoded_preview_gop_interval(MMHandleType handle, int inte
 
        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;
+}
+