[0.2.138] Add new event - MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED 94/314294/1 accepted/tizen/7.0/unified/20240711.165647
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 5 Jul 2024 07:29:20 +0000 (16:29 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Wed, 10 Jul 2024 02:29:14 +0000 (11:29 +0900)
- The event is sent when pipeline is removed.

Change-Id: I6471c3cce953c9944b96a579c4749bcd9a970d88
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
legacy/include/legacy_player.h
legacy/src/legacy_player.c
muse/include/muse_player.h
muse/src/muse_player.c
packaging/mmsvc-player.spec

index 5c111e7452380d88d5f0423a37875dc9e78fc37b..4639770087bf1f103c4ff48bee12f60751f5c702 100644 (file)
@@ -216,6 +216,7 @@ typedef enum {
        LEGACY_PLAYER_CALLBACK_TYPE_RETURN_BUFFER,
        LEGACY_PLAYER_CALLBACK_TYPE_SERVICE_DISCONNECTED,
        LEGACY_PLAYER_CALLBACK_TYPE_INTERRUPT_STARTED,
+       LEGACY_PLAYER_CALLBACK_TYPE_STATE_CHANGED,
        LEGACY_PLAYER_CALLBACK_TYPE_NUM
 } legacy_player_callback_type_e;
 
@@ -282,6 +283,11 @@ typedef void (*legacy_player_media_stream_seek_cb)(legacy_player_callback_type_e
  */
 typedef void (*legacy_player_video_stream_changed_cb)(int width, int height, int fps, int bit_rate, void *user_data);
 
+/**
+ * @brief Called when the media player is state changed(actually unrealized now).
+ */
+typedef void (*legacy_player_state_changed_cb)(int state_previous, int state_current, void *user_data);
+
 /**
  * @brief Creates a player handle for playing multimedia content.
  * @since_tizen 2.3
index 982c13396dd85590afad3ab95dded27121d1f69c..74da84321eae30a9feb20b54241432e97376e0be 100644 (file)
@@ -401,6 +401,14 @@ static int __lplayer_message_callback(int message, void *param, void *user_data)
                                handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_PREPARE] = NULL;
                        }
                        L_PLAYER_USER_CB_UNLOCK(handle, LEGACY_PLAYER_CALLBACK_TYPE_PREPARE);
+               } else if (msg->state.previous > MM_PLAYER_STATE_NULL && msg->state.current == MM_PLAYER_STATE_NULL) {
+                       LOGI("Unrealized!");
+                       if (handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_STATE_CHANGED]) {
+                               ((legacy_player_state_changed_cb)handle->user_cb[LEGACY_PLAYER_CALLBACK_TYPE_STATE_CHANGED])(
+                                       __lplayer_convert_state(msg->state.previous),
+                                       __lplayer_convert_state(msg->state.current),
+                                       handle->user_data[LEGACY_PLAYER_CALLBACK_TYPE_STATE_CHANGED]);
+                       }
                }
                break;
        case MM_MESSAGE_BEGIN_OF_STREAM:        /* 0x104 */
index 7d4a260cc4e530cd3ae9e3e6cbaac0f4f3eedff8..04ed50c1a2db260fd79b0301c5980880d436b1e0 100644 (file)
@@ -84,6 +84,7 @@ typedef enum {
        MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER,
        MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED,
        MUSE_PLAYER_EVENT_TYPE_INTERRUPT_STARTED,
+       MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED,
        MUSE_PLAYER_EVENT_TYPE_NUM
 } muse_player_event_e;
 
index d6249d1cc71b011b4cdda44f7231ac9e75ca712d..b27da28460518531d6e8145ee5fa6f7e6300c172 100644 (file)
@@ -825,6 +825,19 @@ static void __mmplayer_flush_buffer(muse_player_event_e ev, muse_module_h module
        __mplayer_remove_export_media_packet(module);
 }
 
+static void __mmplayer_state_changed_cb(int state_previous, int state_current, void *user_data)
+{
+       muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
+       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED;
+       muse_module_h module = (muse_module_h)user_data;
+
+       LOGD("ENTER state %d -> %d", state_previous, state_current);
+
+       PLAYER_SEND_EVENT_MSG(api, ev, module,
+               MUSE_TYPE_INT, "previous", state_previous,
+               MUSE_TYPE_INT, "current", state_current);
+}
+
 static void __mplayer_error_cb(int code, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
@@ -897,6 +910,7 @@ static void *__mplayer_callback_function[MUSE_PLAYER_EVENT_TYPE_NUM] = {
        __mplayer_default_callback,   /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */
        NULL,                         /* MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED */
        __mmplayer_flush_buffer,      /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT_STARTED */
+       __mmplayer_state_changed_cb   /* MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED */
 };
 
 static int __mplayer_set_callback_func(muse_player_handle_t *muse_player, muse_player_event_e type, bool set, void *user_data)
@@ -1240,6 +1254,12 @@ int player_disp_create(muse_module_h module)
        if (ret != PLAYER_ERROR_NONE)
                goto ERROR;
 
+       if (legacy_player_set_callback(muse_player->player_handle,
+               MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED,
+               __mplayer_callback_function[MUSE_PLAYER_EVENT_TYPE_STATE_CHANGED],
+               (void *)module) != PLAYER_ERROR_NONE)
+               LOGW("failed to set state changed callback");
+
        muse_player->total_size_of_buffers = DEFAULT_VDEC_TOTAL_SIZE_OF_BUFFER;
        muse_player->extra_size_of_buffers = DEFAULT_VDEC_EXTRA_SIZE_OF_BUFFER;
        g_mutex_init(&muse_player->list_lock);
index 6865cc1bb1923469a24481e86e136ae623cf067d..371a88d35bc0cf6b6f6a9eea5570b15d456516d1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.137
+Version:    0.2.138
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0