Video360 and openalsink elements added, video360 internal API implementation added
[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_player_resource.h"
47 #include "mm_player_sound_focus.h"
48 #include "mm_player_pd.h"
49 #include "mm_player_streaming.h"
50
51 /*===========================================================================================
52 |                                                                                                                                                                                       |
53 |  GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                       |
54 |                                                                                                                                                                                       |
55 ========================================================================================== */
56
57 /*---------------------------------------------------------------------------
58 |    GLOBAL #defines:                                                                                                           |
59 ---------------------------------------------------------------------------*/
60 #define MM_PLAYER_IMGB_MPLANE_MAX       4
61 #define MM_PLAYER_STREAM_COUNT_MAX      3
62
63 #define MM_PLAYER_CAST(x_player)                ((mm_player_t *)(x_player))
64 /**
65  * @x_player: MMHandleType of player
66  *
67  * Get the PD downloader of this player.
68  */
69 #define MM_PLAYER_GET_PD(x_player)      (MM_PLAYER_CAST(x_player)->pd_downloader)
70 /**
71  * @x_player: MMHandleType of player
72  *
73  * Get the attributes handle of this player.
74  */
75 #define MM_PLAYER_GET_ATTRS(x_player)   (MM_PLAYER_CAST(x_player)->attrs)
76
77 #define ROTATION_USING_SINK     0
78 #define ROTATION_USING_CUSTOM   1
79 #define ROTATION_USING_FLIP     2
80
81 #define VIDEO360_MAX_ZOOM       10.0f
82
83 /*---------------------------------------------------------------------------
84 |    GLOBAL CONSTANT DEFINITIONS:                                                                                       |
85 ---------------------------------------------------------------------------*/
86 enum latency_mode {
87         AUDIO_LATENCY_MODE_LOW = 0,     /**< Low audio latency mode */
88         AUDIO_LATENCY_MODE_MID,         /**< Middle audio latency mode */
89         AUDIO_LATENCY_MODE_HIGH,        /**< High audio latency mode */
90 };
91
92 enum tag_info {
93         TAG_AUDIO_CODEC = 0x0001,
94         TAG_VIDEO_CODEC = 0x0002,
95         TAG_ARTIST              = 0x0004,
96         TAG_TITLE               = 0x0008,
97         TAG_ALBUM               = 0x0010,
98         TAG_GENRE               = 0x0020,
99         TAG_COPYRIGHT   = 0x0040,
100         TAG_DATE                = 0x0080,
101         TAG_DESCRIPTION = 0x0100,
102         TAG_TRACK_NUMBER = 0x0200
103 };
104
105 enum content_attr_flag {
106         ATTR_MISSING_ONLY = 0x0001,
107         ATTR_DURATION = 0x0002,
108         ATTR_AUDIO  = 0x0004,
109         ATTR_VIDEO = 0x0008,
110         ATTR_BITRATE = 0x0010,
111         ATTR_ALL = 0x0020,
112 };
113
114 /* async mode makes trouble. alsasink sometimes fails to pause. */
115 enum alassink_sync {
116         ALSASINK_SYNC,
117         ALSASINK_ASYNC
118 };
119
120 /**
121  * Enumerations of Player Uri type
122  */
123 enum MMPlayerUriType {
124         MM_PLAYER_URI_TYPE_NONE,                        /**< Player URI type None */
125         MM_PLAYER_URI_TYPE_URL_RTSP,            /**< Player URI type RTSP */
126         MM_PLAYER_URI_TYPE_URL_HTTP,            /**< Player URI type HTTP */
127         MM_PLAYER_URI_TYPE_URL_MMS,                     /**< Player URI type MMS */
128         MM_PLAYER_URI_TYPE_MEM,                         /**< Player URI type Mem */
129         MM_PLAYER_URI_TYPE_FILE,                        /**< Player URI type File */
130         MM_PLAYER_URI_TYPE_URL,                         /**< Player URI type URL */
131         MM_PLAYER_URI_TYPE_MS_BUFF,                     /**< Player URI type Media Stream Buffer */
132         MM_PLAYER_URI_TYPE_HLS,                         /**< Player URI type http live streaming */
133         MM_PLAYER_URI_TYPE_SS,                          /**< Player URI type Smooth streaming */
134         MM_PLAYER_URI_TYPE_DASH,                        /**< Player URI type Mpeg Dash */
135         MM_PLAYER_URI_TYPE_NO_PERMISSION,       /**< Player URI type No Permission  */
136         MM_PLAYER_URI_TYPE_TEMP,                        /**< Player URI type Temp */
137 };
138
139 typedef enum _MissingCodec {
140         MISSING_PLUGIN_NONE = 0x00,
141         MISSING_PLUGIN_AUDIO = 0x01,
142         MISSING_PLUGIN_VIDEO = 0x02
143 } MissingCodec;
144
145
146 typedef enum _FoundCodec {
147         FOUND_PLUGIN_NONE = 0x00,
148         FOUND_PLUGIN_AUDIO = 0x01,
149         FOUND_PLUGIN_VIDEO = 0x02
150 } FoundCodec;
151
152 /**
153  * Enumeration of signal type
154  */
155 typedef enum {
156         MM_PLAYER_SIGNAL_TYPE_AUTOPLUG = 0,
157         MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
158         MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
159         MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
160         MM_PLAYER_SIGNAL_TYPE_OTHERS,
161         MM_PLAYER_SIGNAL_TYPE_ALL,
162         MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
163 } MMPlayerSignalType;
164
165 /* main pipeline's element id */
166 enum MainElementID {
167         MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
168         MMPLAYER_M_SRC,
169         MMPLAYER_M_2ND_SRC,     /* 2nd Source Element for es buff src */
170         MMPLAYER_M_SUBSRC,
171
172         /* it could be a decodebin or could be a typefind. depends on player ini */
173         MMPLAYER_M_TYPEFIND,
174         MMPLAYER_M_AUTOPLUG,
175
176         MMPLAYER_M_AUTOPLUG_V_DEC,
177         MMPLAYER_M_AUTOPLUG_A_DEC,
178
179         /* NOTE : we need two fakesink to autoplug without decodebin.
180          * first one will hold whole pipeline state. and second one will hold state of
181          * a sink-decodebin for an elementary stream. no metter if there's more then one
182          * elementary streams because MSL reuse it.
183          */
184         MMPLAYER_M_SRC_FAKESINK,
185         MMPLAYER_M_SRC_2ND_FAKESINK,
186
187         /* streaming plugin */
188         MMPLAYER_M_MUXED_S_BUFFER,
189         MMPLAYER_M_DEMUXED_S_BUFFER,
190         MMPLAYER_M_ID3DEMUX,
191         MMPLAYER_M_ADAPTIVE_DEMUX,
192
193         /* es buff src queue */
194         MMPLAYER_M_V_BUFFER,
195         MMPLAYER_M_A_BUFFER,
196         MMPLAYER_M_S_BUFFER,
197
198         /* FIXIT : if there's really no usage for following IDs. remove it */
199         MMPLAYER_M_DEC1,
200         MMPLAYER_M_DEC2,
201         MMPLAYER_M_Q1,
202         MMPLAYER_M_Q2,
203         MMPLAYER_M_DEMUX,
204         MMPLAYER_M_SUBPARSE,
205         MMPLAYER_M_DEMUX_EX,
206         MMPLAYER_M_V_INPUT_SELECTOR,    // video input_select
207         MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
208         MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
209         MMPLAYER_M_A_TEE,
210         MMPLAYER_M_A_Q1,
211         MMPLAYER_M_A_Q2,
212         MMPLAYER_M_A_CONV,
213         MMPLAYER_M_A_FILTER,
214         MMPLAYER_M_A_DEINTERLEAVE,
215         MMPLAYER_M_A_SELECTOR,
216         MMPLAYER_M_V_SINK,
217         MMPLAYER_M_V_CONV,
218         MMPLAYER_M_NUM
219 };
220
221 /* audio pipeline's element id */
222 enum AudioElementID {
223         MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
224         MMPLAYER_A_TP,
225         MMPLAYER_A_CONV,
226         MMPLAYER_A_VOL,
227         MMPLAYER_A_FILTER,
228         MMPLAYER_A_FILTER_SEC,
229         MMPLAYER_A_CAPS_DEFAULT,
230         MMPLAYER_A_CONV_BFORMAT,
231         MMPLAYER_A_CAPS_360,
232         MMPLAYER_A_SINK,
233         MMPLAYER_A_RESAMPLER,
234         MMPLAYER_A_DEINTERLEAVE,
235         MMPLAYER_A_NUM
236 };
237
238 /* video pipeline's element id */
239 enum VideoElementID {
240         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
241         MMPLAYER_V_FLIP,
242         MMPLAYER_V_CONV,
243         MMPLAYER_V_SCALE,
244         MMPLAYER_V_CAPS,
245         MMPLAYER_V_SINK,
246         MMPLAYER_V_360,
247         MMPLAYER_V_NUM
248 };
249
250 /* text pipeline's element id */
251 enum TextElementID {
252         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
253         MMPLAYER_T_QUEUE,
254         MMPLAYER_T_VIDEO_QUEUE,
255         MMPLAYER_T_VIDEO_CONVERTER,
256         MMPLAYER_T_OVERLAY,
257         MMPLAYER_T_FAKE_SINK,
258         MMPLAYER_T_IDENTITY,
259         MMPLAYER_T_NUM
260 };
261
262 /* midi main pipeline's element id */
263 enum MidiElementID {
264         MMPLAYER_MIDI_PIPE,
265         MMPLAYER_MIDI_PLAYER,
266         MMPLAYER_MIDI_NUM
267 };
268
269 enum PlayerCommandState {
270         MMPLAYER_COMMAND_NONE,
271         MMPLAYER_COMMAND_CREATE,
272         MMPLAYER_COMMAND_DESTROY,
273         MMPLAYER_COMMAND_UNREALIZE,
274         MMPLAYER_COMMAND_START,
275         MMPLAYER_COMMAND_REALIZE,
276         MMPLAYER_COMMAND_STOP,
277         MMPLAYER_COMMAND_PAUSE,
278         MMPLAYER_COMMAND_RESUME,
279         MMPLAYER_COMMAND_NUM
280 };
281
282 /* Note : StreamingSrcError is error enum for streaming source which post error message
283  *      using custom message made by itself. The enum value must start with zero,
284  *      because the streaming source(secrtspsrc) also does.
285  */
286 enum StreamingSrcError {
287         MMPLAYER_STREAMING_ERROR_NONE = 0,
288         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
289         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
290         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
291         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
292         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
293         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
294         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
295         MMPLAYER_STREAMING_ERROR_INVALID_URL,
296         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
297         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
298         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
299         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
300         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
301         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
302         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
303         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
304         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
305         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
306         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
307         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
308         MMPLAYER_STREAMING_ERROR_GONE,
309         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
310         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
311         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
312         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
313         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
314         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
315         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
316         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
317         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
318         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
319         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
320         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
321         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
322         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
323         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
324         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
325         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
326         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
327         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
328         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
329         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
330         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
331         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
332         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
333 };
334
335 typedef enum {
336         MMPLAYER_PATH_VOD = 0,
337         MMPLAYER_PATH_TEXT,
338         MMPLAYER_PATH_MAX
339 } MMPlayerPathType;
340
341 /* Video360 related enums. These are duplication from video360.h from
342  * gst-plugins-tizen.
343  * */
344 typedef enum {
345         VIDEO360_MODE_UNKNOWN = -1,
346         VIDEO360_MODE_MONOSCOPIC = 0,
347         VIDEO360_MODE_STEREOSCOPIC_TOP_BOTTOM = 1,
348         VIDEO360_MODE_STEREOSCOPIC_LEFT_RIGHT = 2,
349         VIDEO360_MODE_STEREOSCOPIC_STEREO_MESH = 3,
350         VIDEO360_MODE_LAST_ITEM
351 } mm_player_stereo_mode_e;
352
353 typedef enum {
354         VIDEO360_PROJECTION_TYPE_UNKNOWN = -1,
355         VIDEO360_PROJECTION_TYPE_EQUIRECTANGULAR = 0,
356         VIDEO360_PROJECTION_TYPE_CUBEMAP = 1,
357         VIDEO360_PROJECTION_TYPE_MESH = 2,
358         VIDEO360_PROJECTION_TYPE_LAST_ITEM
359 } mm_player_projection_type_e;
360
361 /* Spatial audio related enums. These are duplication from mm_file.h from
362  * libmm-fileinfo.
363  * */
364 typedef enum {
365         MMFILE_AMBISONIC_TYPE_UNKNOWN = 0,
366         MMFILE_AMBISONIC_TYPE_PERIPHONIC = 1,           /**< To comply with Google's Spatial Audio RFC*/
367         MMFILE_AMBISONIC_TYPE_NON_PERIPHONIC = 2,
368 } MMFILE_AMBISONIC_TYPE;
369
370 typedef enum {
371         MMFILE_AMBISONIC_FORMAT_UNKNOWN = 0,
372         MMFILE_AMBISONIC_FORMAT_AMBIX = 1,              /**< AMBIX (Channel sequence: ACN, Normalization: SN3D) */
373         MMFILE_AMBISONIC_FORMAT_AMB = 2,                /**< .AMB, Tetraproc (Channel sequence: FuMa, Normalization: FuMa) */
374         MMFILE_AMBISONIC_FORMAT_UA = 3,                 /**< Universal Ambisonics (Channel sequence: SID, Normalization: N3D) */
375 } MMFILE_AMBISONIC_FORMAT;
376
377 typedef enum {
378         MMFILE_AMBISONIC_ORDER_UNKNOWN = 0,
379         MMFILE_AMBISONIC_ORDER_FOA = 1,                 /**< First order Ambisonics */
380         MMFILE_AMBISONIC_ORDER_SOA = 2,                 /**< Second order Ambisonics */
381         MMFILE_AMBISONIC_ORDER_TOA = 3,                 /**< Third order Ambisonics */
382 } MMFILE_AMBISONIC_ORDER;
383
384 /*---------------------------------------------------------------------------
385 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
386 ---------------------------------------------------------------------------*/
387
388 typedef struct {
389         int id;
390         GstElement *gst;
391 } MMPlayerGstElement;
392
393 typedef struct {
394         GstTagList *tag_list;
395         MMPlayerGstElement *mainbin;
396         MMPlayerGstElement *audiobin;
397         MMPlayerGstElement *videobin;
398         MMPlayerGstElement *textbin;
399 } MMPlayerGstPipelineInfo;
400
401 typedef struct {
402         float volume;
403         int mute;
404         int bluetooth;  /* enable/disable */
405 } MMPlayerSoundInfo;
406
407 typedef struct {
408         char *buf;
409         int len;
410         int offset;
411
412 } tBuffer; /* FIXIT : choose better name */
413
414 typedef struct {
415         int uri_type;
416         int     play_mode;
417         void *mem;
418         int     mem_size;
419         char uri[MM_MAX_URL_LEN];
420         char urgent[MM_MAX_FILENAME_LEN];
421 } MMPlayerParseProfile;
422
423 typedef struct {
424         storage_type_e type;
425         storage_state_e state;
426         int id;
427 } MMPlayerStorageInfo;
428
429 typedef struct {
430         bool is_pending;
431         MMPlayerPosFormatType format;
432         unsigned long pos;
433 } MMPlayerPendingSeek;
434
435 typedef struct {
436         GObject* obj;
437         gulong sig;
438 } MMPlayerSignalItem;
439
440 typedef struct {
441         bool rich_audio;
442         bool safety_volume;
443         bool pcm_extraction;
444         bool video_zc; // video zero-copy
445         bool subtitle_off;
446         bool media_packet_video_stream;
447 } MMPlayerSetMode;
448
449 typedef struct {
450         GMainContext *global_default;
451         GMainContext *thread_default;
452 } MMPlayerGMainContext;
453
454 typedef struct {
455         gint uri_idx;
456         GList *uri_list;
457 } MMPlayerUriList;
458
459 typedef struct {
460         gint active_pad_index;
461         gint total_track_num;
462         GPtrArray *channels;
463         gulong block_id;
464         gulong event_probe_id;
465 } mm_player_selector_t;
466
467 typedef struct {
468         gboolean running;
469
470         gboolean stream_changed;
471         gboolean reconfigure;
472
473         GstClockTime start_time[MM_PLAYER_TRACK_TYPE_MAX];      /* updated once get SEGMENT event */
474         GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
475         gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];
476
477 } mm_player_gapless_t;
478
479 typedef struct {
480         int channel;
481         int bitrate;
482         int depth;
483         bool is_little_endian;
484         guint64 channel_mask;
485         void *pcm_data;
486         int data_size;
487         int buff_size;
488 } mm_player_audio_stream_buff_t;
489
490 /**
491  * @brief data of video_bo_list
492  * @details this will be used when the sw codec is running.
493  * @since_tizen 3.0
494  */
495 typedef struct {
496         gboolean using;
497         void* bo;
498 } mm_player_video_bo_info_t;
499
500 typedef struct {
501         gint bandwidth;
502         gint width;
503         gint height;
504 } VariantData;
505
506 typedef struct {
507         GList* var_list;
508         VariantData limit;
509 } MMAdaptiveVariantInfo;
510
511 typedef struct {
512         int is_spherical;
513         int is_stitched;
514         char *stitching_software;
515         char *projection_type_string;
516         char *stereo_mode_string;
517         mm_player_projection_type_e projection_type;
518         mm_player_stereo_mode_e stereo_mode;
519         int source_count;
520         int init_view_heading;
521         int init_view_pitch;
522         int init_view_roll;
523         int timestamp;
524         int full_pano_width_pixels;
525         int full_pano_height_pixels;
526         int cropped_area_image_width;
527         int cropped_area_image_height;
528         int cropped_area_left;
529         int cropped_area_top;
530         int ambisonic_type;
531         int ambisonic_format;
532         int ambisonic_order;
533 } mm_player_spherical_metadata_t;
534
535 typedef struct {
536         /* STATE */
537         int state;                                      // player current state
538         int prev_state;                         // player previous state
539         int pending_state;                      // player state which is going to now
540         int target_state;                               // player state which user want to go to
541         guint state_change_timeout;
542
543         gboolean section_repeat;
544         gint section_repeat_start;
545         gint section_repeat_end;
546         guint play_count;
547
548         gchar *album_art;
549
550         int cmd;
551
552         /* command lock */
553         GMutex cmd_lock;
554         GMutex playback_lock;
555
556         /* repeat thread lock */
557         GCond repeat_thread_cond;
558         GMutex repeat_thread_mutex;
559         GThread* repeat_thread;
560         gboolean repeat_thread_exit;
561
562         /* next play thread */
563         GThread* next_play_thread;
564         gboolean next_play_thread_exit;
565         GCond next_play_thread_cond;
566         GMutex next_play_thread_mutex;
567         mm_player_gapless_t gapless;
568
569         /* capture thread */
570         GThread* capture_thread;
571         gboolean capture_thread_exit;
572         GCond capture_thread_cond;
573         GMutex capture_thread_mutex;
574         MMPlayerVideoCapture capture;
575         MMPlayerVideoColorspace video_cs;
576         MMVideoBuffer captured;
577
578         /* fakesink handling lock */
579         GMutex fsink_lock;
580
581         /* update tag lock */
582         GMutex update_tag_lock;
583
584         /* player attributes */
585         MMHandleType attrs;
586
587         /* message callback */
588         MMMessageCallback msg_cb;
589         void* msg_cb_param;
590
591         /* progressive download */
592         mm_player_pd_t *pd_downloader;
593         gchar *pd_file_save_path;
594         MMPlayerPDMode pd_mode;
595
596         /* streaming player */
597         mm_player_streaming_t *streamer;
598         gchar *http_file_buffering_path;
599
600         /* gstreamer pipeline */
601         MMPlayerGstPipelineInfo *pipeline;
602
603         /* pad */
604         GstPad *ghost_pad_for_videobin;
605
606         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
607         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
608         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
609         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
610         GMutex media_stream_cb_lock;
611
612         int video_num_buffers;  /* total num of buffers in vcodec */
613         int video_extra_num_buffers; /* extra num of buffers in vcodec */
614
615         void* buffer_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
616         void* seek_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
617
618         /* video stream changed callback */
619         mm_player_stream_changed_callback video_stream_changed_cb;
620         void* video_stream_changed_cb_user_param;
621
622         /* audio stream changed callback */
623         mm_player_stream_changed_callback audio_stream_changed_cb;
624         void* audio_stream_changed_cb_user_param;
625
626         /* video stream callback */
627         mm_player_video_stream_callback video_stream_cb;
628         void* video_stream_cb_user_param;
629         GCond video_bo_cond;
630         GMutex video_bo_mutex;
631         GList* video_bo_list; /* mm_player_video_bo_info_t, bo list for decoded video data by sw codec */
632         int video_bo_size;
633         bool video_stream_prerolled;
634
635         /* audio stram callback */
636         mm_player_audio_stream_callback audio_stream_cb;
637         void* audio_stream_cb_user_param;
638         bool audio_stream_sink_sync;
639         GList* audio_stream_buff_list; /* mm_player_audio_stream_buff_t, buff list of extract pcm data */
640
641         /* audio buffer callback */
642         mm_player_audio_stream_callback_ex audio_stream_render_cb_ex;
643
644         /* video capture callback*/
645         gulong video_capture_cb_probe_id;
646
647         /* sound info */
648         MMPlayerSoundInfo       sound;
649
650         /* type string */
651         gchar *type;
652
653         /* video stream caps parsed by demuxer */
654         GstCaps* v_stream_caps;
655
656         /* audio effect infomation */
657         MMAudioEffectInfo audio_effect_info;
658         gboolean bypass_audio_effect;
659
660         gulong audio_cb_probe_id;
661
662         /* for appsrc */
663         tBuffer mem_buf;
664
665         /* content profile */
666         MMPlayerParseProfile profile;
667         MMPlayerStorageInfo storage_info[MMPLAYER_PATH_MAX];
668
669         /* streaming service type */
670         MMStreamingType streaming_type;
671
672         /* autoplugging */
673         GList* factories;
674         gboolean have_dynamic_pad;
675         GList* parsers; // list of linked parser name
676         GList* audio_decoders; // list of linked audio name
677         gboolean no_more_pad;
678         gint num_dynamic_pad;
679         gboolean has_many_types;
680
681         /* progress callback timer */
682         /* FIXIT : since duplicated functionality with get_position
683          * this function will be deprecated after fixing all application
684          * which are using it.
685          */
686         guint progress_timer;
687
688         /* timer for sending delayed EOS */
689         guint eos_timer;
690
691         /* last point (msec) that player is paused or seeking */
692         gint64 last_position;
693
694         /* duration */
695         gint64 duration;
696
697         /* data size of http streaming  */
698         guint64 http_content_size;
699
700         /* last error */
701         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
702
703         gboolean smooth_streaming;
704
705         gint videodec_linked;
706         gint audiodec_linked;
707         gint videosink_linked;
708         gint audiosink_linked;
709         gint textsink_linked;
710
711         /* missing plugin during autoplugging */
712         MissingCodec not_supported_codec;
713
714         /* unlinked audio/video mime type */
715         gchar *unlinked_video_mime;
716         gchar *unlinked_audio_mime;
717         gchar *unlinked_demuxer_mime;
718
719         /* found codec during autoplugging */
720         FoundCodec can_support_codec;
721
722         gboolean not_found_demuxer;
723
724         /* support seek even though player is not start */
725         MMPlayerPendingSeek pending_seek;
726
727         gboolean doing_seek;
728
729         /* prevent to post msg over and over */
730         gboolean msg_posted;
731
732         /* list of sink elements */
733         GList* sink_elements;
734
735         /* signal notifiers */
736         GList* signals[MM_PLAYER_SIGNAL_TYPE_MAX];
737         guint bus_watcher;
738         MMPlayerGMainContext context;
739         MMPlayerUriList uri_info;
740
741         gboolean is_sound_extraction;
742
743         gfloat playback_rate;
744
745         /* player state resumed by fast rewind */
746         gboolean resumed_by_rewind;
747
748         gboolean is_nv12_tiled;
749
750         /* resource manager for H/W resources */
751         MMPlayerResourceManager resource_manager[RESOURCE_TYPE_MAX];
752
753         /* sound focus for being compatible with legacy session policy internally */
754         MMPlayerSoundFocus sound_focus;
755
756         gboolean is_subtitle_off;
757         gboolean is_external_subtitle_present;
758         gboolean is_external_subtitle_added_now;
759         gboolean pending_resume;
760
761         /* contents bitrate for buffering management */
762         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
763         guint total_bitrate;
764         guint updated_bitrate_count;
765         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
766         guint total_maximum_bitrate;
767         guint updated_maximum_bitrate_count;
768
769         /* prevent it from posting duplicatly*/
770         gboolean sent_bos;
771
772         /* timeout source for lazy pause */
773         guint resume_event_id;
774         guint resumable_cancel_id;
775
776         gboolean play_subtitle;
777         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
778
779         /* PD downloader message callback and param */
780         MMMessageCallback pd_msg_cb;
781         void* pd_msg_cb_param;
782
783         /* adjust subtitle position store */
784         gint64 adjust_subtitle_pos;
785         GList *subtitle_language_list;
786
787         /* To store the current multiwindow status */
788         gboolean last_multiwin_status;
789
790         /* To store the current running audio pad index of demuxer */
791         gint demux_pad_index;
792
793         mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
794         mm_player_selector_t audio_mode;
795         gboolean use_deinterleave;
796         guint max_audio_channels;
797
798         guint internal_text_idx;
799         guint external_text_idx;
800
801         MMPlayerSetMode set_mode;
802
803         /* initialize values */
804         mm_player_ini_t ini;
805
806         /* video share sync */
807         gint64 video_share_api_delta;
808         gint64 video_share_clock_delta;
809
810         /* just for native app (video hub) */
811         gboolean video_hub_download_mode;
812         gboolean sync_handler;
813
814         /* store dump pad list */
815         GList* dump_list;
816
817         /* whether a video has closed caption or not */
818         gboolean has_closed_caption;
819
820         GstElement *video_fakesink;
821
822         /* audio stream caps parsed by demuxer or set by external demuxer */
823         GstCaps* a_stream_caps;
824
825         /* subtitle stream caps parsed by demuxer or set by external demuxer */
826         GstCaps* s_stream_caps;
827
828         /* es player using feed-data callback or calling app_src_push_buffer directly*/
829         gboolean es_player_push_mode;
830
831         /* tmb buffer manager for s/w codec tmb_bo */
832         tbm_bufmgr bufmgr;
833
834         int pcm_samplerate;
835         int pcm_channel;
836
837         MMAdaptiveVariantInfo adaptive_info;
838
839         /* Video360 related stuff
840          * */
841         bool is_content_spherical;
842         mm_player_spherical_metadata_t video360_metadata;
843         bool is_openal_plugin_used;
844         bool is_video360_plugin_used;
845         /* User settable values */
846         bool is_video360_enabled;
847         float video360_yaw_radians;
848         float video360_pitch_radians;
849         float video360_zoom;
850         int video360_horizontal_fov;
851         int video360_vertical_fov;
852
853 } mm_player_t;
854
855 typedef struct {
856         gchar *language_code;
857         gchar *language_key;
858         gboolean active;
859 } MMPlayerLangStruct;
860
861 typedef struct {
862         GstPad *dump_pad;
863         gulong probe_handle_id;
864         FILE *dump_element_file;
865 } mm_player_dump_t;
866
867 typedef struct {
868         char *name;
869         int value_type;
870         int flags;                              // r, w
871         void *default_value;
872         int valid_type;                 // validity type
873         int value_min;                  //<- set validity value range
874         int value_max;          //->
875 } MMPlayerAttrsSpec;
876
877 /*===========================================================================================
878 |                                                                                                                                                                                       |
879 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
880 |                                                                                                                                                                                       |
881 ========================================================================================== */
882 #ifdef __cplusplus
883         extern "C" {
884 #endif
885
886 int _mmplayer_create_player(MMHandleType hplayer);
887 int _mmplayer_destroy(MMHandleType hplayer);
888 int _mmplayer_realize(MMHandleType hplayer);
889 int _mmplayer_unrealize(MMHandleType hplayer);
890 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
891 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
892 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
893 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
894 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
895 int _mmplayer_start(MMHandleType hplayer);
896 int _mmplayer_stop(MMHandleType hplayer);
897 int _mmplayer_pause(MMHandleType hplayer);
898 int _mmplayer_resume(MMHandleType hplayer);
899 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
900 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
901 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
902 int _mmplayer_adjust_video_postion(MMHandleType hplayer, int offset);
903 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
904 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
905 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
906 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
907 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
908 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
909 int _mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param);
910 int _mmplayer_set_audiostream_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
911 int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
912 int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int* silent);
913 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filepath);
914 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
915
916 /* test API for tuning audio gain. this API should be
917  * deprecated before the day of final release
918  */
919 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
920 int _mmplayer_update_video_param(mm_player_t* player, char *param_name);
921 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
922 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
923 int _mmplayer_audio_effect_custom_apply(mm_player_t *player);
924
925 int _mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param);
926 gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessageParamType* param);
927
928 int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type, int index);
929 int _mmplayer_sync_subtitle_pipeline(mm_player_t* player);
930 int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode);
931 int _mmplayer_use_system_clock(MMHandleType hplayer);
932 int _mmplayer_set_video_share_master_clock(MMHandleType hplayer, long long clock, long long clock_delta, long long video_time, long long media_clock, long long audio_time);
933 int _mmplayer_get_video_share_master_clock(MMHandleType hplayer, long long *video_time, long long *media_clock, long long *audio_time);
934 int _mmplayer_get_video_rotate_angle(MMHandleType hplayer, int *angle);
935 int _mmplayer_enable_sync_handler(MMHandleType hplayer, bool enable);
936 int _mmplayer_set_file_buffering_path(MMHandleType hplayer, const char* file_path);
937 int _mmplayer_set_uri(MMHandleType hplayer, const char* uri);
938 int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_path);
939 int _mmplayer_get_next_uri(MMHandleType hplayer, char** uri);
940 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool* exist);
941 void _mm_player_video_stream_internal_buffer_unref(void *buffer);
942 int _mmplayer_set_pcm_spec(MMHandleType hplayer, int samplerate, int channel);
943 int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
944 int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
945 int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int state);
946 int __mmplayer_gst_set_state(mm_player_t* player, GstElement * pipeline,  GstState state, gboolean async, gint timeout);
947 int __mmplayer_set_state(mm_player_t* player, int state);
948 int __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command);
949 gboolean __mmplayer_dump_pipeline_state(mm_player_t* player);
950 void __mmplayer_remove_g_source_from_context(GMainContext *context, guint source_id);
951 /* util */
952 const gchar * __get_state_name(int state);
953 gboolean __mmplayer_can_do_interrupt(mm_player_t *player);
954 gboolean __is_streaming(mm_player_t* player);
955 gboolean __is_rtsp_streaming(mm_player_t* player);
956 gboolean __is_live_streaming(mm_player_t* player);
957 gboolean __is_http_streaming(mm_player_t* player);
958 gboolean __is_http_live_streaming(mm_player_t* player);
959 gboolean __is_dash_streaming(mm_player_t* player);
960 gboolean __is_smooth_streaming(mm_player_t* player);
961 gboolean __is_http_progressive_down(mm_player_t* player);
962
963 gboolean __mmplayer_check_useful_message(mm_player_t *player, GstMessage * message);
964 gboolean __mmplayer_handle_gst_error(mm_player_t* player, GstMessage * message, GError* error);
965 gint __gst_handle_core_error(mm_player_t* player, int code);
966 gint __gst_handle_library_error(mm_player_t* player, int code);
967 gint __gst_handle_resource_error(mm_player_t* player, int code, GstMessage * message);
968 gint __gst_handle_stream_error(mm_player_t* player, GError* error, GstMessage * message);
969 int _mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid);
970 int _mmplayer_get_client_pid(MMHandleType hplayer, int* pid);
971 int __mmplayer_get_video_angle(mm_player_t* player, int *user_angle, int *org_angle);
972 int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo);
973 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
974 int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
975 int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
976 int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
977 int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
978 int _mmplayer_set_streaming_buffering_time(MMHandleType hplayer, int buffer_ms, int rebuffer_ms);
979 int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *buffer_ms, int *rebuffer_ms);
980
981 #ifdef __cplusplus
982         }
983 #endif
984
985 #endif  /* __MM_PLAYER_PRIV_H__ */