[Release version 0.2.21] Add new API to support sound stream information set 14/60314/3 accepted/tizen/common/20160322.145933 accepted/tizen/ivi/20160322.084358 accepted/tizen/mobile/20160322.084303 accepted/tizen/tv/20160322.084319 accepted/tizen/wearable/20160322.084338 submit/tizen/20160322.011425
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 25 Feb 2016 03:39:53 +0000 (12:39 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Wed, 9 Mar 2016 03:43:49 +0000 (12:43 +0900)
Change-Id: I5caca63d53bc397b0c88aab79a4f1629b0546cab
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
CMakeLists.txt
include/recorder.h
packaging/capi-media-recorder.spec
src/recorder.c
test/CMakeLists.txt
test/recorder_test.c

index ea5eab1..1569e97 100644 (file)
@@ -9,8 +9,8 @@ SET(service "media")
 SET(submodule "recorder")
 
 # for package file
-SET(dependents "dlog capi-media-camera capi-media-audio-io mmsvc-recorder storage mused")
-SET(pc_dependents "capi-base-common capi-media-camera capi-media-audio-io")
+SET(dependents "dlog capi-media-camera capi-media-audio-io mmsvc-recorder storage mused capi-media-sound-manager")
+SET(pc_dependents "capi-base-common capi-media-camera capi-media-audio-io capi-media-sound-manager")
 
 SET(fw_name "${project_prefix}-${service}-${submodule}")
 
index cf66acb..bf6c9f8 100644 (file)
@@ -19,6 +19,7 @@
 #include <tizen.h>
 #include <camera.h>
 #include <audio_io.h>
+#include <sound_manager.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -650,6 +651,26 @@ int recorder_set_file_format(recorder_h recorder, recorder_file_format_e format)
 int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format);
 
 
+/**
+ * @brief Sets the recorder's sound manager stream information.
+ * @since_tizen 3.0
+ * @remarks You can set sound stream information including audio routing.
+ *          For more details, please refer to @ref CAPI_MEDIA_SOUND_MANAGER_MODULE
+ * @param[in]  recorder        The handle to the media recorder
+ * @param[in]  stream_info     The sound manager info
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RECORDER_ERROR_NONE Successful
+ * @retval #RECORDER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RECORDER_ERROR_INVALID_STATE Invalid state
+ * @retval #RECORDER_ERROR_INVALID_OPERATION Invalid operation
+ * @pre The recorder state must be #RECORDER_STATE_CREATED or #RECORDER_STATE_READY
+ * @see #sound_stream_info_h
+ * @see sound_manager_create_stream_information()
+ * @see sound_manager_destroy_stream_information()
+ */
+int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stream_info);
+
+
  /**
  * @}
 */
index c2166a6..a647604 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-recorder
 Summary:    A Recorder API
-Version:    0.2.20
+Version:    0.2.21
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -17,6 +17,7 @@ BuildRequires:  pkgconfig(evas)
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(capi-media-tool)
 BuildRequires:  pkgconfig(capi-media-audio-io)
+BuildRequires:  pkgconfig(capi-media-sound-manager)
 BuildRequires:  pkgconfig(storage)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
index 2f8290b..d41f0e7 100644 (file)
@@ -18,6 +18,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <recorder.h>
+#include <sound_manager.h>
+#include <sound_manager_internal.h>
 #include <storage.h>
 #include <muse_recorder.h>
 #include <muse_recorder_msg.h>
@@ -985,7 +987,7 @@ static int _recorder_create_common(recorder_h *recorder, muse_recorder_type_e ty
                goto _ERR_RECORDER_EXIT;
        }
 
-       ret = client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, CALLBACK_TIME_OUT);
+       ret = client_wait_for_cb_return(MUSE_RECORDER_API_CREATE, pc->cb_info, RECORDER_CALLBACK_TIME_OUT);
        if (ret == RECORDER_ERROR_NONE) {
                muse_recorder_msg_get_pointer(handle, pc->cb_info->recv_msg);
                if (handle == 0) {
@@ -1534,6 +1536,56 @@ int recorder_get_file_format(recorder_h recorder, recorder_file_format_e *format
 }
 
 
+int recorder_set_sound_stream_info(recorder_h recorder, sound_stream_info_h stream_info)
+{
+       int ret = RECORDER_ERROR_NONE;
+       muse_recorder_api_e api = MUSE_RECORDER_API_SET_SOUND_STREAM_INFO;
+       recorder_cli_s *pc = NULL;
+       bool is_available = false;
+       int sock_fd;
+       int stream_index = 0;
+       char *stream_type = NULL;
+
+       if (recorder == NULL || stream_info == NULL) {
+               LOGE("NULL pointer handle");
+               return RECORDER_ERROR_INVALID_PARAMETER;
+       }
+
+       pc = (recorder_cli_s *)recorder;
+       if (pc->cb_info == NULL) {
+               LOGE("INVALID_PARAMETER(0x%08x)", RECORDER_ERROR_INVALID_PARAMETER);
+               return RECORDER_ERROR_INVALID_PARAMETER;
+       }
+
+       sock_fd = pc->cb_info->fd;
+
+       LOGD("ENTER");
+
+       ret = sound_manager_is_available_stream_information(stream_info, NATIVE_API_RECORDER, &is_available);
+       if (ret != SOUND_MANAGER_ERROR_NONE) {
+               LOGE("stream info verification failed");
+               return RECORDER_ERROR_INVALID_OPERATION;
+       }
+
+       if (is_available == false) {
+               LOGE("stream information is not available");
+               return RECORDER_ERROR_INVALID_OPERATION;
+       }
+
+       ret = sound_manager_get_type_from_stream_information(stream_info, &stream_type);
+       ret |= sound_manager_get_index_from_stream_information(stream_info, &stream_index);
+
+       LOGD("sound manager return [0x%x]", ret);
+
+       if (ret == SOUND_MANAGER_ERROR_NONE)
+               muse_recorder_msg_send2(api, sock_fd, pc->cb_info, ret, STRING, stream_type, INT, stream_index);
+       else
+               ret = RECORDER_ERROR_INVALID_OPERATION;
+
+       return ret;
+}
+
+
 int recorder_set_state_changed_cb(recorder_h recorder, recorder_state_changed_cb callback, void* user_data)
 {
        if (recorder == NULL || callback == NULL) {
index de39ed5..88541b7 100644 (file)
@@ -5,7 +5,7 @@ SET(fw_test "${fw_name}-test")
 #link_directories(${CMAKE_SOURCE_DIR}/../)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED elementary evas)
+pkg_check_modules(${fw_test} REQUIRED elementary evas capi-media-sound-manager)
 FOREACH(flag ${${fw_test}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
     MESSAGE(${flag})
index eb96abd..4825ecf 100644 (file)
@@ -31,6 +31,7 @@
 #include <dlog.h>
 #include <Ecore.h>
 #include <Elementary.h>
+#include <sound_manager.h>
 
 /*-----------------------------------------------------------------------
   |    GLOBAL VARIABLE DEFINITIONS:                                       |
@@ -1396,6 +1397,14 @@ static gboolean init_handle()
 
        return TRUE;
 }
+
+
+static void _sound_stream_focus_state_changed_cb(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change, const char *additional_info, void *user_data)
+{
+       g_print("focus changed : reason %d\n", reason_for_change);
+       return;
+}
+
 /**
  * This function is to change camcorder mode.
  *
@@ -1517,6 +1526,16 @@ static gboolean mode_change()
                                continue;
                        }
 
+                       {
+                               sound_stream_info_h stream_info = NULL;
+
+                               sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, _sound_stream_focus_state_changed_cb, hcamcorder, &stream_info);
+                               if (stream_info) {
+                                       recorder_set_sound_stream_info(hcamcorder->recorder, stream_info);
+                                       sound_manager_destroy_stream_information(stream_info);
+                               }
+                       }
+
                        err = recorder_attr_set_audio_device(hcamcorder->recorder, RECORDER_AUDIO_DEVICE_MIC);
                        if (err != RECORDER_ERROR_NONE) {
                                LOGE("set audio device failed 0x%x", err);