[0.6.268] handle seek to eos
[platform/core/multimedia/libmm-player.git] / src / mm_player_gst.c
index 7961390..e509314 100644 (file)
@@ -3410,9 +3410,10 @@ static gpointer __mmplayer_gst_bus_msg_thread(gpointer data)
 }
 
 static int
-__mmplayer_gst_check_duration(mmplayer_t *player, gint64 position)
+__mmplayer_gst_check_position(mmplayer_t *player, gint64 position)
 {
        gint64 dur_nsec = 0;
+       gint64 pos_nsec = 0;
 
        MMPLAYER_FENTER();
        MMPLAYER_RETURN_VAL_IF_FAIL(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED);
@@ -3447,6 +3448,15 @@ __mmplayer_gst_check_duration(mmplayer_t *player, gint64 position)
                return MM_ERROR_INVALID_ARGUMENT;
        }
 
+       if (gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_nsec)) {
+               if ((pos_nsec == player->duration) && /* current pos is end of stream  */
+                       ((position / GST_MSECOND) == (player->duration / GST_MSECOND))) {
+                       MMPLAYER_POST_MSG(player, MM_MESSAGE_SEEK_COMPLETED, NULL);
+                       player->seek_state = MMPLAYER_SEEK_NONE;
+                       return MM_ERROR_PLAYER_NO_OP;
+               }
+       }
+
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;
 }
@@ -3941,9 +3951,9 @@ _mmplayer_gst_set_position(mmplayer_t *player, gint64 position, gboolean interna
                && (MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PAUSED))
                goto PENDING;
 
-       ret = __mmplayer_gst_check_duration(player, position);
+       ret = __mmplayer_gst_check_position(player, position);
        if (ret != MM_ERROR_NONE) {
-               LOGE("failed to check duration 0x%X", ret);
+               LOGW("result of check position info 0x%X", ret);
                return (ret == MM_ERROR_PLAYER_NO_OP) ? MM_ERROR_NONE : ret;
        }