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