[ACR-1420] Add API for audio offload 77/208277/22
authorEunhye Choi <eunhae1.choi@samsung.com>
Fri, 21 Jun 2019 04:12:07 +0000 (13:12 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Fri, 19 Jul 2019 05:36:30 +0000 (14:36 +0900)
- required feature :
  http://tizen.org/feature/multimedia.player.audio_offload

Change-Id: I9aaa50afc2ec816d169d50fbb22e44a37d1c1fd6

doc/player_doc.h
include/player.h
include/player_private.h
src/player.c
src/player_internal.c
test/player_test.c

index c03c8ca..c0f13a3 100644 (file)
  *  - http://tizen.org/feature/opengles.version.2_0
  *  - http://tizen.org/feature/multimedia.player.spherical_video
  *    These features are required for 360 video playback.
+ *  - http://tizen.org/feature/multimedia.player.audio_offload
+ *    This feature is required for hardware-offloaded audio processing.
  * @if WEARABLE
  *  - http://tizen.org/feature/network.internet
  *    This feature is required for network streaming.
  * @endif
+ *
  * It is recommended to design feature related codes in your application for reliability.
  * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.
  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.
index 9e7b674..9c0e08d 100644 (file)
@@ -390,6 +390,18 @@ typedef void (*player_media_stream_buffer_status_cb)(player_media_stream_buffer_
 typedef void (*player_media_stream_seek_cb)(unsigned long long offset, void *user_data);
 
 /**
+ * @brief Called to inform about the supported media format MIME type.
+ * @details The supported media format can vary depending on the device capabilities.
+ * @since_tizen 5.5
+ * @param[in] format      The supportable media format MIME type
+ * @param[in] user_data   The user data passed from the callback registration function
+ * @return @c true to continue with the next iteration of the loop, otherwise @c false to break out of the loop
+ * @see #media_format_mimetype_e
+ * @see player_audio_offload_foreach_supported_format()
+ */
+typedef bool (*player_supported_media_format_cb)(media_format_mimetype_e format, void *user_data);
+
+/**
  * @}
  */
 
@@ -721,7 +733,9 @@ int player_set_sound_stream_info(player_h player, sound_stream_info_h stream_inf
  *          To get the current audio latency mode, use player_get_audio_latency_mode().
  *          If it's high mode, audio output interval can be increased so, it can keep more audio data to play.
  *          But, state transition like pause or resume can be more slower than default(mid) mode.
- *
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION and
+ *          this will not work at all even if it was called before enabling offload. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[in] latency_mode The latency mode to be applied to the audio
  * @return @c 0 on success,
@@ -731,12 +745,15 @@ int player_set_sound_stream_info(player_h player, sound_stream_info_h stream_inf
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @see #audio_latency_mode_e
  * @see player_get_audio_latency_mode()
+ * @see player_audio_offload_set_enabled()
  */
 int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_mode);
 
 /**
  * @brief Gets the current audio latency mode.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[out] latency_mode The latency mode to get from the audio
  * @return @c 0 on success,
@@ -746,6 +763,7 @@ int player_set_audio_latency_mode(player_h player, audio_latency_mode_e latency_
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @see #audio_latency_mode_e
  * @see player_set_audio_latency_mode()
+ * @see player_audio_offload_set_enabled()
  */
 int player_get_audio_latency_mode(player_h player, audio_latency_mode_e *latency_mode);
 
@@ -1072,6 +1090,9 @@ int player_unset_media_packet_video_frame_decoded_cb(player_h player);
  *          and it is available until it's destroyed by media_packet_destroy().\n
  *          The packet has to be destroyed as quickly as possible after rendering the data\n
  *          and all the packets have to be destroyed before player_unprepare() is called.\n
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION and
+ *          this will not work at all even if it was called before enabling offload. (Since 5.5)
  * @param[in] player     The handle to the media player
  * @param[in] format     The media format handle about required audio PCM specification.
  *                       This format has to include PCM MIME type, audio channel and sampling rate.
@@ -1087,6 +1108,7 @@ int player_unset_media_packet_video_frame_decoded_cb(player_h player);
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @pre The player's state must be #PLAYER_STATE_IDLE.
  * @see player_unset_media_packet_audio_frame_decoded_cb()
+ * @see player_audio_offload_set_enabled()
  * @par Example
    @code
       #include <player.h>
@@ -1611,21 +1633,28 @@ int player_get_duration_nsec(player_h player, int64_t *nanoseconds);
 /**
  * @brief Gets the number of equalizer bands.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[out] count The number of equalizer bands
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #PLAYER_ERROR_NONE Successful
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation (Since 5.5)
  * @see player_audio_effect_equalizer_is_available()
  * @see player_audio_effect_set_equalizer_band_level()
  * @see player_audio_effect_set_equalizer_all_bands()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_get_equalizer_bands_count(player_h player, int *count);
 
 /**
  * @brief Sets the gain set for the given equalizer band.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION and
+ *          this will not work at all even if it was called before enabling offload. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[in] index The index of the equalizer band to be set
  * @param[in] level The new gain in decibel that is set to the given band [dB]
@@ -1639,12 +1668,15 @@ int player_audio_effect_get_equalizer_bands_count(player_h player, int *count);
  * @see player_audio_effect_get_equalizer_level_range()
  * @see player_audio_effect_get_equalizer_band_level()
  * @see player_audio_effect_set_equalizer_all_bands()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_set_equalizer_band_level(player_h player, int index, int level);
 
 /**
  * @brief Gets the gain set for the given equalizer band.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in]   player The handle to the media player
  * @param[in]   index The index of the requested equalizer band
  * @param[out]   level The gain in decibel of the given band [dB]
@@ -1652,14 +1684,19 @@ int player_audio_effect_set_equalizer_band_level(player_h player, int index, int
  *         otherwise a negative error value
  * @retval #PLAYER_ERROR_NONE Successful
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation (Since 5.5)
  * @see player_audio_effect_equalizer_is_available()
  * @see player_audio_effect_set_equalizer_band_level()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_get_equalizer_band_level(player_h player, int index, int *level);
 
 /**
  * @brief Sets all bands of the equalizer.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION and
+ *          this will not work at all even if it was called before enabling offload. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[in] band_levels The list of band levels to be set
  * @param[in] length The length of the band level
@@ -1672,12 +1709,15 @@ int player_audio_effect_get_equalizer_band_level(player_h player, int index, int
  * @see player_audio_effect_get_equalizer_bands_count()
  * @see player_audio_effect_get_equalizer_level_range()
  * @see player_audio_effect_set_equalizer_band_level()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_levels, int length);
 
 /**
  * @brief Gets the valid band level range of the equalizer.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[out] min The minimum value to be set [dB]
  * @param[out] max The maximum value to be set [dB]
@@ -1689,12 +1729,15 @@ int player_audio_effect_set_equalizer_all_bands(player_h player, int *band_level
  * @see player_audio_effect_equalizer_is_available()
  * @see player_audio_effect_set_equalizer_band_level()
  * @see player_audio_effect_set_equalizer_all_bands()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_get_equalizer_level_range(player_h player, int *min, int *max);
 
 /**
  * @brief Gets the band frequency of the equalizer.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[in]  index The index of the requested equalizer band
  * @param[out] frequency The frequency of the given band [dB]
@@ -1702,13 +1745,17 @@ int player_audio_effect_get_equalizer_level_range(player_h player, int *min, int
  *         otherwise a negative error value
  * @retval #PLAYER_ERROR_NONE Successful
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation (Since 5.5)
  * @see player_audio_effect_equalizer_is_available()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_get_equalizer_band_frequency(player_h player, int index, int *frequency);
 
 /**
  * @brief Gets the band frequency range of the equalizer.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[in]  index The index of the requested equalizer band
  * @param[out] range The frequency range of the given band [dB]
@@ -1716,13 +1763,17 @@ int player_audio_effect_get_equalizer_band_frequency(player_h player, int index,
  *         otherwise a negative error value
  * @retval #PLAYER_ERROR_NONE Successful
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation (Since 5.5)
  * @see player_audio_effect_equalizer_is_available()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int index, int *range);
 
 /**
  * @brief Clears the equalizer effect.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player The handle to the media player
  * @return @c 0 on success,
  *         otherwise a negative error value
@@ -1732,12 +1783,15 @@ int player_audio_effect_get_equalizer_band_frequency_range(player_h player, int
  * @see player_audio_effect_equalizer_is_available()
  * @see player_audio_effect_set_equalizer_band_level()
  * @see player_audio_effect_set_equalizer_all_bands()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_equalizer_clear(player_h player);
 
 /**
  * @brief Checks whether the custom equalizer effect is available.
  * @since_tizen @if WEARABLE 2.3.1 @else 2.3 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[out] available If @c true the specified audio effect is available,
  *                       otherwise @c false
@@ -1745,8 +1799,10 @@ int player_audio_effect_equalizer_clear(player_h player);
  *         otherwise a negative error value
  * @retval #PLAYER_ERROR_NONE Successful
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation (Since 5.5)
  * @see player_audio_effect_set_equalizer_band_level()
  * @see player_audio_effect_set_equalizer_all_bands()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_effect_equalizer_is_available(player_h player, bool *available);
 
@@ -2003,6 +2059,8 @@ int player_unset_buffering_cb(player_h player);
  * @remarks #PLAYER_ERROR_INVALID_OPERATION occurs when streaming playback.
  * @remarks No operation is performed, if @a rate is @c 0.
  * @remarks The sound is muted, when playback rate is under @c 0.0 and over @c 2.0.
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player   The handle to the media player
  * @param[in] rate     The playback rate (-5.0x ~ 5.0x)
  * @return @c 0 on success,
@@ -2012,6 +2070,7 @@ int player_unset_buffering_cb(player_h player);
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
  * @pre The player state must be one of #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED.
+ * @see player_audio_offload_set_enabled()
  */
 int player_set_playback_rate(player_h player, float rate);
 
@@ -2152,6 +2211,8 @@ int player_unset_video_stream_changed_cb(player_h player);
  * @brief Gets current track index.
  * @details Index starts from 0.
  * @since_tizen @if WEARABLE 3.0 @else 2.4 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in]  player   The handle to the media player
  * @param[in]  type     The type of target stream which is #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_TEXT
  * @param[out] index    The index of track
@@ -2162,6 +2223,7 @@ int player_unset_video_stream_changed_cb(player_h player);
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
  * @pre The player state must be one of #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ * @see player_audio_offload_set_enabled()
  */
 int player_get_current_track(player_h player, player_stream_type_e type, int *index);
 
@@ -2169,6 +2231,8 @@ int player_get_current_track(player_h player, player_stream_type_e type, int *in
  * @brief Gets language code of a track.
  * @since_tizen @if WEARABLE 3.0 @else 2.4 @endif
  * @remarks @a code must be released with @c free() by caller
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player   The handle to the media player
  * @param[in] type     The type of target stream which is #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_TEXT
  * @param[in] index    The index of track
@@ -2180,12 +2244,15 @@ int player_get_current_track(player_h player, player_stream_type_e type, int *in
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
  * @pre The player state must be one of #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ * @see player_audio_offload_set_enabled()
  */
 int player_get_track_language_code(player_h player, player_stream_type_e type, int index, char **code);
 
 /**
  * @brief Gets the track count.
  * @since_tizen @if WEARABLE 3.0 @else 2.4 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player   The handle to the media player
  * @param[in] type     The type of target stream which is #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_TEXT
  * @param[out] count The number of track
@@ -2196,12 +2263,15 @@ int player_get_track_language_code(player_h player, player_stream_type_e type, i
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
  * @pre The player state must be one of #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ * @see player_audio_offload_set_enabled()
  */
 int player_get_track_count(player_h player, player_stream_type_e type, int *count);
 
 /**
  * @brief Selects a track to play.
  * @since_tizen @if WEARABLE 3.0 @else 2.4 @endif
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in] player   The handle to the media player
  * @param[in] type     The type of target stream which is #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_TEXT
  * @param[in] index    The index of track
@@ -2213,6 +2283,7 @@ int player_get_track_count(player_h player, player_stream_type_e type, int *coun
  * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
  * @pre The player state must be one of #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
  * @see player_get_current_track()
+ * @see player_audio_offload_set_enabled()
  */
 int player_select_track(player_h player, player_stream_type_e type, int index);
 
@@ -2327,6 +2398,9 @@ int player_is_audio_only(player_h player, bool *audio_only);
  * @details If the replaygain status is @c true, replaygain is applied (if contents has a replaygain tag).
  *          If it is @c false, the replaygain isn't affected by tag and properties.
  * @since_tizen 5.0
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION and
+ *          this will not work at all even if it was called before enabling offload. (Since 5.5)
  * @param[in]   player The handle to the media player
  * @param[in]   enabled The new replaygain status: (@c true = enable, @c false = disable)
  * @return @c 0 on success,
@@ -2335,12 +2409,15 @@ int player_is_audio_only(player_h player, bool *audio_only);
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @see player_is_replaygain_enabled()
+ * @see player_audio_offload_set_enabled()
  */
 int player_set_replaygain_enabled(player_h player, bool enabled);
 
 /**
  * @brief Gets the player's replaygain status.
  * @since_tizen 5.0
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in]   player    The handle to the media player
  * @param[out]  enabled   Pointer to store current replaygain status:
  *                        (@c true = enabled replaygain,
@@ -2351,6 +2428,7 @@ int player_set_replaygain_enabled(player_h player, bool enabled);
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @see player_set_replaygain_enabled()
+ * @see player_audio_offload_set_enabled()
  */
 int player_is_replaygain_enabled(player_h player, bool *enabled);
 
@@ -2426,6 +2504,9 @@ int player_get_video_roi_area(player_h player, double *x_scale, double *y_scale,
  * @since_tizen 5.5
  * @remarks This function is used for audio content only.
  * @remarks Enabling pitch control could increase the CPU usage on some devices.
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION and
+ *          this will not work at all even if it was called before enabling offload. (Since 5.5)
  * @param[in] player   The handle to the media player
  * @param[in] enabled  The new audio pitch control status (default: false)
  * @return @c 0 on success,
@@ -2438,6 +2519,7 @@ int player_get_video_roi_area(player_h player, double *x_scale, double *y_scale,
  * @see player_audio_pitch_is_enabled()
  * @see player_audio_pitch_set_value()
  * @see player_audio_pitch_get_value()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_pitch_set_enabled(player_h player, bool enabled);
 
@@ -2445,6 +2527,8 @@ int player_audio_pitch_set_enabled(player_h player, bool enabled);
  * @brief Gets the status of controlling the pitch of audio.
  * @since_tizen 5.5
  * @remarks This function is used for audio content only.
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in]   player   The handle to the media player
  * @param[out]  enabled  The audio pitch control status (default: false)
  * @return @c 0 on success,
@@ -2455,6 +2539,7 @@ int player_audio_pitch_set_enabled(player_h player, bool enabled);
  * @see player_audio_pitch_set_enabled()
  * @see player_audio_pitch_set_value()
  * @see player_audio_pitch_get_value()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_pitch_is_enabled(player_h player, bool *enabled);
 
@@ -2462,6 +2547,9 @@ int player_audio_pitch_is_enabled(player_h player, bool *enabled);
  * @brief Sets the pitch of audio.
  * @since_tizen 5.5
  * @remarks This function is used for audio content only.
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION and
+ *          this will not work at all even if it was called before enabling offload. (Since 5.5)
  * @param[in] player The handle to the media player
  * @param[in] value  The audio stream pitch value  \n
  *                   Valid range is 0.5~2. Default value is 1.
@@ -2474,6 +2562,7 @@ int player_audio_pitch_is_enabled(player_h player, bool *enabled);
  * @see player_audio_pitch_set_enabled()
  * @see player_audio_pitch_is_enabled()
  * @see player_audio_pitch_get_value()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_pitch_set_value(player_h player, float value);
 
@@ -2481,6 +2570,8 @@ int player_audio_pitch_set_value(player_h player, float value);
  * @brief Gets the pitch of audio.
  * @since_tizen 5.5
  * @remarks This function is used for audio content only.
+ * @remarks If audio offload is enabled by calling player_audio_offload_set_enabled(),
+ *          this function will return #PLAYER_ERROR_INVALID_OPERATION. (Since 5.5)
  * @param[in]  player The handle to the media player
  * @param[out] value  The audio stream pitch value \n
  *                    Valid range is 0.5~2. Default value is 1.
@@ -2492,10 +2583,127 @@ int player_audio_pitch_set_value(player_h player, float value);
  * @see player_audio_pitch_set_enabled()
  * @see player_audio_pitch_is_enabled()
  * @see player_audio_pitch_set_value()
+ * @see player_audio_offload_set_enabled()
  */
 int player_audio_pitch_get_value(player_h player, float *value);
 
 /**
+ * @brief Retrieves all supported media formats for audio offload.
+ * @details The supported media format can vary depending on the device capabilities.
+ * @since_tizen 5.5
+ * @remarks This function is related to the following feature:\n
+ *          %http://tizen.org/feature/multimedia.player.audio_offload\n
+ * @param[in] player      The handle to the media player
+ * @param[in] callback    The iteration callback function
+ * @param[in] user_data   The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @see player_supported_media_format_cb()
+ * @see player_audio_offload_set_enabled()
+ * @see player_audio_offload_is_enabled()
+ * @see player_audio_offload_is_activated()
+ */
+int player_audio_offload_foreach_supported_format(player_h player, player_supported_media_format_cb callback, void *user_data);
+
+/**
+ * @brief Enables or disables the audio offload.
+ * @details The player lets the hardware decode and render the sound if the audio offload is enabled.
+ *          This will reduce the power consumption, but will disable the ability to handle output PCM.
+ *          Please check the remarks for a list of functions which will not work if offloading is enabled.
+ * @since_tizen 5.5
+ * @remarks This function is related to the following feature:\n
+ *          %http://tizen.org/feature/multimedia.player.audio_offload\n
+ *          The sound stream type of the player should be #SOUND_STREAM_TYPE_MEDIA.\n
+ *          If audio offload is enabled, the following functions will return #PLAYER_ERROR_INVALID_OPERATION
+ *          and they will not work at all even if they were called before enabling offload. :\n
+ *          player_audio_effect_get_equalizer_bands_count()\n
+ *          player_audio_effect_set_equalizer_band_level()\n
+ *          player_audio_effect_get_equalizer_band_level()\n
+ *          player_audio_effect_set_equalizer_all_bands()\n
+ *          player_audio_effect_get_equalizer_level_range()\n
+ *          player_audio_effect_get_equalizer_band_frequency()\n
+ *          player_audio_effect_get_equalizer_band_frequency_range()\n
+ *          player_audio_effect_equalizer_clear()\n
+ *          player_audio_effect_equalizer_is_available()\n
+ *          player_set_media_packet_audio_frame_decoded_cb()\n
+ *          player_set_audio_latency_mode()\n
+ *          player_get_audio_latency_mode()\n
+ *          player_set_playback_rate()\n
+ *          player_get_current_track()\n
+ *          player_get_track_language_code()\n
+ *          player_get_track_count()\n
+ *          player_select_track()\n
+ *          player_set_replaygain_enabled()\n
+ *          player_is_replaygain_enabled()\n
+ *          player_audio_pitch_set_enabled()\n
+ *          player_audio_pitch_is_enabled()\n
+ *          player_audio_pitch_set_value()\n
+ *          player_audio_pitch_get_value()\n
+ * @param[in] player   The handle to the media player
+ * @param[in] enabled  The new audio offload status (default: false)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @pre The player state must be #PLAYER_STATE_IDLE.
+ * @see player_set_sound_stream_info()
+ * @see player_set_interrupted_cb()
+ * @see player_audio_offload_foreach_supported_format()
+ * @see player_audio_offload_is_enabled()
+ * @see player_audio_offload_is_activated()
+ */
+int player_audio_offload_set_enabled(player_h player, bool enabled);
+
+/**
+ * @brief Gets the enabling status of audio offload.
+ * @since_tizen 5.5
+ * @remarks This function is related to the following feature:\n
+ *          %http://tizen.org/feature/multimedia.player.audio_offload\n
+ * @param[in]   player   The handle to the media player
+ * @param[out]  enabled  The enabling status (default: false)
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @see player_audio_offload_foreach_supported_format()
+ * @see player_audio_offload_set_enabled()
+ * @see player_audio_offload_is_activated()
+ */
+int player_audio_offload_is_enabled(player_h player, bool *enabled);
+
+/**
+ * @brief Gets the activation status of audio offload.
+ * @details Audio offload could be inactivated depending on the
+ *          audio device capability even if the audio offload feature is supported.
+ * @since_tizen 5.5
+ * @remarks This function is related to the following feature:\n
+ *          %http://tizen.org/feature/multimedia.player.audio_offload\n
+ * @param[in]   player     The handle to the media player
+ * @param[out]  activated  The activation status
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid state
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
+ * @pre The player state must be one of #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED
+ * @see player_audio_offload_foreach_supported_format()
+ * @see player_audio_offload_set_enabled()
+ * @see player_audio_offload_is_enabled()
+ */
+int player_audio_offload_is_activated(player_h player, bool *activated);
+
+/**
  * @}
  */
 
index 44ae873..6031c49 100644 (file)
@@ -86,6 +86,7 @@ do { \
 #define CALLBACK_TIME_OUT 5000 /* ms */
 #define MAX_SERVER_TIME_OUT 35000 /* ms */
 #define MAX_URL_LEN    2048    /**< Maximum length of the maximum URL */
+#define MAX_SUPPORTED_MEDIA_FORMAT 10
 
 /**
  * @brief Enumeration for private display type
index c5c5801..c1ade03 100644 (file)
@@ -46,6 +46,7 @@
 #define PLAYER_FEATURE_SOUND_STREAM      "http://tizen.org/feature/multimedia.player.stream_info"
 #define PLAYER_FEATURE_OPENGL            "http://tizen.org/feature/opengles.version.2_0"
 #define PLAYER_FEATURE_SPHERICAL_VIDEO   "http://tizen.org/feature/multimedia.player.spherical_video"
+#define PLAYER_FEATURE_AUDIO_OFFLOAD     "http://tizen.org/feature/multimedia.player.audio_offload"
 #ifndef M_PI
 #define M_PI  3.14159265358979323846
 #endif
@@ -509,7 +510,7 @@ static int __set_callback(muse_player_event_e type, player_h player, void *callb
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(callback);
 
-       if (MUSE_PLAYER_EVENT_TYPE_BUFFERING == type) {
+       if (type == MUSE_PLAYER_EVENT_TYPE_BUFFERING) {
                if (!_player_check_network_availability())
                        return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
        }
@@ -1278,7 +1279,7 @@ static void __video_stream_changed_cb_handler(callback_cb_info_s *cb_info, _play
 }
 
 static void (*_user_callbacks[MUSE_PLAYER_EVENT_TYPE_NUM])(callback_cb_info_s *cb_info, _player_recv_data *recv_data) = {
-       __prepare_cb_handler,           /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
+       __prepare_cb_handler,   /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
        __complete_cb_handler,  /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
        __interrupt_cb_handler, /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
        __error_cb_handler,             /* MUSE_PLAYER_EVENT_TYPE_ERROR */
@@ -5385,3 +5386,102 @@ int player_audio_pitch_get_value(player_h player, float *value)
        LOGD("LEAVE 0x%X", ret);
        return ret;
 }
+
+int player_audio_offload_foreach_supported_format(player_h player, player_supported_media_format_cb callback, void *user_data)
+{
+       int ret = PLAYER_ERROR_NONE;
+       player_cli_s *pc = (player_cli_s *)player;
+       muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_GET_SUPPORTED_FORMAT;
+       char *ret_buf = NULL;
+       int format_info[MAX_SUPPORTED_MEDIA_FORMAT] = {0,};
+       int len = 0, idx = 0;
+
+       PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(callback);
+
+       LOGD("ENTER");
+
+       PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+
+       player_msg_get_type(len, ret_buf, INT);
+       player_msg_get_array(format_info, ret_buf);
+
+       LOGD("num of format %d", len);
+       for (idx = 0 ; idx < len ; idx++) {
+               if (!callback(format_info[idx], user_data)) {
+                       LOGW("stop foreach callback");
+                       break;
+               }
+       }
+
+       LOGD("LEAVE 0x%X", ret);
+       g_free(ret_buf);
+       return ret;
+}
+
+int player_audio_offload_set_enabled(player_h player, bool enabled)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_SET_ENABLED;
+       player_cli_s *pc = (player_cli_s *)player;
+       char *ret_buf = NULL;
+       int val = (int)enabled;
+
+       PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+       PLAYER_INSTANCE_CHECK(player);
+
+       LOGD("ENTER");
+
+       PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "val", val);
+       g_free(ret_buf);
+       return ret;
+}
+
+int player_audio_offload_is_enabled(player_h player, bool *enabled)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_IS_ENABLED;
+       player_cli_s *pc = (player_cli_s *)player;
+       char *ret_buf = NULL;
+       int val = -1;
+
+       PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(enabled);
+
+       LOGD("ENTER");
+
+       PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+       if (ret == PLAYER_ERROR_NONE) {
+               player_msg_get(val, ret_buf);
+               *enabled = (bool)val;
+       }
+
+       g_free(ret_buf);
+       return ret;
+}
+
+int player_audio_offload_is_activated(player_h player, bool *activated)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_IS_ACTIVATED;
+       player_cli_s *pc = (player_cli_s *)player;
+       char *ret_buf = NULL;
+       int val = -1;
+
+       PLAYER_FEATURE_CHECK(PLAYER_FEATURE_AUDIO_OFFLOAD);
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(activated);
+
+       LOGD("ENTER");
+
+       PLAYER_SEND_MSG(api, pc, ret_buf, ret);
+       if (ret == PLAYER_ERROR_NONE) {
+               player_msg_get(val, ret_buf);
+               *activated = (bool)val;
+       }
+
+       g_free(ret_buf);
+       return ret;
+}
index c3ad8ed..62061aa 100644 (file)
@@ -437,41 +437,3 @@ int player_get_codec_type(player_h player, player_stream_type_e stream_type, pla
        LOGD("LEAVE");
        return ret;
 }
-
-int player_set_audio_offload_enabled(player_h player, bool enabled)
-{
-       PLAYER_INSTANCE_CHECK(player);
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_SET_ENABLED;
-       player_cli_s *pc = (player_cli_s *)player;
-       char *ret_buf = NULL;
-       int val = (int)enabled;
-
-       LOGD("ENTER");
-
-       PLAYER_SEND_MSG(api, pc, ret_buf, ret, MUSE_TYPE_INT, "val", val);
-       g_free(ret_buf);
-       return ret;
-}
-
-int player_is_audio_offload_enabled(player_h player, bool *enabled)
-{
-       PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(enabled);
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_AUDIO_OFFLOAD_IS_ENABLED;
-       player_cli_s *pc = (player_cli_s *)player;
-       char *ret_buf = NULL;
-       int val = -1;
-
-       LOGD("ENTER");
-
-       PLAYER_SEND_MSG(api, pc, ret_buf, ret);
-       if (ret == PLAYER_ERROR_NONE) {
-               player_msg_get(val, ret_buf);
-               *enabled = (bool)val;
-       }
-
-       g_free(ret_buf);
-       return ret;
-}
index 3f2eb64..dea9327 100644 (file)
@@ -64,9 +64,6 @@ typedef struct {
        FILE *fp_out;
 } audio_pcm_dump_t;
 
-extern int player_set_audio_offload_enabled(player_h player, bool enabled);
-extern int player_is_audio_offload_enabled(player_h player, bool *enabled);
-
 #ifdef USE_EVENT_HANDLER
 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void *data, float e[3]);
 static void event_handler_set_dov_fov();
@@ -2203,14 +2200,21 @@ static void is_replaygain_enabled(bool *enable)
        g_print("                                                            ==> [Player_Test] replaygain = %d\n", *enable);
 }
 
+static void _supported_media_format_cb(media_format_mimetype_e format, void *user_data)
+{
+       g_print("- supported format mimetype 0x%X\n", format);
+}
+
 static void set_audio_offload_enabled(bool enabled)
 {
        bool is_enabled = false;
 
-       player_is_audio_offload_enabled(g_player[0], &is_enabled);
+       player_audio_offload_is_enabled(g_player[0], &is_enabled);
        g_print("[Player_Test] offload setting %d -> %d\n", is_enabled, enabled);
 
-       if (player_set_audio_offload_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
+       player_audio_offload_foreach_supported_format(g_player[0], _supported_media_format_cb, (void *)g_player[0]);
+
+       if (player_audio_offload_set_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
                g_print("failed to set audio offload\n");
 }