to add video parser by default, remove factory sorting function
[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 /**
113  * Enumerations of Player Mode
114  */
115 enum MMPlayerMode {
116         MM_PLAYER_MODE_NONE,                    /**< Player mode None */
117         MM_PLAYER_MODE_MIDI,                    /**< Player mode Midi */
118         MM_PLAYER_MODE_GST,                     /**< Player mode Gstreamer */
119 };
120
121
122 /**
123  * Enumerations of Player Uri type
124  */
125 enum MMPlayerUriType {
126         MM_PLAYER_URI_TYPE_NONE,                /**< Player URI type None */
127         MM_PLAYER_URI_TYPE_URL_RTSP,    /**< Player URI type RTSP */
128         MM_PLAYER_URI_TYPE_URL_WFD,  /**< Player URI type WFD */
129         MM_PLAYER_URI_TYPE_URL_HTTP,/**< Player URI type HTTP */
130         MM_PLAYER_URI_TYPE_URL_MMS,/**< Player URI type MMS */
131         MM_PLAYER_URI_TYPE_MEM,         /**< Player URI type Mem */
132         MM_PLAYER_URI_TYPE_FILE,                /**< Player URI type File */
133         MM_PLAYER_URI_TYPE_URL,                 /**< Player URI type URL */
134         MM_PLAYER_URI_TYPE_BUFF,                /**< Player URI type Buffer */
135         MM_PLAYER_URI_TYPE_ES_BUFF,             /**< Player URI type ES Buffer */
136         MM_PLAYER_URI_TYPE_HLS,                 /**< Player URI type http live streaming */
137         MM_PLAYER_URI_TYPE_SS,                  /**< Player URI type Smooth streaming */
138         MM_PLAYER_URI_TYPE_DASH,                        /**< Player URI type Mpeg Dash */
139         MM_PLAYER_URI_TYPE_NO_PERMISSION,/**< Player URI type No Permission  */
140         MM_PLAYER_URI_TYPE_TEMP,                        /**< Player URI type Temp */
141 };
142
143 typedef enum _MissingCodec
144 {
145         MISSING_PLUGIN_NONE                     = 0x00,
146         MISSING_PLUGIN_AUDIO                    = 0x01,
147         MISSING_PLUGIN_VIDEO                    = 0x02
148 }MissingCodec;
149
150
151 typedef enum _FoundCodec
152 {
153         FOUND_PLUGIN_NONE                       = 0x00,
154         FOUND_PLUGIN_AUDIO                      = 0x01,
155         FOUND_PLUGIN_VIDEO                      = 0x02
156 }FoundCodec;
157
158 /**
159  * Enumeration of signal type
160  */
161 typedef enum {
162         MM_PLAYER_SIGNAL_TYPE_AUTOPLUG = 0,
163         MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
164         MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
165         MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
166         MM_PLAYER_SIGNAL_TYPE_OTHERS,
167         MM_PLAYER_SIGNAL_TYPE_ALL,
168         MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
169 }MMPlayerSignalType;
170
171 /* main pipeline's element id */
172 enum MainElementID
173 {
174         MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
175         MMPLAYER_M_SRC,
176         MMPLAYER_M_2ND_SRC,     /* 2nd Source Element for es buff src */
177         MMPLAYER_M_SUBSRC,
178
179         /* it could be a decodebin or could be a typefind. depends on player ini */
180         MMPLAYER_M_TYPEFIND,
181         MMPLAYER_M_AUTOPLUG,
182
183         MMPLAYER_M_AUTOPLUG_V_DEC,
184         MMPLAYER_M_AUTOPLUG_A_DEC,
185
186         /* NOTE : we need two fakesink to autoplug without decodebin.
187          * first one will hold whole pipeline state. and second one will hold state of
188          * a sink-decodebin for an elementary stream. no metter if there's more then one
189          * elementary streams because MSL reuse it.
190          */
191         MMPLAYER_M_SRC_FAKESINK,
192         MMPLAYER_M_SRC_2ND_FAKESINK,
193
194         /* streaming plugin */
195         MMPLAYER_M_MUXED_S_BUFFER,
196         MMPLAYER_M_DEMUXED_S_BUFFER,
197         MMPLAYER_M_ID3DEMUX,
198
199         /* es buff src queue */
200         MMPLAYER_M_V_BUFFER,
201         MMPLAYER_M_A_BUFFER,
202         MMPLAYER_M_S_BUFFER,
203
204         /* FIXIT : if there's really no usage for following IDs. remove it */
205         MMPLAYER_M_DEC1,
206         MMPLAYER_M_DEC2,
207         MMPLAYER_M_Q1,
208         MMPLAYER_M_Q2,
209         MMPLAYER_M_DEMUX,
210         MMPLAYER_M_SUBPARSE,
211         MMPLAYER_M_DEMUX_EX,
212         MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
213         MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
214         MMPLAYER_M_A_TEE,
215         MMPLAYER_M_A_Q1,
216         MMPLAYER_M_A_Q2,
217         MMPLAYER_M_A_CONV,
218         MMPLAYER_M_A_FILTER,
219         MMPLAYER_M_A_DEINTERLEAVE,
220         MMPLAYER_M_A_SELECTOR,
221         MMPLAYER_M_NUM
222 };
223
224 /* audio pipeline's element id */
225 enum AudioElementID
226 {
227         MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
228         MMPLAYER_A_TP,
229         MMPLAYER_A_CONV,
230         MMPLAYER_A_VOL,
231         MMPLAYER_A_FILTER,
232         MMPLAYER_A_FILTER_SEC,
233         MMPLAYER_A_VSP,
234         MMPLAYER_A_CAPS_DEFAULT,
235         MMPLAYER_A_SINK,
236         MMPLAYER_A_RESAMPLER,
237         MMPLAYER_A_DEINTERLEAVE,
238         MMPLAYER_A_NUM
239 };
240
241 /* video pipeline's element id */
242 enum VideoElementID
243 {
244         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
245         MMPLAYER_V_FLIP,
246         MMPLAYER_V_CONV,
247         MMPLAYER_V_SCALE,
248         MMPLAYER_V_CAPS,
249         MMPLAYER_V_SINK,
250         MMPLAYER_V_NUM
251 };
252
253 /* text pipeline's element id */
254 enum TextElementID
255 {
256         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
257         MMPLAYER_T_TEXT_FAKE_QUEUE,
258         MMPLAYER_T_VIDEO_QUEUE,
259         MMPLAYER_T_VIDEO_CONVERTER,
260         MMPLAYER_T_OVERLAY,
261         MMPLAYER_T_FAKE_SINK,
262         MMPLAYER_T_TEXT_FAKE_IDENTITY,
263         MMPLAYER_T_NUM
264 };
265
266 /* midi main pipeline's element id */
267 enum MidiElementID
268 {
269         MMPLAYER_MIDI_PIPE,
270         MMPLAYER_MIDI_PLAYER,
271         MMPLAYER_MIDI_NUM
272 };
273
274 enum PlayerCommandState
275 {
276         MMPLAYER_COMMAND_NONE,
277         MMPLAYER_COMMAND_CREATE,
278         MMPLAYER_COMMAND_DESTROY,
279         MMPLAYER_COMMAND_UNREALIZE,
280         MMPLAYER_COMMAND_START,
281         MMPLAYER_COMMAND_REALIZE,
282         MMPLAYER_COMMAND_STOP,
283         MMPLAYER_COMMAND_PAUSE,
284         MMPLAYER_COMMAND_RESUME,
285         MMPLAYER_COMMAND_NUM
286 };
287
288 /* Note : StreamingSrcError is error enum for streaming source which post error message
289  *      using custom message made by itself. The enum value must start with zero,
290  *      because the streaming source(secrtspsrc) also does.
291  */
292 enum StreamingSrcError
293 {
294         MMPLAYER_STREAMING_ERROR_NONE = 0,
295         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
296         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
297         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
298         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
299         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
300         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
301         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
302         MMPLAYER_STREAMING_ERROR_INVALID_URL,
303         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
304         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
305         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
306         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
307         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
308         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
309         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
310         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
311         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
312         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
313         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
314         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
315         MMPLAYER_STREAMING_ERROR_GONE,
316         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
317         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
318         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
319         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
320         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
321         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
322         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
323         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
324         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
325         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
326         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
327         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
328         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
329         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
330         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
331         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
332         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
333         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
334         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
335         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
336         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
337         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
338         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
339         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
340 };
341
342 /*---------------------------------------------------------------------------
343 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
344 ---------------------------------------------------------------------------*/
345
346 typedef struct
347 {
348         int id;
349         GstElement *gst;
350 } MMPlayerGstElement;
351
352 typedef struct
353 {
354         GstTagList                      *tag_list;
355         MMPlayerGstElement      *mainbin;
356         MMPlayerGstElement      *audiobin;
357         MMPlayerGstElement      *videobin;
358         MMPlayerGstElement      *textbin;
359 } MMPlayerGstPipelineInfo;
360
361 typedef struct
362 {
363         float volume;
364         int mute;
365         int bluetooth;  /* enable/disable */
366 } MMPlayerSoundInfo;
367
368 typedef struct {
369         char *buf;
370         int len;
371         int offset;
372
373 } tBuffer; /* FIXIT : choose better name */
374
375 typedef struct {
376         int uri_type;
377         int     play_mode;
378         void *mem;
379         int     mem_size;
380         char uri[MM_MAX_URL_LEN];
381         char urgent[MM_MAX_FILENAME_LEN];
382 } MMPlayerParseProfile;
383
384 typedef struct {
385         bool is_pending;
386         MMPlayerPosFormatType format;
387         unsigned long pos;
388 }MMPlayerPendingSeek;
389
390 typedef struct {
391         GObject* obj;
392         gulong sig;
393 } MMPlayerSignalItem;
394
395 typedef struct {
396         bool rich_audio;
397         bool safety_volume;
398         bool pcm_extraction;
399         bool video_zc; // video zero-copy
400         bool subtitle_off;
401         bool media_packet_video_stream;
402 }MMPlayerSetMode;
403
404 typedef struct {
405         GMainContext *global_default;
406         GMainContext *thread_default;
407 }MMPlayerGMainContext;
408
409 typedef struct {
410         gint uri_idx;
411         GList *uri_list;
412 }MMPlayerUriList;
413
414 typedef struct {
415         gint active_pad_index;
416         gint total_track_num;
417         GPtrArray *channels;
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         /* STATE */
432         int state;                                      // player current state
433         int prev_state;                         // player previous state
434         int pending_state;                      // player state which is going to now
435         int target_state;                               // player state which user want to go to
436         guint state_change_timeout;
437
438         gboolean section_repeat;
439         gint section_repeat_start;
440         gint section_repeat_end;
441         guint play_count;
442
443         gchar *album_art;
444
445         int cmd;
446
447         /* command lock */
448         GMutex cmd_lock;
449         GMutex playback_lock;
450
451         /* repeat thread lock */
452         GCond repeat_thread_cond;
453         GMutex repeat_thread_mutex;
454         GThread* repeat_thread;
455         gboolean repeat_thread_exit;
456
457         /* next play thread */
458         GThread* next_play_thread;
459         gboolean next_play_thread_exit;
460         GCond next_play_thread_cond;
461         GMutex next_play_thread_mutex;
462
463         /* capture thread */
464         GThread* capture_thread;
465         gboolean capture_thread_exit;
466         GCond capture_thread_cond;
467         GMutex capture_thread_mutex;
468         MMPlayerVideoCapture capture;
469         MMPlayerVideoColorspace video_cs;
470         MMVideoBuffer captured;
471
472         /* fakesink handling lock */
473         GMutex fsink_lock;
474
475         /* player attributes */
476         MMHandleType attrs;
477
478         /* message callback */
479         MMMessageCallback msg_cb;
480         void* msg_cb_param;
481         GMutex msg_cb_lock;
482
483         /* progressive download */
484         mm_player_pd_t *pd_downloader;
485         gchar *pd_file_save_path;
486         MMPlayerPDMode pd_mode;
487
488         /* streaming player */
489         mm_player_streaming_t *streamer;
490
491         /* gstreamer pipeline */
492         MMPlayerGstPipelineInfo *pipeline;
493
494         /* pad */
495         GstPad *ghost_pad_for_videobin;
496
497         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
498         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
499         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
500         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
501
502         void* buffer_cb_user_param;
503
504         /* video stream changed callback */
505         mm_player_stream_changed_callback video_stream_changed_cb;
506         void* video_stream_changed_cb_user_param;
507
508         /* audio stream changed callback */
509         mm_player_stream_changed_callback audio_stream_changed_cb;
510         void* audio_stream_changed_cb_user_param;
511
512         /* video stream callback */
513         mm_player_video_stream_callback video_stream_cb;
514         void* video_stream_cb_user_param;
515         int use_video_stream;
516
517         /* audio stram callback */
518         mm_player_audio_stream_callback audio_stream_cb;
519         void* audio_stream_cb_user_param;
520         bool audio_stream_sink_sync;
521
522         /* audio buffer callback */
523         mm_player_audio_stream_callback_ex audio_stream_render_cb_ex;
524
525         /* video capture callback*/
526         gulong video_capture_cb_probe_id;
527
528         /* video frame render error callback */
529         mm_player_video_frame_render_error_callback video_frame_render_error_cb;
530         void* video_frame_render_error_cb_user_param;
531
532         /* sound info */
533         MMPlayerSoundInfo       sound;
534
535         /* type string */
536         gchar *type;
537
538         /* video stream caps parsed by demuxer */
539         GstCaps* v_stream_caps;
540
541         /* audio effect infomation */
542         MMAudioEffectInfo audio_effect_info;
543         gboolean bypass_audio_effect;
544
545         gulong audio_cb_probe_id;
546         gulong video_cb_probe_id;
547
548         /* for appsrc */
549         tBuffer mem_buf;
550
551         /* content profile */
552         MMPlayerParseProfile profile;
553
554         /* streaming service type */
555         MMStreamingType streaming_type;
556
557         /* autoplugging */
558         GList* factories;
559         gboolean have_dynamic_pad;
560         GList* parsers; // list of linked parser name
561         GList* audio_decoders; // list of linked audio name
562         gboolean no_more_pad;
563         gint num_dynamic_pad;
564         gboolean has_many_types;
565
566         /* progress callback timer */
567         /* FIXIT : since duplicated functionality with get_position
568          * this function will be deprecated after fixing all application
569          * which are using it.
570          */
571         guint progress_timer;
572
573         /* timer for sending delayed EOS */
574         guint eos_timer;
575
576         /* last point (msec) that player is paused or seeking */
577         gint64 last_position;
578
579         /* duration */
580         gint64 duration;
581
582         /* data size of http streaming  */
583         guint64 http_content_size;
584
585         /* last error */
586         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
587
588         gboolean smooth_streaming;
589
590         gint videodec_linked;
591         gint audiodec_linked;
592         gint videosink_linked;
593         gint audiosink_linked;
594         gint textsink_linked;
595
596         /* missing plugin during autoplugging */
597         MissingCodec not_supported_codec;
598
599         /*unlinked audio/video mime type */
600         gchar *unlinked_video_mime;
601         gchar *unlinked_audio_mime;
602         gchar *unlinked_demuxer_mime;
603
604         /* found codec during autoplugging */
605         FoundCodec can_support_codec;
606
607         gboolean not_found_demuxer;
608
609         /* support seek even though player is not start */
610         MMPlayerPendingSeek pending_seek;
611
612         gboolean doing_seek;
613
614         /* prevent to post msg over and over */
615         gboolean msg_posted;
616
617         /* list of sink elements */
618         GList* sink_elements;
619
620         /* signal notifiers */
621         GList* signals[MM_PLAYER_SIGNAL_TYPE_MAX];
622         guint bus_watcher;
623         MMPlayerGMainContext context;
624         MMPlayerUriList uri_info;
625
626         gboolean is_sound_extraction;
627
628         gfloat playback_rate;
629
630         /* player state resumed by fast rewind */
631         gboolean resumed_by_rewind;
632
633         gboolean is_nv12_tiled;
634         gboolean is_drm_file;
635
636         MMPlayerASM sm;
637
638         gboolean is_subtitle_off;
639         gboolean is_external_subtitle_present;
640
641         /* contents bitrate for buffering management */
642         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
643         guint total_bitrate;
644         guint updated_bitrate_count;
645         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
646         guint total_maximum_bitrate;
647         guint updated_maximum_bitrate_count;
648
649         /* prevent it from posting duplicatly*/
650         gboolean sent_bos;
651
652         /* timeout source for lazy pause */
653         guint lazy_pause_event_id;
654         guint resume_event_id;
655         guint resumable_cancel_id;
656
657         gboolean keep_detecting_vcodec;
658
659         gboolean play_subtitle;
660         gboolean use_textoverlay;
661         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
662
663         /* PD downloader message callback and param */
664         MMMessageCallback pd_msg_cb;
665         void* pd_msg_cb_param;
666
667         /* adjust subtitle position store */
668         gint64 adjust_subtitle_pos;
669         GList *subtitle_language_list;
670
671         /* To store the current multiwindow status */
672         gboolean last_multiwin_status;
673
674         /* To store the current running audio pad index of demuxer */
675         gint demux_pad_index;
676
677         mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
678         mm_player_selector_t audio_mode;
679         gboolean use_deinterleave;
680         guint max_audio_channels;
681
682         guint internal_text_idx;
683         guint external_text_idx;
684
685         MMPlayerSetMode set_mode;
686
687         /* decodbin usage */
688         gboolean use_decodebin;
689
690         /* initialize values */
691         mm_player_ini_t ini;
692
693         /* check to use h/w codec */
694         GstCaps* state_tune_caps;
695         gboolean ignore_asyncdone;
696
697         /* video share sync */
698         gint64 video_share_api_delta;
699         gint64 video_share_clock_delta;
700
701         /* just for native app (video hub) */
702         gboolean video_hub_download_mode;
703         gboolean sync_handler;
704
705         /* seamless next playing */
706         gboolean src_changed;
707         gboolean pp_rebuilding;
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__ */