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