[1.0.1] Remove unused reference to fix mem leak
[platform/core/multimedia/libmm-player.git] / src / include / mm_player_priv.h
index 972aded..c5fbb44 100644 (file)
@@ -29,6 +29,7 @@
 |                                                                                                                                                                              |
 ========================================================================================== */
 #include <glib.h>
+#include <gmodule.h>
 #include <gst/gst.h>
 #include <mm_attrs.h>
 #include <math.h>
 #include <tbm_bufmgr.h>
 #include <storage.h>
 #include "mm_player.h"
-#include "mm_player_internal.h"
 #include "mm_player_audioeffect.h"
 #include "mm_message.h"
 #include "mm_player_ini.h"
 #include <mm_resource_manager.h>
-#include "mm_player_sound_focus.h"
-#include "mm_player_pd.h"
 #include "mm_player_streaming.h"
+#include "mm_player_attrs.h"
 
 /*===========================================================================================
 |                                                                                                                                                                                      |
 #define MM_PLAYER_IMGB_MPLANE_MAX      4
 #define MM_PLAYER_STREAM_COUNT_MAX     3
 
-#define MM_PLAYER_CAST(x_player)               ((mm_player_t *)(x_player))
-/**
- * @x_player: MMHandleType of player
- *
- * Get the PD downloader of this player.
- */
-#define MM_PLAYER_GET_PD(x_player)     (MM_PLAYER_CAST(x_player)->pd_downloader)
+#define MM_PLAYER_CAST(x_player)               ((mmplayer_t *)(x_player))
 /**
  * @x_player: MMHandleType of player
  *
  */
 #define MM_PLAYER_GET_ATTRS(x_player)  (MM_PLAYER_CAST(x_player)->attrs)
 
-#define ROTATION_USING_SINK     0
-#define ROTATION_USING_CUSTOM   1
-#define ROTATION_USING_FLIP     2
-
 #define MM_MAX_STRING_LENGTH    4000 /* have to be less than MUSE_MSG_MAX_LENGTH */
 
 #define VIDEO360_MAX_ZOOM      10.0f
 
+#define DEFAULT_NUM_OF_V_OUT_BUFFER            4
+
 /*---------------------------------------------------------------------------
 |    GLOBAL CONSTANT DEFINITIONS:                                                                                      |
 ---------------------------------------------------------------------------*/
@@ -113,16 +104,17 @@ enum content_attr_flag {
        ATTR_ALL = 0x0020,
 };
 
-/* async mode makes trouble. alsasink sometimes fails to pause. */
-enum alassink_sync {
-       ALSASINK_SYNC,
-       ALSASINK_ASYNC
+enum mmplayer_sink_type {
+       MMPLAYER_VIDEO_SINK = 0x01,
+       MMPLAYER_AUDIO_SINK = 0x02,
+       MMPLAYER_TEXT_SINK = 0x04,
+       MMPLAYER_SINK_ALL = 0x07,
 };
 
 /**
  * Enumerations of Player Uri type
  */
-enum MMPlayerUriType {
+enum mmplayer_uri_type {
        MM_PLAYER_URI_TYPE_NONE,                        /**< Player URI type None */
        MM_PLAYER_URI_TYPE_URL_RTSP,            /**< Player URI type RTSP */
        MM_PLAYER_URI_TYPE_URL_HTTP,            /**< Player URI type HTTP */
@@ -138,18 +130,18 @@ enum MMPlayerUriType {
        MM_PLAYER_URI_TYPE_TEMP,                        /**< Player URI type Temp */
 };
 
-typedef enum _MissingCodec {
+typedef enum {
        MISSING_PLUGIN_NONE = 0x00,
        MISSING_PLUGIN_AUDIO = 0x01,
        MISSING_PLUGIN_VIDEO = 0x02
-} MissingCodec;
+} missing_codec_e;
 
 
-typedef enum _FoundCodec {
+typedef enum {
        FOUND_PLUGIN_NONE = 0x00,
        FOUND_PLUGIN_AUDIO = 0x01,
        FOUND_PLUGIN_VIDEO = 0x02
-} FoundCodec;
+} found_codec_e;
 
 /**
  * Enumeration of signal type
@@ -162,10 +154,10 @@ typedef enum {
        MM_PLAYER_SIGNAL_TYPE_OTHERS,
        MM_PLAYER_SIGNAL_TYPE_ALL,
        MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
-} MMPlayerSignalType;
+} mmplayer_signal_type_e;
 
 /* main pipeline's element id */
-enum MainElementID {
+typedef enum {
        MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
        MMPLAYER_M_SRC,
        MMPLAYER_M_2ND_SRC,     /* 2nd Source Element for es buff src */
@@ -178,18 +170,12 @@ enum MainElementID {
        MMPLAYER_M_AUTOPLUG_V_DEC,
        MMPLAYER_M_AUTOPLUG_A_DEC,
 
-       /* NOTE : we need two fakesink to autoplug without decodebin.
-        * first one will hold whole pipeline state. and second one will hold state of
-        * a sink-decodebin for an elementary stream. no metter if there's more then one
-        * elementary streams because MSL reuse it.
-        */
+       /*fakesink will hold whole pipeline state. */
        MMPLAYER_M_SRC_FAKESINK,
-       MMPLAYER_M_SRC_2ND_FAKESINK,
 
        /* streaming plugin */
        MMPLAYER_M_MUXED_S_BUFFER,
        MMPLAYER_M_DEMUXED_S_BUFFER,
-       MMPLAYER_M_ID3DEMUX,
        MMPLAYER_M_ADAPTIVE_DEMUX,
 
        /* es buff src queue */
@@ -204,45 +190,45 @@ enum MainElementID {
        MMPLAYER_M_Q2,
        MMPLAYER_M_DEMUX,
        MMPLAYER_M_SUBPARSE,
-       MMPLAYER_M_DEMUX_EX,
+       MMPLAYER_M_V_PARSE,
        MMPLAYER_M_V_INPUT_SELECTOR,    // video input_select
        MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
        MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
-       MMPLAYER_M_A_TEE,
-       MMPLAYER_M_A_Q1,
-       MMPLAYER_M_A_Q2,
-       MMPLAYER_M_A_CONV,
-       MMPLAYER_M_A_FILTER,
-       MMPLAYER_M_A_DEINTERLEAVE,
-       MMPLAYER_M_A_SELECTOR,
-       MMPLAYER_M_V_SINK,
-       MMPLAYER_M_V_CONV,
+       MMPLAYER_M_V_CONCAT,    // video concat
+       MMPLAYER_M_A_CONCAT,    // audio concat
+       MMPLAYER_M_T_CONCAT,    // text concat
        MMPLAYER_M_NUM
-};
+} main_element_id_e;
 
 /* audio pipeline's element id */
-enum AudioElementID {
+enum audio_element_id {
        MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
-       MMPLAYER_A_TP,
        MMPLAYER_A_CONV,
        MMPLAYER_A_VOL,
        MMPLAYER_A_FILTER,
        MMPLAYER_A_FILTER_SEC,
-       MMPLAYER_A_CAPS_DEFAULT,
        MMPLAYER_A_CONV_BFORMAT,
        MMPLAYER_A_CAPS_360,
        MMPLAYER_A_SINK,
        MMPLAYER_A_RESAMPLER,
-       MMPLAYER_A_DEINTERLEAVE,
+       MMPLAYER_A_RGVOL,
+       MMPLAYER_A_CONV_PITCH,
+       MMPLAYER_A_PITCH,
+       MMPLAYER_A_TEE,
+       MMPLAYER_A_TEE_Q1,
+       MMPLAYER_A_TEE_Q2,
+       MMPLAYER_A_EXTRACT_CONV,
+       MMPLAYER_A_EXTRACT_RESAMPLER,
+       MMPLAYER_A_EXTRACT_CAPS,
+       MMPLAYER_A_EXTRACT_DEINTERLEAVE,
+       MMPLAYER_A_EXTRACT_SINK,
        MMPLAYER_A_NUM
 };
 
 /* video pipeline's element id */
-enum VideoElementID {
+enum video_element_id {
        MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
-       MMPLAYER_V_FLIP,
        MMPLAYER_V_CONV,
-       MMPLAYER_V_SCALE,
        MMPLAYER_V_CAPS,
        MMPLAYER_V_SINK,
        MMPLAYER_V_360,
@@ -250,7 +236,7 @@ enum VideoElementID {
 };
 
 /* text pipeline's element id */
-enum TextElementID {
+enum text_element_id {
        MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
        MMPLAYER_T_QUEUE,
        MMPLAYER_T_VIDEO_QUEUE,
@@ -261,14 +247,7 @@ enum TextElementID {
        MMPLAYER_T_NUM
 };
 
-/* midi main pipeline's element id */
-enum MidiElementID {
-       MMPLAYER_MIDI_PIPE,
-       MMPLAYER_MIDI_PLAYER,
-       MMPLAYER_MIDI_NUM
-};
-
-enum PlayerCommandState {
+typedef enum {
        MMPLAYER_COMMAND_NONE,
        MMPLAYER_COMMAND_CREATE,
        MMPLAYER_COMMAND_DESTROY,
@@ -279,13 +258,13 @@ enum PlayerCommandState {
        MMPLAYER_COMMAND_PAUSE,
        MMPLAYER_COMMAND_RESUME,
        MMPLAYER_COMMAND_NUM
-};
+} mmplayer_command_state_e;
 
-/* Note : StreamingSrcError is error enum for streaming source which post error message
+/* Note : mmplayer_streaming_src_error is error enum for streaming source which post error message
  *     using custom message made by itself. The enum value must start with zero,
  *     because the streaming source(secrtspsrc) also does.
  */
-enum StreamingSrcError {
+enum mmplayer_streaming_src_error {
        MMPLAYER_STREAMING_ERROR_NONE = 0,
        MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
        MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
@@ -335,10 +314,16 @@ enum StreamingSrcError {
 };
 
 typedef enum {
+       MMPLAYER_SEEK_NONE = 0,
+       MMPLAYER_SEEK_IN_PROGRESS,
+       MMPLAYER_SEEK_COMPLETED,        /* after getting async done but before posting seek complete */
+} mmplayer_seek_state_e;
+
+typedef enum {
        MMPLAYER_PATH_VOD = 0,
        MMPLAYER_PATH_TEXT,
        MMPLAYER_PATH_MAX
-} MMPlayerPathType;
+} mmplayer_path_type_e;
 
 /* Video360 related enums. These are duplication from video360.h from
  * gst-plugins-tizen.
@@ -350,7 +335,7 @@ typedef enum {
        VIDEO360_MODE_STEREOSCOPIC_LEFT_RIGHT = 2,
        VIDEO360_MODE_STEREOSCOPIC_STEREO_MESH = 3,
        VIDEO360_MODE_LAST_ITEM
-} mm_player_stereo_mode_e;
+} mmplayer_stereo_mode_e;
 
 typedef enum {
        VIDEO360_PROJECTION_TYPE_UNKNOWN = -1,
@@ -358,7 +343,7 @@ typedef enum {
        VIDEO360_PROJECTION_TYPE_CUBEMAP = 1,
        VIDEO360_PROJECTION_TYPE_MESH = 2,
        VIDEO360_PROJECTION_TYPE_LAST_ITEM
-} mm_player_projection_type_e;
+} mmplayer_projection_type_e;
 
 /* Spatial audio related enums. These are duplication from mm_file.h from
  * libmm-fileinfo.
@@ -367,21 +352,28 @@ typedef enum {
        MMFILE_AMBISONIC_TYPE_UNKNOWN = 0,
        MMFILE_AMBISONIC_TYPE_PERIPHONIC = 1,           /**< To comply with Google's Spatial Audio RFC*/
        MMFILE_AMBISONIC_TYPE_NON_PERIPHONIC = 2,
-} MMFILE_AMBISONIC_TYPE;
+} mmfile_ambisonic_type_e;
 
 typedef enum {
        MMFILE_AMBISONIC_FORMAT_UNKNOWN = 0,
        MMFILE_AMBISONIC_FORMAT_AMBIX = 1,              /**< AMBIX (Channel sequence: ACN, Normalization: SN3D) */
        MMFILE_AMBISONIC_FORMAT_AMB = 2,                /**< .AMB, Tetraproc (Channel sequence: FuMa, Normalization: FuMa) */
        MMFILE_AMBISONIC_FORMAT_UA = 3,                 /**< Universal Ambisonics (Channel sequence: SID, Normalization: N3D) */
-} MMFILE_AMBISONIC_FORMAT;
+} mmfile_ambisonic_format_e;
 
 typedef enum {
        MMFILE_AMBISONIC_ORDER_UNKNOWN = 0,
        MMFILE_AMBISONIC_ORDER_FOA = 1,                 /**< First order Ambisonics */
        MMFILE_AMBISONIC_ORDER_SOA = 2,                 /**< Second order Ambisonics */
        MMFILE_AMBISONIC_ORDER_TOA = 3,                 /**< Third order Ambisonics */
-} MMFILE_AMBISONIC_ORDER;
+} mmfile_ambisonic_order_e;
+
+typedef enum {
+       MMPLAYER_RESOURCE_TYPE_VIDEO_DECODER,
+       MMPLAYER_RESOURCE_TYPE_VIDEO_OVERLAY,
+       MMPLAYER_RESOURCE_TYPE_AUDIO_OFFLOAD,
+       MMPLAYER_RESOURCE_TYPE_MAX,
+} mmplayer_resource_type_e;
 
 /*---------------------------------------------------------------------------
 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                     |
@@ -390,77 +382,83 @@ typedef enum {
 typedef struct {
        int id;
        GstElement *gst;
-} MMPlayerGstElement;
+} mmplayer_gst_element_t;
 
 typedef struct {
        GstTagList *tag_list;
-       MMPlayerGstElement *mainbin;
-       MMPlayerGstElement *audiobin;
-       MMPlayerGstElement *videobin;
-       MMPlayerGstElement *textbin;
-} MMPlayerGstPipelineInfo;
+       mmplayer_gst_element_t *mainbin;
+       mmplayer_gst_element_t *audiobin;
+       mmplayer_gst_element_t *videobin;
+       mmplayer_gst_element_t *textbin;
+} mmplayer_pipeline_info_t;
 
 typedef struct {
        float volume;
-       int mute;
-       int bluetooth;  /* enable/disable */
-} MMPlayerSoundInfo;
+       bool mute;
+       bool rg_enable;
+} mmplayer_sound_info_t;
 
 typedef struct {
        char *buf;
        int len;
        int offset;
-
-} tBuffer; /* FIXIT : choose better name */
+} mmplayer_input_buffer_t;
 
 typedef struct {
        int uri_type;
-       int     play_mode;
-       void *mem;
-       int     mem_size;
+       mmplayer_input_buffer_t input_mem;
        char uri[MM_MAX_URL_LEN];
        char urgent[MM_MAX_FILENAME_LEN];
-} MMPlayerParseProfile;
+} mmplayer_parse_profile_t;
 
 typedef struct {
        storage_type_e type;
        storage_state_e state;
        int id;
        char path[MM_MAX_URL_LEN];
-} MMPlayerStorageInfo;
+} mmplayer_storage_info_t;
 
 typedef struct {
        bool is_pending;
-       MMPlayerPosFormatType format;
-       unsigned long pos;
-} MMPlayerPendingSeek;
+       gint64 pos;
+} mmplayer_pending_seek_t;
 
 typedef struct {
-       GObjectobj;
+       GObject *obj;
        gulong sig;
-} MMPlayerSignalItem;
+} mmplayer_signal_item_t;
 
 typedef struct {
        bool rich_audio;
-       bool safety_volume;
-       bool pcm_extraction;
        bool video_zc; // video zero-copy
        bool subtitle_off;
-       bool media_packet_video_stream;
-} MMPlayerSetMode;
+       bool video_export;
+} mmplayer_setting_mode_t; /* FIXME: renaming */
+
+typedef struct {
+       GMainContext *global_default;
+       GMainContext *thread_default;
+} mmplayer_context_info_t;
 
 typedef struct {
        gint uri_idx;
        GList *uri_list;
-} MMPlayerUriList;
+} mmplayer_uri_list_t;
+
+typedef struct {
+       double scale_x;
+       double scale_y;
+       double scale_width;
+       double scale_height;
+} mmplayer_video_roi_t;
 
 typedef struct {
-       gint active_pad_index;
+       gint active_track_index;
        gint total_track_num;
-       GPtrArray *channels;
-       gulong block_id;
-       gulong event_probe_id;
-} mm_player_selector_t;
+       GPtrArray *streams;
+       gulong block_id;                /* FIXME: will be removed */
+       gulong event_probe_id;  /* FIXME: will be removed */
+} mmplayer_track_t;
 
 typedef struct {
        gboolean running;
@@ -472,18 +470,17 @@ typedef struct {
        GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
        gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];
 
-} mm_player_gapless_t;
+} mmplayer_gapless_t;
 
 typedef struct {
        int channel;
        int bitrate;
-       int depth;
-       bool is_little_endian;
        guint64 channel_mask;
        void *pcm_data;
        int data_size;
        int buff_size;
-} mm_player_audio_stream_buff_t;
+       media_format_mimetype_e pcm_format;
+} mmplayer_audio_stream_buff_t;
 
 /**
  * @brief data of video_bo_list
@@ -491,20 +488,27 @@ typedef struct {
  * @since_tizen 3.0
  */
 typedef struct {
-       gboolean using;
-       voidbo;
-} mm_player_video_bo_info_t;
+       gboolean used;
+       void *bo;
+} mmplayer_video_bo_info_t;
 
 typedef struct {
        gint bandwidth;
        gint width;
        gint height;
-} VariantData;
+} stream_variant_t;
 
 typedef struct {
-       GList* var_list;
-       VariantData limit;
-} MMAdaptiveVariantInfo;
+       GList *var_list;
+       stream_variant_t limit;
+} mmplayer_adaptive_variant_info_t;
+
+typedef struct {
+       GCond ticket_cond;
+       GMutex ticket_mutex;
+       guint ticket_queue_head;
+       guint ticket_queue_tail;
+} mmplayer_ticket_lock_t;
 
 typedef struct {
        int is_spherical;
@@ -512,8 +516,8 @@ typedef struct {
        char *stitching_software;
        char *projection_type_string;
        char *stereo_mode_string;
-       mm_player_projection_type_e projection_type;
-       mm_player_stereo_mode_e stereo_mode;
+       mmplayer_projection_type_e projection_type;
+       mmplayer_stereo_mode_e stereo_mode;
        int source_count;
        int init_view_heading;
        int init_view_pitch;
@@ -528,7 +532,20 @@ typedef struct {
        int ambisonic_type;
        int ambisonic_format;
        int ambisonic_order;
-} mm_player_spherical_metadata_t;
+} mmplayer_spherical_metadata_t;
+
+typedef struct {
+       GModule *img_module;
+       GModule *imgp_module;
+       int  (*create)(unsigned int, unsigned int,
+                       int, const unsigned char *, size_t, void **);
+       void (*destroy)(void *);
+       int  (*get)(void *, unsigned int *, unsigned int *,
+                       int *, unsigned char **, size_t *);
+       void (*debug)(void *, const char *);
+       int  (*rotate)(void *, int, void **);
+       int  (*convert)(void *, int, void **);
+} mm_img_util_interface_t;
 
 typedef struct {
        /* STATE */
@@ -538,47 +555,37 @@ typedef struct {
        int target_state;                               // player state which user want to go to
        guint state_change_timeout;
 
-       gboolean section_repeat;
-       gint section_repeat_start;
-       gint section_repeat_end;
-       guint play_count;
-
        gchar *album_art;
 
        int cmd;
 
        /* command lock */
-       GMutex cmd_lock;
-       GMutex playback_lock;
-
-       /* repeat thread lock */
-       GCond repeat_thread_cond;
-       GMutex repeat_thread_mutex;
-       GThread* repeat_thread;
-       gboolean repeat_thread_exit;
-
-       /* next play thread */
-       GThread* next_play_thread;
-       gboolean next_play_thread_exit;
-       GCond next_play_thread_cond;
-       GMutex next_play_thread_mutex;
-       mm_player_gapless_t gapless;
+       mmplayer_ticket_lock_t *cmd_lock;
+       GMutex reconfigure_lock;
+       GCond reconfigure_cond;
+
+       /* gapless play thread */
+       GThread *gapless_play_thread;
+       gboolean gapless_play_thread_exit;
+       GCond gapless_play_thread_cond;
+       GMutex gapless_play_thread_mutex;
+       mmplayer_gapless_t gapless;
 
        /* capture thread */
-       GThreadcapture_thread;
+       GThread *capture_thread;
        gboolean capture_thread_exit;
        GCond capture_thread_cond;
        GMutex capture_thread_mutex;
-       MMPlayerVideoCapture capture;
-       MMPlayerVideoColorspace video_cs;
+       mmplayer_video_capture_t capture;
+       mmplayer_video_color_space_e video_cs;
        MMVideoBuffer captured;
+       mm_img_util_interface_t *img_util;
 
        /* gst bus msg thread, create during realize */
-       GThreadbus_msg_thread;
+       GThread *bus_msg_thread;
        gboolean bus_msg_thread_exit;
        GCond bus_msg_thread_cond;
        GMutex bus_msg_thread_mutex;
-       gint bus_msg_timeout; /* ms */
 
        /* fakesink handling lock */
        GMutex fsink_lock;
@@ -588,100 +595,74 @@ typedef struct {
 
        /* player attributes */
        MMHandleType attrs;
+       mmplayer_attrs_spec_t *default_attrs;
 
        /* message callback */
        MMMessageCallback msg_cb;
-       void* msg_cb_param;
-
-       /* progressive download */
-       mm_player_pd_t *pd_downloader;
-       gchar *pd_file_save_path;
-       MMPlayerPDMode pd_mode;
+       void *msg_cb_param;
 
        /* streaming player */
-       mm_player_streaming_t *streamer;
-       gchar *http_file_buffering_path;
+       mmplayer_streaming_t *streamer;
 
        /* gstreamer pipeline */
-       MMPlayerGstPipelineInfo *pipeline;
+       mmplayer_pipeline_info_t        *pipeline;
 
        /* pad */
        GstPad *ghost_pad_for_videobin;
 
        guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
        guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
-       mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
-       mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
-       GMutex media_stream_cb_lock;
-
-       int video_num_buffers;  /* total num of buffers in vcodec */
-       int video_extra_num_buffers; /* extra num of buffers in vcodec */
-
-       void* buffer_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
-       void* seek_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
-
-       /* video stream changed callback */
-       mm_player_stream_changed_callback video_stream_changed_cb;
-       void* video_stream_changed_cb_user_param;
 
        /* audio stream changed callback */
        mm_player_stream_changed_callback audio_stream_changed_cb;
-       voidaudio_stream_changed_cb_user_param;
+       void *audio_stream_changed_cb_user_param;
 
        /* video stream callback */
-       mm_player_video_stream_callback video_stream_cb;
-       void* video_stream_cb_user_param;
+       mm_player_video_decoded_callback video_decoded_cb;
+       void *video_decoded_cb_user_param;
        GCond video_bo_cond;
        GMutex video_bo_mutex;
-       GList* video_bo_list; /* mm_player_video_bo_info_t, bo list for decoded video data by sw codec */
+       GList *video_bo_list; /* mmplayer_video_bo_info_t, bo list for decoded video data by sw codec */
        int video_bo_size;
        bool video_stream_prerolled;
 
-       /* audio stram callback */
-       mm_player_audio_stream_callback audio_stream_cb;
-       void* audio_stream_cb_user_param;
-       bool audio_stream_sink_sync;
-       GList* audio_stream_buff_list; /* mm_player_audio_stream_buff_t, buff list of extract pcm data */
-
-       /* audio buffer callback */
-       mm_player_audio_stream_callback_ex audio_stream_render_cb_ex;
+       /* audio stream callback */
+       mm_player_audio_decoded_callback audio_decoded_cb;
+       void *audio_decoded_cb_user_param;
+       GList *audio_stream_buff_list; /* mmplayer_audio_stream_buff_t, buff list of extract pcm data */
+       mmplayer_audio_extract_opt_e audio_extract_opt;
 
        /* video capture callback*/
        gulong video_capture_cb_probe_id;
 
        /* sound info */
-       MMPlayerSoundInfo       sound;
+       mmplayer_sound_info_t   sound;
 
        /* type string */
-       gchar *type;
+       gchar *type_caps_str;
 
        /* video stream caps parsed by demuxer */
-       GstCapsv_stream_caps;
+       GstCaps *v_stream_caps;
 
-       /* audio effect infomation */
-       MMAudioEffectInfo audio_effect_info;
+       /* audio effect information */
+       mm_audio_effect_info_t audio_effect_info;
        gboolean bypass_audio_effect;
 
-       gulong audio_cb_probe_id;
-
-       /* for appsrc */
-       tBuffer mem_buf;
-
        /* content profile */
-       MMPlayerParseProfile profile;
-       MMPlayerStorageInfo storage_info[MMPLAYER_PATH_MAX];
+       mmplayer_parse_profile_t profile;
+       mmplayer_storage_info_t storage_info[MMPLAYER_PATH_MAX];
 
        /* streaming service type */
        MMStreamingType streaming_type;
 
        /* autoplugging */
-       GList* factories;
-       gboolean have_dynamic_pad;
-       GList* parsers; // list of linked parser name
-       GList* audio_decoders; // list of linked audio name
+       GList *factories;
+       GList *audio_decoders; // list of linked audio name
        gboolean no_more_pad;
        gint num_dynamic_pad;
        gboolean has_many_types;
+       gboolean need_audio_dec_sorting;
+       gboolean need_video_dec_sorting;
 
        /* progress callback timer */
        /* FIXIT : since duplicated functionality with get_position
@@ -693,7 +674,7 @@ typedef struct {
        /* timer for sending delayed EOS */
        guint eos_timer;
 
-       /* last point (msec) that player is paused or seeking */
+       /* last point that player is paused or seeking */
        gint64 last_position;
 
        /* duration */
@@ -709,12 +690,10 @@ typedef struct {
 
        gint videodec_linked;
        gint audiodec_linked;
-       gint videosink_linked;
-       gint audiosink_linked;
        gint textsink_linked;
 
        /* missing plugin during autoplugging */
-       MissingCodec not_supported_codec;
+       missing_codec_e not_supported_codec;
 
        /* unlinked audio/video mime type */
        gchar *unlinked_video_mime;
@@ -722,25 +701,31 @@ typedef struct {
        gchar *unlinked_demuxer_mime;
 
        /* found codec during autoplugging */
-       FoundCodec can_support_codec;
+       found_codec_e can_support_codec;
 
        gboolean not_found_demuxer;
 
        /* support seek even though player is not start */
-       MMPlayerPendingSeek pending_seek;
-
-       gboolean doing_seek;
+       mmplayer_pending_seek_t pending_seek;
+       mmplayer_seek_state_e seek_state;
 
        /* prevent to post msg over and over */
        gboolean msg_posted;
 
        /* list of sink elements */
-       GList* sink_elements;
+       GList *sink_elements;
+
+       /* for destroy bus thread */
+       GMutex bus_watcher_mutex;
+       GCond bus_watcher_cond;
 
        /* signal notifiers */
-       GList* signals[MM_PLAYER_SIGNAL_TYPE_MAX];
-       GMainContext *global_default;
-       MMPlayerUriList uri_info;
+       GList *signals[MM_PLAYER_SIGNAL_TYPE_MAX];
+       guint bus_watcher;
+       GQueue *bus_msg_q;
+       GMutex bus_msg_q_lock;
+       mmplayer_context_info_t context;
+       mmplayer_uri_list_t uri_info;
 
        gboolean is_sound_extraction;
 
@@ -753,13 +738,9 @@ typedef struct {
 
        /* resource manager for H/W resources */
        mm_resource_manager_h resource_manager;
-       mm_resource_manager_res_h video_overlay_resource;
-       mm_resource_manager_res_h video_decoder_resource;
+       mm_resource_manager_res_h hw_resource[MMPLAYER_RESOURCE_TYPE_MAX];
        gboolean interrupted_by_resource;
 
-       /* sound focus for being compatible with legacy session policy internally */
-       MMPlayerSoundFocus sound_focus;
-
        gboolean is_subtitle_off;
        gboolean is_external_subtitle_present;
        gboolean is_external_subtitle_added_now;
@@ -771,82 +752,54 @@ typedef struct {
        guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
        guint total_maximum_bitrate;
 
-       /* prevent it from posting duplicatly*/
+       /* prevent from posting duplicated BOS message */
        gboolean sent_bos;
 
-       /* timeout source for lazy pause */
-       guint resume_event_id;
-       guint resumable_cancel_id;
-
        gboolean play_subtitle;
        gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
 
-       /* PD downloader message callback and param */
-       MMMessageCallback pd_msg_cb;
-       void* pd_msg_cb_param;
-
        /* adjust subtitle position store */
        gint64 adjust_subtitle_pos;
        GList *subtitle_language_list;
        GCond subtitle_info_cond;
        GMutex subtitle_info_mutex;
 
-       /* To store the current multiwindow status */
-       gboolean last_multiwin_status;
-
-       /* To store the current running audio pad index of demuxer */
-       gint demux_pad_index;
-
-       mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
-       mm_player_selector_t audio_mode;
-       gboolean use_deinterleave;
-       guint max_audio_channels;
+       mmplayer_track_t track[MM_PLAYER_TRACK_TYPE_MAX];
 
        guint internal_text_idx;
        guint external_text_idx;
 
-       MMPlayerSetMode set_mode;
+       mmplayer_setting_mode_t set_mode;
 
        /* initialize values */
-       mm_player_ini_t ini;
-
-       /* video share sync */
-       gint64 video_share_api_delta;
-       gint64 video_share_clock_delta;
-
-       /* just for native app (video hub) */
-       gboolean video_hub_download_mode;
-       gboolean sync_handler;
+       mmplayer_ini_t ini;
 
        /* store dump pad list */
-       GListdump_list;
+       GList *dump_list;
 
        /* whether a video has closed caption or not */
        gboolean has_closed_caption;
 
-       GstElement *video_fakesink;
 
        /* audio stream caps parsed by demuxer or set by external demuxer */
-       GstCapsa_stream_caps;
+       GstCaps *a_stream_caps;
 
        /* subtitle stream caps parsed by demuxer or set by external demuxer */
-       GstCapss_stream_caps;
+       GstCaps *s_stream_caps;
 
        /* es player using feed-data callback or calling app_src_push_buffer directly*/
        gboolean es_player_push_mode;
 
-       /* tmb buffer manager for s/w codec tmb_bo */
+       /* tbm buffer manager for s/w codec tmb_bo */
        tbm_bufmgr bufmgr;
 
-       int pcm_samplerate;
-       int pcm_channel;
-
-       MMAdaptiveVariantInfo adaptive_info;
+       mmplayer_adaptive_variant_info_t adaptive_info;
 
        /* Video360 related stuff
         * */
+       gboolean is_360_feature_enabled;
        gboolean is_content_spherical;
-       mm_player_spherical_metadata_t video360_metadata;
+       mmplayer_spherical_metadata_t video360_metadata;
        gboolean is_openal_plugin_used;
        /* User settable values */
        gboolean is_video360_enabled;
@@ -856,29 +809,27 @@ typedef struct {
        int video360_horizontal_fov;
        int video360_vertical_fov;
 
-} mm_player_t;
+       /* Video ROI area scale value */
+       mmplayer_video_roi_t video_roi;
+
+       /* build audio offload */
+       gboolean build_audio_offload;
+       guint audio_device_cb_id;
+
+       int client_pid;
+} mmplayer_t;
 
 typedef struct {
        gchar *language_code;
        gchar *language_key;
        gboolean active;
-} MMPlayerLangStruct;
+} mmplayer_lang_info_t;
 
 typedef struct {
        GstPad *dump_pad;
        gulong probe_handle_id;
        FILE *dump_element_file;
-} mm_player_dump_t;
-
-typedef struct {
-       char *name;
-       int value_type;
-       int flags;                              // r, w
-       void *default_value;
-       int valid_type;                 // validity type
-       int value_min;                  //<- set validity value range
-       int value_max;          //->
-} MMPlayerAttrsSpec;
+} mmplayer_dump_t;
 
 /*===========================================================================================
 |                                                                                                                                                                                      |
@@ -893,98 +844,90 @@ int _mmplayer_create_player(MMHandleType hplayer);
 int _mmplayer_destroy(MMHandleType hplayer);
 int _mmplayer_realize(MMHandleType hplayer);
 int _mmplayer_unrealize(MMHandleType hplayer);
-int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
-int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
-int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
-int _mmplayer_set_mute(MMHandleType hplayer, int mute);
-int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
+int _mmplayer_get_state(MMHandleType hplayer, int *state);
+int _mmplayer_set_volume(MMHandleType hplayer, float volume);
+int _mmplayer_get_volume(MMHandleType hplayer, float *volume);
+int _mmplayer_set_mute(MMHandleType hplayer, bool mute);
+int _mmplayer_get_mute(MMHandleType hplayer, bool *mute);
 int _mmplayer_start(MMHandleType hplayer);
 int _mmplayer_stop(MMHandleType hplayer);
 int _mmplayer_pause(MMHandleType hplayer);
+int _mmplayer_abort_pause(MMHandleType hplayer);
 int _mmplayer_resume(MMHandleType hplayer);
-int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
-int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
-int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
-int _mmplayer_adjust_video_postion(MMHandleType hplayer, int offset);
-int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
-int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
+int _mmplayer_set_position(MMHandleType hplayer, gint64 pos);
+int _mmplayer_get_duration(MMHandleType hplayer, gint64 *duration);
+int _mmplayer_adjust_subtitle_position(MMHandleType hplayer, int pos);
 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
-int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
-int _mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param);
-int _mmplayer_set_audiostream_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
+int _mmplayer_set_video_decoded_cb(MMHandleType hplayer, mm_player_video_decoded_callback callback, void *user_param);
 int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
-int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int* silent);
-int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filepath);
-int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
-
-/* test API for tuning audio gain. this API should be
- * deprecated before the day of final release
- */
-int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
-int _mmplayer_update_video_param(mm_player_t* player, char *param_name);
-int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
-int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
-int _mmplayer_audio_effect_custom_apply(mm_player_t *player);
-
-int _mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param);
-gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessageParamType* param);
-
-int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type, int index);
-int _mmplayer_sync_subtitle_pipeline(mm_player_t* player);
-int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode);
+int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent);
+int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath);
+int _mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos);
+int _mmplayer_update_video_overlay_param(mmplayer_t *player, const char *param_name);
+int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, int wl_surface_id);
+int _mmplayer_audio_effect_custom_apply(mmplayer_t *player);
+int _mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
+int _mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type, int index);
+int _mmplayer_sync_subtitle_pipeline(mmplayer_t *player);
 int _mmplayer_use_system_clock(MMHandleType hplayer);
-int _mmplayer_set_video_share_master_clock(MMHandleType hplayer, long long clock, long long clock_delta, long long video_time, long long media_clock, long long audio_time);
-int _mmplayer_get_video_share_master_clock(MMHandleType hplayer, long long *video_time, long long *media_clock, long long *audio_time);
-int _mmplayer_enable_sync_handler(MMHandleType hplayer, bool enable);
-int _mmplayer_set_file_buffering_path(MMHandleType hplayer, const char* file_path);
-int _mmplayer_set_uri(MMHandleType hplayer, const char* uri);
-int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_path);
-int _mmplayer_get_next_uri(MMHandleType hplayer, char** uri);
-int _mmplayer_has_closed_caption(MMHandleType hplayer, bool* exist);
+int _mmplayer_set_uri(MMHandleType hplayer, const char *uri);
+int _mmplayer_set_next_uri(MMHandleType hplayer, const char *uri, bool is_first_path);
+int _mmplayer_get_next_uri(MMHandleType hplayer, char **uri);
+int _mmplayer_has_closed_caption(MMHandleType hplayer, bool *exist);
 void _mm_player_video_stream_internal_buffer_unref(void *buffer);
-int _mmplayer_set_pcm_spec(MMHandleType hplayer, int samplerate, int channel);
 int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
-int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
 int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state);
-int __mmplayer_gst_set_state(mm_player_t* player, GstElement * pipeline,  GstState state, gboolean async, gint timeout);
-int __mmplayer_set_state(mm_player_t* player, int state);
-int __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command);
-gboolean __mmplayer_dump_pipeline_state(mm_player_t* player);
-void __mmplayer_remove_g_source_from_context(GMainContext *context, guint source_id);
-void _mmplayer_bus_msg_thread_destroy(MMHandleType hplayer);
-
-/* util */
-const gchar * __get_state_name(int state);
-gboolean __mmplayer_can_do_interrupt(mm_player_t *player);
-gboolean __is_streaming(mm_player_t* player);
-gboolean __is_rtsp_streaming(mm_player_t* player);
-gboolean __is_live_streaming(mm_player_t* player);
-gboolean __is_http_streaming(mm_player_t* player);
-gboolean __is_http_live_streaming(mm_player_t* player);
-gboolean __is_dash_streaming(mm_player_t* player);
-gboolean __is_smooth_streaming(mm_player_t* player);
-gboolean __is_http_progressive_down(mm_player_t* player);
-
-gboolean __mmplayer_check_useful_message(mm_player_t *player, GstMessage * message);
-gboolean __mmplayer_handle_gst_error(mm_player_t* player, GstMessage * message, GError* error);
-gint __gst_handle_core_error(mm_player_t* player, int code);
-gint __gst_handle_library_error(mm_player_t* player, int code);
-gint __gst_handle_resource_error(mm_player_t* player, int code, GstMessage * message);
-gint __gst_handle_stream_error(mm_player_t* player, GError* error, GstMessage * message);
-int _mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid);
-int _mmplayer_get_client_pid(MMHandleType hplayer, int* pid);
-int __mmplayer_get_video_angle(mm_player_t* player, int *user_angle, int *org_angle);
-int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo);
+int _mmplayer_video_stream_release_bo(mmplayer_t *player, void *bo);
 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
 int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
 int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
 int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
-int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
-int _mmplayer_set_streaming_buffering_time(MMHandleType hplayer, int buffer_ms, int rebuffer_ms);
-int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *buffer_ms, int *rebuffer_ms);
-int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type);
+int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *prebuffer_ms, int *rebuffer_ms);
+int _mmplayer_set_codec_type(MMHandleType hplayer, mmplayer_stream_type_e stream_type, mmplayer_codec_type_e codec_type);
+int _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled);
+int _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled);
+int _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height);
+int _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
+int _mmplayer_audio_offload_is_activated(MMHandleType hplayer, bool *activated);
+int _mmplayer_is_audio_control_available(MMHandleType hplayer, mmplayer_audio_control_opt_e opt, bool *available);
+
+/* internal */
+void _mmplayer_bus_msg_thread_destroy(MMHandleType hplayer);
+void _mmplayer_bus_watcher_remove(MMHandleType hplayer);
+void _mmplayer_watcher_removed_notify(gpointer data);
+void _mmplayer_set_state(mmplayer_t *player, int state);
+int _mmplayer_check_state(mmplayer_t *player, mmplayer_command_state_e command);
+gboolean _mmplayer_update_content_attrs(mmplayer_t *player, enum content_attr_flag flag);
+void _mmplayer_cancel_eos_timer(mmplayer_t *player);
+void _mmplayer_audio_stream_clear_buffer(mmplayer_t *player, gboolean send_all);
+MMStreamingType _mmplayer_get_stream_service_type(mmplayer_t *player);
+int _mmplayer_get_video_angle(mmplayer_t *player, int *display_angle, int *orientations);
+gboolean _mmplayer_gst_remove_fakesink(mmplayer_t *player, mmplayer_gst_element_t *fakesink);
+void _mmplayer_add_signal_connection(mmplayer_t *player, GObject *object, mmplayer_signal_type_e type, const gchar *signal, GCallback cb_funct, gpointer u_data);
+void _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data);
+gint _mmplayer_gst_decode_autoplug_select(GstElement *bin,  GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer data);
+GValueArray *_mmplayer_gst_decode_autoplug_sort(GstElement *bin, GstPad *pad, GstCaps *caps, GValueArray *factories, gpointer data);
+gboolean _mmplayer_gst_create_decoder(mmplayer_t *player, GstPad *srcpad, const GstCaps *caps);
+void _mmplayer_gst_element_added(GstBin *bin, GstElement *element, gpointer data);
+GstElement *_mmplayer_gst_make_decodebin(mmplayer_t *player);
+int _mmplayer_gst_element_add_bucket_to_bin(GstBin *bin, GList *element_bucket);
+int _mmplayer_gst_element_link_bucket(GList *element_bucket);
+void _mmplayer_typefind_have_type(GstElement *tf, guint probability, GstCaps *caps, gpointer data);
+int _mmplayer_parse_profile(const char *uri, void *param, mmplayer_parse_profile_t *data);
+int _mmplayer_set_client_pid(MMHandleType hplayer, int pid);
+void _mmplayer_set_reconfigure_state(mmplayer_t *player, gboolean state);
+void _mmplayer_gst_decode_pad_removed(GstElement *elem, GstPad *new_pad, gpointer data);
+void _mmplayer_gst_decode_no_more_pads(GstElement *elem, gpointer data);
+void _mmplayer_gst_decode_drained(GstElement *bin, gpointer data);
+void _mmplayer_gst_about_to_finish(GstElement *bin, gpointer data);
+int _mmplayer_update_not_supported_codec_info(mmplayer_t *player, const gchar *factory_class, const gchar *mime);
+void _mmplayer_gst_decode_unknown_type(GstElement *elem, GstPad *pad, GstCaps *caps, gpointer data);
+gboolean _mmplayer_gst_decode_autoplug_continue(GstElement *bin, GstPad *pad, GstCaps *caps, gpointer data);
+void _mmplayer_pipeline_complete(GstElement *decodebin, gpointer data);
+void _mmplayer_set_audio_attrs(mmplayer_t *player, GstCaps *caps);
+int _mmplayer_acquire_hw_resource(mmplayer_t *player, mmplayer_resource_type_e type);
 
 #ifdef __cplusplus
        }