[0.2.113] refactoring the callback handling code 02/205902/2
authorEunhye Choi <eunhae1.choi@samsung.com>
Fri, 10 May 2019 07:49:22 +0000 (16:49 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Mon, 13 May 2019 04:12:03 +0000 (13:12 +0900)
- Unify some callback handling path by using
  default callback format

Change-Id: I579ecf6d22e6b2ab1f7d0d8890ffe198210f6613

legacy/include/legacy_player.h
legacy/include/legacy_player_internal.h
legacy/include/legacy_player_private.h
legacy/src/legacy_player.c
legacy/src/legacy_player_internal.c
muse/src/muse_player.c
packaging/mmsvc-player.spec

index 5406dfac6f743d014fc73578483536070dfed425..6f0d6eed4497dd05a5107250272869885541e098 100644 (file)
@@ -177,163 +177,62 @@ typedef enum {
        PLAYER_CONTENT_INFO_YEAR,       /**< Year */
 } player_content_info_e;
 
+/**
+ * @brief  Default callback type
+ */
+typedef void (*legacy_player_default_callback)(muse_player_event_e type, void *user_data);
+
 /**
  * @brief  Called when the subtitle is updated.
- * @since_tizen 2.3
- * @param[in]   duration       The duration of the updated subtitle
- * @param[in]   text           The text of the updated subtitle
- * @param[in]   user_data      The user data passed from the callback registration function
- * @see legacy_player_set_subtitle_updated_cb()
- * @see legacy_player_unset_subtitle_updated_cb()
  */
 typedef void (*player_subtitle_updated_cb)(unsigned long duration, char *text, void *user_data);
 
 /**
  * @brief Called when the media player is prepared.
- * @since_tizen 2.3
- * @details It will be invoked when player has reached the begin of stream.
- * @param[in]   user_data  The user data passed from the callback registration function
- * @pre legacy_player_prepare_async() will cause this callback.
- * @post The player state will be #PLAYER_STATE_READY.
  * @see legacy_player_prepare_async()
  */
 typedef void (*legacy_player_prepared_cb)(void *user_data);
 
-/**
- * @brief Called when the media player is completed.
- * @since_tizen 2.3
- * @details It will be invoked when player has reached the end of the stream.
- * @param[in]   user_data  The user data passed from the callback registration function
- * @pre It will be invoked when the playback is completed if you register this callback using legacy_player_set_completed_cb().
- * @see legacy_player_set_completed_cb()
- * @see legacy_player_unset_completed_cb()
- */
-typedef void (*player_completed_cb)(void *user_data);
-
-/**
- * @brief Called when the seek operation is completed.
- * @since_tizen 2.3
- * @param[in]   user_data  The user data passed from the callback registration function
- * @see legacy_player_set_play_position()
- */
-typedef void (*player_seek_completed_cb)(void *user_data);
-
-/**
- * @brief Called when the media player is interrupted.
- * @since_tizen 2.3
- * @param[in]  user_data       The user data passed from the callback registration function
- * @see legacy_player_set_interrupted_cb()
- * @see legacy_player_unset_interrupted_cb()
- */
-typedef void (*player_interrupted_cb)(void *user_data);
-
 /**
  * @brief Called when an error occurs in the media player.
- * @details Following error codes can be delivered.
- *          #PLAYER_ERROR_INVALID_OPERATION
- *          #PLAYER_ERROR_INVALID_STATE
- *          #PLAYER_ERROR_INVALID_URI
- *          #PLAYER_ERROR_CONNECTION_FAILED
- *          #PLAYER_ERROR_DRM_NOT_PERMITTED
- *          #PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE
- *          #PLAYER_ERROR_NOT_SUPPORTED_FILE
- *          #PLAYER_ERROR_SEEK_FAILED
- *          #PLAYER_ERROR_SERVICE_DISCONNECTED
- * @since_tizen 2.3
- * @param[in]  error_code  The error code
- * @param[in]  user_data       The user data passed from the callback registration function
- * @see legacy_player_set_error_cb()
- * @see legacy_player_unset_error_cb()
  */
 typedef void (*player_error_cb)(int error_code, void *user_data);
 
 /**
  * @brief Called when the buffering percentage of the media playback is updated.
- * @since_tizen 2.3
- * @details If the buffer is full, it will return 100%.
- * @param[in]   percent        The percentage of buffering completed (0~100)
- * @param[in]   user_data      The user data passed from the callback registration function
- * @see legacy_player_set_buffering_cb()
- * @see legacy_player_unset_buffering_cb()
  */
 typedef void (*player_buffering_cb)(int percent, void *user_data);
 
 /**
  * @brief Called when the video is captured.
- * @since_tizen 2.3
- * @remarks The color space format of the captured image is IMAGE_UTIL_COLORSPACE_RGB888.
- * @param[in]   data   The captured image buffer
- * @param[in]   width  The width of the captured image
- * @param[in]   height  The height of the captured image
- * @param[in]   size   The size of the captured image
- * @param[in]   user_data      The user data passed from the callback registration function
- * @see legacy_player_capture_video()
  */
 typedef void (*player_video_captured_cb)(unsigned char *data, int width, int height, unsigned int size, void *user_data);
 
 /**
  * @brief Called to register for notifications about delivering video data when each video frame is decoded.
- * @param[in] video_data video decoded data
- * @param[in] user_data The user data passed from the callback registration function
  */
 typedef bool (*legacy_player_media_packet_video_decoded_cb)(void *video_data, void *user_data);
 
 /**
  * @brief Called to register for notifications about delivering audio data when audio frame is decoded.
- * @param[in] audio_data audio decoded data
- * @param[in] user_data The user data passed from the callback registration function
  */
 typedef bool (*legacy_player_media_packet_audio_decoded_cb)(void *audio_data, void *user_data);
 
 /**
  * @brief Called when the buffer level drops below the threshold of max size or no free space in buffer.
- * @since_tizen 2.4
- * @remarks This API is used for media stream playback only.
- * @param[in] user_data The user data passed from the callback registration function
- * @see legacy_player_set_media_stream_buffer_status_cb()
- * @see legacy_player_set_media_stream_buffer_max_size()
- * @see legacy_player_set_media_stream_buffer_min_threshold()
  */
-typedef void (*player_media_stream_buffer_status_cb)(player_media_stream_buffer_status_e status, void *user_data);
+typedef void (*player_media_stream_buffer_status_cb)(muse_player_event_e type, player_media_stream_buffer_status_e status, void *user_data);
 
 /**
  * @brief Called to notify the next push-buffer offset when seeking is occurred.
- * @since_tizen 2.4
- * @remarks This API is used for media stream playback only.
- * @details The next push-buffer should produce buffers from the new offset.
- * @param[in] offset The new byte position to seek
- * @param[in] user_data The user data passed from the callback registration function
  */
-typedef void (*player_media_stream_seek_cb)(unsigned long long offset, void *user_data);
+typedef void (*player_media_stream_seek_cb)(muse_player_event_e type, unsigned long long offset, void *user_data);
 
 /**
  * @brief Called to notify the video stream changed.
- * @since_tizen 2.4
- * @details The video stream changing is detected just before rendering operation.
- * @param[in] width    The width of the captured image
- * @param[in] height The height of the captured image
- * @param[in] fps The frame per second of the video \n
- *            It can be @c 0 if there is no video stream information.
- * @param[in] bit_rate The video bit rate [Hz] \n
- *            It can be an invalid value if there is no video stream information.
- * @param[in] user_data The user data passed from the callback registration function
- * @see legacy_player_set_video_stream_changed_cb()
  */
 typedef void (*player_video_stream_changed_cb)(int width, int height, int fps, int bit_rate, void *user_data);
 
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-/**
- * @brief Called when the buffer needs to be released for gapless.
- * @since_tizen 4.0
- * @details It will be invoked when the player is under the construction for gapless.
- * @param[in]   user_data  The user data passed from the callback registration function
- * @pre It will be invoked when the playback is completed if you register this callback using legacy_player_set_completed_cb().
- * @see legacy_player_set_retrieve_buffer_cb()
- * @see legacy_player_unset_retrieve_buffer_cb()
- */
-typedef void (*player_retrieve_buffer_cb)(void *user_data);
-#endif
-
 /**
  * @brief Creates a player handle for playing multimedia content.
  * @since_tizen 2.3
@@ -440,6 +339,12 @@ int legacy_player_prepare_async(legacy_player_h player, legacy_player_prepared_c
  */
 int legacy_player_unprepare(legacy_player_h player);
 
+/**
+ * @brief Set and Unset the legacy player callback
+ */
+int legacy_player_set_callback(legacy_player_h player, muse_player_event_e type, void *callback, void *user_data);
+int legacy_player_unset_callback(legacy_player_h player, muse_player_event_e type);
+
 /**
  * @brief Sets the data source (file-path, HTTP or RSTP URI) to use.
  *
@@ -594,30 +499,6 @@ int legacy_player_get_audio_latency_mode(legacy_player_h player, audio_latency_m
 
 /**
  * @brief Starts or resumes playback.
- * @since_tizen 2.3
- * @remarks Sound can be mixed with other sounds if you don't control the stream focus in sound-manager module since 3.0.\n
- * You can refer to @ref CAPI_MEDIA_SUOND_MANAGER_MODULE.
- * @details Plays current media content, or resumes play if paused.
- *
- * @param[in]   player The handle to the media player
- * @return @c 0 on success,
- * otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_CONNECTION_FAILED Network connection failed
- * @retval #PLAYER_ERROR_SOUND_POLICY Sound policy error
- * @pre legacy_player_prepare() must be called before calling this function.
- * @pre The player state must be set to #PLAYER_STATE_READY by calling legacy_player_prepare() or set to #PLAYER_STATE_PAUSED by calling legacy_player_pause().
- * @post The player state will be #PLAYER_STATE_PLAYING.
- * @post It invokes legacy_player_completed_cb() when playback completes, if you set a callback with legacy_player_set_completed_cb().
- * @see legacy_player_prepare()
- * @see legacy_player_prepare_async()
- * @see legacy_player_stop()
- * @see legacy_player_pause()
- * @see legacy_player_set_completed_cb()
- * @see legacy_player_completed_cb()
  */
 int legacy_player_start(legacy_player_h player);
 
@@ -674,10 +555,9 @@ int legacy_player_pause(legacy_player_h player);
  * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
  * @retval #PLAYER_ERROR_SEEK_FAILED Seek operation failure
  * @pre The player state must be one of these: #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED.
- * @post It invokes legacy_player_seek_completed_cb() when seek operation completes, if you set a callback.
  * @see legacy_player_get_play_position()
  */
-int legacy_player_set_play_position(legacy_player_h player, int64_t nanoseconds, bool accurate, player_seek_completed_cb callback, void *user_data);
+int legacy_player_set_play_position(legacy_player_h player, int64_t nanoseconds, bool accurate, void *callback, void *user_data);
 
 /**
  * @brief Gets the current position in milliseconds.
@@ -793,24 +673,6 @@ int legacy_player_set_display(legacy_player_h player, player_display_type_e type
 
 int legacy_player_release_video_stream_bo(legacy_player_h player, void *bo);
 
-/**
- * @brief Registers a media packet video callback function to be called once per frame.
- * @remarks This function should be called before preparing. \n
- *             A registered callback is called on the internal thread of the player. \n
- *          A video frame can be retrieved using a registered callback.\n
- *          The callback function holds the same buffer that will be drawn on the display device.\n
- * @param[in] player The handle to the media player
- * @param[in] callback The callback function to be registered
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid state
- * @pre        The player's state should be #PLAYER_STATE_IDLE. And, #PLAYER_DISPLAY_TYPE_NONE should be set by calling legacy_player_set_display().
- */
-int legacy_player_set_media_packet_video_frame_decoded_cb(legacy_player_h player, legacy_player_media_packet_video_decoded_cb callback, void *user_data);
-
 /**
  * @brief  Pushes elementary stream to decode audio or video
  * @since_tizen 2.4
@@ -853,75 +715,6 @@ int legacy_player_push_media_stream(legacy_player_h player, media_packet_h packe
  */
 int legacy_player_set_media_stream_info(legacy_player_h player, player_stream_type_e type, media_format_h format);
 
-/**
- * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred.
- * @since_tizen 2.4
- * @remarks This API is used for media stream playback only.
- * @param[in] player   The handle to the media player
- * @param[in] type     The type of target stream
- * @param[in] callback The buffer status callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
- * @post legacy_player_media_stream_buffer_status_cb() will be invoked.
- * @see legacy_player_unset_media_stream_buffer_status_cb()
- * @see legacy_player_media_stream_buffer_status_cb()
- */
-int legacy_player_set_media_stream_buffer_status_cb(legacy_player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the buffer status callback function.
- * @since_tizen 2.4
- * @remarks This API is used for media stream playback only.
- * @param[in] player The handle to the media player
- * @param[in] type   The type of target stream
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @see legacy_player_set_media_stream_buffer_status_cb()
- */
-int legacy_player_unset_media_stream_buffer_status_cb(legacy_player_h player, player_stream_type_e type);
-
-/**
- * @brief Registers a callback function to be invoked when seeking is occurred.
- * @since_tizen 2.4
- * @remarks This API is used for media stream playback only.
- * @param[in] player    The handle to the media player
- * @param[in] type      The type of target stream
- * @param[in] callback  The callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
- * @post legacy_player_media_stream_seek_cb() will be invoked.
- * @see legacy_player_unset_media_stream_seek_cb()
- * @see legacy_player_media_stream_seek_cb()
- */
-int legacy_player_set_media_stream_seek_cb(legacy_player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the seek callback function.
- * @since_tizen 2.4
- * @param[in] player The handle to the media player
- * @param[in] type   The type of target stream
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @see legacy_player_set_media_stream_seek_cb()
- */
-int legacy_player_unset_media_stream_seek_cb(legacy_player_h player, player_stream_type_e type);
-
 /**
  * @brief Sets the max size bytes of buffer.
  * @since_tizen 2.4
@@ -1436,130 +1229,6 @@ int legacy_player_set_streaming_user_agent(legacy_player_h player, const char *u
  */
 int legacy_player_get_streaming_download_progress(legacy_player_h player, int *start, int *end);
 
-/**
- * @brief Registers a callback function to be invoked when the playback is finished.
- * @since_tizen 2.3
- * @param[in] player   The handle to the media player
- * @param[in] callback The callback function to register
- * @param[in] user_data        The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @post  legacy_player_completed_cb() will be invoked.
- * @see legacy_player_unset_completed_cb()
- * @see legacy_player_completed_cb()
- * @see legacy_player_start()
- */
-int legacy_player_set_completed_cb(legacy_player_h player, player_completed_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the callback function.
- * @since_tizen 2.3
- * @param[in] player The handle to the media player
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @see legacy_player_set_completed_cb()
- */
-int legacy_player_unset_completed_cb(legacy_player_h player);
-
-/**
- * @brief Registers a callback function to be invoked when the playback is interrupted or the interrupt is completed.
- * @since_tizen 2.3
- * @param[in] player   The handle to the media player
- * @param[in] callback The callback function to register
- * @param[in] user_data        The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @post  player_interrupted_cb() will be invoked.
- * @see legacy_player_unset_interrupted_cb()
- * @see legacy_player_interrupted_cb()
- */
-int legacy_player_set_interrupted_cb(legacy_player_h player, player_interrupted_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the callback function.
- * @since_tizen 2.3
- * @param[in] player The handle to the media player
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @see legacy_player_set_interrupted_cb()
- */
-int legacy_player_unset_interrupted_cb(legacy_player_h player);
-
-/**
- * @brief Registers a callback function to be invoked when an error occurs.
- * @since_tizen 2.3
- * @param[in] player   The handle to the media player
- * @param[in] callback The callback function to register
- * @param[in] user_data        The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @post  legacy_player_error_cb() will be invoked.
- * @see legacy_player_unset_error_cb()
- * @see legacy_player_error_cb()
- */
-int legacy_player_set_error_cb(legacy_player_h player, player_error_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the callback function.
- * @since_tizen 2.3
- * @param[in] player The handle to the media player
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @see legacy_player_set_error_cb()
- */
-int legacy_player_unset_error_cb(legacy_player_h player);
-
-/**
- * @brief Registers a callback function to be invoked when there is a change in the buffering status of a media stream.
- * @since_tizen 2.3
- * @remarks The media resource should be streamed over the network.
- * @param[in] player   The handle to the media player
- * @param[in] callback The callback function to register
- * @param[in] user_data        The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @retval #PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE Unsupported feature
- * @post  legacy_player_buffering_cb() will be invoked.
- * @see legacy_player_unset_buffering_cb()
- * @see legacy_player_set_uri()
- * @see legacy_player_buffering_cb()
- */
-int legacy_player_set_buffering_cb(legacy_player_h player, player_buffering_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the callback function.
- * @since_tizen 2.3
- * @param[in] player The handle to the media player
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @see legacy_player_set_buffering_cb()
- */
-int legacy_player_unset_buffering_cb(legacy_player_h player);
-
 /**
  * @brief Sets the playback rate.
  * @since_tizen 2.3
@@ -1593,38 +1262,6 @@ int legacy_player_set_playback_rate(legacy_player_h player, float rate);
  */
 int legacy_player_set_subtitle_path(legacy_player_h player, const char *path);
 
-/**
- * @brief Registers a callback function to be invoked when a subtitle updates.
- * @since_tizen 2.3
- * @param[in] player   The handle to the media player
- * @param[in] callback The callback function to register
- * @param[in] user_data        The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @pre The subtitle must be set by calling legacy_player_set_subtitle_path().
- * @post  legacy_player_subtitle_updated_cb() will be invoked.
- * @see legacy_player_unset_subtitle_updated_cb()
- * @see legacy_player_subtitle_updated_cb()
- * @see legacy_player_set_subtitle_path()
- */
-int legacy_player_set_subtitle_updated_cb(legacy_player_h player, player_subtitle_updated_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the callback function.
- * @since_tizen 2.3
- * @param[in] player The handle to the media player
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @see legacy_player_set_subtitle_updated_cb()
- */
-int legacy_player_unset_subtitle_updated_cb(legacy_player_h player);
-
 /**
  * @brief Sets the seek position for the subtitle.
  * @since_tizen 2.3.1
@@ -1642,38 +1279,6 @@ int legacy_player_unset_subtitle_updated_cb(legacy_player_h player);
  */
 int legacy_player_set_subtitle_position_offset(legacy_player_h player, int millisecond);
 
-/**
- * @brief Registers a callback function to be invoked when video stream is changed.
- * @since_tizen 2.4
- * @remarks The stream changing is detected just before rendering operation.
- * @param[in] player   The handle to the media player
- * @param[in] callback The stream changed callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
- * @post legacy_player_video_stream_changed_cb() will be invoked.
- * @see legacy_player_unset_video_stream_changed_cb()
- * @see legacy_player_video_stream_changed_cb()
- */
-int legacy_player_set_video_stream_changed_cb(legacy_player_h player, player_video_stream_changed_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the video stream changed callback function.
- * @since_tizen 2.4
- * @param[in] player The handle to the media player
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @see legacy_player_set_video_stream_changed_cb()
- */
-int legacy_player_unset_video_stream_changed_cb(legacy_player_h player);
-
 /**
  * @brief Gets current track index.
  * @since_tizen 2.4
@@ -1751,37 +1356,6 @@ int legacy_player_get_track_count(legacy_player_h player, player_stream_type_e t
  */
 int legacy_player_select_track(legacy_player_h player, player_stream_type_e type, int index);
 
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-/**
- * @brief Registers a callback function that is to be invoked when the buffer needs to be released for gapless.
- * @since_tizen 4.0
- * @param[in] player   The handle to the media player
- * @param[in] callback The callback function to register
- * @param[in] user_data        The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @post  player_retrieve_buffer_cb() will be invoked.
- * @see legacy_player_unset_retrieve_buffer_cb()
- */
-int legacy_player_set_retrieve_buffer_cb(legacy_player_h player, player_retrieve_buffer_cb callback, void *user_data);
-
-/**
- * @brief Unregisters the callback function.
- * @since_tizen 4.0
- * @param[in] player The handle to the media player
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
- * @see legacy_player_set_retrieve_buffer_cb()
- */
-int legacy_player_unset_retrieve_buffer_cb(legacy_player_h player);
-#endif
-
 /**
  * @brief Manage the external storage state
  * @since_tizen 3.0
@@ -1970,14 +1544,6 @@ int legacy_player_set_max_adaptive_variant_limit(legacy_player_h player, int ban
  */
 int legacy_player_get_max_adaptive_variant_limit(legacy_player_h player, int *bandwidth, int *width, int *height);
 
-/**
- * @brief Checks user callback lock
- * @since_tizen 3.0
- * @param[in] type The event type of player
- * @return @c 1 on success, 0 on failure
- */
-bool _check_enabled_user_cb_lock(int event_id);
-
 /**
  * @brief Sets the audio only mode.
  * @since_tizen 4.0
index d805f269150ca0ecd8ede03957d88cffc800c5b7..bcd45f97530bc59227abc848c75dfe74d7f4ba6c 100644 (file)
@@ -44,16 +44,9 @@ typedef enum
 
 /**
  * @brief Called when the buffer level drops below the min size or exceeds the max size.
- * @since_tizen 3.0
- * @remarks This API is used for media stream playback only.
- * @param[in] status The buffer status
- * @param[in] bytes The current buffer level bytes
- * @param[in] user_data The user data passed from the callback registration function
- * @see legacy_player_set_media_stream_buffer_status_cb_ex()
- * @see legacy_player_set_media_stream_buffer_max_size()
- * @see legacy_player_set_media_stream_buffer_min_threshold()
  */
-typedef void (*player_media_stream_buffer_status_cb_ex)(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data);
+typedef void (*player_media_stream_buffer_status_cb_ex)(muse_player_event_e type,
+               player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data);
 
 /**
  * @brief Registers a callback function to be invoked when audio frame is decoded. Audio only contents is possible. If included video, error happens.
@@ -73,7 +66,8 @@ typedef void (*player_media_stream_buffer_status_cb_ex)(player_media_stream_buff
  * @pre The player state must be #PLAYER_STATE_IDLE by legacy_player_create() or legacy_player_unprepare().
  * @post legacy_player_media_packet_audio_decoded_cb() will be invoked.
  */
-int legacy_player_set_pcm_extraction_mode(legacy_player_h player, bool sync, legacy_player_media_packet_audio_decoded_cb callback, void *user_data);
+int legacy_player_set_pcm_extraction_mode(legacy_player_h player, bool sync,
+               legacy_player_media_packet_audio_decoded_cb callback, void *user_data);
 
 /**
  * @brief Set pcm mode spec. Samplerate, channel is needed.
@@ -107,41 +101,6 @@ int legacy_player_set_pcm_spec(legacy_player_h player, const char *format, int s
  */
 int legacy_player_set_streaming_playback_rate(legacy_player_h player, float rate);
 
-/**
- * @brief Registers a callback function to be invoked when buffer underrun or overflow is occurred.
- * @since_tizen 3.0
- * @remarks This API is used for media stream playback only.
- * @param[in] player   The handle to the media player
- * @param[in] type     The type of target stream
- * @param[in] callback The buffer status callback function to register
- * @param[in] user_data The user data to be passed to the callback function
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre The player state must be set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare().
- * @post player_media_stream_buffer_status_cb_ex() will be invoked.
- * @see legacy_player_unset_media_stream_buffer_status_cb_ex()
- * @see player_media_stream_buffer_status_cb_ex()
- */
-int legacy_player_set_media_stream_buffer_status_cb_ex(legacy_player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data);
-
-/**
- * @brief Unregisters the buffer status callback function.
- * @since_tizen 3.0
- * @remarks This API is used for media stream playback only.
- * @param[in] player The handle to the media player
- * @param[in] type   The type of target stream
- * @return @c 0 on success,
- *         otherwise a negative error value
- * @retval #PLAYER_ERROR_NONE Successful
- * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
- * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
- * @see legacy_player_set_media_stream_buffer_status_cb()
- */
-int legacy_player_unset_media_stream_buffer_status_cb_ex(legacy_player_h player, player_stream_type_e type);
-
 /**
  * @brief Sets DRC(dynamic resolution change) information of media stream data.
  * @since_tizen 3.0
index 6f65e69806c399ad71408f34874ccaebcdedab00..484adbdf399c432bdc9b00beb2f39df143e6b190 100644 (file)
@@ -48,20 +48,6 @@ extern "C" {
                PLAYER_CHECK_CONDITION(arg >= min, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");   \
        } while (0)
 
-/* user_cb_lock */
-#define LEGACY_PLAYER_USER_CB_LOCK(x_handle, type) \
-       do { \
-               if (_check_enabled_user_cb_lock(type))  \
-                       g_mutex_lock(&((legacy_player_t *)x_handle)->user_cb_lock[type]);       \
-       } while (0)
-
-#define LEGACY_PLAYER_USER_CB_UNLOCK(x_handle, type) \
-       do { \
-               if (_check_enabled_user_cb_lock(type))  \
-                       g_mutex_unlock(&((legacy_player_t *)x_handle)->user_cb_lock[type]);     \
-       } while (0)
-
-
 #ifdef TIZEN_TTRACE
 #include <ttrace.h>
 #define PLAYER_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_VIDEO, NAME)
@@ -107,6 +93,11 @@ typedef struct {
        mmplayer_audio_extract_opt_e pcm_extract_opt;
 } legacy_player_t;
 
+typedef struct {
+       muse_player_event_e type;
+       player_state_e state;
+} legacy_player_callback_pre_state_t;
+
 int __player_convert_error_code(int code, char *func_name);
 bool __player_state_validate(legacy_player_t *handle, player_state_e threshold);
 
index 42c5408e5e463c7071f27aaef917b039b5387f59..b9d66ede8df5a58288887f560aa6e7daf98f2b86 100644 (file)
                } \
        } while (0)
 
+/* user_cb_lock */
+#define LEGACY_PLAYER_USER_CB_LOCK(x_handle, type) \
+       do { \
+               if (__check_enabled_user_cb_lock(type)) \
+                       g_mutex_lock(&((legacy_player_t *)x_handle)->user_cb_lock[type]);       \
+       } while (0)
+
+#define LEGACY_PLAYER_USER_CB_UNLOCK(x_handle, type) \
+       do { \
+               if (__check_enabled_user_cb_lock(type)) \
+                       g_mutex_unlock(&((legacy_player_t *)x_handle)->user_cb_lock[type]); \
+       } while (0)
+
 /*
  * Internal Implementation
  */
@@ -244,44 +257,6 @@ bool __player_state_validate(legacy_player_t *handle, player_state_e threshold)
        return true;
 }
 
-static int __set_callback(muse_player_event_e type, legacy_player_h player, void *callback, void *user_data)
-{
-       legacy_player_t *handle = (legacy_player_t *)player;
-       PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(callback);
-
-       handle->user_cb[type] = callback;
-       handle->user_data[type] = user_data;
-       LOGI("Event type : %d ", type);
-       return PLAYER_ERROR_NONE;
-}
-
-static int __unset_callback(muse_player_event_e type, legacy_player_h player)
-{
-       legacy_player_t *handle = (legacy_player_t *)player;
-       PLAYER_INSTANCE_CHECK(player);
-       handle->user_cb[type] = NULL;
-       handle->user_data[type] = NULL;
-       LOGI("Event type : %d ", type);
-       return PLAYER_ERROR_NONE;
-}
-
-static int
-__set_buffer_export_callback(legacy_player_t *handle)
-{
-       int ret = MM_ERROR_NONE;
-
-       if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME])
-               ret = mm_player_set_video_decoded_callback(handle->mm_handle,
-                               (mm_player_video_decoded_callback)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME], handle->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]);
-
-       if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME])
-               ret = mm_player_set_audio_decoded_callback(handle->mm_handle, handle->pcm_extract_opt,
-                               (mm_player_audio_decoded_callback)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME], handle->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME]);
-
-       return ret;
-}
-
 static player_state_e __convert_player_state(mmplayer_state_e state)
 {
        if (state == MM_PLAYER_STATE_NONE)
@@ -290,6 +265,18 @@ static player_state_e __convert_player_state(mmplayer_state_e state)
        return state + 1;
 }
 
+static bool __check_enabled_user_cb_lock(int type)
+{
+       switch (type) {
+       case MUSE_PLAYER_EVENT_TYPE_PREPARE:          /* fall through */
+       case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO:    /* fall through */
+       case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO:    /* fall through */
+               return true;
+       default:
+               return false;
+       }
+}
+
 static void __buffer_status_callback(legacy_player_t *handle, MMMessageParamType *msg)
 {
        muse_player_event_e event_type;
@@ -315,7 +302,8 @@ static void __buffer_status_callback(legacy_player_t *handle, MMMessageParamType
        LEGACY_PLAYER_USER_CB_LOCK(handle, event_type);
        if (handle->user_cb[event_type]) {
                LOGD("event type %d, status %d", event_type, buffer_status);
-               ((player_media_stream_buffer_status_cb)handle->user_cb[event_type])(buffer_status, handle->user_data[event_type]);
+               ((player_media_stream_buffer_status_cb)handle->user_cb[event_type]) \
+                               (event_type, buffer_status, handle->user_data[event_type]);
                LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
                return;
        }
@@ -325,11 +313,14 @@ static void __buffer_status_callback(legacy_player_t *handle, MMMessageParamType
        LEGACY_PLAYER_USER_CB_LOCK(handle, event_type_internal);
        if (handle->user_cb[event_type_internal]) {
                LOGD("event type %d, status %d, bytes %llu", event_type_internal, buffer_status, buffer_bytes);
-               ((player_media_stream_buffer_status_cb_ex)handle->user_cb[event_type_internal])(buffer_status, buffer_bytes, handle->user_data[event_type_internal]);
+               ((player_media_stream_buffer_status_cb_ex)handle->user_cb[event_type_internal]) \
+                               (event_type_internal, buffer_status, buffer_bytes, handle->user_data[event_type_internal]);
        }
        LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type_internal);
+
 }
 
+
 static void __video_stream_changed_callback(legacy_player_t *handle)
 {
        int ret = MM_ERROR_NONE;
@@ -354,6 +345,16 @@ static void __video_stream_changed_callback(legacy_player_t *handle)
        return;
 }
 
+static void __default_callback(legacy_player_t *handle, muse_player_event_e type)
+{
+       LOGD("type %d", type);
+
+       LEGACY_PLAYER_USER_CB_LOCK(handle, type);
+       if (handle->user_cb[type])
+               ((legacy_player_default_callback)handle->user_cb[type])(type, handle->user_data[type]);
+       LEGACY_PLAYER_USER_CB_UNLOCK(handle, type);
+}
+
 static int __msg_callback(int message, void *param, void *user_data)
 {
        legacy_player_t *handle = (legacy_player_t *)user_data;
@@ -377,7 +378,7 @@ static int __msg_callback(int message, void *param, void *user_data)
                LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
                break;
        case MM_MESSAGE_STATE_CHANGED:  /* 0x03 */
-               LOGI("STATE CHANGED INTERNALLY - from : %d,  to : %d (CAPI State : %d)", msg->state.previous, msg->state.current, handle->state);
+               LOGI("state chagned from: %d, to: %d (CAPI State: %d)", msg->state.previous, msg->state.current, handle->state);
                if (msg->state.previous == MM_PLAYER_STATE_READY && msg->state.current == MM_PLAYER_STATE_PAUSED) {
                        LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PREPARE);
                        if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PREPARE]) {
@@ -398,30 +399,29 @@ static int __msg_callback(int message, void *param, void *user_data)
                LOGI("Ready to streaming information (BOS) [current state : %d]", handle->state);
                break;
        case MM_MESSAGE_END_OF_STREAM:  /* 0x105 */
-               if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE]) {
-                       LOGD("Playback is completed.");
-                       ((player_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_COMPLETE]);
-               }
+               LOGD("Playback is completed.");
+               __default_callback(handle, MUSE_PLAYER_EVENT_TYPE_COMPLETE);
                break;
 #ifdef TIZEN_FEATURE_EVAS_RENDERER
        case MM_MESSAGE_GAPLESS_CONSTRUCTION:   /* 0x105 */
-               if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])
-                       ((player_retrieve_buffer_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER]);
+               LOGD("Retrieve exported buffers.");
+               __default_callback(handle, MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER);
                break;
 #endif
        case MM_MESSAGE_BUFFERING:      /* 0x103 */
                if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])
-                       ((player_buffering_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING])(msg->connection.buffering, handle->user_data[MUSE_PLAYER_EVENT_TYPE_BUFFERING]);
+                       ((player_buffering_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_BUFFERING]) \
+                                       (msg->connection.buffering, handle->user_data[MUSE_PLAYER_EVENT_TYPE_BUFFERING]);
                break;
        case MM_MESSAGE_STATE_INTERRUPTED:      /* 0x04 */
-               if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]) {
-                       if (msg->union_type == MM_MSG_UNION_STATE) {
-                               LOGW("received mm state msg prev:%d, curr:%d", msg->state.previous, msg->state.current);
-                               handle->state = __convert_player_state(msg->state.current);
-                               LOGW("player state is changed to %d by resource conflict", handle->state);
-                       }
-                       ((player_interrupted_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_INTERRUPT])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_INTERRUPT]);
+               if (msg->union_type == MM_MSG_UNION_STATE) {
+                       LOGW("received mm state msg prev:%d, curr:%d", msg->state.previous, msg->state.current);
+                       handle->state = __convert_player_state(msg->state.current);
+                       LOGW("player state is changed to %d by resource conflict", handle->state);
                }
+
+               LOGD("Interrupted");
+               __default_callback(handle, MUSE_PLAYER_EVENT_TYPE_INTERRUPT);
                break;
        case MM_MESSAGE_CONNECTION_TIMEOUT:     /* 0x102 */
                LOGE("PLAYER_ERROR_CONNECTION_FAILED : CONNECTION_TIMEOUT");
@@ -429,12 +429,14 @@ static int __msg_callback(int message, void *param, void *user_data)
                break;
        case MM_MESSAGE_UPDATE_SUBTITLE:        /* 0x109 */
                if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE])
-                       ((player_subtitle_updated_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE])(msg->subtitle.duration, (char *)msg->data, handle->user_data[MUSE_PLAYER_EVENT_TYPE_SUBTITLE]);
+                       ((player_subtitle_updated_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SUBTITLE]) \
+                                       (msg->subtitle.duration, (char *)msg->data, handle->user_data[MUSE_PLAYER_EVENT_TYPE_SUBTITLE]);
                break;
        case MM_MESSAGE_VIDEO_NOT_CAPTURED:     /* 0x113 */
                LOGE("PLAYER_ERROR_VIDEO_CAPTURE_FAILED");
                if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])
-                       ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(PLAYER_ERROR_VIDEO_CAPTURE_FAILED, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
+                       ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) \
+                                       (PLAYER_ERROR_VIDEO_CAPTURE_FAILED, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]);
                break;
        case MM_MESSAGE_VIDEO_CAPTURED: /* 0x110 */
        {
@@ -449,8 +451,8 @@ static int __msg_callback(int message, void *param, void *user_data)
                                                        capture->orientation, capture->width, capture->height, capture->size);
 
                                /* call application callback */
-                               ((player_video_captured_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])
-                                               (capture->data, capture->width, capture->height, capture->size, handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
+                               ((player_video_captured_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])(capture->data, \
+                                               capture->width, capture->height, capture->size, handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
                        }
 
                        handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
@@ -480,12 +482,11 @@ static int __msg_callback(int message, void *param, void *user_data)
                                        LOGW("Failed to set display_visible '1' (0x%x)", ret);
                        }
                }
-               if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK]) {
-                       LOGD("Seek is completed");
-                       ((player_seek_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK]);
-                       handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
-                       handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
-               }
+
+               LOGD("Seek is completed");
+               __default_callback(handle, MUSE_PLAYER_EVENT_TYPE_SEEK);
+               handle->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
+               handle->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = NULL;
                break;
        case MM_MESSAGE_PLAY_POSITION:
                LOGI("MM_MESSAGE_PLAY_POSITION (%"PRId64" ns)", msg->time.elapsed);
@@ -506,7 +507,7 @@ static int __msg_callback(int message, void *param, void *user_data)
                        event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
 
                if (handle->user_cb[event_type])
-                       ((player_media_stream_seek_cb)handle->user_cb[event_type])(msg->seek_data.offset, handle->user_data[event_type]);
+                       ((player_media_stream_seek_cb)handle->user_cb[event_type])(event_type, msg->seek_data.offset, handle->user_data[event_type]);
 
                break;
        }
@@ -546,16 +547,52 @@ static MMDisplaySurfaceType __player_convert_display_type(player_display_type_e
        }
 }
 
-bool _check_enabled_user_cb_lock(int type)
+static int __check_callback_precondition(legacy_player_t *handle, muse_player_event_e type)
 {
-       switch (type) {
-       case MUSE_PLAYER_EVENT_TYPE_PREPARE:          /* fall through */
-       case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO:    /* fall through */
-       case MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO:    /* fall through */
-               return true;
-       default:
-               return false;
+       int i = 0;
+       int size = 0;
+       legacy_player_callback_pre_state_t callback_pre_state[] = {
+               {MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME, PLAYER_STATE_IDLE},
+               {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, PLAYER_STATE_IDLE},
+               {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, PLAYER_STATE_IDLE},
+               {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO, PLAYER_STATE_IDLE},
+               {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO, PLAYER_STATE_IDLE},
+               {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, PLAYER_STATE_IDLE},
+               {MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, PLAYER_STATE_IDLE},
+               {MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, PLAYER_STATE_IDLE},
+       };
+
+       size = sizeof(callback_pre_state)/sizeof(legacy_player_callback_pre_state_t);
+
+       /* check pre-state */
+       for (; i < size; i++) {
+               if (type == callback_pre_state[i].type) {
+                       PLAYER_STATE_CHECK(handle, callback_pre_state[i].state);
+                       break;
+               }
        }
+
+       return PLAYER_ERROR_NONE;
+}
+
+static int
+__set_buffer_export_callback(legacy_player_t *handle)
+{
+       int ret = MM_ERROR_NONE;
+       muse_player_event_e video_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME;
+       muse_player_event_e audio_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME;
+
+       if (handle->user_cb[video_type])
+               ret = mm_player_set_video_decoded_callback(handle->mm_handle,
+                               (mm_player_video_decoded_callback)handle->user_cb[video_type],
+                               handle->user_data[video_type]);
+
+       if (handle->user_cb[audio_type])
+               ret = mm_player_set_audio_decoded_callback(handle->mm_handle, handle->pcm_extract_opt,
+                               (mm_player_audio_decoded_callback)handle->user_cb[audio_type],
+                               handle->user_data[audio_type]);
+
+       return ret;
 }
 
 /*
@@ -593,7 +630,7 @@ int legacy_player_create(legacy_player_h *player)
        handle->is_media_stream = false;
 
        for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
-               if (_check_enabled_user_cb_lock(type))
+               if (__check_enabled_user_cb_lock(type))
                        g_mutex_init(&handle->user_cb_lock[type]);
        }
 
@@ -639,7 +676,7 @@ int legacy_player_destroy(legacy_player_h player)
        __player_update_state(handle, PLAYER_INTERNAL_STATE_NONE);
 
        for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) {
-               if (_check_enabled_user_cb_lock(type))
+               if (__check_enabled_user_cb_lock(type))
                        g_mutex_clear(&handle->user_cb_lock[type]);
        }
 
@@ -1115,7 +1152,7 @@ int legacy_player_pause(legacy_player_h player)
        return PLAYER_ERROR_NONE;
 }
 
-int legacy_player_set_play_position(legacy_player_h player, int64_t nanoseconds, bool accurate, player_seek_completed_cb callback, void *user_data)
+int legacy_player_set_play_position(legacy_player_h player, int64_t nanoseconds, bool accurate, void *callback, void *user_data)
 {
        legacy_player_t *handle = (legacy_player_t *)player;
        int ret = MM_ERROR_NONE;
@@ -1832,176 +1869,58 @@ int legacy_player_get_streaming_download_progress(legacy_player_h player, int *s
        return PLAYER_ERROR_NONE;
 }
 
-int legacy_player_set_completed_cb(legacy_player_h player, player_completed_cb callback, void *user_data)
-{
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player, callback, user_data);
-}
-
-int legacy_player_unset_completed_cb(legacy_player_h player)
-{
-       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_COMPLETE, player);
-}
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-int legacy_player_set_retrieve_buffer_cb(legacy_player_h player, player_retrieve_buffer_cb callback, void *user_data)
-{
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player, callback, user_data);
-}
-
-int legacy_player_unset_retrieve_buffer_cb(legacy_player_h player)
-{
-       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER, player);
-}
-#endif
-
-int legacy_player_set_interrupted_cb(legacy_player_h player, player_interrupted_cb callback, void *user_data)
-{
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player, callback, user_data);
-}
-
-int legacy_player_unset_interrupted_cb(legacy_player_h player)
-{
-       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_INTERRUPT, player);
-}
-
-int legacy_player_set_error_cb(legacy_player_h player, player_error_cb callback, void *user_data)
-{
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player, callback, user_data);
-}
-
-int legacy_player_unset_error_cb(legacy_player_h player)
-{
-       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_ERROR, player);
-}
-
-int legacy_player_set_buffering_cb(legacy_player_h player, player_buffering_cb callback, void *user_data)
-{
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player, callback, user_data);
-}
-
-int legacy_player_unset_buffering_cb(legacy_player_h player)
-{
-       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_BUFFERING, player);
-}
-
-int legacy_player_set_subtitle_updated_cb(legacy_player_h player, player_subtitle_updated_cb callback, void *user_data)
-{
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player, callback, user_data);
-}
-
-int legacy_player_unset_subtitle_updated_cb(legacy_player_h player)
-{
-       return __unset_callback(MUSE_PLAYER_EVENT_TYPE_SUBTITLE, player);
-}
-
-int legacy_player_release_video_stream_bo(legacy_player_h player, void *bo)
-{
-       legacy_player_t *handle = (legacy_player_t *)player;
-       PLAYER_INSTANCE_CHECK(player);
-
-       LOGD("ENTER %p %p", player, bo);
-
-       mm_player_release_video_stream_bo(handle->mm_handle, bo);
-
-       LOGD("LEAVE");
-
-       return PLAYER_ERROR_NONE;
-}
-
-int legacy_player_set_media_packet_video_frame_decoded_cb(legacy_player_h player, legacy_player_media_packet_video_decoded_cb callback, void *user_data)
+int legacy_player_set_callback(legacy_player_h player, muse_player_event_e type, void *callback, void *user_data)
 {
+       int ret = PLAYER_ERROR_NONE;
        legacy_player_t *handle = (legacy_player_t *)player;
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(callback);
-       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
-
-       handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = callback;
-       handle->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = user_data;
 
-       return PLAYER_ERROR_NONE;
-}
+       ret = __check_callback_precondition(handle, type);
+       if (ret != PLAYER_ERROR_NONE) {
+               LOGE("precondition failure, type %d", type);
+               return ret;
+       }
 
-int legacy_player_set_video_stream_changed_cb(legacy_player_h player, player_video_stream_changed_cb callback, void *user_data)
-{
-       legacy_player_t *handle = (legacy_player_t *)player;
-       PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(callback);
-       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+       LEGACY_PLAYER_USER_CB_LOCK(player, type);
 
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player, callback, user_data);
-}
+       LOGD("event type : %d ", type);
 
-int legacy_player_unset_video_stream_changed_cb(legacy_player_h player)
-{
-       PLAYER_INSTANCE_CHECK(player);
+       handle->user_cb[type] = callback;
+       handle->user_data[type] = user_data;
 
-       __unset_callback(MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED, player);
+       LEGACY_PLAYER_USER_CB_UNLOCK(player, type);
 
        return PLAYER_ERROR_NONE;
 }
 
-int legacy_player_set_media_stream_buffer_status_cb(legacy_player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb callback, void *user_data)
+int legacy_player_unset_callback(legacy_player_h player, muse_player_event_e type)
 {
        legacy_player_t *handle = (legacy_player_t *)player;
        PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(callback);
-       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
-       /* the type can be expaned with default and text. */
-       if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
-               LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type);
-               return PLAYER_ERROR_INVALID_PARAMETER;
-       }
+       LOGD("event type : %d ", type);
 
-       if (type == PLAYER_STREAM_TYPE_VIDEO)
-               return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player, callback, user_data);
-       else
-               return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player, callback, user_data);
-}
+       LEGACY_PLAYER_USER_CB_LOCK(player, type);
 
-int legacy_player_unset_media_stream_buffer_status_cb(legacy_player_h player, player_stream_type_e type)
-{
-       PLAYER_INSTANCE_CHECK(player);
+       handle->user_cb[type] = NULL;
+       handle->user_data[type] = NULL;
 
-       if (type == PLAYER_STREAM_TYPE_VIDEO)
-               __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS, player);
-       else if (type == PLAYER_STREAM_TYPE_AUDIO)
-               __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS, player);
-       else
-               return PLAYER_ERROR_INVALID_PARAMETER;
+       LEGACY_PLAYER_USER_CB_UNLOCK(player, type);
 
        return PLAYER_ERROR_NONE;
 }
 
-int legacy_player_set_media_stream_seek_cb(legacy_player_h player, player_stream_type_e type, player_media_stream_seek_cb callback, void *user_data)
+int legacy_player_release_video_stream_bo(legacy_player_h player, void *bo)
 {
        legacy_player_t *handle = (legacy_player_t *)player;
        PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(callback);
-       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
-
-       /* the type can be expaned with default and text. */
-       if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
-               LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type);
-               return PLAYER_ERROR_INVALID_PARAMETER;
-       }
 
-       if (type == PLAYER_STREAM_TYPE_VIDEO)
-               return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player, callback, user_data);
-
-       return __set_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player, callback, user_data);
-}
+       LOGD("ENTER %p %p", player, bo);
 
-int legacy_player_unset_media_stream_seek_cb(legacy_player_h player, player_stream_type_e type)
-{
-       PLAYER_INSTANCE_CHECK(player);
+       mm_player_release_video_stream_bo(handle->mm_handle, bo);
 
-       if (type == PLAYER_STREAM_TYPE_VIDEO)
-               __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK, player);
-       else if (type == PLAYER_STREAM_TYPE_AUDIO)
-               __unset_callback(MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK, player);
-       else
-               return PLAYER_ERROR_INVALID_PARAMETER;
+       LOGD("LEAVE");
 
        return PLAYER_ERROR_NONE;
 }
index 5b25a7baf9e358fba666c0900475501fafc84f0d..e68527b42066cd3680c7da3e6331afcfb5926074 100644 (file)
@@ -108,64 +108,6 @@ int legacy_player_set_streaming_playback_rate(legacy_player_h player, float rate
        return ret;
 }
 
-int legacy_player_set_media_stream_buffer_status_cb_ex(legacy_player_h player, player_stream_type_e type, player_media_stream_buffer_status_cb_ex callback, void *user_data)
-{
-       legacy_player_t *handle = (legacy_player_t *)player;
-       muse_player_event_e event_type;
-       PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(callback);
-
-       if (handle->state != PLAYER_STATE_IDLE) {
-               LOGE("PLAYER_ERROR_INVALID_STATE : current state - %d", handle->state);
-               return PLAYER_ERROR_INVALID_STATE;
-       }
-       /* the type can be expaned with default and text. */
-       if ((type != PLAYER_STREAM_TYPE_VIDEO) && (type != PLAYER_STREAM_TYPE_AUDIO)) {
-               LOGE("PLAYER_ERROR_INVALID_PARAMETER(type : %d)", type);
-               return PLAYER_ERROR_INVALID_PARAMETER;
-       }
-
-       if (type == PLAYER_STREAM_TYPE_VIDEO)
-               event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
-       else
-               event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
-
-       LEGACY_PLAYER_USER_CB_LOCK(handle, event_type);
-
-       handle->user_cb[event_type] = callback;
-       handle->user_data[event_type] = user_data;
-
-       LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
-
-       LOGI("Event type : %d ", type);
-       return PLAYER_ERROR_NONE;
-}
-
-int legacy_player_unset_media_stream_buffer_status_cb_ex(legacy_player_h player, player_stream_type_e type)
-{
-       legacy_player_t *handle = (legacy_player_t *)player;
-       muse_player_event_e event_type;
-       PLAYER_INSTANCE_CHECK(player);
-
-       if (type == PLAYER_STREAM_TYPE_VIDEO)
-               event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
-       else if (type == PLAYER_STREAM_TYPE_AUDIO)
-               event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
-       else
-               return PLAYER_ERROR_INVALID_PARAMETER;
-
-       LEGACY_PLAYER_USER_CB_LOCK(handle, event_type);
-
-       handle->user_cb[event_type] = NULL;
-       handle->user_data[event_type] = NULL;
-
-       LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type);
-
-       LOGI("Event type : %d ", type);
-
-       return PLAYER_ERROR_NONE;
-}
-
 int legacy_player_set_media_stream_dynamic_resolution(legacy_player_h player, bool drc)
 {
        legacy_player_t *handle = (legacy_player_t *)player;
index 5a2f4f349811f691b43a7e8610412ccbf7860006..e62053a1cc877b44a50056b24eab3d60cb1a0dc6 100644 (file)
@@ -504,53 +504,6 @@ static void _prepare_async_cb(void *user_data)
        PLAYER_SEND_EVENT_MSG(api, ev, module);
 }
 
-static void __player_callback(muse_player_event_e ev, muse_module_h module)
-{
-       muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-
-       LOGD("ENTER event: %d", ev);
-
-       PLAYER_SEND_EVENT_MSG(api, ev, module);
-}
-
-static void _seek_complate_cb(void *user_data)
-{
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SEEK;
-       __player_callback(ev, (muse_module_h)user_data);
-}
-
-static void _completed_cb(void *user_data)
-{
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_COMPLETE;
-       __player_callback(ev, (muse_module_h)user_data);
-}
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-static void _retrieve_buffer_cb(void *user_data)
-{
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER;
-       __player_callback(ev, (muse_module_h)user_data);
-}
-#endif
-
-static void _set_completed_cb(legacy_player_h player, void *module, bool set)
-{
-       if (set)
-               legacy_player_set_completed_cb(player, _completed_cb, module);
-       else
-               legacy_player_unset_completed_cb(player);
-}
-
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-static void _set_retrieve_buffer_cb(legacy_player_h player, void *module, bool set)
-{
-       if (set)
-               legacy_player_set_retrieve_buffer_cb(player, _retrieve_buffer_cb, module);
-       else
-               legacy_player_unset_retrieve_buffer_cb(player);
-}
-#endif
-
 static void _capture_video_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
@@ -696,7 +649,8 @@ static int _get_media_packet_mimetype(int in_format, media_format_mimetype_e *mi
 
        return PLAYER_ERROR_NONE;
 }
-static bool __video_decoded_callback(void *video_data, void *user_data)
+
+static bool __mplayer_video_decoded_callback(void *video_data, void *user_data)
 {
        int ret = 0;
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
@@ -815,7 +769,7 @@ ERROR:
        return ret_val;
 }
 
-static void _video_stream_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
+static void __mplayer_video_stream_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
        muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED;
@@ -826,77 +780,43 @@ static void _video_stream_changed_cb(int width, int height, int fps, int bit_rat
                        MUSE_TYPE_INT, "fps", fps, MUSE_TYPE_INT, "bit_rate", bit_rate);
 }
 
-static void _media_stream_audio_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
+static void __mplayer_media_stream_buffer_status_cb(muse_player_event_e ev,
+                       player_media_stream_buffer_status_e status, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS;
        muse_module_h module = (muse_module_h)user_data;
 
        PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "status", (int)status);
 }
 
-static void _media_stream_video_buffer_status_cb(player_media_stream_buffer_status_e status, void *user_data)
-{
-       muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS;
-       muse_module_h module = (muse_module_h)user_data;
-
-       PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "status", (int)status);
-}
-
-static void _media_stream_audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
-{
-       muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO;
-       muse_module_h module = (muse_module_h)user_data;
-
-       PLAYER_SEND_EVENT_MSG(api, ev, module,
-                       MUSE_TYPE_INT, "status", (int)status, MUSE_TYPE_INT64, "bytes", (INT64)bytes);
-}
-
-static void _media_stream_video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
+static void __mplayer_media_stream_buffer_status_cb_ex(muse_player_event_e ev,
+                       player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO;
        muse_module_h module = (muse_module_h)user_data;
 
        PLAYER_SEND_EVENT_MSG(api, ev, module,
                        MUSE_TYPE_INT, "status", (int)status, MUSE_TYPE_INT64, "bytes", (INT64)bytes);
 }
 
-static void _media_stream_audio_seek_cb(unsigned long long offset, void *user_data)
+static void __mplayer_media_stream_seek_cb(muse_player_event_e ev, unsigned long long offset, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK;
        muse_module_h module = (muse_module_h)user_data;
 
        PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT64, "offset", (INT64)offset);
 }
 
-static void _media_stream_video_seek_cb(unsigned long long offset, void *user_data)
+static void __mplayer_default_callback(muse_player_event_e ev, muse_module_h module)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK;
-       muse_module_h module = (muse_module_h)user_data;
 
-       PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT64, "offset", (INT64)offset);
-}
-
-static void _interrupted_cb(void *user_data)
-{
-       muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_INTERRUPT;
-       __player_callback(ev, (muse_module_h)user_data);
-}
+       LOGD("ENTER event: %d", ev);
 
-static void _set_interrupted_cb(legacy_player_h player, void *module, bool set)
-{
-       if (set)
-               legacy_player_set_interrupted_cb(player, _interrupted_cb, module);
-       else
-               legacy_player_unset_interrupted_cb(player);
+       PLAYER_SEND_EVENT_MSG(api, ev, module);
 }
 
-static void _error_cb(int code, void *user_data)
+static void __mplayer_error_cb(int code, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
        muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_ERROR;
@@ -907,15 +827,7 @@ static void _error_cb(int code, void *user_data)
        PLAYER_SEND_EVENT_MSG(api, ev, module, MUSE_TYPE_INT, "code", code);
 }
 
-static void _set_error_cb(legacy_player_h player, void *module, bool set)
-{
-       if (set)
-               legacy_player_set_error_cb(player, _error_cb, module);
-       else
-               legacy_player_unset_error_cb(player);
-}
-
-static void _subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
+static void __mplayer_subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
        muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_SUBTITLE;
@@ -927,15 +839,7 @@ static void _subtitle_updated_cb(unsigned long duration, char *text, void *user_
                        MUSE_TYPE_INT, "duration", (int)duration, MUSE_TYPE_STRING, "text", (const char *)text);
 }
 
-static void _set_subtitle_cb(legacy_player_h player, void *module, bool set)
-{
-       if (set)
-               legacy_player_set_subtitle_updated_cb(player, _subtitle_updated_cb, module);
-       else
-               legacy_player_unset_subtitle_updated_cb(player);
-}
-
-static void _buffering_cb(int percent, void *user_data)
+static void __mplayer_buffering_cb(int percent, void *user_data)
 {
        muse_player_cb_e api = MUSE_PLAYER_CB_EVENT;
        muse_player_event_e ev = MUSE_PLAYER_EVENT_TYPE_BUFFERING;
@@ -947,165 +851,70 @@ static void _buffering_cb(int percent, void *user_data)
 
 }
 
-static void _set_buffering_cb(legacy_player_h player, void *module, bool set)
-{
-       if (set)
-               legacy_player_set_buffering_cb(player, _buffering_cb, module);
-       else
-               legacy_player_unset_buffering_cb(player);
-}
-
-static void _set_media_packet_video_frame_cb(legacy_player_h player, void *data, bool set)
-{
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-       muse_module_h module = (muse_module_h)data;
-       muse_player_handle_t *muse_player = NULL;
-       muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
-
-       if (set) {
-               muse_player->export_video_data = true;
-               ret = legacy_player_set_media_packet_video_frame_decoded_cb(player, __video_decoded_callback, module);
-       } else {
-               muse_player->export_video_data = false;
-               LOGD("video data will not be exported.");
-       }
-
-       PLAYER_RETURN_MSG(api, ret, module);
-}
-
-static void _set_video_stream_changed_cb(legacy_player_h player, void *data, bool set)
-{
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-       muse_module_h module = (muse_module_h)data;
-
-       if (set)
-               ret = legacy_player_set_video_stream_changed_cb(player, _video_stream_changed_cb, module);
-       else
-               ret = legacy_player_unset_video_stream_changed_cb(player);
-
-       PLAYER_RETURN_MSG(api, ret, module);
-}
-
-static void _set_media_stream_audio_seek_cb(legacy_player_h player, void *data, bool set)
-{
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-       muse_module_h module = (muse_module_h)data;
-
-       if (set)
-               ret = legacy_player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_seek_cb, module);
-       else
-               ret = legacy_player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_AUDIO);
-
-       PLAYER_RETURN_MSG(api, ret, module);
-}
-
-static void _set_media_stream_video_seek_cb(legacy_player_h player, void *data, bool set)
+static void __mplayer_set_enable_data_export(legacy_player_h player, void *data, bool set)
 {
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-       muse_module_h module = (muse_module_h)data;
-
-       if (set)
-               ret = legacy_player_set_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_seek_cb, module);
-       else
-               ret = legacy_player_unset_media_stream_seek_cb(player, PLAYER_STREAM_TYPE_VIDEO);
-
-       PLAYER_RETURN_MSG(api, ret, module);
-}
-
-static void _set_media_stream_audio_buffer_cb(legacy_player_h player, void *data, bool set)
-{
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-       muse_module_h module = (muse_module_h)data;
-
-       if (set)
-               ret = legacy_player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb, module);
-       else
-               ret = legacy_player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_AUDIO);
-
-       PLAYER_RETURN_MSG(api, ret, module);
-}
-
-static void _set_media_stream_video_buffer_cb(legacy_player_h player, void *data, bool set)
-{
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
        muse_module_h module = (muse_module_h)data;
+       muse_player_handle_t *muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
+
+       muse_player->export_video_data = set;
+}
+
+static void *__mplayer_callback_function[MUSE_PLAYER_EVENT_TYPE_NUM] = {
+       NULL,                           /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
+       __mplayer_default_callback,     /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
+       __mplayer_default_callback,     /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
+       __mplayer_error_cb,             /* MUSE_PLAYER_EVENT_TYPE_ERROR */
+       __mplayer_buffering_cb,         /* MUSE_PLAYER_EVENT_TYPE_BUFFERING */
+       __mplayer_subtitle_updated_cb,  /* MUSE_PLAYER_EVENT_TYPE_SUBTITLE */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_CAPTURE */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_SEEK */
+       __mplayer_video_decoded_callback, /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */
+#ifdef _PLAYER_FOR_PRODUCT
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_IMAGE_BUFFER */
+       NULL,                /* MUSE_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE */
+#endif
+       __mplayer_media_stream_buffer_status_cb,     /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS */
+       __mplayer_media_stream_buffer_status_cb,     /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS */
+       __mplayer_media_stream_buffer_status_cb_ex,  /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO */
+       __mplayer_media_stream_buffer_status_cb_ex,  /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO */
+       __mplayer_media_stream_seek_cb,              /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK */
+       __mplayer_media_stream_seek_cb,              /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
+       NULL,                                        /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
+       __mplayer_video_stream_changed_cb,           /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
+       __mplayer_default_callback,   /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */
+#endif
+       NULL,                         /* MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED */
+       NULL,                         /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME, DEPRECATED_PLAYER_INTERNAL_API */
+};
 
-       if (set)
-               ret = legacy_player_set_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb, module);
-       else
-               ret = legacy_player_unset_media_stream_buffer_status_cb(player, PLAYER_STREAM_TYPE_VIDEO);
-
-       PLAYER_RETURN_MSG(api, ret, module);
-}
-
-static void _set_media_stream_audio_buffer_cb_ex(legacy_player_h player, void *data, bool set)
+static int __mplayer_set_callback_func(legacy_player_h player, muse_player_event_e type, bool set, void *user_data)
 {
        int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-       muse_module_h module = (muse_module_h)data;
 
-       if (set)
-               ret = legacy_player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO, _media_stream_audio_buffer_status_cb_ex, module);
-       else
-               ret = legacy_player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_AUDIO);
+       LOGD("set callback type %d, set %d", type, set);
 
-       PLAYER_RETURN_MSG(api, ret, module);
-}
+       if (!__mplayer_callback_function[type]) {
+               LOGE("there is no mplayer callback");
+               return PLAYER_ERROR_INVALID_OPERATION;
+       }
 
-static void _set_media_stream_video_buffer_cb_ex(legacy_player_h player, void *data, bool set)
-{
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
-       muse_module_h module = (muse_module_h)data;
+       if (type == MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME)
+               __mplayer_set_enable_data_export(player, user_data, set);
 
        if (set)
-               ret = legacy_player_set_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO, _media_stream_video_buffer_status_cb_ex, module);
+               ret = legacy_player_set_callback(player, type, __mplayer_callback_function[type], user_data);
        else
-               ret = legacy_player_unset_media_stream_buffer_status_cb_ex(player, PLAYER_STREAM_TYPE_VIDEO);
+               ret = legacy_player_unset_callback(player, type);
 
-       PLAYER_RETURN_MSG(api, ret, module);
+       return ret;
 }
 
-static void (*set_callback_func[MUSE_PLAYER_EVENT_TYPE_NUM])(legacy_player_h player, void *user_data, bool set) = {
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_PREPARE */
-       _set_completed_cb,              /* MUSE_PLAYER_EVENT_TYPE_COMPLETE */
-       _set_interrupted_cb,    /* MUSE_PLAYER_EVENT_TYPE_INTERRUPT */
-       _set_error_cb,                  /* MUSE_PLAYER_EVENT_TYPE_ERROR */
-       _set_buffering_cb,              /* MUSE_PLAYER_EVENT_TYPE_BUFFERING */
-       _set_subtitle_cb,               /* MUSE_PLAYER_EVENT_TYPE_SUBTITLE */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_CAPTURE */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_SEEK */
-       _set_media_packet_video_frame_cb,       /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_AUDIO_FRAME */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_SUPPORTED_AUDIO_EFFECT_PRESET */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_MISSED_PLUGIN */
-#ifdef _PLAYER_FOR_PRODUCT
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_IMAGE_BUFFER */
-       NULL,                                   /* MUSE_PLAYER_EVENT_TYPE_SELECTED_SUBTITLE_LANGUAGE */
-#endif
-       _set_media_stream_video_buffer_cb,      /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS */
-       _set_media_stream_audio_buffer_cb,      /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS */
-       _set_media_stream_video_buffer_cb_ex,   /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO */
-       _set_media_stream_audio_buffer_cb_ex,   /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO */
-       _set_media_stream_video_seek_cb,        /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_SEEK */
-       _set_media_stream_audio_seek_cb,        /* MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_SEEK */
-       NULL,                                                           /* MUSE_PLAYER_EVENT_TYPE_AUDIO_STREAM_CHANGED */
-       _set_video_stream_changed_cb,           /* MUSE_PLAYER_EVENT_TYPE_VIDEO_STREAM_CHANGED */
-#ifdef TIZEN_FEATURE_EVAS_RENDERER
-       _set_retrieve_buffer_cb,        /* MUSE_PLAYER_EVENT_TYPE_RETURN_BUFFER */
-#endif
-       NULL,                           /* MUSE_PLAYER_EVENT_TYPE_SERVICE_DISCONNECTED */
-       NULL,                           /* MUSE_PLAYER_EVENT_TYPE_AUDIO_FRAME, DEPRECATED_PLAYER_INTERNAL_API */
-};
-
 static int _push_media_stream(muse_player_handle_t *muse_player, player_push_media_msg_type *push_media, char *buf)
 {
        int ret = MEDIA_FORMAT_ERROR_NONE;
@@ -1754,7 +1563,7 @@ int player_disp_set_play_position(muse_module_h module)
                                                                INVALID_MUSE_TYPE_VALUE);
        if (ret_val) {
                muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
-               ret = legacy_player_set_play_position(muse_player->player_handle, pos, accurate, _seek_complate_cb, module);
+               ret = legacy_player_set_play_position(muse_player->player_handle, pos, accurate, __mplayer_default_callback, module);
        } else {
                ret = PLAYER_ERROR_INVALID_OPERATION;
        }
@@ -2691,15 +2500,27 @@ int player_disp_set_callback(muse_module_h module)
                                                                MUSE_TYPE_INT, "set", (void *)&set,
                                                                INVALID_MUSE_TYPE_VALUE);
 
-       if (ret_val) {
-               muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
-               if (type < MUSE_PLAYER_EVENT_TYPE_NUM && set_callback_func[type] != NULL)
-                       set_callback_func[type] (muse_player->player_handle, module, set);
-       } else {
+       if (!ret_val) {
+               LOGE("failed to get param value");
                ret = PLAYER_ERROR_INVALID_OPERATION;
-               PLAYER_RETURN_MSG(MUSE_PLAYER_API_SET_CALLBACK, ret, module);
+               goto EXIT;
+       }
+
+       if (type >= MUSE_PLAYER_EVENT_TYPE_NUM) {
+               LOGE("invalid type value %d", type);
+               ret = PLAYER_ERROR_INVALID_PARAMETER;
+               goto EXIT;
        }
 
+       muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
+       ret = __mplayer_set_callback_func(muse_player->player_handle, type, set, module);
+       if (ret != PLAYER_ERROR_NONE) {
+               LOGE("failed to set callback type %d", type);
+               /* goto EXIT; */
+       }
+
+EXIT:
+       PLAYER_RETURN_MSG(MUSE_PLAYER_API_SET_CALLBACK, ret, module);
        return ret;
 }
 
index a24d0a3696ecad257d2475f103c9e00af109f7b6..666a77fe823cdcd93d6ebd696dbec081ca52aadc 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.112
+Version:    0.2.113
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0