Add interface about sound stream information 53/300053/1 accepted/tizen/unified/20231018.120806
authorYoungwoo Cho <young222.cho@samsung.com>
Fri, 13 Oct 2023 01:37:48 +0000 (10:37 +0900)
committerYoungwoo Cho <young222.cho@samsung.com>
Mon, 16 Oct 2023 07:56:26 +0000 (16:56 +0900)
- add interface about sound stream information
  to set properties such as media.role

Change-Id: Iff69bc9912e3cd98974694c9b475a99c8ed1c633
Signed-off-by: Youngwoo Cho <young222.cho@samsung.com>
14 files changed:
CMakeLists.txt
esplusplayer.pc.in
include/esplusplayer/esplusplayer.h
include/esplusplayer_capi/esplusplayer_capi.h
packaging/esplusplayer.spec
src/esplusplayer/CMakeLists.txt
src/esplusplayer/include_internal/esplayer/esplayer.h
src/esplusplayer/src/esplayer.cpp
src/esplusplayer/src/esplusplayer_capi.cpp
src/plusplayer-core/CMakeLists.txt
src/plusplayer-core/include_internal/core/trackrendereradapter.h
src/plusplayer-core/src/trackrendereradapter.cpp
test/CMakeLists.txt
test/esplusplayer_test.cpp

index 9b8127a..889728d 100644 (file)
@@ -13,6 +13,7 @@ SET(PC_CFLAGS "-I/usr/include/esplusplayer_capi")
 ENDIF(${USE_MIXER} STREQUAL "yes")
 
 IF(${TIZEN_PUBLIC} STREQUAL "ON")
+SET(PC_REQUIRED "capi-media-sound-manager")
 SET(PC_CFLAGS "${PC_CFLAGS} -DTIZEN_FEATURE_PUBLIC")
 ENDIF(${TIZEN_PUBLIC} STREQUAL "ON")
 
index be8b623..a319c7d 100644 (file)
@@ -1,10 +1,11 @@
-\r
-prefix = @PREFIX@\r
-exec_prefix = /usr\r
-libdir = @LIB_INSTALL_DIR@\r
-\r
-Name: @PC_NAME@\r
-Description: @PACKAGE_DESCRYPTION@\r
-Version: @VERSION@\r
-Libs: -L${libdir} @PC_LDFLAGS@\r
-Cflags : @PC_CFLAGS@\r
+
+prefix = @PREFIX@
+exec_prefix = /usr
+libdir = @LIB_INSTALL_DIR@
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRYPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags : @PC_CFLAGS@
index f51fc27..e04a50d 100644 (file)
 #include <utility>
 #include <vector>
 
+#ifdef TIZEN_FEATURE_PUBLIC
+#include <sound_manager.h>
+#endif
+
 #ifdef USE_MIXER
 #include "mixer/mixer.h"
 #endif
@@ -1333,6 +1337,18 @@ class EsPlusPlayer : private boost::noncopyable {
    * @return    @c True on success, otherwise @c False
    */
   virtual bool EnableVideoHole(bool value) { return false; }
+
+  /**
+   * @brief     Set sound stream information
+   * @param     [in] stream_info : sound stream information
+   * @pre       The player state must be set to #EsState::kIdle.
+   * @post      None
+   * @return    @c True on success, otherwise @c False
+   * @exception  None
+   */
+  virtual bool SetSoundStreamInfo(const sound_stream_info_h stream_info) {
+    return false;
+  }
 #endif
   // LCOV_EXCL_STOP
 
index a809c7c..6e8e3c2 100644 (file)
 #ifndef __ESPLUSPLAYER_ESPLUSPLAYER_CAPI_ESPLUSPLAYER_CAPI_H__
 #define __ESPLUSPLAYER_ESPLUSPLAYER_CAPI_ESPLUSPLAYER_CAPI_H__
 
+#ifdef TIZEN_FEATURE_PUBLIC
+#include <media/sound_manager.h>
+#endif
+
 #include "esplusplayer_capi/buffer.h"
 #include "esplusplayer_capi/display.h"
 #include "esplusplayer_capi/drm.h"
@@ -3955,6 +3959,31 @@ int esplusplayer_set_simple_mix_out_buffer_level(
  *            esplusplayer_set_media_packet_video_decoded_cb()
  */
 int esplusplayer_enable_video_hole(esplusplayer_handle handle, const bool value);
+
+/**
+ * @brief     Set sound stream information
+ * @param     [in] handle      : esplusplayer handle.
+ * @param     [in] stream_info : sound stream information
+ * @return    @c ESPLUSPLAYER_ERROR_TYPE_NONE on success,otherwise @c one of
+ * esplusplayer_error_type
+ *            values will be returned.
+ * @retval    #ESPLUSPLAYER_ERROR_TYPE_NONE Successful
+ * @retval    #ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER Invalid parameter
+ * @retval    #ESPLUSPLAYER_ERROR_TYPE_INVALID_OPERATION Internal operation
+ * failed
+ * @code
+ *            esplusplayer_open(esplayer);
+ *            esplusplayer_set_sound_stream_info(esplayer, stream_info);
+ *            // ... your codes ...
+ *            esplusplayer_close(esplayer);
+ * @endcode
+ * @pre       The player state must be set to #ESPLUSPLAYER_STATE_IDLE
+ * @post      None
+ * @exception None
+ * @see       esplusplayer_open()
+ */
+int esplusplayer_set_sound_stream_info(
+    esplusplayer_handle handle, const sound_stream_info_h stream_info);
 #endif
 #ifdef __cplusplus
 }
index b0b6785..7265f60 100644 (file)
@@ -11,7 +11,7 @@
 Name:       esplusplayer
 Summary:    new multimedia streaming player
 Version:    1.2.1
-Release:    1
+Release:    2
 Group:      Multimedia/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
@@ -29,6 +29,7 @@ BuildRequires:  pkgconfig(evas)
 BuildRequires:  pkgconfig(ecore-wl2)
 %if %{with TIZEN_PUBLIC}
 BuildRequires:  pkgconfig(libtrackrenderer)
+BuildRequires:  pkgconfig(capi-media-sound-manager)
 # for test
 BuildRequires:  pkgconfig(capi-mediademuxer)
 BuildRequires:  pkgconfig(appcore-efl)
index 74ecd3e..6d9ab72 100644 (file)
@@ -31,6 +31,8 @@ SET(dependents ${dependents} "libavoc")
 ELSE(${PRODUCT_TYPE_AUDIO} STREQUAL "no")
 SET(dependents ${dependents} "libavoc-av")
 ENDIF(${PRODUCT_TYPE_AUDIO} STREQUAL "no")
+ELSE(${TIZEN_PUBLIC} STREQUAL "OFF")
+SET(dependents ${dependents} "capi-media-sound-manager")
 ENDIF(${TIZEN_PUBLIC} STREQUAL "OFF")
 
 INCLUDE(FindPkgConfig)
index 508bc5c..769dd04 100644 (file)
@@ -170,6 +170,10 @@ class EsPlayer : public EsPlusPlayer {
   bool GetVideoStreamRotationInfo(VideoRotation* rotation) override;
   bool SetSimpleMixOutBufferLevel(
       const PlayerSimpleMixOutBufferLevel level) override;
+#ifdef TIZEN_FEATURE_PUBLIC
+  bool EnableVideoHole(bool value) override;
+  bool SetSoundStreamInfo(const sound_stream_info_h stream_info) override;
+#endif // TIZEN_FEATURE_PUBLIC
 
  private:
   using SubmitPacketOperator =
@@ -297,9 +301,6 @@ class EsPlayer : public EsPlusPlayer {
   };
 #endif // USE_MIXER
 
-#ifdef TIZEN_FEATURE_PUBLIC
-  bool EnableVideoHole(bool value) override;
-#endif
 
  private:
   std::vector<Track> track_;
index bc81466..782a4e8 100644 (file)
@@ -3063,6 +3063,19 @@ bool EsPlayer::EnableVideoHole(bool value) {
   }
   return trackrenderer_->EnableVideoHole(value);
 }
+
+bool EsPlayer::SetSoundStreamInfo(const sound_stream_info_h stream_info) {
+  if (state_manager_.GetState() != EsState::kIdle) {
+    LOG_ERROR_P(this, "Invalid State , current %d",
+                state_manager_.GetStateEnum());
+    return false;
+  }
+  if (!stream_info) {
+    LOG_ERROR_P(this, "stream_info is null");
+    return false;
+  }
+  return trackrenderer_->SetSoundStreamInfo(stream_info);
+}
 #endif
 
 namespace es_conf {
index bb43f18..45aca6c 100644 (file)
@@ -2456,4 +2456,14 @@ int esplusplayer_enable_video_hole(esplusplayer_handle handle, const bool value)
   auto ret = cast_(handle)->EnableVideoHole(value);
   return convert_return_type_(ret);
 }
+
+int esplusplayer_set_sound_stream_info(
+    esplusplayer_handle handle, const sound_stream_info_h stream_info) {
+  LOG_ENTER_P(cast_(handle))
+  if (is_null_(handle) || is_null_(stream_info))
+    return ESPLUSPLAYER_ERROR_TYPE_INVALID_PARAMETER;
+
+  auto ret = cast_(handle)->SetSoundStreamInfo(stream_info);
+  return convert_return_type_(ret);
+}
 #endif
index 00cacbd..e9fb4a8 100644 (file)
@@ -20,6 +20,8 @@ IF(${TIZEN_PUBLIC} STREQUAL "OFF")
 SET(dependents ${dependents} "context-aware-api"
                              "drmdecrypt"
                              "logger")
+ELSE(${TIZEN_PUBLIC} STREQUAL "OFF")
+SET(dependents ${dependents} "capi-media-sound-manager")
 ENDIF(${TIZEN_PUBLIC} STREQUAL "OFF")
 
 INCLUDE(FindPkgConfig)
index 368388c..3efbf1a 100644 (file)
@@ -241,6 +241,7 @@ class TrackRendererAdapter {
   bool SetSimpleMixOutBufferLevel(const int& level);
 #ifdef TIZEN_FEATURE_PUBLIC
   bool EnableVideoHole(bool value);
+  bool SetSoundStreamInfo(const sound_stream_info_h stream_info);
 #endif
 
  private:
index 3e29110..45bbd6b 100644 (file)
@@ -1041,6 +1041,11 @@ bool TrackRendererAdapter::SetVideoStreamRotationInfo(
 bool TrackRendererAdapter::EnableVideoHole(bool value) {
   return (trackrenderer_enable_video_hole(handle_, value) != kFailed);
 }
+
+bool TrackRendererAdapter::SetSoundStreamInfo(
+    const sound_stream_info_h stream_info) {
+  return (trackrenderer_set_sound_stream_info(handle_, stream_info) != kFailed);
+}
 #endif
 
 // LCOV_EXCL_START
index 7c2e1d4..e314d54 100644 (file)
@@ -11,7 +11,7 @@ SET(${fw_name}_CXXFLAGS "-Wall -Werror -std=c++17 -pthread -fPIE -Wl,-z,relro -f
 SET(${fw_name}_LDFLAGS)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0 appcore-efl elementary capi-mediademuxer)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0 appcore-efl elementary capi-mediademuxer capi-media-sound-manager)
 
 FOREACH(flag ${${fw_test}_CFLAGS})
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index e48580f..1df7aef 100644 (file)
@@ -23,6 +23,7 @@
 #include <dlog.h>
 #include <mediademuxer.h>
 #include <getopt.h>
+#include <sound_manager.h>
 
 #include "esplusplayer_capi/esplusplayer_capi.h"
 #include "esplusplayer_capi/esplusplayer_internal.h"
@@ -60,6 +61,7 @@ enum {
        CURRENT_STATUS_ENABLE_VIDEO_HOLE,
        CURRENT_STATUS_SET_RENDER_TIME_OFFSET,
        CURRENT_STATUS_SET_LOW_LATENCY_MODE,
+       CURRENT_STATUS_SET_SOUND_STREAM_INFO,
 };
 
 /* for video display */
@@ -99,6 +101,7 @@ typedef struct {
        bool stop_thread;
        int video_track_id;
        int audio_track_id;
+       sound_stream_info_h stream_info;
 } test_h;
 
 static appdata g_ad;
@@ -470,6 +473,11 @@ static void __deinit_test()
                return;
        }
 
+       if (g_test_h->stream_info) {
+               sound_manager_destroy_stream_information(g_test_h->stream_info);
+               g_test_h->stream_info = NULL;
+       }
+
        // need to stop feeding thread;
        mediademuxer_stop(g_test_h->demux_h);
        mediademuxer_unprepare(g_test_h->demux_h);
@@ -797,6 +805,11 @@ static void __test_close()
                return;
        }
 
+       if (g_test_h->stream_info) {
+               sound_manager_destroy_stream_information(g_test_h->stream_info);
+               g_test_h->stream_info = NULL;
+       }
+
        int ret = esplusplayer_close(g_test_h->espp_h);
        if (ret != ESPLUSPLAYER_ERROR_TYPE_NONE)
                g_print("                       => failed to esplusplayer_close()\n");
@@ -1332,6 +1345,69 @@ static void __test_enable_video_hole(bool value)
                g_print("                       => esplusplayer_enable_video_hole() success\n");
 }
 
+static void __test_set_sound_stream_info(int type)
+{
+       if (!g_test_h) {
+               g_print("test handle is NULL\n");
+               return;
+       }
+
+       sound_device_list_h device_list = NULL;
+       int ret = SOUND_MANAGER_ERROR_NONE;
+
+       if (g_test_h->stream_info) {
+               sound_manager_destroy_stream_information(g_test_h->stream_info);
+               g_print("stream information is already set, destroy stream info\n");
+       }
+       if (sound_manager_create_stream_information(static_cast<sound_stream_type_e>(type), NULL, NULL, &g_test_h->stream_info)) {
+               g_print("failed to create stream_information()\n");
+               return;
+       }
+       /* In case of MEDIA_EXTERNAL_ONLY, we need to set external device manually */
+       if (type == (int)SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY) {
+               sound_device_h device = NULL;
+               sound_device_type_e device_type;
+
+               if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
+                       g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
+                       goto END;
+               }
+               while (!(ret = sound_manager_get_next_device(device_list, &device))) {
+                       if ((ret = sound_manager_get_device_type(device, &device_type))) {
+                               g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
+                               goto END;
+                       }
+                       if (device_type == SOUND_DEVICE_BLUETOOTH_MEDIA || device_type == SOUND_DEVICE_USB_AUDIO) {
+                               if ((ret = sound_manager_add_device_for_stream_routing(g_test_h->stream_info, device))) {
+                                       g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
+                                       goto END;
+                               }
+                               if ((ret = sound_manager_apply_stream_routing(g_test_h->stream_info))) {
+                                       g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
+                                       goto END;
+                               }
+                               break;
+                       }
+               }
+               if (ret != SOUND_MANAGER_ERROR_NONE) {
+                       g_print("failed to sound_manager_get_next_device(), ret(0x%x)\n", ret);
+                       goto END;
+               }
+       }
+
+       if (esplusplayer_set_sound_stream_info(g_test_h->espp_h, g_test_h->stream_info) != ESPLUSPLAYER_ERROR_TYPE_NONE) {
+               g_print("                       => failed to esplusplayer_set_sound_stream_info\n");
+               sound_manager_destroy_stream_information(g_test_h->stream_info);
+               g_test_h->stream_info = NULL;
+       } else {
+               g_print("                       => esplusplayer_set_sound_stream_info() success\n");
+       }
+
+END:
+       if (device_list)
+               sound_manager_free_device_list(device_list);
+}
+
 static void __test_quick_prepare()
 {
        int ret = 0;
@@ -1492,6 +1568,8 @@ static void __interpret_main_menu(char *cmd)
                        g_menu_state = CURRENT_STATUS_SET_VIDEO_ROI;
                } else if (strncmp(cmd, "drt", 3) == 0) {
                        g_menu_state = CURRENT_STATUS_SET_DISPLAY_ROTATION;
+               } else if (strncmp(cmd, "ssi", 3) == 0) {
+                       g_menu_state = CURRENT_STATUS_SET_SOUND_STREAM_INFO;
                } else {
                        g_print("unknown menu \n");
                }
@@ -1534,7 +1612,8 @@ static void __display_sub_basic()
        g_print("h.Set Mute\n");
        g_print("[etc] ");
        g_print("sr.Set render time offset\t");
-       g_print("ll.Set low latency mode\n\n");
+       g_print("ll.Set low latency mode\n");
+       g_print("      ssi.Set sound stream info\n\n");
 
        g_print("-- << mediademuxer cmd >> ---------------------------------------------------------------\n");
        g_print("prd.prepare demuxer\n\n");
@@ -1588,6 +1667,8 @@ static void __displaymenu()
                g_print("*** Input stream type and time offset\n");
        } else if (g_menu_state == CURRENT_STATUS_SET_LOW_LATENCY_MODE) {
                g_print("*** Input low latency mode (0: none, 1: disable preroll)\n");
+       } else if (g_menu_state == CURRENT_STATUS_SET_SOUND_STREAM_INFO) {
+               g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
        } else {
                g_print("*** Unknown status.\n");
                quit_program();
@@ -1867,6 +1948,13 @@ static void interpret(char *cmd)
                reset_menu_state();
                break;
        }
+       case CURRENT_STATUS_SET_SOUND_STREAM_INFO:
+       {
+               value = atoi(cmd);
+               __test_set_sound_stream_info(value);
+               reset_menu_state();
+               break;
+       }
        default:
                break;
        }