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