[0.6.290] Fix adaptive streaming not being prepared due to upgrade to GST 1.22.7
[platform/core/multimedia/libmm-player.git] / src / mm_player.c
index 683dddb..e572e20 100644 (file)
@@ -36,6 +36,7 @@
 #include "mm_player_tracks.h"
 #include "mm_player_es.h"
 #include "mm_player_360.h"
+#include "mm_player_gst.h"
 
 int mm_player_create(MMHandleType *player)
 {
@@ -52,11 +53,10 @@ int mm_player_create(MMHandleType *player)
                goto ERROR;
        }
 
-       /* create player cmd lock */
-       g_mutex_init(&new_player->cmd_lock);
-
-       /* create player playback lock */
-       g_mutex_init(&new_player->playback_lock);
+       /* create player lock and cond */
+       MMPLAYER_CMD_LOCK_INIT(new_player);
+       g_mutex_init(&new_player->reconfigure_lock);
+       g_cond_init(&new_player->reconfigure_cond);
 
        /* load ini files */
        if (MM_ERROR_NONE != mm_player_ini_load(&new_player->ini)) {
@@ -86,9 +86,9 @@ ERROR:
 
        if (new_player) {
                _mmplayer_destroy((MMHandleType)new_player);
-               g_mutex_clear(&new_player->cmd_lock);
-               g_mutex_clear(&new_player->playback_lock);
-
+               MMPLAYER_CMD_LOCK_DEINIT(new_player);
+               g_mutex_clear(&new_player->reconfigure_lock);
+               g_cond_clear(&new_player->reconfigure_cond);
                MMPLAYER_FREEIF(new_player);
        }
 
@@ -102,9 +102,10 @@ int mm_player_destroy(MMHandleType player)
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
+       _mmplayer_bus_watcher_remove(player);
        /* destroy the gst bus msg thread if it is remained.
           this funct have to be called before getting cmd lock. */
-       __mmplayer_bus_msg_thread_destroy(player);
+       _mmplayer_bus_msg_thread_destroy(player);
 
        MMPLAYER_CMD_LOCK(player);
 
@@ -112,8 +113,12 @@ int mm_player_destroy(MMHandleType player)
 
        MMPLAYER_CMD_UNLOCK(player);
 
-       g_mutex_clear(&((mmplayer_t *)player)->cmd_lock);
-       g_mutex_clear(&((mmplayer_t *)player)->playback_lock);
+       MMPLAYER_CMD_LOCK(player);
+       MMPLAYER_CMD_UNLOCK(player);
+
+       MMPLAYER_CMD_LOCK_DEINIT(player);
+       g_mutex_clear(&((mmplayer_t *)player)->reconfigure_lock);
+       g_cond_clear(&((mmplayer_t *)player)->reconfigure_cond);
 
        memset((mmplayer_t *)player, 0x00, sizeof(mmplayer_t));
 
@@ -144,8 +149,9 @@ int mm_player_abort_pause(MMHandleType player)
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
+       _mmplayer_bus_watcher_remove(player);
        /* destroy the gst bus msg thread not to be blocked in pause(without cmd lock). */
-       __mmplayer_bus_msg_thread_destroy(player);
+       _mmplayer_bus_msg_thread_destroy(player);
 
        /* abort the pause operation for preparing(without cmd lock). */
        result = _mmplayer_abort_pause(player);
@@ -305,7 +311,7 @@ int mm_player_get_state(MMHandleType player, mmplayer_state_e *state)
 }
 
 /* NOTE : It does not support some use cases, eg using colorspace converter */
-int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay)
+int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, int wl_surface_id)
 {
        int result = MM_ERROR_NONE;
 
@@ -313,7 +319,7 @@ int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display
 
        MMPLAYER_CMD_LOCK(player);
 
-       result = _mmplayer_change_videosink(player, display_surface_type, display_overlay);
+       result = _mmplayer_change_videosink(player, display_surface_type, wl_surface_id);
 
        MMPLAYER_CMD_UNLOCK(player);
 
@@ -419,7 +425,7 @@ int mm_player_get_position(MMHandleType player, int64_t *pos)
 
        MMPLAYER_CMD_LOCK(player);
 
-       result = _mmplayer_get_position(player, pos);
+       result = _mmplayer_gst_get_position((mmplayer_t *)player, pos);
 
        MMPLAYER_CMD_UNLOCK(player);
 
@@ -481,7 +487,7 @@ int mm_player_adjust_subtitle_position(MMHandleType player, int pos)
 
        MMPLAYER_CMD_LOCK(player);
 
-       result = _mmplayer_adjust_subtitle_postion(player, pos);
+       result = _mmplayer_adjust_subtitle_position(player, pos);
 
        MMPLAYER_CMD_UNLOCK(player);
 
@@ -834,40 +840,6 @@ int mm_player_get_media_stream_buffer_min_percent(MMHandleType player, mmplayer_
        return result;
 }
 
-int mm_player_set_media_stream_buffer_status_callback(MMHandleType player, mmplayer_stream_type_e type, mm_player_media_stream_buffer_status_callback callback, void *user_param)
-{
-       int result = MM_ERROR_NONE;
-
-       LOGD("\n");
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_set_media_stream_buffer_status_cb(player, type, callback, user_param);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
-int mm_player_set_media_stream_seek_data_callback(MMHandleType player, mmplayer_stream_type_e type, mm_player_media_stream_seek_data_callback callback, void *user_param)
-{
-       int result = MM_ERROR_NONE;
-
-       LOGD("\n");
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_set_media_stream_seek_data_cb(player, type, callback, user_param);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
 int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
 {
        int result = MM_ERROR_NONE;
@@ -883,21 +855,6 @@ int mm_player_set_audio_stream_changed_callback(MMHandleType player, mm_player_s
        return result;
 }
 
-int mm_player_set_video_stream_changed_callback(MMHandleType player, mm_player_stream_changed_callback callback, void *user_param)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_set_videostream_changed_cb(player, callback, user_param);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
 int mm_player_get_timeout(MMHandleType player, int *timeout)
 {
        int result = MM_ERROR_NONE;
@@ -914,22 +871,6 @@ int mm_player_get_timeout(MMHandleType player, int *timeout)
        return result;
 }
 
-int mm_player_get_num_of_video_out_buffers(MMHandleType player, int *num, int *extra_num)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(num && extra_num, MM_ERROR_COMMON_INVALID_ARGUMENT);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_get_num_of_video_out_buffers(player, num, extra_num);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
 int mm_player_set_media_stream_dynamic_resolution(MMHandleType player, bool drc)
 {
        int result = MM_ERROR_NONE;
@@ -1069,22 +1010,6 @@ int mm_player_set_audio_only(MMHandleType player, bool audio_only)
        return result;
 }
 
-int mm_player_get_audio_only(MMHandleType player, bool *audio_only)
-{
-       int result = MM_ERROR_NONE;
-
-       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-       MMPLAYER_RETURN_VAL_IF_FAIL(audio_only, MM_ERROR_INVALID_ARGUMENT);
-
-       MMPLAYER_CMD_LOCK(player);
-
-       result = _mmplayer_get_audio_only(player, audio_only);
-
-       MMPLAYER_CMD_UNLOCK(player);
-
-       return result;
-}
-
 int mm_player_360_is_content_spherical(MMHandleType player, bool *is_spherical)
 {
        int result = MM_ERROR_NONE;
@@ -1221,7 +1146,7 @@ int mm_player_360_get_field_of_view(MMHandleType player, int *horizontal_degrees
        return result;
 }
 
-int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type)
+int mm_player_set_codec_type(MMHandleType player, mmplayer_stream_type_e stream_type, mmplayer_codec_type_e codec_type)
 {
        int result = MM_ERROR_NONE;
 
@@ -1296,3 +1221,48 @@ int mm_player_get_video_roi_area(MMHandleType player, double *scale_x, double *s
 
        return result;
 }
+
+int mm_player_set_client_pid(MMHandleType player, int pid)
+{
+       int result = MM_ERROR_NONE;
+
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+       MMPLAYER_CMD_LOCK(player);
+
+       result = _mmplayer_set_client_pid(player, pid);
+
+       MMPLAYER_CMD_UNLOCK(player);
+
+       return result;
+}
+
+int mm_player_audio_offload_is_activated(MMHandleType player, bool *activated)
+{
+       int result = MM_ERROR_NONE;
+
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(activated, MM_ERROR_INVALID_ARGUMENT);
+
+       MMPLAYER_CMD_LOCK(player);
+
+       result = _mmplayer_audio_offload_is_activated(player, activated);
+
+       MMPLAYER_CMD_UNLOCK(player);
+
+       return result;
+}
+
+int mm_player_is_audio_control_available(MMHandleType player, mmplayer_audio_control_opt_e opt, bool *available)
+{
+       int result = MM_ERROR_NONE;
+
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(available, MM_ERROR_INVALID_ARGUMENT);
+
+       MMPLAYER_CMD_LOCK(player);
+       result = _mmplayer_is_audio_control_available(player, opt, available);
+       MMPLAYER_CMD_UNLOCK(player);
+
+       return result;
+}