[0.6.86] customizing the bus msg polling period
[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 MM_MAX_STRING_LENGTH    4000 /* have to be less than MUSE_MSG_MAX_LENGTH */
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_SINK,
231         MMPLAYER_A_RESAMPLER,
232         MMPLAYER_A_DEINTERLEAVE,
233         MMPLAYER_A_NUM
234 };
235
236 /* video pipeline's element id */
237 enum VideoElementID {
238         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
239         MMPLAYER_V_FLIP,
240         MMPLAYER_V_CONV,
241         MMPLAYER_V_SCALE,
242         MMPLAYER_V_CAPS,
243         MMPLAYER_V_SINK,
244         MMPLAYER_V_NUM
245 };
246
247 /* text pipeline's element id */
248 enum TextElementID {
249         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
250         MMPLAYER_T_QUEUE,
251         MMPLAYER_T_VIDEO_QUEUE,
252         MMPLAYER_T_VIDEO_CONVERTER,
253         MMPLAYER_T_OVERLAY,
254         MMPLAYER_T_FAKE_SINK,
255         MMPLAYER_T_IDENTITY,
256         MMPLAYER_T_NUM
257 };
258
259 /* midi main pipeline's element id */
260 enum MidiElementID {
261         MMPLAYER_MIDI_PIPE,
262         MMPLAYER_MIDI_PLAYER,
263         MMPLAYER_MIDI_NUM
264 };
265
266 enum PlayerCommandState {
267         MMPLAYER_COMMAND_NONE,
268         MMPLAYER_COMMAND_CREATE,
269         MMPLAYER_COMMAND_DESTROY,
270         MMPLAYER_COMMAND_UNREALIZE,
271         MMPLAYER_COMMAND_START,
272         MMPLAYER_COMMAND_REALIZE,
273         MMPLAYER_COMMAND_STOP,
274         MMPLAYER_COMMAND_PAUSE,
275         MMPLAYER_COMMAND_RESUME,
276         MMPLAYER_COMMAND_NUM
277 };
278
279 /* Note : StreamingSrcError is error enum for streaming source which post error message
280  *      using custom message made by itself. The enum value must start with zero,
281  *      because the streaming source(secrtspsrc) also does.
282  */
283 enum StreamingSrcError {
284         MMPLAYER_STREAMING_ERROR_NONE = 0,
285         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
286         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
287         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
288         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
289         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
290         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
291         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
292         MMPLAYER_STREAMING_ERROR_INVALID_URL,
293         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
294         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
295         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
296         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
297         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
298         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
299         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
300         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
301         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
302         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
303         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
304         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
305         MMPLAYER_STREAMING_ERROR_GONE,
306         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
307         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
308         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
309         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
310         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
311         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
312         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
313         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
314         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
315         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
316         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
317         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
318         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
319         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
320         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
321         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
322         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
323         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
324         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
325         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
326         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
327         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
328         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
329         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
330 };
331
332 typedef enum {
333         MMPLAYER_PATH_VOD = 0,
334         MMPLAYER_PATH_TEXT,
335         MMPLAYER_PATH_MAX
336 } MMPlayerPathType;
337
338 /*---------------------------------------------------------------------------
339 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
340 ---------------------------------------------------------------------------*/
341
342 typedef struct {
343         int id;
344         GstElement *gst;
345 } MMPlayerGstElement;
346
347 typedef struct {
348         GstTagList *tag_list;
349         MMPlayerGstElement *mainbin;
350         MMPlayerGstElement *audiobin;
351         MMPlayerGstElement *videobin;
352         MMPlayerGstElement *textbin;
353 } MMPlayerGstPipelineInfo;
354
355 typedef struct {
356         float volume;
357         int mute;
358         int bluetooth;  /* enable/disable */
359 } MMPlayerSoundInfo;
360
361 typedef struct {
362         char *buf;
363         int len;
364         int offset;
365
366 } tBuffer; /* FIXIT : choose better name */
367
368 typedef struct {
369         int uri_type;
370         int     play_mode;
371         void *mem;
372         int     mem_size;
373         char uri[MM_MAX_URL_LEN];
374         char urgent[MM_MAX_FILENAME_LEN];
375 } MMPlayerParseProfile;
376
377 typedef struct {
378         storage_type_e type;
379         storage_state_e state;
380         int id;
381         char path[MM_MAX_URL_LEN];
382 } MMPlayerStorageInfo;
383
384 typedef struct {
385         bool is_pending;
386         MMPlayerPosFormatType format;
387         unsigned long pos;
388 } MMPlayerPendingSeek;
389
390 typedef struct {
391         GObject* obj;
392         gulong sig;
393 } MMPlayerSignalItem;
394
395 typedef struct {
396         bool rich_audio;
397         bool safety_volume;
398         bool pcm_extraction;
399         bool video_zc; // video zero-copy
400         bool subtitle_off;
401         bool media_packet_video_stream;
402 } MMPlayerSetMode;
403
404 typedef struct {
405         gint uri_idx;
406         GList *uri_list;
407 } MMPlayerUriList;
408
409 typedef struct {
410         gint active_pad_index;
411         gint total_track_num;
412         GPtrArray *channels;
413         gulong block_id;
414         gulong event_probe_id;
415 } mm_player_selector_t;
416
417 typedef struct {
418         gboolean running;
419
420         gboolean stream_changed;
421         gboolean reconfigure;
422
423         GstClockTime start_time[MM_PLAYER_TRACK_TYPE_MAX];      /* updated once get SEGMENT event */
424         GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
425         gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];
426
427 } mm_player_gapless_t;
428
429 typedef struct {
430         int channel;
431         int bitrate;
432         int depth;
433         bool is_little_endian;
434         guint64 channel_mask;
435         void *pcm_data;
436         int data_size;
437         int buff_size;
438 } mm_player_audio_stream_buff_t;
439
440 /**
441  * @brief data of video_bo_list
442  * @details this will be used when the sw codec is running.
443  * @since_tizen 3.0
444  */
445 typedef struct {
446         gboolean using;
447         void* bo;
448 } mm_player_video_bo_info_t;
449
450 typedef struct {
451         gint bandwidth;
452         gint width;
453         gint height;
454 } VariantData;
455
456 typedef struct {
457         GList* var_list;
458         VariantData limit;
459 } MMAdaptiveVariantInfo;
460
461 typedef struct {
462         /* STATE */
463         int state;                                      // player current state
464         int prev_state;                         // player previous state
465         int pending_state;                      // player state which is going to now
466         int target_state;                               // player state which user want to go to
467         guint state_change_timeout;
468
469         gboolean section_repeat;
470         gint section_repeat_start;
471         gint section_repeat_end;
472         guint play_count;
473
474         gchar *album_art;
475
476         int cmd;
477
478         /* command lock */
479         GMutex cmd_lock;
480         GMutex playback_lock;
481
482         /* repeat thread lock */
483         GCond repeat_thread_cond;
484         GMutex repeat_thread_mutex;
485         GThread* repeat_thread;
486         gboolean repeat_thread_exit;
487
488         /* next play thread */
489         GThread* next_play_thread;
490         gboolean next_play_thread_exit;
491         GCond next_play_thread_cond;
492         GMutex next_play_thread_mutex;
493         mm_player_gapless_t gapless;
494
495         /* capture thread */
496         GThread* capture_thread;
497         gboolean capture_thread_exit;
498         GCond capture_thread_cond;
499         GMutex capture_thread_mutex;
500         MMPlayerVideoCapture capture;
501         MMPlayerVideoColorspace video_cs;
502         MMVideoBuffer captured;
503
504         /* gst bus msg thread, create during realize */
505         GThread* bus_msg_thread;
506         gboolean bus_msg_thread_exit;
507         GCond bus_msg_thread_cond;
508         GMutex bus_msg_thread_mutex;
509         gint bus_msg_timeout; /* ms */
510
511         /* fakesink handling lock */
512         GMutex fsink_lock;
513
514         /* update tag lock */
515         GMutex update_tag_lock;
516
517         /* player attributes */
518         MMHandleType attrs;
519
520         /* message callback */
521         MMMessageCallback msg_cb;
522         void* msg_cb_param;
523
524         /* progressive download */
525         mm_player_pd_t *pd_downloader;
526         gchar *pd_file_save_path;
527         MMPlayerPDMode pd_mode;
528
529         /* streaming player */
530         mm_player_streaming_t *streamer;
531         gchar *http_file_buffering_path;
532
533         /* gstreamer pipeline */
534         MMPlayerGstPipelineInfo *pipeline;
535
536         /* pad */
537         GstPad *ghost_pad_for_videobin;
538
539         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
540         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
541         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
542         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
543         GMutex media_stream_cb_lock;
544
545         int video_num_buffers;  /* total num of buffers in vcodec */
546         int video_extra_num_buffers; /* extra num of buffers in vcodec */
547
548         void* buffer_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
549         void* seek_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
550
551         /* video stream changed callback */
552         mm_player_stream_changed_callback video_stream_changed_cb;
553         void* video_stream_changed_cb_user_param;
554
555         /* audio stream changed callback */
556         mm_player_stream_changed_callback audio_stream_changed_cb;
557         void* audio_stream_changed_cb_user_param;
558
559         /* video stream callback */
560         mm_player_video_stream_callback video_stream_cb;
561         void* video_stream_cb_user_param;
562         GCond video_bo_cond;
563         GMutex video_bo_mutex;
564         GList* video_bo_list; /* mm_player_video_bo_info_t, bo list for decoded video data by sw codec */
565         int video_bo_size;
566         bool video_stream_prerolled;
567
568         /* audio stram callback */
569         mm_player_audio_stream_callback audio_stream_cb;
570         void* audio_stream_cb_user_param;
571         bool audio_stream_sink_sync;
572         GList* audio_stream_buff_list; /* mm_player_audio_stream_buff_t, buff list of extract pcm data */
573
574         /* audio buffer callback */
575         mm_player_audio_stream_callback_ex audio_stream_render_cb_ex;
576
577         /* video capture callback*/
578         gulong video_capture_cb_probe_id;
579
580         /* sound info */
581         MMPlayerSoundInfo       sound;
582
583         /* type string */
584         gchar *type;
585
586         /* video stream caps parsed by demuxer */
587         GstCaps* v_stream_caps;
588
589         /* audio effect infomation */
590         MMAudioEffectInfo audio_effect_info;
591         gboolean bypass_audio_effect;
592
593         gulong audio_cb_probe_id;
594
595         /* for appsrc */
596         tBuffer mem_buf;
597
598         /* content profile */
599         MMPlayerParseProfile profile;
600         MMPlayerStorageInfo storage_info[MMPLAYER_PATH_MAX];
601
602         /* streaming service type */
603         MMStreamingType streaming_type;
604
605         /* autoplugging */
606         GList* factories;
607         gboolean have_dynamic_pad;
608         GList* parsers; // list of linked parser name
609         GList* audio_decoders; // list of linked audio name
610         gboolean no_more_pad;
611         gint num_dynamic_pad;
612         gboolean has_many_types;
613
614         /* progress callback timer */
615         /* FIXIT : since duplicated functionality with get_position
616          * this function will be deprecated after fixing all application
617          * which are using it.
618          */
619         guint progress_timer;
620
621         /* timer for sending delayed EOS */
622         guint eos_timer;
623
624         /* last point (msec) that player is paused or seeking */
625         gint64 last_position;
626
627         /* duration */
628         gint64 duration;
629
630         /* data size of http streaming  */
631         guint64 http_content_size;
632
633         /* last error */
634         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
635
636         gboolean smooth_streaming;
637
638         gint videodec_linked;
639         gint audiodec_linked;
640         gint videosink_linked;
641         gint audiosink_linked;
642         gint textsink_linked;
643
644         /* missing plugin during autoplugging */
645         MissingCodec not_supported_codec;
646
647         /* unlinked audio/video mime type */
648         gchar *unlinked_video_mime;
649         gchar *unlinked_audio_mime;
650         gchar *unlinked_demuxer_mime;
651
652         /* found codec during autoplugging */
653         FoundCodec can_support_codec;
654
655         gboolean not_found_demuxer;
656
657         /* support seek even though player is not start */
658         MMPlayerPendingSeek pending_seek;
659
660         gboolean doing_seek;
661
662         /* prevent to post msg over and over */
663         gboolean msg_posted;
664
665         /* list of sink elements */
666         GList* sink_elements;
667
668         /* signal notifiers */
669         GList* signals[MM_PLAYER_SIGNAL_TYPE_MAX];
670         GMainContext *global_default;
671         MMPlayerUriList uri_info;
672
673         gboolean is_sound_extraction;
674
675         gfloat playback_rate;
676
677         /* player state resumed by fast rewind */
678         gboolean resumed_by_rewind;
679
680         gboolean is_nv12_tiled;
681
682         /* resource manager for H/W resources */
683         MMPlayerResourceManager resource_manager[RESOURCE_TYPE_MAX];
684
685         /* sound focus for being compatible with legacy session policy internally */
686         MMPlayerSoundFocus sound_focus;
687
688         gboolean is_subtitle_off;
689         gboolean is_external_subtitle_present;
690         gboolean is_external_subtitle_added_now;
691         gboolean pending_resume;
692
693         /* contents bitrate for buffering management */
694         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
695         guint total_bitrate;
696         guint updated_bitrate_count;
697         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
698         guint total_maximum_bitrate;
699         guint updated_maximum_bitrate_count;
700
701         /* prevent it from posting duplicatly*/
702         gboolean sent_bos;
703
704         /* timeout source for lazy pause */
705         guint resume_event_id;
706         guint resumable_cancel_id;
707
708         gboolean play_subtitle;
709         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
710
711         /* PD downloader message callback and param */
712         MMMessageCallback pd_msg_cb;
713         void* pd_msg_cb_param;
714
715         /* adjust subtitle position store */
716         gint64 adjust_subtitle_pos;
717         GList *subtitle_language_list;
718         GCond subtitle_info_cond;
719         GMutex subtitle_info_mutex;
720
721         /* To store the current multiwindow status */
722         gboolean last_multiwin_status;
723
724         /* To store the current running audio pad index of demuxer */
725         gint demux_pad_index;
726
727         mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
728         mm_player_selector_t audio_mode;
729         gboolean use_deinterleave;
730         guint max_audio_channels;
731
732         guint internal_text_idx;
733         guint external_text_idx;
734
735         MMPlayerSetMode set_mode;
736
737         /* initialize values */
738         mm_player_ini_t ini;
739
740         /* video share sync */
741         gint64 video_share_api_delta;
742         gint64 video_share_clock_delta;
743
744         /* just for native app (video hub) */
745         gboolean video_hub_download_mode;
746         gboolean sync_handler;
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         GstElement *video_fakesink;
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         int pcm_samplerate;
769         int pcm_channel;
770
771         MMAdaptiveVariantInfo adaptive_info;
772 } mm_player_t;
773
774 typedef struct {
775         gchar *language_code;
776         gchar *language_key;
777         gboolean active;
778 } MMPlayerLangStruct;
779
780 typedef struct {
781         GstPad *dump_pad;
782         gulong probe_handle_id;
783         FILE *dump_element_file;
784 } mm_player_dump_t;
785
786 typedef struct {
787         char *name;
788         int value_type;
789         int flags;                              // r, w
790         void *default_value;
791         int valid_type;                 // validity type
792         int value_min;                  //<- set validity value range
793         int value_max;          //->
794 } MMPlayerAttrsSpec;
795
796 /*===========================================================================================
797 |                                                                                                                                                                                       |
798 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
799 |                                                                                                                                                                                       |
800 ========================================================================================== */
801 #ifdef __cplusplus
802         extern "C" {
803 #endif
804
805 int _mmplayer_create_player(MMHandleType hplayer);
806 int _mmplayer_destroy(MMHandleType hplayer);
807 int _mmplayer_realize(MMHandleType hplayer);
808 int _mmplayer_unrealize(MMHandleType hplayer);
809 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
810 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
811 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
812 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
813 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
814 int _mmplayer_start(MMHandleType hplayer);
815 int _mmplayer_stop(MMHandleType hplayer);
816 int _mmplayer_pause(MMHandleType hplayer);
817 int _mmplayer_resume(MMHandleType hplayer);
818 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
819 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
820 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
821 int _mmplayer_adjust_video_postion(MMHandleType hplayer, int offset);
822 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
823 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
824 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
825 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
826 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
827 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
828 int _mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param);
829 int _mmplayer_set_audiostream_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
830 int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
831 int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int* silent);
832 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filepath);
833 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
834
835 /* test API for tuning audio gain. this API should be
836  * deprecated before the day of final release
837  */
838 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
839 int _mmplayer_update_video_param(mm_player_t* player, char *param_name);
840 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
841 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
842 int _mmplayer_audio_effect_custom_apply(mm_player_t *player);
843
844 int _mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param);
845 gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessageParamType* param);
846
847 int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type, int index);
848 int _mmplayer_sync_subtitle_pipeline(mm_player_t* player);
849 int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode);
850 int _mmplayer_use_system_clock(MMHandleType hplayer);
851 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);
852 int _mmplayer_get_video_share_master_clock(MMHandleType hplayer, long long *video_time, long long *media_clock, long long *audio_time);
853 int _mmplayer_get_video_rotate_angle(MMHandleType hplayer, int *angle);
854 int _mmplayer_enable_sync_handler(MMHandleType hplayer, bool enable);
855 int _mmplayer_set_file_buffering_path(MMHandleType hplayer, const char* file_path);
856 int _mmplayer_set_uri(MMHandleType hplayer, const char* uri);
857 int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_path);
858 int _mmplayer_get_next_uri(MMHandleType hplayer, char** uri);
859 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool* exist);
860 void * _mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer);
861 void _mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer);
862 int _mmplayer_set_pcm_spec(MMHandleType hplayer, int samplerate, int channel);
863 int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
864 int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
865 int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state);
866 int __mmplayer_gst_set_state(mm_player_t* player, GstElement * pipeline,  GstState state, gboolean async, gint timeout);
867 int __mmplayer_set_state(mm_player_t* player, int state);
868 int __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command);
869 gboolean __mmplayer_dump_pipeline_state(mm_player_t* player);
870 void __mmplayer_remove_g_source_from_context(GMainContext *context, guint source_id);
871 void _mmplayer_bus_msg_thread_destroy(MMHandleType hplayer);
872
873 /* util */
874 const gchar * __get_state_name(int state);
875 gboolean __mmplayer_can_do_interrupt(mm_player_t *player);
876 gboolean __is_streaming(mm_player_t* player);
877 gboolean __is_rtsp_streaming(mm_player_t* player);
878 gboolean __is_live_streaming(mm_player_t* player);
879 gboolean __is_http_streaming(mm_player_t* player);
880 gboolean __is_http_live_streaming(mm_player_t* player);
881 gboolean __is_dash_streaming(mm_player_t* player);
882 gboolean __is_smooth_streaming(mm_player_t* player);
883 gboolean __is_http_progressive_down(mm_player_t* player);
884
885 gboolean __mmplayer_check_useful_message(mm_player_t *player, GstMessage * message);
886 gboolean __mmplayer_handle_gst_error(mm_player_t* player, GstMessage * message, GError* error);
887 gint __gst_handle_core_error(mm_player_t* player, int code);
888 gint __gst_handle_library_error(mm_player_t* player, int code);
889 gint __gst_handle_resource_error(mm_player_t* player, int code, GstMessage * message);
890 gint __gst_handle_stream_error(mm_player_t* player, GError* error, GstMessage * message);
891 int _mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid);
892 int _mmplayer_get_client_pid(MMHandleType hplayer, int* pid);
893 int __mmplayer_get_video_angle(mm_player_t* player, int *user_angle, int *org_angle);
894 int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo);
895 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
896 int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
897 int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
898 int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
899 int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
900 int _mmplayer_set_streaming_buffering_time(MMHandleType hplayer, int buffer_ms, int rebuffer_ms);
901 int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *buffer_ms, int *rebuffer_ms);
902
903 #ifdef __cplusplus
904         }
905 #endif
906
907 #endif  /* __MM_PLAYER_PRIV_H__ */