static gboolean __gst_send_event_to_sink(mm_player_t* player, GstEvent* event);
-static int __mmplayer_set_pcm_extraction(mm_player_t* player);
static gboolean __mmplayer_can_extract_pcm(mm_player_t* player);
/* util */
/* this function sets the player state and also report
* it to applicaton by calling callback function
*/
-int
+void
__mmplayer_set_state(mm_player_t* player, int state)
{
MMMessageParamType msg = {0, };
gboolean post_bos = FALSE;
- MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
+ MMPLAYER_RETURN_IF_FAIL(player);
if (MMPLAYER_CURRENT_STATE(player) == state) {
LOGW("already same state(%s)\n", MMPLAYER_STATE_GET_NAME(state));
MMPLAYER_PENDING_STATE(player) = MM_PLAYER_STATE_NONE;
- return MM_ERROR_NONE;
+ return;
}
/* update player states */
/* state changed by resource callback */
if (player->interrupted_by_resource) {
- msg.state.code = MM_PLAYER_FOCUS_CHANGED_BY_RESOURCE_CONFLICT;
- MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, &msg);
+ MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, NULL);
} else { /* state changed by usecase */
MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_CHANGED, &msg);
}
} else {
LOGD("intermediate state, do nothing.\n");
MMPLAYER_PRINT_STATE(player);
- return MM_ERROR_NONE;
+ return;
}
if (post_bos) {
player->sent_bos = TRUE;
}
- return MM_ERROR_NONE;
+ return;
}
static gpointer __mmplayer_next_play_thread(gpointer data)
static int __gst_start(mm_player_t* player)
{
- gboolean sound_extraction = 0;
int ret = MM_ERROR_NONE;
gboolean async = FALSE;
MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
- /* get sound_extraction property */
- mm_attrs_get_int_by_name(player->attrs, "pcm_extraction", &sound_extraction);
-
/* NOTE : if SetPosition was called before Start. do it now */
/* streaming doesn't support it. so it should be always sync */
/* !!create one more api to check if there is pending seek rather than checking variables */
- if ((player->pending_seek.is_pending || sound_extraction) && !MMPLAYER_IS_STREAMING(player)) {
+ if (player->pending_seek.is_pending && !MMPLAYER_IS_STREAMING(player)) {
MMPLAYER_TARGET_STATE(player) = MM_PLAYER_STATE_PAUSED;
ret = __gst_pause(player, FALSE);
if (ret != MM_ERROR_NONE) {
- LOGE("failed to set state to PAUSED for pending seek\n");
+ LOGE("failed to set state to PAUSED for pending seek");
return ret;
}
MMPLAYER_TARGET_STATE(player) = MM_PLAYER_STATE_PLAYING;
-
- if (sound_extraction) {
- LOGD("setting pcm extraction\n");
-
- ret = __mmplayer_set_pcm_extraction(player);
- if (MM_ERROR_NONE != ret) {
- LOGW("failed to set pcm extraction\n");
- return ret;
- }
- } else {
- if (MM_ERROR_NONE != __gst_pending_seek(player))
- LOGW("failed to seek pending postion. starting from the begin of content.\n");
- }
+ if (__gst_pending_seek(player) != MM_ERROR_NONE)
+ LOGW("failed to seek pending postion. starting from the begin of content");
}
LOGD("current state before doing transition");
MMPLAYER_PRINT_STATE(player);
/* set pipeline state to PLAYING */
- if (player->es_player_push_mode)
- async = TRUE;
- /* set pipeline state to PLAYING */
ret = __mmplayer_gst_set_state(player,
player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PLAYING, async, MMPLAYER_STATE_CHANGE_TIMEOUT(player));
MMPLAYER_PENDING_STATE(player) = MM_PLAYER_STATE_PLAYING;
MMPLAYER_PRINT_STATE(player);
- /* generate dot file before returning error */
- MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-status-resume");
-
if (async)
- LOGD("do async state transition to PLAYING.\n");
+ LOGD("do async state transition to PLAYING");
/* set pipeline state to PLAYING */
timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player);
ret = __mmplayer_gst_set_state(player,
player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PLAYING, async, timeout);
if (ret != MM_ERROR_NONE) {
- LOGE("failed to set state to PLAYING\n");
- return ret;
+ LOGE("failed to set state to PLAYING");
+ goto EXIT;
} else {
- if (async == FALSE) {
- // MMPLAYER_SET_STATE(player, MM_PLAYER_STATE_PLAYING);
- LOGD("update state machine to %d\n", MM_PLAYER_STATE_PLAYING);
- ret = __mmplayer_set_state(player, MM_PLAYER_STATE_PLAYING);
- }
+ if (async == FALSE)
+ MMPLAYER_SET_STATE(player, MM_PLAYER_STATE_PLAYING);
}
- /* generate dot file before returning error */
+EXIT:
+ /* generate dot file */
MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-status-resume");
MMPLAYER_FLEAVE();
MMPLAYER_FENTER();
- MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
/* check current state */
MMPLAYER_CHECK_STATE(player, MMPLAYER_COMMAND_START);
- /* NOTE : we should check and create pipeline again if not created as we destroy
- * whole pipeline when stopping in streamming playback
- */
- if (!player->pipeline) {
- ret = __gst_realize(player);
- if (MM_ERROR_NONE != ret) {
- LOGE("failed to realize before starting. only in streamming\n");
- /* unlock */
- return ret;
- }
- }
-
+ /* PD - start streaming */
ret = __mmplayer_start_streaming_ext(player);
if (ret != MM_ERROR_NONE) {
LOGE("failed to start streaming ext 0x%X", ret);
if (ret != MM_ERROR_NONE)
LOGE("failed to start player.\n");
+ if ((player->streamer) && (player->streamer->buffering_state & MM_PLAYER_BUFFERING_IN_PROGRESS)) {
+ LOGD("force playing start even during buffering");
+ player->streamer->buffering_state = MM_PLAYER_BUFFERING_ABORT;
+ }
+
MMPLAYER_FLEAVE();
return ret;
return ret;
}
-static int
-__mmplayer_set_pcm_extraction(mm_player_t* player)
-{
- gint64 start_nsec = 0;
- gint64 end_nsec = 0;
- gint64 dur_nsec = 0;
- gint64 dur_msec = 0;
- int required_start = 0;
- int required_end = 0;
- int ret = 0;
-
- MMPLAYER_FENTER();
-
- MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
-
- mm_attrs_multiple_get(player->attrs,
- NULL,
- "pcm_extraction_start_msec", &required_start,
- "pcm_extraction_end_msec", &required_end,
- NULL);
-
- LOGD("pcm extraction required position is from [%d] to [%d](msec)\n", required_start, required_end);
-
- if (required_start == 0 && required_end == 0) {
- LOGD("extracting entire stream");
- return MM_ERROR_NONE;
- } else if (required_start < 0 || required_start > required_end || required_end < 0) {
- LOGD("invalid range for pcm extraction");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- /* get duration */
- ret = gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec);
- if (!ret) {
- LOGE("failed to get duration");
- return MM_ERROR_PLAYER_INTERNAL;
- }
- dur_msec = GST_TIME_AS_MSECONDS(dur_nsec);
-
- if (dur_msec < required_end) {
- // FIXME
- LOGD("invalid end pos for pcm extraction");
- return MM_ERROR_INVALID_ARGUMENT;
- }
-
- start_nsec = required_start * G_GINT64_CONSTANT(1000000);
- end_nsec = required_end * G_GINT64_CONSTANT(1000000);
-
- if ((!__gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
- 1.0,
- GST_FORMAT_TIME,
- (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
- GST_SEEK_TYPE_SET, start_nsec,
- GST_SEEK_TYPE_SET, end_nsec))) {
- LOGE("failed to seek for pcm extraction\n");
-
- return MM_ERROR_PLAYER_SEEK;
- }
-
- LOGD("succeeded to set up segment extraction from [%llu] to [%llu](nsec)\n", start_nsec, end_nsec);
-
- MMPLAYER_FLEAVE();
-
- return MM_ERROR_NONE;
-}
-
int
_mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming)
{