26cb28a9fa14bce9d0b6cf3febd9170f5091b0a3
[platform/core/multimedia/libmm-player.git] / src / include / mm_player_priv.h
1 /*
2  * libmm-player
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __MM_PLAYER_PRIV_H__
24 #define __MM_PLAYER_PRIV_H__
25
26 /*===========================================================================================
27 |                                                                                                                                                                                       |
28 |  INCLUDE FILES                                                                                                                                                        |
29 |                                                                                                                                                                               |
30 ========================================================================================== */
31 #include <glib.h>
32 #include <gst/gst.h>
33 #include <mm_attrs.h>
34 #include <math.h>
35 #include <sys/stat.h>
36 #include <unistd.h>
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <tbm_bufmgr.h>
40 #include <storage.h>
41 #include "mm_player.h"
42 #include "mm_player_audioeffect.h"
43 #include "mm_message.h"
44 #include "mm_player_ini.h"
45 #include <mm_resource_manager.h>
46 #include "mm_player_streaming.h"
47
48 /*===========================================================================================
49 |                                                                                                                                                                                       |
50 |  GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                       |
51 |                                                                                                                                                                                       |
52 ========================================================================================== */
53
54 /*---------------------------------------------------------------------------
55 |    GLOBAL #defines:                                                                                                           |
56 ---------------------------------------------------------------------------*/
57 #define MM_PLAYER_IMGB_MPLANE_MAX       4
58 #define MM_PLAYER_STREAM_COUNT_MAX      3
59
60 #define MM_PLAYER_CAST(x_player)                ((mmplayer_t *)(x_player))
61 /**
62  * @x_player: MMHandleType of player
63  *
64  * Get the attributes handle of this player.
65  */
66 #define MM_PLAYER_GET_ATTRS(x_player)   (MM_PLAYER_CAST(x_player)->attrs)
67
68 #define MM_MAX_STRING_LENGTH    4000 /* have to be less than MUSE_MSG_MAX_LENGTH */
69
70 #define VIDEO360_MAX_ZOOM       10.0f
71
72 /*---------------------------------------------------------------------------
73 |    GLOBAL CONSTANT DEFINITIONS:                                                                                       |
74 ---------------------------------------------------------------------------*/
75 enum latency_mode {
76         AUDIO_LATENCY_MODE_LOW = 0,     /**< Low audio latency mode */
77         AUDIO_LATENCY_MODE_MID,         /**< Middle audio latency mode */
78         AUDIO_LATENCY_MODE_HIGH,        /**< High audio latency mode */
79 };
80
81 enum tag_info {
82         TAG_AUDIO_CODEC = 0x0001,
83         TAG_VIDEO_CODEC = 0x0002,
84         TAG_ARTIST              = 0x0004,
85         TAG_TITLE               = 0x0008,
86         TAG_ALBUM               = 0x0010,
87         TAG_GENRE               = 0x0020,
88         TAG_COPYRIGHT   = 0x0040,
89         TAG_DATE                = 0x0080,
90         TAG_DESCRIPTION = 0x0100,
91         TAG_TRACK_NUMBER = 0x0200
92 };
93
94 enum content_attr_flag {
95         ATTR_MISSING_ONLY = 0x0001,
96         ATTR_DURATION = 0x0002,
97         ATTR_AUDIO  = 0x0004,
98         ATTR_VIDEO = 0x0008,
99         ATTR_BITRATE = 0x0010,
100         ATTR_ALL = 0x0020,
101 };
102
103 enum mmplayer_sink_type {
104         MMPLAYER_VIDEO_SINK = 0x01,
105         MMPLAYER_AUDIO_SINK = 0x02,
106         MMPLAYER_TEXT_SINK = 0x04,
107         MMPLAYER_SINK_ALL = 0x07,
108 };
109
110 /**
111  * Enumerations of Player Uri type
112  */
113 enum mmplayer_uri_type {
114         MM_PLAYER_URI_TYPE_NONE,                        /**< Player URI type None */
115         MM_PLAYER_URI_TYPE_URL_RTSP,            /**< Player URI type RTSP */
116         MM_PLAYER_URI_TYPE_URL_HTTP,            /**< Player URI type HTTP */
117         MM_PLAYER_URI_TYPE_URL_MMS,                     /**< Player URI type MMS */
118         MM_PLAYER_URI_TYPE_MEM,                         /**< Player URI type Mem */
119         MM_PLAYER_URI_TYPE_FILE,                        /**< Player URI type File */
120         MM_PLAYER_URI_TYPE_URL,                         /**< Player URI type URL */
121         MM_PLAYER_URI_TYPE_MS_BUFF,                     /**< Player URI type Media Stream Buffer */
122         MM_PLAYER_URI_TYPE_HLS,                         /**< Player URI type http live streaming */
123         MM_PLAYER_URI_TYPE_SS,                          /**< Player URI type Smooth streaming */
124         MM_PLAYER_URI_TYPE_DASH,                        /**< Player URI type Mpeg Dash */
125         MM_PLAYER_URI_TYPE_NO_PERMISSION,       /**< Player URI type No Permission  */
126         MM_PLAYER_URI_TYPE_TEMP,                        /**< Player URI type Temp */
127 };
128
129 typedef enum {
130         MISSING_PLUGIN_NONE = 0x00,
131         MISSING_PLUGIN_AUDIO = 0x01,
132         MISSING_PLUGIN_VIDEO = 0x02
133 } missing_codec_e;
134
135
136 typedef enum {
137         FOUND_PLUGIN_NONE = 0x00,
138         FOUND_PLUGIN_AUDIO = 0x01,
139         FOUND_PLUGIN_VIDEO = 0x02
140 } found_codec_e;
141
142 /**
143  * Enumeration of signal type
144  */
145 typedef enum {
146         MM_PLAYER_SIGNAL_TYPE_AUTOPLUG = 0,
147         MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
148         MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
149         MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
150         MM_PLAYER_SIGNAL_TYPE_OTHERS,
151         MM_PLAYER_SIGNAL_TYPE_ALL,
152         MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
153 } mmplayer_signal_type_e;
154
155 /* main pipeline's element id */
156 typedef enum {
157         MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
158         MMPLAYER_M_SRC,
159         MMPLAYER_M_2ND_SRC,     /* 2nd Source Element for es buff src */
160         MMPLAYER_M_SUBSRC,
161
162         /* it could be a decodebin or could be a typefind. depends on player ini */
163         MMPLAYER_M_TYPEFIND,
164         MMPLAYER_M_AUTOPLUG,
165
166         MMPLAYER_M_AUTOPLUG_V_DEC,
167         MMPLAYER_M_AUTOPLUG_A_DEC,
168
169         /*fakesink will hold whole pipeline state. */
170         MMPLAYER_M_SRC_FAKESINK,
171
172         /* streaming plugin */
173         MMPLAYER_M_MUXED_S_BUFFER,
174         MMPLAYER_M_DEMUXED_S_BUFFER,
175         MMPLAYER_M_ID3DEMUX,
176         MMPLAYER_M_ADAPTIVE_DEMUX,
177
178         /* es buff src queue */
179         MMPLAYER_M_V_BUFFER,
180         MMPLAYER_M_A_BUFFER,
181         MMPLAYER_M_S_BUFFER,
182
183         /* FIXIT : if there's really no usage for following IDs. remove it */
184         MMPLAYER_M_DEC1,
185         MMPLAYER_M_DEC2,
186         MMPLAYER_M_Q1,
187         MMPLAYER_M_Q2,
188         MMPLAYER_M_DEMUX,
189         MMPLAYER_M_SUBPARSE,
190         MMPLAYER_M_V_INPUT_SELECTOR,    // video input_select
191         MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
192         MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
193         MMPLAYER_M_NUM
194 } main_element_id_e;
195
196 /* audio pipeline's element id */
197 enum audio_element_id {
198         MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
199         MMPLAYER_A_CONV,
200         MMPLAYER_A_VOL,
201         MMPLAYER_A_FILTER,
202         MMPLAYER_A_FILTER_SEC,
203         MMPLAYER_A_CONV_BFORMAT,
204         MMPLAYER_A_CAPS_360,
205         MMPLAYER_A_SINK,
206         MMPLAYER_A_RESAMPLER,
207         MMPLAYER_A_RGVOL,
208         MMPLAYER_A_CONV_PITCH,
209         MMPLAYER_A_PITCH,
210         MMPLAYER_A_TEE,
211         MMPLAYER_A_TEE_Q1,
212         MMPLAYER_A_TEE_Q2,
213         MMPLAYER_A_EXTRACT_CONV,
214         MMPLAYER_A_EXTRACT_RESAMPLER,
215         MMPLAYER_A_EXTRACT_CAPS,
216         MMPLAYER_A_EXTRACT_DEINTERLEAVE,
217         MMPLAYER_A_EXTRACT_SINK,
218         MMPLAYER_A_NUM
219 };
220
221 /* video pipeline's element id */
222 enum video_element_id {
223         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
224         MMPLAYER_V_CONV,
225         MMPLAYER_V_CAPS,
226         MMPLAYER_V_SINK,
227         MMPLAYER_V_360,
228         MMPLAYER_V_NUM
229 };
230
231 /* text pipeline's element id */
232 enum text_element_id {
233         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
234         MMPLAYER_T_QUEUE,
235         MMPLAYER_T_VIDEO_QUEUE,
236         MMPLAYER_T_VIDEO_CONVERTER,
237         MMPLAYER_T_OVERLAY,
238         MMPLAYER_T_FAKE_SINK,
239         MMPLAYER_T_IDENTITY,
240         MMPLAYER_T_NUM
241 };
242
243 typedef enum {
244         MMPLAYER_COMMAND_NONE,
245         MMPLAYER_COMMAND_CREATE,
246         MMPLAYER_COMMAND_DESTROY,
247         MMPLAYER_COMMAND_UNREALIZE,
248         MMPLAYER_COMMAND_START,
249         MMPLAYER_COMMAND_REALIZE,
250         MMPLAYER_COMMAND_STOP,
251         MMPLAYER_COMMAND_PAUSE,
252         MMPLAYER_COMMAND_RESUME,
253         MMPLAYER_COMMAND_NUM
254 } mmplayer_command_state_e;
255
256 /* Note : mmplayer_streaming_src_error is error enum for streaming source which post error message
257  *      using custom message made by itself. The enum value must start with zero,
258  *      because the streaming source(secrtspsrc) also does.
259  */
260 enum mmplayer_streaming_src_error {
261         MMPLAYER_STREAMING_ERROR_NONE = 0,
262         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
263         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
264         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
265         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
266         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
267         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
268         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
269         MMPLAYER_STREAMING_ERROR_INVALID_URL,
270         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
271         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
272         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
273         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
274         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
275         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
276         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
277         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
278         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
279         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
280         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
281         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
282         MMPLAYER_STREAMING_ERROR_GONE,
283         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
284         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
285         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
286         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
287         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
288         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
289         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
290         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
291         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
292         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
293         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
294         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
295         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
296         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
297         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
298         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
299         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
300         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
301         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
302         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
303         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
304         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
305         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
306         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
307 };
308
309 typedef enum {
310         MMPLAYER_SEEK_NONE = 0,
311         MMPLAYER_SEEK_IN_PROGRESS,
312         MMPLAYER_SEEK_COMPLETED,        /* after getting async done but before posting seek complete */
313 } mmplayer_seek_state_e;
314
315 typedef enum {
316         MMPLAYER_PATH_VOD = 0,
317         MMPLAYER_PATH_TEXT,
318         MMPLAYER_PATH_MAX
319 } mmplayer_path_type_e;
320
321 /* Video360 related enums. These are duplication from video360.h from
322  * gst-plugins-tizen.
323  * */
324 typedef enum {
325         VIDEO360_MODE_UNKNOWN = -1,
326         VIDEO360_MODE_MONOSCOPIC = 0,
327         VIDEO360_MODE_STEREOSCOPIC_TOP_BOTTOM = 1,
328         VIDEO360_MODE_STEREOSCOPIC_LEFT_RIGHT = 2,
329         VIDEO360_MODE_STEREOSCOPIC_STEREO_MESH = 3,
330         VIDEO360_MODE_LAST_ITEM
331 } mmplayer_stereo_mode_e;
332
333 typedef enum {
334         VIDEO360_PROJECTION_TYPE_UNKNOWN = -1,
335         VIDEO360_PROJECTION_TYPE_EQUIRECTANGULAR = 0,
336         VIDEO360_PROJECTION_TYPE_CUBEMAP = 1,
337         VIDEO360_PROJECTION_TYPE_MESH = 2,
338         VIDEO360_PROJECTION_TYPE_LAST_ITEM
339 } mmplayer_projection_type_e;
340
341 /* Spatial audio related enums. These are duplication from mm_file.h from
342  * libmm-fileinfo.
343  * */
344 typedef enum {
345         MMFILE_AMBISONIC_TYPE_UNKNOWN = 0,
346         MMFILE_AMBISONIC_TYPE_PERIPHONIC = 1,           /**< To comply with Google's Spatial Audio RFC*/
347         MMFILE_AMBISONIC_TYPE_NON_PERIPHONIC = 2,
348 } mmfile_ambisonic_type_e;
349
350 typedef enum {
351         MMFILE_AMBISONIC_FORMAT_UNKNOWN = 0,
352         MMFILE_AMBISONIC_FORMAT_AMBIX = 1,              /**< AMBIX (Channel sequence: ACN, Normalization: SN3D) */
353         MMFILE_AMBISONIC_FORMAT_AMB = 2,                /**< .AMB, Tetraproc (Channel sequence: FuMa, Normalization: FuMa) */
354         MMFILE_AMBISONIC_FORMAT_UA = 3,                 /**< Universal Ambisonics (Channel sequence: SID, Normalization: N3D) */
355 } mmfile_ambisonic_format_e;
356
357 typedef enum {
358         MMFILE_AMBISONIC_ORDER_UNKNOWN = 0,
359         MMFILE_AMBISONIC_ORDER_FOA = 1,                 /**< First order Ambisonics */
360         MMFILE_AMBISONIC_ORDER_SOA = 2,                 /**< Second order Ambisonics */
361         MMFILE_AMBISONIC_ORDER_TOA = 3,                 /**< Third order Ambisonics */
362 } mmfile_ambisonic_order_e;
363
364 /*---------------------------------------------------------------------------
365 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
366 ---------------------------------------------------------------------------*/
367
368 typedef struct {
369         int id;
370         GstElement *gst;
371 } mmplayer_gst_element_t;
372
373 typedef struct {
374         GstTagList *tag_list;
375         mmplayer_gst_element_t *mainbin;
376         mmplayer_gst_element_t *audiobin;
377         mmplayer_gst_element_t *videobin;
378         mmplayer_gst_element_t *textbin;
379 } mmplayer_pipeline_info_t;
380
381 typedef struct {
382         float volume;
383         bool mute;
384         bool rg_enable;
385 } mmplayer_sound_info_t;
386
387 typedef struct {
388         char *buf;
389         int len;
390         int offset;
391 } mmplayer_input_buffer_t;
392
393 typedef struct {
394         int uri_type;
395         mmplayer_input_buffer_t input_mem;
396         char uri[MM_MAX_URL_LEN];
397         char urgent[MM_MAX_FILENAME_LEN];
398 } mmplayer_parse_profile_t;
399
400 typedef struct {
401         storage_type_e type;
402         storage_state_e state;
403         int id;
404         char path[MM_MAX_URL_LEN];
405 } mmplayer_storage_info_t;
406
407 typedef struct {
408         bool is_pending;
409         gint64 pos;
410 } mmplayer_pending_seek_t;
411
412 typedef struct {
413         GObject *obj;
414         gulong sig;
415 } mmplayer_signal_item_t;
416
417 typedef struct {
418         bool rich_audio;
419         bool video_zc; // video zero-copy
420         bool subtitle_off;
421         bool video_export;
422 } mmplayer_setting_mode_t; /* FIXME: renaming */
423
424 typedef struct {
425         GMainContext *global_default;
426         GMainContext *thread_default;
427 } mmplayer_context_info_t;
428
429 typedef struct {
430         gint uri_idx;
431         GList *uri_list;
432 } mmplayer_uri_list_t;
433
434 typedef struct {
435         double scale_x;
436         double scale_y;
437         double scale_width;
438         double scale_height;
439 } mmplayer_video_roi_t;
440
441 typedef struct {
442         gint active_pad_index;
443         gint total_track_num;
444         GPtrArray *channels;
445         gulong block_id;
446         gulong event_probe_id;
447 } mmplayer_selector_t;
448
449 typedef struct {
450         gboolean running;
451
452         gboolean stream_changed;
453         gboolean reconfigure;
454
455         GstClockTime start_time[MM_PLAYER_TRACK_TYPE_MAX];      /* updated once get SEGMENT event */
456         GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
457         gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];
458
459 } mmplayer_gapless_t;
460
461 typedef struct {
462         int channel;
463         int bitrate;
464         int depth;
465         bool is_little_endian;
466         guint64 channel_mask;
467         void *pcm_data;
468         int data_size;
469         int buff_size;
470         media_format_mimetype_e pcm_format;
471 } mmplayer_audio_stream_buff_t;
472
473 /**
474  * @brief data of video_bo_list
475  * @details this will be used when the sw codec is running.
476  * @since_tizen 3.0
477  */
478 typedef struct {
479         gboolean used;
480         void *bo;
481 } mmplayer_video_bo_info_t;
482
483 typedef struct {
484         gint bandwidth;
485         gint width;
486         gint height;
487 } stream_variant_t;
488
489 typedef struct {
490         GList *var_list;
491         stream_variant_t limit;
492 } mmplayer_adaptive_variant_info_t;
493
494 typedef struct {
495         int is_spherical;
496         int is_stitched;
497         char *stitching_software;
498         char *projection_type_string;
499         char *stereo_mode_string;
500         mmplayer_projection_type_e projection_type;
501         mmplayer_stereo_mode_e stereo_mode;
502         int source_count;
503         int init_view_heading;
504         int init_view_pitch;
505         int init_view_roll;
506         int timestamp;
507         int full_pano_width_pixels;
508         int full_pano_height_pixels;
509         int cropped_area_image_width;
510         int cropped_area_image_height;
511         int cropped_area_left;
512         int cropped_area_top;
513         int ambisonic_type;
514         int ambisonic_format;
515         int ambisonic_order;
516 } mmplayer_spherical_metadata_t;
517
518 typedef struct {
519         /* STATE */
520         int state;                                      // player current state
521         int prev_state;                         // player previous state
522         int pending_state;                      // player state which is going to now
523         int target_state;                               // player state which user want to go to
524         guint state_change_timeout;
525
526         gchar *album_art;
527
528         int cmd;
529
530         /* command lock */
531         GMutex cmd_lock;
532         GMutex playback_lock;
533
534         /* gapless play thread */
535         GThread *gapless_play_thread;
536         gboolean gapless_play_thread_exit;
537         GCond gapless_play_thread_cond;
538         GMutex gapless_play_thread_mutex;
539         mmplayer_gapless_t gapless;
540
541         /* capture thread */
542         GThread *capture_thread;
543         gboolean capture_thread_exit;
544         GCond capture_thread_cond;
545         GMutex capture_thread_mutex;
546         mmplayer_video_capture_t capture;
547         mmplayer_video_color_space_e video_cs;
548         MMVideoBuffer captured;
549
550         /* gst bus msg thread, create during realize */
551         GThread *bus_msg_thread;
552         gboolean bus_msg_thread_exit;
553         GCond bus_msg_thread_cond;
554         GMutex bus_msg_thread_mutex;
555
556         /* fakesink handling lock */
557         GMutex fsink_lock;
558
559         /* update tag lock */
560         GMutex update_tag_lock;
561
562         /* player attributes */
563         MMHandleType attrs;
564
565         /* message callback */
566         MMMessageCallback msg_cb;
567         void *msg_cb_param;
568
569         /* streaming player */
570         mmplayer_streaming_t *streamer;
571
572         /* gstreamer pipeline */
573         mmplayer_pipeline_info_t        *pipeline;
574
575         /* pad */
576         GstPad *ghost_pad_for_videobin;
577
578         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
579         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
580         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
581         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
582         GMutex media_stream_cb_lock;
583
584         int video_num_buffers;  /* total num of buffers in vcodec */
585         int video_extra_num_buffers; /* extra num of buffers in vcodec */
586
587         void *buffer_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
588         void *seek_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
589
590         /* video stream changed callback */
591         mm_player_stream_changed_callback video_stream_changed_cb;
592         void *video_stream_changed_cb_user_param;
593
594         /* audio stream changed callback */
595         mm_player_stream_changed_callback audio_stream_changed_cb;
596         void *audio_stream_changed_cb_user_param;
597
598         /* video stream callback */
599         mm_player_video_decoded_callback video_decoded_cb;
600         void *video_decoded_cb_user_param;
601         GCond video_bo_cond;
602         GMutex video_bo_mutex;
603         GList *video_bo_list; /* mmplayer_video_bo_info_t, bo list for decoded video data by sw codec */
604         int video_bo_size;
605         bool video_stream_prerolled;
606
607         /* audio stream callback */
608         mm_player_audio_decoded_callback audio_decoded_cb;
609         void *audio_decoded_cb_user_param;
610         GList *audio_stream_buff_list; /* mmplayer_audio_stream_buff_t, buff list of extract pcm data */
611         mmplayer_audio_extract_opt_e audio_extract_opt;
612
613         /* video capture callback*/
614         gulong video_capture_cb_probe_id;
615
616         /* sound info */
617         mmplayer_sound_info_t   sound;
618
619         /* type string */
620         gchar *type;
621
622         /* video stream caps parsed by demuxer */
623         GstCaps *v_stream_caps;
624
625         /* audio effect infomation */
626         mm_audio_effect_info_t audio_effect_info;
627         gboolean bypass_audio_effect;
628
629         /* content profile */
630         mmplayer_parse_profile_t profile;
631         mmplayer_storage_info_t storage_info[MMPLAYER_PATH_MAX];
632
633         /* streaming service type */
634         MMStreamingType streaming_type;
635
636         /* autoplugging */
637         GList *factories;
638         GList *audio_decoders; // list of linked audio name
639         gboolean no_more_pad;
640         gint num_dynamic_pad;
641         gboolean has_many_types;
642
643         /* progress callback timer */
644         /* FIXIT : since duplicated functionality with get_position
645          * this function will be deprecated after fixing all application
646          * which are using it.
647          */
648         guint progress_timer;
649
650         /* timer for sending delayed EOS */
651         guint eos_timer;
652
653         /* last point that player is paused or seeking */
654         gint64 last_position;
655
656         /* duration */
657         gint64 duration;
658
659         /* data size of http streaming  */
660         guint64 http_content_size;
661
662         /* last error */
663         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
664
665         gboolean smooth_streaming;
666
667         gint videodec_linked;
668         gint audiodec_linked;
669         gint textsink_linked;
670
671         /* missing plugin during autoplugging */
672         missing_codec_e not_supported_codec;
673
674         /* unlinked audio/video mime type */
675         gchar *unlinked_video_mime;
676         gchar *unlinked_audio_mime;
677         gchar *unlinked_demuxer_mime;
678
679         /* found codec during autoplugging */
680         found_codec_e can_support_codec;
681
682         gboolean not_found_demuxer;
683
684         /* support seek even though player is not start */
685         mmplayer_pending_seek_t pending_seek;
686         mmplayer_seek_state_e seek_state;
687
688         /* prevent to post msg over and over */
689         gboolean msg_posted;
690
691         /* list of sink elements */
692         GList *sink_elements;
693
694         /* signal notifiers */
695         GList *signals[MM_PLAYER_SIGNAL_TYPE_MAX];
696         guint bus_watcher;
697         GQueue *bus_msg_q;
698         GMutex bus_msg_q_lock;
699         mmplayer_context_info_t context;
700         mmplayer_uri_list_t uri_info;
701
702         gboolean is_sound_extraction;
703
704         gfloat playback_rate;
705
706         /* player state resumed by fast rewind */
707         gboolean resumed_by_rewind;
708
709         gboolean is_nv12_tiled;
710
711         /* resource manager for H/W resources */
712         mm_resource_manager_h resource_manager;
713         mm_resource_manager_res_h video_overlay_resource;
714         mm_resource_manager_res_h video_decoder_resource;
715         gboolean interrupted_by_resource;
716
717         gboolean is_subtitle_off;
718         gboolean is_external_subtitle_present;
719         gboolean is_external_subtitle_added_now;
720         gboolean pending_resume;
721
722         /* contents bitrate for buffering management */
723         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
724         guint total_bitrate;
725         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
726         guint total_maximum_bitrate;
727
728         /* prevent it from posting duplicatly*/
729         gboolean sent_bos;
730
731         gboolean play_subtitle;
732         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
733
734         /* adjust subtitle position store */
735         gint64 adjust_subtitle_pos;
736         GList *subtitle_language_list;
737         GCond subtitle_info_cond;
738         GMutex subtitle_info_mutex;
739
740         /* To store the current running audio pad index of demuxer */
741         gint demux_pad_index;
742
743         mmplayer_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
744
745         guint internal_text_idx;
746         guint external_text_idx;
747
748         mmplayer_setting_mode_t set_mode;
749
750         /* initialize values */
751         mmplayer_ini_t ini;
752
753         /* store dump pad list */
754         GList *dump_list;
755
756         /* whether a video has closed caption or not */
757         gboolean has_closed_caption;
758
759
760         /* audio stream caps parsed by demuxer or set by external demuxer */
761         GstCaps *a_stream_caps;
762
763         /* subtitle stream caps parsed by demuxer or set by external demuxer */
764         GstCaps *s_stream_caps;
765
766         /* es player using feed-data callback or calling app_src_push_buffer directly*/
767         gboolean es_player_push_mode;
768
769         /* tmb buffer manager for s/w codec tmb_bo */
770         tbm_bufmgr bufmgr;
771
772         mmplayer_adaptive_variant_info_t adaptive_info;
773
774         /* Video360 related stuff
775          * */
776         gboolean is_360_feature_enabled;
777         gboolean is_content_spherical;
778         mmplayer_spherical_metadata_t video360_metadata;
779         gboolean is_openal_plugin_used;
780         /* User settable values */
781         gboolean is_video360_enabled;
782         float video360_yaw_radians;
783         float video360_pitch_radians;
784         float video360_zoom;
785         int video360_horizontal_fov;
786         int video360_vertical_fov;
787
788         /* Video ROI area scale value */
789         mmplayer_video_roi_t video_roi;
790
791         /* build audio offload */
792         gboolean build_audio_offload;
793         guint audio_device_cb_id;
794 } mmplayer_t;
795
796 typedef struct {
797         gchar *language_code;
798         gchar *language_key;
799         gboolean active;
800 } mmplayer_lang_info_t;
801
802 typedef struct {
803         GstPad *dump_pad;
804         gulong probe_handle_id;
805         FILE *dump_element_file;
806 } mmplayer_dump_t;
807
808 typedef struct {
809         char *name;
810         int value_type;
811         int flags;                              // r, w
812         void *default_value;
813         int valid_type;                 // validity type
814         int value_min;                  //<- set validity value range
815         int value_max;          //->
816 } mmplayer_attrs_spec_t;
817
818 /*===========================================================================================
819 |                                                                                                                                                                                       |
820 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
821 |                                                                                                                                                                                       |
822 ========================================================================================== */
823 #ifdef __cplusplus
824         extern "C" {
825 #endif
826
827 int _mmplayer_create_player(MMHandleType hplayer);
828 int _mmplayer_destroy(MMHandleType hplayer);
829 int _mmplayer_realize(MMHandleType hplayer);
830 int _mmplayer_unrealize(MMHandleType hplayer);
831 int _mmplayer_get_state(MMHandleType hplayer, int *state);
832 int _mmplayer_set_volume(MMHandleType hplayer, float volume);
833 int _mmplayer_get_volume(MMHandleType hplayer, float *volume);
834 int _mmplayer_set_mute(MMHandleType hplayer, bool mute);
835 int _mmplayer_get_mute(MMHandleType hplayer, bool *mute);
836 int _mmplayer_start(MMHandleType hplayer);
837 int _mmplayer_stop(MMHandleType hplayer);
838 int _mmplayer_pause(MMHandleType hplayer);
839 int _mmplayer_abort_pause(MMHandleType hplayer);
840 int _mmplayer_resume(MMHandleType hplayer);
841 int _mmplayer_set_position(MMHandleType hplayer, gint64 pos);
842 int _mmplayer_get_duration(MMHandleType hplayer, gint64 *duration);
843 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int pos);
844 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
845 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
846 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
847 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
848 int _mmplayer_set_video_decoded_cb(MMHandleType hplayer, mm_player_video_decoded_callback callback, void *user_param);
849 int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
850 int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent);
851 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath);
852 int _mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos);
853 int _mmplayer_update_video_param(mmplayer_t *player, char *param_name);
854 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
855 int _mmplayer_audio_effect_custom_apply(mmplayer_t *player);
856 int _mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
857 int _mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type, int index);
858 int _mmplayer_sync_subtitle_pipeline(mmplayer_t *player);
859 int _mmplayer_use_system_clock(MMHandleType hplayer);
860 int _mmplayer_set_uri(MMHandleType hplayer, const char *uri);
861 int _mmplayer_set_next_uri(MMHandleType hplayer, const char *uri, bool is_first_path);
862 int _mmplayer_get_next_uri(MMHandleType hplayer, char **uri);
863 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool *exist);
864 void _mm_player_video_stream_internal_buffer_unref(void *buffer);
865 int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
866 int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
867 int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state);
868 int _mmplayer_video_stream_release_bo(mmplayer_t *player, void *bo);
869 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
870 int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
871 int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
872 int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
873 int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
874 int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *prebuffer_ms, int *rebuffer_ms);
875 int _mmplayer_set_codec_type(MMHandleType hplayer, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type);
876 int _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled);
877 int _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled);
878 int _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height);
879 int _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
880
881 /* internal */
882 void _mmplayer_bus_msg_thread_destroy(MMHandleType hplayer);
883 void _mmplayer_set_state(mmplayer_t *player, int state);
884 int _mmplayer_check_state(mmplayer_t *player, mmplayer_command_state_e command);
885 gboolean _mmplayer_update_content_attrs(mmplayer_t *player, enum content_attr_flag flag);
886 void _mmplayer_cancel_eos_timer(mmplayer_t *player);
887 void _mmplayer_audio_stream_clear_buffer(mmplayer_t *player, gboolean send_all);
888 MMStreamingType _mmplayer_get_stream_service_type(mmplayer_t *player);
889 int _mmplayer_get_video_angle(mmplayer_t *player, int *display_angle, int *orientations);
890 gboolean _mmplayer_gst_remove_fakesink(mmplayer_t *player, mmplayer_gst_element_t *fakesink);
891 void _mmplayer_add_signal_connection(mmplayer_t *player, GObject *object, mmplayer_signal_type_e type, const gchar *signal, GCallback cb_funct, gpointer u_data);
892 void _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data);
893 gint _mmplayer_gst_decode_autoplug_select(GstElement *bin,  GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer data);
894 gboolean _mmplayer_gst_create_decoder(mmplayer_t *player, GstPad *srcpad, const GstCaps *caps);
895 void _mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data);
896 GstElement *_mmplayer_gst_make_decodebin(mmplayer_t *player);
897 int _mmplayer_gst_element_add_bucket_to_bin(GstBin *bin, GList *element_bucket);
898 int _mmplayer_gst_element_link_bucket(GList *element_bucket);
899 void _mmplayer_typefind_have_type(GstElement *tf, guint probability, GstCaps *caps, gpointer data);
900 int _mmplayer_parse_profile(const char *uri, void *param, mmplayer_parse_profile_t *data);
901
902 #ifdef __cplusplus
903         }
904 #endif
905
906 #endif  /* __MM_PLAYER_PRIV_H__ */