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