[0.6.149] resolve set state complexity issue 17/193317/3
authorGilbok Lee <gilbok.lee@samsung.com>
Mon, 19 Nov 2018 08:11:19 +0000 (17:11 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Tue, 20 Nov 2018 03:42:22 +0000 (12:42 +0900)
- Divided the __mmplayer_set_state function.

Change-Id: I60e7418266f15b0c34c4cac7e29ac55cd0b86c48

packaging/libmm-player.spec
src/mm_player_priv.c [changed mode: 0644->0755]

index ee0cf7a..f24e520 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.148
+Version:    0.6.149
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
old mode 100644 (file)
new mode 100755 (executable)
index 10e45da..303237b
@@ -205,6 +205,9 @@ static MMPlayerVideoStreamDataType* __mmplayer_create_stream_from_pad(GstPad *pa
 static void __mmplayer_zerocopy_set_stride_elevation_bo(MMPlayerVideoStreamDataType *stream, GstMemory *mem);
 static gboolean __mmplayer_swcodec_set_stride_elevation(MMPlayerVideoStreamDataType *stream);
 static gboolean __mmplayer_swcodec_set_bo(mm_player_t *player, MMPlayerVideoStreamDataType *stream, GstMemory *mem);
+
+static void __mmplayer_set_pause_state(mm_player_t *player);
+static void __mmplayer_set_playing_state(mm_player_t *player);
 /*===========================================================================================
 |                                                                                                                                                                                      |
 |  FUNCTION DEFINITIONS                                                                                                                                                |
@@ -357,10 +360,9 @@ MMStreamingType __mmplayer_get_stream_service_type(mm_player_t* player)
  * it to applicaton by calling callback function
  */
 void
-__mmplayer_set_state(mm_player_tplayer, int state)
+__mmplayer_set_state(mm_player_t *player, int state)
 {
        MMMessageParamType msg = {0, };
-       gboolean post_bos = FALSE;
 
        MMPLAYER_RETURN_IF_FAIL(player);
 
@@ -384,74 +386,12 @@ __mmplayer_set_state(mm_player_t* player, int state)
        case MM_PLAYER_STATE_NULL:
        case MM_PLAYER_STATE_READY:
                break;
-
        case MM_PLAYER_STATE_PAUSED:
-               {
-                       if (!player->sent_bos) {
-                               /* rtsp case, get content attrs by GstMessage */
-                               if (!MMPLAYER_IS_RTSP_STREAMING(player)) {
-                                       /* it's first time to update all content attrs. */
-                                       __mmplayer_update_content_attrs(player, ATTR_ALL);
-                               }
-                       }
-               }
+               __mmplayer_set_pause_state(player);
                break;
-
        case MM_PLAYER_STATE_PLAYING:
-               {
-                       /* try to get content metadata */
-                       if (!player->sent_bos) {
-                               /* NOTE : giving ATTR_MISSING_ONLY may have dependency with
-                                * c-api since c-api doesn't use _start() anymore. It may not work propery with
-                                * legacy mmfw-player api */
-                               __mmplayer_update_content_attrs(player, ATTR_MISSING_ONLY);
-                       }
-
-                       if ((player->cmd == MMPLAYER_COMMAND_START) || (player->cmd == MMPLAYER_COMMAND_RESUME)) {
-                               if (!player->sent_bos)
-                                       __mmplayer_handle_missed_plugin(player);
-                       }
-
-                       if (player->resumed_by_rewind && player->playback_rate < 0.0) {
-                               /* initialize because auto resume is done well. */
-                               player->resumed_by_rewind = FALSE;
-                               player->playback_rate = 1.0;
-                       }
-
-                       if (!player->sent_bos) {
-                               /* check audio codec field is set or not
-                                * we can get it from typefinder or codec's caps.
-                                */
-                               gchar *audio_codec = NULL;
-                               mm_attrs_get_string_by_name(player->attrs, "content_audio_codec", &audio_codec);
-
-                               /* The codec format can't be sent for audio only case like amr, mid etc.
-                                * Because, parser don't make related TAG.
-                                * So, if it's not set yet, fill it with found data.
-                                */
-                               if (!audio_codec) {
-                                       if (g_strrstr(player->type, "audio/midi"))
-                                               audio_codec = g_strdup("MIDI");
-                                       else if (g_strrstr(player->type, "audio/x-amr"))
-                                               audio_codec = g_strdup("AMR");
-                                       else if (g_strrstr(player->type, "audio/mpeg") && !g_strrstr(player->type, "mpegversion= (int)1"))
-                                               audio_codec = g_strdup("AAC");
-                                       else
-                                               audio_codec = g_strdup("unknown");
-                                       mm_attrs_set_string_by_name(player->attrs, "content_audio_codec", audio_codec);
-
-                                       MMPLAYER_FREEIF(audio_codec);
-                                       if (mm_attrs_commit_all(player->attrs))
-                                               LOGE("failed to update attributes\n");
-
-                                       LOGD("set audio codec type with caps\n");
-                               }
-
-                               post_bos = TRUE;
-                       }
-               }
+               __mmplayer_set_playing_state(player);
                break;
-
        case MM_PLAYER_STATE_NONE:
        default:
                LOGW("invalid target state, there is nothing to do.\n");
@@ -480,7 +420,8 @@ __mmplayer_set_state(mm_player_t* player, int state)
                return;
        }
 
-       if (post_bos) {
+       if (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PLAYING
+               && !player->sent_bos) {
                MMPLAYER_POST_MSG(player, MM_MESSAGE_BEGIN_OF_STREAM, NULL);
                player->sent_bos = TRUE;
        }
@@ -9357,3 +9298,75 @@ ERROR:
 
        return FALSE;
 }
+
+static void
+__mmplayer_set_pause_state(mm_player_t *player)
+{
+       if (player->sent_bos)
+               return;
+
+       /* rtsp case, get content attrs by GstMessage */
+       if (MMPLAYER_IS_RTSP_STREAMING(player))
+               return;
+
+       /* it's first time to update all content attrs. */
+       __mmplayer_update_content_attrs(player, ATTR_ALL);
+}
+
+static void
+__mmplayer_set_playing_state(mm_player_t *player)
+{
+       gchar *audio_codec = NULL;
+
+       if (player->resumed_by_rewind && player->playback_rate < 0.0) {
+               /* initialize because auto resume is done well. */
+               player->resumed_by_rewind = FALSE;
+               player->playback_rate = 1.0;
+       }
+
+       if (player->sent_bos)
+               return;
+
+       /* try to get content metadata */
+
+       /* NOTE : giving ATTR_MISSING_ONLY may have dependency with
+        * c-api since c-api doesn't use _start() anymore. It may not work propery with
+        * legacy mmfw-player api
+        */
+       __mmplayer_update_content_attrs(player, ATTR_MISSING_ONLY);
+
+       if ((player->cmd == MMPLAYER_COMMAND_START)
+               || (player->cmd == MMPLAYER_COMMAND_RESUME)) {
+               __mmplayer_handle_missed_plugin(player);
+       }
+
+       /* check audio codec field is set or not
+        * we can get it from typefinder or codec's caps.
+        */
+       mm_attrs_get_string_by_name(player->attrs, "content_audio_codec", &audio_codec);
+
+       /* The codec format can't be sent for audio only case like amr, mid etc.
+        * Because, parser don't make related TAG.
+        * So, if it's not set yet, fill it with found data.
+        */
+       if (!audio_codec) {
+               if (g_strrstr(player->type, "audio/midi"))
+                       audio_codec = "MIDI";
+               else if (g_strrstr(player->type, "audio/x-amr"))
+                       audio_codec = "AMR";
+               else if (g_strrstr(player->type, "audio/mpeg")
+                               && !g_strrstr(player->type, "mpegversion= (int)1"))
+                       audio_codec = "AAC";
+               else
+                       audio_codec = "unknown";
+
+               mm_attrs_set_string_by_name(player->attrs, "content_audio_codec", audio_codec);
+
+               if (mm_attrs_commit_all(player->attrs))
+                       LOGE("failed to update attributes\n");
+
+               LOGD("set audio codec type with caps\n");
+       }
+
+       return;
+}
\ No newline at end of file