2182cb3d54d5f17598c106a68407a69e2bb70aa1
[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_internal.h"
43 #include "mm_player_audioeffect.h"
44 #include "mm_message.h"
45 #include "mm_player_ini.h"
46 #include <mm_resource_manager.h>
47 #include "mm_player_streaming.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 /*---------------------------------------------------------------------------
74 |    GLOBAL CONSTANT DEFINITIONS:                                                                                       |
75 ---------------------------------------------------------------------------*/
76 enum latency_mode {
77         AUDIO_LATENCY_MODE_LOW = 0,     /**< Low audio latency mode */
78         AUDIO_LATENCY_MODE_MID,         /**< Middle audio latency mode */
79         AUDIO_LATENCY_MODE_HIGH,        /**< High audio latency mode */
80 };
81
82 enum tag_info {
83         TAG_AUDIO_CODEC = 0x0001,
84         TAG_VIDEO_CODEC = 0x0002,
85         TAG_ARTIST              = 0x0004,
86         TAG_TITLE               = 0x0008,
87         TAG_ALBUM               = 0x0010,
88         TAG_GENRE               = 0x0020,
89         TAG_COPYRIGHT   = 0x0040,
90         TAG_DATE                = 0x0080,
91         TAG_DESCRIPTION = 0x0100,
92         TAG_TRACK_NUMBER = 0x0200
93 };
94
95 enum content_attr_flag {
96         ATTR_MISSING_ONLY = 0x0001,
97         ATTR_DURATION = 0x0002,
98         ATTR_AUDIO  = 0x0004,
99         ATTR_VIDEO = 0x0008,
100         ATTR_BITRATE = 0x0010,
101         ATTR_ALL = 0x0020,
102 };
103
104 enum mmplayer_sink_type {
105         MMPLAYER_VIDEO_SINK = 0x01,
106         MMPLAYER_AUDIO_SINK = 0x02,
107         MMPLAYER_TEXT_SINK = 0x04,
108         MMPLAYER_SINK_ALL = 0x07,
109 };
110
111 /**
112  * Enumerations of Player Uri type
113  */
114 enum mmplayer_uri_type {
115         MM_PLAYER_URI_TYPE_NONE,                        /**< Player URI type None */
116         MM_PLAYER_URI_TYPE_URL_RTSP,            /**< Player URI type RTSP */
117         MM_PLAYER_URI_TYPE_URL_HTTP,            /**< Player URI type HTTP */
118         MM_PLAYER_URI_TYPE_URL_MMS,                     /**< Player URI type MMS */
119         MM_PLAYER_URI_TYPE_MEM,                         /**< Player URI type Mem */
120         MM_PLAYER_URI_TYPE_FILE,                        /**< Player URI type File */
121         MM_PLAYER_URI_TYPE_URL,                         /**< Player URI type URL */
122         MM_PLAYER_URI_TYPE_MS_BUFF,                     /**< Player URI type Media Stream Buffer */
123         MM_PLAYER_URI_TYPE_HLS,                         /**< Player URI type http live streaming */
124         MM_PLAYER_URI_TYPE_SS,                          /**< Player URI type Smooth streaming */
125         MM_PLAYER_URI_TYPE_DASH,                        /**< Player URI type Mpeg Dash */
126         MM_PLAYER_URI_TYPE_NO_PERMISSION,       /**< Player URI type No Permission  */
127         MM_PLAYER_URI_TYPE_TEMP,                        /**< Player URI type Temp */
128 };
129
130 typedef enum {
131         MISSING_PLUGIN_NONE = 0x00,
132         MISSING_PLUGIN_AUDIO = 0x01,
133         MISSING_PLUGIN_VIDEO = 0x02
134 } missing_codec_e;
135
136
137 typedef enum {
138         FOUND_PLUGIN_NONE = 0x00,
139         FOUND_PLUGIN_AUDIO = 0x01,
140         FOUND_PLUGIN_VIDEO = 0x02
141 } found_codec_e;
142
143 /**
144  * Enumeration of signal type
145  */
146 typedef enum {
147         MM_PLAYER_SIGNAL_TYPE_AUTOPLUG = 0,
148         MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
149         MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
150         MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
151         MM_PLAYER_SIGNAL_TYPE_OTHERS,
152         MM_PLAYER_SIGNAL_TYPE_ALL,
153         MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
154 } mmplayer_signal_type_e;
155
156 /* main pipeline's element id */
157 typedef enum {
158         MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
159         MMPLAYER_M_SRC,
160         MMPLAYER_M_2ND_SRC,     /* 2nd Source Element for es buff src */
161         MMPLAYER_M_SUBSRC,
162
163         /* it could be a decodebin or could be a typefind. depends on player ini */
164         MMPLAYER_M_TYPEFIND,
165         MMPLAYER_M_AUTOPLUG,
166
167         MMPLAYER_M_AUTOPLUG_V_DEC,
168         MMPLAYER_M_AUTOPLUG_A_DEC,
169
170         /*fakesink will hold whole pipeline state. */
171         MMPLAYER_M_SRC_FAKESINK,
172
173         /* streaming plugin */
174         MMPLAYER_M_MUXED_S_BUFFER,
175         MMPLAYER_M_DEMUXED_S_BUFFER,
176         MMPLAYER_M_ID3DEMUX,
177         MMPLAYER_M_ADAPTIVE_DEMUX,
178
179         /* es buff src queue */
180         MMPLAYER_M_V_BUFFER,
181         MMPLAYER_M_A_BUFFER,
182         MMPLAYER_M_S_BUFFER,
183
184         /* FIXIT : if there's really no usage for following IDs. remove it */
185         MMPLAYER_M_DEC1,
186         MMPLAYER_M_DEC2,
187         MMPLAYER_M_Q1,
188         MMPLAYER_M_Q2,
189         MMPLAYER_M_DEMUX,
190         MMPLAYER_M_SUBPARSE,
191         MMPLAYER_M_V_INPUT_SELECTOR,    // video input_select
192         MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
193         MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
194         MMPLAYER_M_NUM
195 } main_element_id_e;
196
197 /* audio pipeline's element id */
198 enum audio_element_id {
199         MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
200         MMPLAYER_A_CONV,
201         MMPLAYER_A_VOL,
202         MMPLAYER_A_FILTER,
203         MMPLAYER_A_FILTER_SEC,
204         MMPLAYER_A_CAPS_DEFAULT,
205         MMPLAYER_A_CONV_BFORMAT,
206         MMPLAYER_A_CAPS_360,
207         MMPLAYER_A_SINK,
208         MMPLAYER_A_RESAMPLER,
209         MMPLAYER_A_DEINTERLEAVE,
210         MMPLAYER_A_RGVOL,
211         MMPLAYER_A_CONV_PITCH,
212         MMPLAYER_A_PITCH,
213         MMPLAYER_A_NUM
214 };
215
216 /* video pipeline's element id */
217 enum video_element_id {
218         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
219         MMPLAYER_V_CONV,
220         MMPLAYER_V_CAPS,
221         MMPLAYER_V_SINK,
222         MMPLAYER_V_360,
223         MMPLAYER_V_NUM
224 };
225
226 /* text pipeline's element id */
227 enum text_element_id {
228         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
229         MMPLAYER_T_QUEUE,
230         MMPLAYER_T_VIDEO_QUEUE,
231         MMPLAYER_T_VIDEO_CONVERTER,
232         MMPLAYER_T_OVERLAY,
233         MMPLAYER_T_FAKE_SINK,
234         MMPLAYER_T_IDENTITY,
235         MMPLAYER_T_NUM
236 };
237
238 typedef enum {
239         MMPLAYER_COMMAND_NONE,
240         MMPLAYER_COMMAND_CREATE,
241         MMPLAYER_COMMAND_DESTROY,
242         MMPLAYER_COMMAND_UNREALIZE,
243         MMPLAYER_COMMAND_START,
244         MMPLAYER_COMMAND_REALIZE,
245         MMPLAYER_COMMAND_STOP,
246         MMPLAYER_COMMAND_PAUSE,
247         MMPLAYER_COMMAND_RESUME,
248         MMPLAYER_COMMAND_NUM
249 } mmplayer_command_state_e;
250
251 /* Note : mmplayer_streaming_src_error is error enum for streaming source which post error message
252  *      using custom message made by itself. The enum value must start with zero,
253  *      because the streaming source(secrtspsrc) also does.
254  */
255 enum mmplayer_streaming_src_error {
256         MMPLAYER_STREAMING_ERROR_NONE = 0,
257         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
258         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
259         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
260         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
261         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
262         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
263         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
264         MMPLAYER_STREAMING_ERROR_INVALID_URL,
265         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
266         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
267         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
268         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
269         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
270         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
271         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
272         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
273         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
274         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
275         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
276         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
277         MMPLAYER_STREAMING_ERROR_GONE,
278         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
279         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
280         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
281         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
282         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
283         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
284         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
285         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
286         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
287         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
288         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
289         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
290         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
291         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
292         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
293         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
294         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
295         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
296         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
297         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
298         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
299         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
300         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
301         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
302 };
303
304 typedef enum {
305         MMPLAYER_SEEK_NONE = 0,
306         MMPLAYER_SEEK_IN_PROGRESS,
307         MMPLAYER_SEEK_COMPLETED,        /* after getting async done but before posting seek complete */
308 } mmplayer_seek_state_e;
309
310 typedef enum {
311         MMPLAYER_PATH_VOD = 0,
312         MMPLAYER_PATH_TEXT,
313         MMPLAYER_PATH_MAX
314 } mmplayer_path_type_e;
315
316 /* Video360 related enums. These are duplication from video360.h from
317  * gst-plugins-tizen.
318  * */
319 typedef enum {
320         VIDEO360_MODE_UNKNOWN = -1,
321         VIDEO360_MODE_MONOSCOPIC = 0,
322         VIDEO360_MODE_STEREOSCOPIC_TOP_BOTTOM = 1,
323         VIDEO360_MODE_STEREOSCOPIC_LEFT_RIGHT = 2,
324         VIDEO360_MODE_STEREOSCOPIC_STEREO_MESH = 3,
325         VIDEO360_MODE_LAST_ITEM
326 } mmplayer_stereo_mode_e;
327
328 typedef enum {
329         VIDEO360_PROJECTION_TYPE_UNKNOWN = -1,
330         VIDEO360_PROJECTION_TYPE_EQUIRECTANGULAR = 0,
331         VIDEO360_PROJECTION_TYPE_CUBEMAP = 1,
332         VIDEO360_PROJECTION_TYPE_MESH = 2,
333         VIDEO360_PROJECTION_TYPE_LAST_ITEM
334 } mmplayer_projection_type_e;
335
336 /* Spatial audio related enums. These are duplication from mm_file.h from
337  * libmm-fileinfo.
338  * */
339 typedef enum {
340         MMFILE_AMBISONIC_TYPE_UNKNOWN = 0,
341         MMFILE_AMBISONIC_TYPE_PERIPHONIC = 1,           /**< To comply with Google's Spatial Audio RFC*/
342         MMFILE_AMBISONIC_TYPE_NON_PERIPHONIC = 2,
343 } mmfile_ambisonic_type_e;
344
345 typedef enum {
346         MMFILE_AMBISONIC_FORMAT_UNKNOWN = 0,
347         MMFILE_AMBISONIC_FORMAT_AMBIX = 1,              /**< AMBIX (Channel sequence: ACN, Normalization: SN3D) */
348         MMFILE_AMBISONIC_FORMAT_AMB = 2,                /**< .AMB, Tetraproc (Channel sequence: FuMa, Normalization: FuMa) */
349         MMFILE_AMBISONIC_FORMAT_UA = 3,                 /**< Universal Ambisonics (Channel sequence: SID, Normalization: N3D) */
350 } mmfile_ambisonic_format_e;
351
352 typedef enum {
353         MMFILE_AMBISONIC_ORDER_UNKNOWN = 0,
354         MMFILE_AMBISONIC_ORDER_FOA = 1,                 /**< First order Ambisonics */
355         MMFILE_AMBISONIC_ORDER_SOA = 2,                 /**< Second order Ambisonics */
356         MMFILE_AMBISONIC_ORDER_TOA = 3,                 /**< Third order Ambisonics */
357 } mmfile_ambisonic_order_e;
358
359 /*---------------------------------------------------------------------------
360 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
361 ---------------------------------------------------------------------------*/
362
363 typedef struct {
364         int id;
365         GstElement *gst;
366 } mmplayer_gst_element_t;
367
368 typedef struct {
369         GstTagList *tag_list;
370         mmplayer_gst_element_t *mainbin;
371         mmplayer_gst_element_t *audiobin;
372         mmplayer_gst_element_t *videobin;
373         mmplayer_gst_element_t *textbin;
374 } mmplayer_pipeline_info_t;
375
376 typedef struct {
377         float volume;
378         int mute;
379         int bluetooth;  /* enable/disable */
380         bool rg_enable;
381 } mmplayer_sound_info_t;
382
383 typedef struct {
384         char *buf;
385         int len;
386         int offset;
387 } mmplayer_input_buffer_t;
388
389 typedef struct {
390         int uri_type;
391         mmplayer_input_buffer_t input_mem;
392         char uri[MM_MAX_URL_LEN];
393         char urgent[MM_MAX_FILENAME_LEN];
394 } mmplayer_parse_profile_t;
395
396 typedef struct {
397         storage_type_e type;
398         storage_state_e state;
399         int id;
400         char path[MM_MAX_URL_LEN];
401 } mmplayer_storage_info_t;
402
403 typedef struct {
404         bool is_pending;
405         gint64 pos;
406 } mmplayer_pending_seek_t;
407
408 typedef struct {
409         GObject *obj;
410         gulong sig;
411 } mmplayer_signal_item_t;
412
413 typedef struct {
414         bool rich_audio;
415         bool video_zc; // video zero-copy
416         bool subtitle_off;
417         bool video_export;
418 } mmplayer_setting_mode_t; /* FIXME: renaming */
419
420 typedef struct {
421         GMainContext *global_default;
422         GMainContext *thread_default;
423 } mmplayer_context_info_t;
424
425 typedef struct {
426         gint uri_idx;
427         GList *uri_list;
428 } mmplayer_uri_list_t;
429
430 typedef struct {
431         double scale_x;
432         double scale_y;
433         double scale_width;
434         double scale_height;
435 } mmplayer_video_roi_t;
436
437 typedef struct {
438         gint active_pad_index;
439         gint total_track_num;
440         GPtrArray *channels;
441         gulong block_id;
442         gulong event_probe_id;
443 } mmplayer_selector_t;
444
445 typedef struct {
446         gboolean running;
447
448         gboolean stream_changed;
449         gboolean reconfigure;
450
451         GstClockTime start_time[MM_PLAYER_TRACK_TYPE_MAX];      /* updated once get SEGMENT event */
452         GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
453         gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];
454
455 } mmplayer_gapless_t;
456
457 typedef struct {
458         int channel;
459         int bitrate;
460         int depth;
461         bool is_little_endian;
462         guint64 channel_mask;
463         void *pcm_data;
464         int data_size;
465         int buff_size;
466         media_format_mimetype_e pcm_format;
467 } mmplayer_audio_stream_buff_t;
468
469 /**
470  * @brief data of video_bo_list
471  * @details this will be used when the sw codec is running.
472  * @since_tizen 3.0
473  */
474 typedef struct {
475         gboolean used;
476         void *bo;
477 } mmplayer_video_bo_info_t;
478
479 typedef struct {
480         gint bandwidth;
481         gint width;
482         gint height;
483 } stream_variant_t;
484
485 typedef struct {
486         GList *var_list;
487         stream_variant_t limit;
488 } mmplayer_adaptive_variant_info_t;
489
490 typedef struct {
491         int is_spherical;
492         int is_stitched;
493         char *stitching_software;
494         char *projection_type_string;
495         char *stereo_mode_string;
496         mmplayer_projection_type_e projection_type;
497         mmplayer_stereo_mode_e stereo_mode;
498         int source_count;
499         int init_view_heading;
500         int init_view_pitch;
501         int init_view_roll;
502         int timestamp;
503         int full_pano_width_pixels;
504         int full_pano_height_pixels;
505         int cropped_area_image_width;
506         int cropped_area_image_height;
507         int cropped_area_left;
508         int cropped_area_top;
509         int ambisonic_type;
510         int ambisonic_format;
511         int ambisonic_order;
512 } mmplayer_spherical_metadata_t;
513
514 typedef struct {
515         /* STATE */
516         int state;                                      // player current state
517         int prev_state;                         // player previous state
518         int pending_state;                      // player state which is going to now
519         int target_state;                               // player state which user want to go to
520         guint state_change_timeout;
521
522         gchar *album_art;
523
524         int cmd;
525
526         /* command lock */
527         GMutex cmd_lock;
528         GMutex playback_lock;
529
530         /* gapless play thread */
531         GThread *gapless_play_thread;
532         gboolean gapless_play_thread_exit;
533         GCond gapless_play_thread_cond;
534         GMutex gapless_play_thread_mutex;
535         mmplayer_gapless_t gapless;
536
537         /* capture thread */
538         GThread *capture_thread;
539         gboolean capture_thread_exit;
540         GCond capture_thread_cond;
541         GMutex capture_thread_mutex;
542         mmplayer_video_capture_t capture;
543         mmplayer_video_color_space_e video_cs;
544         MMVideoBuffer captured;
545
546         /* gst bus msg thread, create during realize */
547         GThread *bus_msg_thread;
548         gboolean bus_msg_thread_exit;
549         GCond bus_msg_thread_cond;
550         GMutex bus_msg_thread_mutex;
551
552         /* fakesink handling lock */
553         GMutex fsink_lock;
554
555         /* update tag lock */
556         GMutex update_tag_lock;
557
558         /* player attributes */
559         MMHandleType attrs;
560
561         /* message callback */
562         MMMessageCallback msg_cb;
563         void *msg_cb_param;
564
565         /* streaming player */
566         mmplayer_streaming_t *streamer;
567
568         /* gstreamer pipeline */
569         mmplayer_pipeline_info_t        *pipeline;
570
571         /* pad */
572         GstPad *ghost_pad_for_videobin;
573
574         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
575         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
576         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
577         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
578         GMutex media_stream_cb_lock;
579
580         int video_num_buffers;  /* total num of buffers in vcodec */
581         int video_extra_num_buffers; /* extra num of buffers in vcodec */
582
583         void *buffer_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
584         void *seek_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
585
586         /* video stream changed callback */
587         mm_player_stream_changed_callback video_stream_changed_cb;
588         void *video_stream_changed_cb_user_param;
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 video_overlay_resource;
710         mm_resource_manager_res_h video_decoder_resource;
711         gboolean interrupted_by_resource;
712
713         gboolean is_subtitle_off;
714         gboolean is_external_subtitle_present;
715         gboolean is_external_subtitle_added_now;
716         gboolean pending_resume;
717
718         /* contents bitrate for buffering management */
719         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
720         guint total_bitrate;
721         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
722         guint total_maximum_bitrate;
723
724         /* prevent it from posting duplicatly*/
725         gboolean sent_bos;
726
727         gboolean play_subtitle;
728         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
729
730         /* adjust subtitle position store */
731         gint64 adjust_subtitle_pos;
732         GList *subtitle_language_list;
733         GCond subtitle_info_cond;
734         GMutex subtitle_info_mutex;
735
736         /* To store the current running audio pad index of demuxer */
737         gint demux_pad_index;
738
739         mmplayer_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
740
741         guint internal_text_idx;
742         guint external_text_idx;
743
744         mmplayer_setting_mode_t set_mode;
745
746         /* initialize values */
747         mmplayer_ini_t ini;
748
749         /* store dump pad list */
750         GList *dump_list;
751
752         /* whether a video has closed caption or not */
753         gboolean has_closed_caption;
754
755
756         /* audio stream caps parsed by demuxer or set by external demuxer */
757         GstCaps *a_stream_caps;
758
759         /* subtitle stream caps parsed by demuxer or set by external demuxer */
760         GstCaps *s_stream_caps;
761
762         /* es player using feed-data callback or calling app_src_push_buffer directly*/
763         gboolean es_player_push_mode;
764
765         /* tmb buffer manager for s/w codec tmb_bo */
766         tbm_bufmgr bufmgr;
767
768         mmplayer_adaptive_variant_info_t adaptive_info;
769
770         /* Video360 related stuff
771          * */
772         gboolean is_360_feature_enabled;
773         gboolean is_content_spherical;
774         mmplayer_spherical_metadata_t video360_metadata;
775         gboolean is_openal_plugin_used;
776         /* User settable values */
777         gboolean is_video360_enabled;
778         float video360_yaw_radians;
779         float video360_pitch_radians;
780         float video360_zoom;
781         int video360_horizontal_fov;
782         int video360_vertical_fov;
783
784         /* Video ROI area scale value */
785         mmplayer_video_roi_t video_roi;
786
787         /* build audio offload */
788         gboolean build_audio_offload;
789         guint audio_device_cb_id;
790 } mmplayer_t;
791
792 typedef struct {
793         gchar *language_code;
794         gchar *language_key;
795         gboolean active;
796 } mmplayer_lang_info_t;
797
798 typedef struct {
799         GstPad *dump_pad;
800         gulong probe_handle_id;
801         FILE *dump_element_file;
802 } mmplayer_dump_t;
803
804 typedef struct {
805         char *name;
806         int value_type;
807         int flags;                              // r, w
808         void *default_value;
809         int valid_type;                 // validity type
810         int value_min;                  //<- set validity value range
811         int value_max;          //->
812 } mmplayer_attrs_spec_t;
813
814 /*===========================================================================================
815 |                                                                                                                                                                                       |
816 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
817 |                                                                                                                                                                                       |
818 ========================================================================================== */
819 #ifdef __cplusplus
820         extern "C" {
821 #endif
822
823 int _mmplayer_create_player(MMHandleType hplayer);
824 int _mmplayer_destroy(MMHandleType hplayer);
825 int _mmplayer_realize(MMHandleType hplayer);
826 int _mmplayer_unrealize(MMHandleType hplayer);
827 int _mmplayer_get_state(MMHandleType hplayer, int *pstate);
828 int _mmplayer_set_volume(MMHandleType hplayer, mmplayer_volume_type_t volume);
829 int _mmplayer_get_volume(MMHandleType hplayer, mmplayer_volume_type_t *volume);
830 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
831 int _mmplayer_get_mute(MMHandleType hplayer, int *pmute);
832 int _mmplayer_start(MMHandleType hplayer);
833 int _mmplayer_stop(MMHandleType hplayer);
834 int _mmplayer_pause(MMHandleType hplayer);
835 int _mmplayer_abort_pause(MMHandleType hplayer);
836 int _mmplayer_resume(MMHandleType hplayer);
837 int _mmplayer_set_position(MMHandleType hplayer, gint64 pos);
838 int _mmplayer_get_position(MMHandleType hplayer, gint64 *pos);
839 int _mmplayer_get_duration(MMHandleType hplayer, gint64 *duration);
840 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int pos);
841 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
842 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
843 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
844 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
845 int _mmplayer_set_video_decoded_cb(MMHandleType hplayer, mm_player_video_decoded_callback callback, void *user_param);
846 int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
847 int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent);
848 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath);
849 int _mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos);
850 int _mmplayer_update_video_param(mmplayer_t *player, char *param_name);
851 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
852 int _mmplayer_audio_effect_custom_apply(mmplayer_t *player);
853 int _mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
854 int _mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type, int index);
855 int _mmplayer_sync_subtitle_pipeline(mmplayer_t *player);
856 int _mmplayer_use_system_clock(MMHandleType hplayer);
857 int _mmplayer_set_uri(MMHandleType hplayer, const char *uri);
858 int _mmplayer_set_next_uri(MMHandleType hplayer, const char *uri, bool is_first_path);
859 int _mmplayer_get_next_uri(MMHandleType hplayer, char **uri);
860 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool *exist);
861 void _mm_player_video_stream_internal_buffer_unref(void *buffer);
862 int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
863 int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
864 int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state);
865 int _mmplayer_video_stream_release_bo(mmplayer_t *player, void *bo);
866 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
867 int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
868 int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
869 int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
870 int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
871 int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *prebuffer_ms, int *rebuffer_ms);
872 int _mmplayer_set_codec_type(MMHandleType hplayer, mmplayer_stream_type_e stream_type, mmplayer_video_codec_type_e codec_type);
873 int _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled);
874 int _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled);
875 int _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height);
876 int _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
877
878 /* internal */
879 void __mmplayer_bus_msg_thread_destroy(MMHandleType hplayer);
880
881 void __mmplayer_set_state(mmplayer_t *player, int state);
882 int __mmplayer_check_state(mmplayer_t *player, mmplayer_command_state_e command);
883 gboolean __mmplayer_update_content_attrs(mmplayer_t *player, enum content_attr_flag flag);
884 void __mmplayer_cancel_eos_timer(mmplayer_t *player);
885 void __mmplayer_audio_stream_clear_buffer(mmplayer_t *player, gboolean send_all);
886 MMStreamingType __mmplayer_get_stream_service_type(mmplayer_t *player);
887 int __mmplayer_get_video_angle(mmplayer_t *player, int *display_angle, int *orientations);
888 gboolean __mmplayer_gst_remove_fakesink(mmplayer_t *player, mmplayer_gst_element_t *fakesink);
889 void __mmplayer_add_signal_connection(mmplayer_t *player, GObject *object, mmplayer_signal_type_e type, const gchar *signal, GCallback cb_funct, gpointer u_data);
890 void __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data);
891 gint __mmplayer_gst_decode_autoplug_select(GstElement *bin,  GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer data);
892 gboolean __mmplayer_gst_create_decoder(mmplayer_t *player, GstPad *srcpad, const GstCaps *caps);
893 void __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data);
894 GstElement *__mmplayer_gst_make_decodebin(mmplayer_t *player);
895 int __mmplayer_gst_element_add_bucket_to_bin(GstBin *bin, GList *element_bucket);
896 int __mmplayer_gst_element_link_bucket(GList *element_bucket);
897 void __mmplayer_typefind_have_type(GstElement *tf, guint probability, GstCaps *caps, gpointer data);
898 int __mmplayer_parse_profile(const char *uri, void *param, mmplayer_parse_profile_t *data);
899
900
901 #ifdef __cplusplus
902         }
903 #endif
904
905 #endif  /* __MM_PLAYER_PRIV_H__ */