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