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