case MM_ERROR_PLAYER_INVALID_STREAM:
case MM_ERROR_PLAYER_STREAMING_FAIL:
case MM_ERROR_PLAYER_NO_OP:
+ case MM_ERROR_NOT_SUPPORT_API:
ret = PLAYER_ERROR_INVALID_OPERATION;
msg = "PLAYER_ERROR_INVALID_OPERATION";
break;
case MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS:
- case MM_ERROR_NOT_SUPPORT_API:
case MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER:
- ret = PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
- msg = "PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE";
+ ret = PLAYER_ERROR_NOT_AVAILABLE;
+ msg = "PLAYER_ERROR_NOT_AVAILABLE";
break;
case MM_ERROR_PLAYER_NO_FREE_SPACE:
ret = PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE;
return PLAYER_ERROR_NONE;
}
+static bool __lplayer_is_offload_precondition_valid(legacy_player_h player)
+{
+ legacy_player_t *handle = (legacy_player_t *)player;
+ int ret = MM_ERROR_NONE;
+ int enabled = 0;
+
+ ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, &enabled, (char *)NULL);
+ if (ret != MM_ERROR_NONE) {
+ LOGE("failed to get offload status 0x%X", ret);
+ return false;
+ }
+
+ LOGD("offload status %d", enabled);
+ return (enabled) ? (false) : (true);
+}
+
+static bool __lplayer_is_audio_control_available(legacy_player_h player, mmplayer_audio_control_opt_e opt)
+{
+ int ret = MM_ERROR_NONE;
+ legacy_player_t *handle = (legacy_player_t *)player;
+ bool available = false;
+
+ LOGD("opt %d", opt);
+ if (!__lplayer_is_offload_precondition_valid(player))
+ return false;
+
+ ret = mm_player_is_audio_control_available(handle->mm_handle, opt, &available);
+ if (ret != MM_ERROR_NONE || !available) {
+ LOGW("available %d, ret 0x%X", available, ret);
+ return false;
+ }
+
+ return true;
+}
+
static int
-__lplayer_set_buffer_export_callback(legacy_player_t *handle)
+__lplayer_set_buffer_export_callback(legacy_player_h player)
{
int ret = MM_ERROR_NONE;
+ legacy_player_t *handle = (legacy_player_t *)player;
legacy_player_callback_type_e video_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_VIDEO_FRAME;
legacy_player_callback_type_e audio_type = LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_AUDIO_FRAME;
(mm_player_video_decoded_callback)handle->user_cb[video_type],
handle->user_data[video_type]);
- if (handle->user_cb[audio_type])
+ if (handle->user_cb[audio_type]) {
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_PCM_EXPORTING)) {
+ LOGW("HW audio path will be setup. exporting audio data is not available");
+ handle->user_cb[audio_type] = NULL;
+ handle->user_data[audio_type] = NULL;
+ return MM_ERROR_NONE;
+ }
+
ret = mm_player_set_audio_decoded_callback(handle->mm_handle, handle->pcm_extract_opt,
(mm_player_audio_decoded_callback)handle->user_cb[audio_type],
handle->user_data[audio_type]);
+ }
return ret;
}
return NULL;
}
-static bool __lplayer_is_offload_precondition_valid(legacy_player_h player)
-{
- int ret = MM_ERROR_NONE;
- int enabled = 0;
- legacy_player_t *handle = (legacy_player_t *)player;
-
- ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_AUDIO_OFFLOAD, &enabled, (char *)NULL);
- if (ret != MM_ERROR_NONE) {
- LOGE("failed to get offload status 0x%X", ret);
- return false;
- }
-
- LOGD("offload status %d", enabled);
- return (enabled) ? (false) : (true);
-}
-
/*
* Public Implementation
*/
goto ERROR;
}
- mm_ret = __lplayer_set_buffer_export_callback(handle);
+ mm_ret = __lplayer_set_buffer_export_callback(player);
if (mm_ret != MM_ERROR_NONE) {
LOGE("failed to set buffer export callback function (0x%x)", mm_ret);
goto ERROR;
if (ret != MM_ERROR_NONE)
LOGW("Failed to set message callback function (0x%x)", ret);
- ret = __lplayer_set_buffer_export_callback(handle);
+ ret = __lplayer_set_buffer_export_callback(player);
if (ret != MM_ERROR_NONE) {
LOGW("Failed to set buffer export callback function (0x%x)", ret);
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ return PLAYER_ERROR_NOT_AVAILABLE;
ret = mm_player_set_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL);
if (ret != MM_ERROR_NONE)
PLAYER_NULL_ARG_CHECK(latency_mode);
if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ return PLAYER_ERROR_NOT_AVAILABLE;
ret = mm_player_get_attribute(handle->mm_handle, NULL, "sound_latency_mode", latency_mode, (char *)NULL);
if (ret != MM_ERROR_NONE)
PLAYER_CHECK_CONDITION(rate >= -5.0 && rate <= 5.0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_READY)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(count);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
ret = mm_player_audio_effect_custom_get_eq_bands_number(handle->mm_handle, count);
if (ret != MM_ERROR_NONE)
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(band_levels);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
ret = mm_player_audio_effect_custom_set_level_eq_from_list(handle->mm_handle, band_levels, length);
if (ret != MM_ERROR_NONE)
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
ret = mm_player_audio_effect_custom_set_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level);
if (ret != MM_ERROR_NONE)
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(level);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
ret = mm_player_audio_effect_custom_get_level(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, index, level);
if (ret != MM_ERROR_NONE)
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(min && max);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
ret = mm_player_audio_effect_custom_get_level_range(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, min, max);
if (ret != MM_ERROR_NONE)
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(frequency);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
ret = mm_player_audio_effect_custom_get_eq_bands_freq(handle->mm_handle, index, frequency);
if (ret != MM_ERROR_NONE)
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(range);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
ret = mm_player_audio_effect_custom_get_eq_bands_width(handle->mm_handle, index, range);
if (ret != MM_ERROR_NONE)
return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
{
legacy_player_t *handle = (legacy_player_t *)player;
int ret = MM_ERROR_NONE;
+ bool available = false;
PLAYER_INSTANCE_CHECK(player);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ ret = mm_player_is_available_custom_effect(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, &available);
+ if (ret != MM_ERROR_NONE || available == false)
+ return PLAYER_ERROR_NOT_AVAILABLE;
ret = mm_player_audio_effect_custom_clear_eq_all(handle->mm_handle);
if (ret != MM_ERROR_NONE)
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(available);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
-
if (!_lplayer_state_validate(handle, PLAYER_STATE_IDLE)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
return PLAYER_ERROR_INVALID_STATE;
}
- ret = mm_player_is_supported_custom_effect_type(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ);
+ /* checked in mm function about audio offload status, filter valid status, etc */
+ ret = mm_player_is_available_custom_effect(handle->mm_handle, MM_AUDIO_EFFECT_CUSTOM_EQ, available);
if (ret != MM_ERROR_NONE)
*available = false;
- else
- *available = true;
+
+ LOGD("audio effect is availeble %d", *available);
return PLAYER_ERROR_NONE;
}
return ret;
}
+ if (type == LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_AUDIO_FRAME) {
+ if (!__lplayer_is_audio_control_available(player,
+ MM_PLAYER_AUDIO_CONTROL_OPT_PCM_EXPORTING))
+ return PLAYER_ERROR_NOT_AVAILABLE;
+ }
+
L_PLAYER_USER_CB_LOCK(player, type);
handle->user_cb[type] = NULL;
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(callback);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_PCM_EXPORTING))
+ return PLAYER_ERROR_NOT_AVAILABLE;
PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
LOGW("Invalid audio format information (%s, %d, %d)", audio_pcm_format, samplerate, channel);
}
- ret = mm_player_set_audio_decoded_callback(handle->mm_handle,
- (mmplayer_audio_extract_opt_e)opt, (mm_player_audio_decoded_callback)callback, user_data);
- if (ret != MM_ERROR_NONE)
- return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+ handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_AUDIO_FRAME] = callback;
+ handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_MEDIA_PACKET_AUDIO_FRAME] = user_data;
+ handle->pcm_extract_opt = opt;
return PLAYER_ERROR_NONE;
}
PLAYER_NULL_ARG_CHECK(count);
if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_READY)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_NULL_ARG_CHECK(index);
if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_READY)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_CHECK_CONDITION(index >= 0, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_READY)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_NULL_ARG_CHECK(code && len);
if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_READY)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_INSTANCE_CHECK(player);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_REPLAYGAIN))
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_IDLE)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(enabled);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_REPLAYGAIN))
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_IDLE)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_INSTANCE_CHECK(player);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_PITCH))
+ return PLAYER_ERROR_NOT_AVAILABLE;
PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(enabled);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_PITCH))
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_IDLE)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_INSTANCE_CHECK(player);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_PITCH))
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_IDLE)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(pitch);
- if (!__lplayer_is_offload_precondition_valid(player))
- return PLAYER_ERROR_INVALID_OPERATION;
+ if (!__lplayer_is_audio_control_available(player, MM_PLAYER_AUDIO_CONTROL_OPT_PITCH))
+ return PLAYER_ERROR_NOT_AVAILABLE;
if (!_lplayer_state_validate(handle, PLAYER_STATE_IDLE)) {
LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
return PLAYER_ERROR_NONE;
}
+
+int legacy_player_set_codec_type(legacy_player_h player, player_stream_type_e stream_type, player_codec_type_ex_e codec_type)
+{
+ legacy_player_t *handle = (legacy_player_t *)player;
+ int ret = MM_ERROR_NONE;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_CHECK_CONDITION((stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO),
+ PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+ PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+ LOGI("stream %d, codec %d", stream_type, codec_type);
+ ret = mm_player_set_codec_type(handle->mm_handle, stream_type, codec_type);
+ if (ret == MM_ERROR_PLAYER_NO_OP) {
+ if (stream_type == PLAYER_STREAM_TYPE_AUDIO)
+ return PLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC;
+ else
+ return PLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC;
+ } else if (ret != MM_ERROR_NONE) {
+ return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+ }
+
+ return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_get_codec_type(legacy_player_h player, player_stream_type_e stream_type, player_codec_type_ex_e *codec_type)
+{
+ legacy_player_t *handle = (legacy_player_t *)player;
+ int ret = MM_ERROR_NONE;
+ const char *attr_name;
+ PLAYER_INSTANCE_CHECK(player);
+ PLAYER_NULL_ARG_CHECK(codec_type);
+ PLAYER_CHECK_CONDITION((stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO),
+ PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+ attr_name = (stream_type == PLAYER_STREAM_TYPE_AUDIO) ? (MM_PLAYER_AUDIO_CODEC_TYPE) : (MM_PLAYER_VIDEO_CODEC_TYPE);
+
+ ret = mm_player_get_attribute(handle->mm_handle, NULL, attr_name, codec_type, (char *)NULL);
+ if (ret != MM_ERROR_NONE)
+ return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+
+ LOGD("stream %d, codec %d", stream_type, *codec_type);
+ return PLAYER_ERROR_NONE;
+}