Add the functions of shared memory src/sink for mused
[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_V_SINK,
211         MMPLAYER_M_NUM
212 };
213
214 /* audio pipeline's element id */
215 enum AudioElementID
216 {
217         MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
218         MMPLAYER_A_TP,
219         MMPLAYER_A_CONV,
220         MMPLAYER_A_VOL,
221         MMPLAYER_A_FILTER,
222         MMPLAYER_A_FILTER_SEC,
223         MMPLAYER_A_VSP,
224         MMPLAYER_A_CAPS_DEFAULT,
225         MMPLAYER_A_SINK,
226         MMPLAYER_A_RESAMPLER,
227         MMPLAYER_A_DEINTERLEAVE,
228         MMPLAYER_A_NUM
229 };
230
231 /* video pipeline's element id */
232 enum VideoElementID
233 {
234         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
235         MMPLAYER_V_FLIP,
236         MMPLAYER_V_CONV,
237         MMPLAYER_V_SCALE,
238         MMPLAYER_V_CAPS,
239         MMPLAYER_V_SINK,
240         MMPLAYER_V_NUM
241 };
242
243 /* text pipeline's element id */
244 enum TextElementID
245 {
246         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
247         MMPLAYER_T_QUEUE,
248         MMPLAYER_T_VIDEO_QUEUE,
249         MMPLAYER_T_VIDEO_CONVERTER,
250         MMPLAYER_T_OVERLAY,
251         MMPLAYER_T_FAKE_SINK,
252         MMPLAYER_T_IDENTITY,
253         MMPLAYER_T_NUM
254 };
255
256 /* midi main pipeline's element id */
257 enum MidiElementID
258 {
259         MMPLAYER_MIDI_PIPE,
260         MMPLAYER_MIDI_PLAYER,
261         MMPLAYER_MIDI_NUM
262 };
263
264 enum PlayerCommandState
265 {
266         MMPLAYER_COMMAND_NONE,
267         MMPLAYER_COMMAND_CREATE,
268         MMPLAYER_COMMAND_DESTROY,
269         MMPLAYER_COMMAND_UNREALIZE,
270         MMPLAYER_COMMAND_START,
271         MMPLAYER_COMMAND_REALIZE,
272         MMPLAYER_COMMAND_STOP,
273         MMPLAYER_COMMAND_PAUSE,
274         MMPLAYER_COMMAND_RESUME,
275         MMPLAYER_COMMAND_NUM
276 };
277
278 /* Note : StreamingSrcError is error enum for streaming source which post error message
279  *      using custom message made by itself. The enum value must start with zero,
280  *      because the streaming source(secrtspsrc) also does.
281  */
282 enum StreamingSrcError
283 {
284         MMPLAYER_STREAMING_ERROR_NONE = 0,
285         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
286         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
287         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
288         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
289         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
290         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
291         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
292         MMPLAYER_STREAMING_ERROR_INVALID_URL,
293         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
294         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
295         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
296         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
297         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
298         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
299         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
300         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
301         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
302         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
303         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
304         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
305         MMPLAYER_STREAMING_ERROR_GONE,
306         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
307         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
308         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
309         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
310         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
311         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
312         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
313         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
314         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
315         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
316         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
317         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
318         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
319         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
320         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
321         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
322         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
323         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
324         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
325         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
326         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
327         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
328         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
329         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
330 };
331
332 /*---------------------------------------------------------------------------
333 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
334 ---------------------------------------------------------------------------*/
335
336 typedef struct
337 {
338         int id;
339         GstElement *gst;
340 } MMPlayerGstElement;
341
342 typedef struct
343 {
344         GstTagList                      *tag_list;
345         MMPlayerGstElement      *mainbin;
346         MMPlayerGstElement      *audiobin;
347         MMPlayerGstElement      *videobin;
348         MMPlayerGstElement      *textbin;
349 } MMPlayerGstPipelineInfo;
350
351 typedef struct
352 {
353         float volume;
354         int mute;
355         int bluetooth;  /* enable/disable */
356 } MMPlayerSoundInfo;
357
358 typedef struct {
359         char *buf;
360         int len;
361         int offset;
362
363 } tBuffer; /* FIXIT : choose better name */
364
365 typedef struct {
366         int uri_type;
367         int     play_mode;
368         void *mem;
369         int     mem_size;
370         char uri[MM_MAX_URL_LEN];
371         char urgent[MM_MAX_FILENAME_LEN];
372 } MMPlayerParseProfile;
373
374 typedef struct {
375         bool is_pending;
376         MMPlayerPosFormatType format;
377         unsigned long pos;
378 }MMPlayerPendingSeek;
379
380 typedef struct {
381         GObject* obj;
382         gulong sig;
383 } MMPlayerSignalItem;
384
385 typedef struct {
386         bool rich_audio;
387         bool safety_volume;
388         bool pcm_extraction;
389         bool video_zc; // video zero-copy
390         bool subtitle_off;
391         bool media_packet_video_stream;
392 }MMPlayerSetMode;
393
394 typedef struct {
395         GMainContext *global_default;
396         GMainContext *thread_default;
397 }MMPlayerGMainContext;
398
399 typedef struct {
400         gint uri_idx;
401         GList *uri_list;
402 }MMPlayerUriList;
403
404 typedef struct {
405         gint active_pad_index;
406         gint total_track_num;
407         GPtrArray *channels;
408         gulong block_id;
409         gulong event_probe_id;
410 } mm_player_selector_t;
411
412 /* Things needed to be done after output device has changed */
413 typedef struct {
414         gboolean need_async;
415         gboolean need_seek;
416         gboolean need_pause_and_resume;
417         guint cb_score;
418         guint required_cb_score;
419         guint id;
420 } mm_player_post_proc_t;
421
422 typedef struct {
423         gboolean running;
424
425         gboolean stream_changed;
426         gboolean reconfigure;
427
428         GstClockTime next_pts;          /* latest decoded buffer's pts+duration */
429         GstClockTime start_time;        /* updated once get SEGMENT event */
430
431         gulong audio_data_probe_id;
432 } mm_player_gapless_t;
433
434 typedef struct {
435         /* STATE */
436         int state;                                      // player current state
437         int prev_state;                         // player previous state
438         int pending_state;                      // player state which is going to now
439         int target_state;                               // player state which user want to go to
440         guint state_change_timeout;
441
442         gboolean section_repeat;
443         gint section_repeat_start;
444         gint section_repeat_end;
445         guint play_count;
446
447         gchar *album_art;
448
449         int cmd;
450
451         /* command lock */
452         GMutex cmd_lock;
453         GMutex playback_lock;
454
455         /* repeat thread lock */
456         GCond repeat_thread_cond;
457         GMutex repeat_thread_mutex;
458         GThread* repeat_thread;
459         gboolean repeat_thread_exit;
460
461         /* next play thread */
462         GThread* next_play_thread;
463         gboolean next_play_thread_exit;
464         GCond next_play_thread_cond;
465         GMutex next_play_thread_mutex;
466         mm_player_gapless_t gapless;
467
468         /* capture thread */
469         GThread* capture_thread;
470         gboolean capture_thread_exit;
471         GCond capture_thread_cond;
472         GMutex capture_thread_mutex;
473         MMPlayerVideoCapture capture;
474         MMPlayerVideoColorspace video_cs;
475         MMVideoBuffer captured;
476
477         /* fakesink handling lock */
478         GMutex fsink_lock;
479
480         /* player attributes */
481         MMHandleType attrs;
482
483         /* message callback */
484         MMMessageCallback msg_cb;
485         void* msg_cb_param;
486         GMutex msg_cb_lock;
487
488         /* progressive download */
489         mm_player_pd_t *pd_downloader;
490         gchar *pd_file_save_path;
491         MMPlayerPDMode pd_mode;
492
493         /* streaming player */
494         mm_player_streaming_t *streamer;
495
496         /* gstreamer pipeline */
497         MMPlayerGstPipelineInfo *pipeline;
498
499         /* pad */
500         GstPad *ghost_pad_for_videobin;
501
502         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
503         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
504         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
505         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
506
507         void* buffer_cb_user_param;
508
509         /* video stream changed callback */
510         mm_player_stream_changed_callback video_stream_changed_cb;
511         void* video_stream_changed_cb_user_param;
512
513         /* audio stream changed callback */
514         mm_player_stream_changed_callback audio_stream_changed_cb;
515         void* audio_stream_changed_cb_user_param;
516
517         /* video stream callback */
518         mm_player_video_stream_callback video_stream_cb;
519         void* video_stream_cb_user_param;
520         int use_video_stream;
521
522         /* audio stram callback */
523         mm_player_audio_stream_callback audio_stream_cb;
524         void* audio_stream_cb_user_param;
525         bool audio_stream_sink_sync;
526
527         /* audio buffer callback */
528         mm_player_audio_stream_callback_ex audio_stream_render_cb_ex;
529
530         /* video capture callback*/
531         gulong video_capture_cb_probe_id;
532
533         /* video frame render error callback */
534         mm_player_video_frame_render_error_callback video_frame_render_error_cb;
535         void* video_frame_render_error_cb_user_param;
536
537         /* sound info */
538         MMPlayerSoundInfo       sound;
539
540         /* type string */
541         gchar *type;
542
543         /* video stream caps parsed by demuxer */
544         GstCaps* v_stream_caps;
545
546         /* audio effect infomation */
547         MMAudioEffectInfo audio_effect_info;
548         gboolean bypass_audio_effect;
549
550         gulong audio_cb_probe_id;
551         gulong video_cb_probe_id;
552
553         /* for appsrc */
554         tBuffer mem_buf;
555
556         /* content profile */
557         MMPlayerParseProfile profile;
558
559         /* streaming service type */
560         MMStreamingType streaming_type;
561
562         /* autoplugging */
563         GList* factories;
564         gboolean have_dynamic_pad;
565         GList* parsers; // list of linked parser name
566         GList* audio_decoders; // list of linked audio name
567         gboolean no_more_pad;
568         gint num_dynamic_pad;
569         gboolean has_many_types;
570
571         /* progress callback timer */
572         /* FIXIT : since duplicated functionality with get_position
573          * this function will be deprecated after fixing all application
574          * which are using it.
575          */
576         guint progress_timer;
577
578         /* timer for sending delayed EOS */
579         guint eos_timer;
580
581         /* last point (msec) that player is paused or seeking */
582         gint64 last_position;
583
584         /* duration */
585         gint64 duration;
586
587         /* data size of http streaming  */
588         guint64 http_content_size;
589
590         /* last error */
591         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
592
593         gboolean smooth_streaming;
594
595         gint videodec_linked;
596         gint audiodec_linked;
597         gint videosink_linked;
598         gint audiosink_linked;
599         gint textsink_linked;
600
601         /* missing plugin during autoplugging */
602         MissingCodec not_supported_codec;
603
604         /*unlinked audio/video mime type */
605         gchar *unlinked_video_mime;
606         gchar *unlinked_audio_mime;
607         gchar *unlinked_demuxer_mime;
608
609         /* found codec during autoplugging */
610         FoundCodec can_support_codec;
611
612         gboolean not_found_demuxer;
613
614         /* support seek even though player is not start */
615         MMPlayerPendingSeek pending_seek;
616
617         gboolean doing_seek;
618
619         /* prevent to post msg over and over */
620         gboolean msg_posted;
621
622         /* list of sink elements */
623         GList* sink_elements;
624
625         /* signal notifiers */
626         GList* signals[MM_PLAYER_SIGNAL_TYPE_MAX];
627         guint bus_watcher;
628         MMPlayerGMainContext context;
629         MMPlayerUriList uri_info;
630
631         gboolean is_sound_extraction;
632
633         gfloat playback_rate;
634
635         /* player state resumed by fast rewind */
636         gboolean resumed_by_rewind;
637
638         gboolean is_nv12_tiled;
639         gboolean is_drm_file;
640
641         MMPlayerASM sm;
642
643         gboolean is_subtitle_off;
644         gboolean is_external_subtitle_present;
645
646         /* contents bitrate for buffering management */
647         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
648         guint total_bitrate;
649         guint updated_bitrate_count;
650         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
651         guint total_maximum_bitrate;
652         guint updated_maximum_bitrate_count;
653
654         /* prevent it from posting duplicatly*/
655         gboolean sent_bos;
656
657         /* timeout source for lazy pause */
658         guint lazy_pause_event_id;
659         guint resume_event_id;
660         guint resumable_cancel_id;
661
662         gboolean keep_detecting_vcodec;
663
664         gboolean play_subtitle;
665         gboolean use_textoverlay;
666         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
667
668         /* PD downloader message callback and param */
669         MMMessageCallback pd_msg_cb;
670         void* pd_msg_cb_param;
671
672         /* adjust subtitle position store */
673         gint64 adjust_subtitle_pos;
674         GList *subtitle_language_list;
675
676         /* To store the current multiwindow status */
677         gboolean last_multiwin_status;
678
679         /* To store the current running audio pad index of demuxer */
680         gint demux_pad_index;
681
682         mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
683         mm_player_selector_t audio_mode;
684         gboolean use_deinterleave;
685         guint max_audio_channels;
686
687         guint internal_text_idx;
688         guint external_text_idx;
689
690         MMPlayerSetMode set_mode;
691
692         /* decodbin usage */
693         gboolean use_decodebin;
694
695         /* initialize values */
696         mm_player_ini_t ini;
697
698         /* check to use h/w codec */
699         GstCaps* state_tune_caps;
700         gboolean ignore_asyncdone;
701
702         /* video share sync */
703         gint64 video_share_api_delta;
704         gint64 video_share_clock_delta;
705
706         /* just for native app (video hub) */
707         gboolean video_hub_download_mode;
708         gboolean sync_handler;
709
710         /* store dump pad list */
711         GList* dump_list;
712
713
714         /* audio/video deivce change handling */
715         mm_player_post_proc_t post_proc;
716
717         /* whether a video has closed caption or not */
718         gboolean has_closed_caption;
719
720         GstElement *video_fakesink;
721
722         /* audio stream caps parsed by demuxer or set by external demuxer */
723         GstCaps* a_stream_caps;
724
725         /* subtitle stream caps parsed by demuxer or set by external demuxer */
726         GstCaps* s_stream_caps;
727
728         /*es player using feed-data callback or calling app_src_push_buffer directly*/
729         gboolean es_player_push_mode;
730
731         /* tmb buffer manager for s/w codec tmb_bo */
732         tbm_bufmgr bufmgr;
733
734         int pcm_samplerate;
735         int pcm_channel;
736 } mm_player_t;
737
738 typedef struct
739 {
740         gchar *language_code;
741         gchar *language_key;
742         gboolean active;
743 }MMPlayerLangStruct;
744
745 typedef struct
746 {
747         GstPad *dump_pad;
748         gulong probe_handle_id;
749         FILE *dump_element_file;
750 } mm_player_dump_t;
751
752 typedef struct{
753         char *name;
754         int value_type;
755         int flags;                              // r, w
756         void *default_value;
757         int valid_type;                 // validity type
758         int value_min;                  //<- set validity value range
759         int value_max;          //->
760 }MMPlayerAttrsSpec;
761
762 /*===========================================================================================
763 |                                                                                                                                                                                       |
764 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
765 |                                                                                                                                                                                       |
766 ========================================================================================== */
767 #ifdef __cplusplus
768         extern "C" {
769 #endif
770
771 int _mmplayer_create_player(MMHandleType hplayer);
772 int _mmplayer_destroy(MMHandleType hplayer);
773 int _mmplayer_realize(MMHandleType hplayer);
774 int _mmplayer_unrealize(MMHandleType hplayer);
775 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
776 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
777 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
778 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
779 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
780 int _mmplayer_start(MMHandleType hplayer);
781 int _mmplayer_stop(MMHandleType hplayer);
782 int _mmplayer_pause(MMHandleType hplayer);
783 int _mmplayer_resume(MMHandleType hplayer);
784 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
785 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
786 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
787 int _mmplayer_adjust_video_postion(MMHandleType hplayer,int offset);
788 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
789 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
790 int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size);
791 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate);
792 int _mmplayer_set_playspeed_ex(MMHandleType hplayer, gdouble rate);
793 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
794 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
795 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
796 int _mmplayer_set_videostream_cb(MMHandleType hplayer,mm_player_video_stream_callback callback, void *user_param);
797 int _mmplayer_set_audiostream_cb(MMHandleType hplayer,mm_player_audio_stream_callback callback, void *user_param);
798 int _mmplayer_set_videoframe_render_error_cb(MMHandleType hplayer, mm_player_video_frame_render_error_callback callback, void *user_param);
799 int _mmplayer_set_subtitle_silent (MMHandleType hplayer, int silent);
800 int _mmplayer_get_subtitle_silent (MMHandleType hplayer, int* silent);
801 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filepath);
802 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
803
804 /* test API for tuning audio gain. this API should be
805  * deprecated before the day of final release
806  */
807 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
808 int _mmplayer_update_video_param(mm_player_t* player);
809 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
810 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
811 int _mmplayer_audio_effect_custom_apply(mm_player_t *player);
812
813 int _mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param);
814 gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessageParamType* param);
815 gboolean __mmplayer_is_streaming(mm_player_t* player);
816
817
818 int _mmplayer_gst_set_audio_channel(MMHandleType hplayer, MMPlayerAudioChannel ch_idx);
819 int _mmplayer_change_track_language (MMHandleType hplayer, MMPlayerTrackType type, int index);
820 int _mmplayer_sync_subtitle_pipeline(mm_player_t* player);
821 int _mmplayer_set_prepare_buffering_time(MMHandleType hplayer, int second);
822 int _mmplayer_set_runtime_buffering_mode(MMHandleType hplayer, MMPlayerBufferingMode mode, int second);
823 int _mmplayer_set_display_zoom(MMHandleType hplayer, float level, int x, int y);
824 int _mmplayer_get_display_zoom(MMHandleType hplayer, float *level, int *x, int *y);
825 int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode);
826 int _mmplayer_use_system_clock (MMHandleType hplayer);
827 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);
828 int _mmplayer_get_video_share_master_clock(MMHandleType hplayer, long long *video_time, long long *media_clock, long long *audio_time);
829 int _mmplayer_get_video_rotate_angle(MMHandleType hplayer, int *angle);
830 int _mmplayer_enable_sync_handler(MMHandleType hplayer, bool enable);
831 int _mmplayer_set_uri(MMHandleType hplayer, const char* uri);
832 int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_path);
833 int _mmplayer_get_next_uri(MMHandleType hplayer, char** uri);
834 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool* exist);
835 int _mmplayer_enable_media_packet_video_stream(MMHandleType hplayer, bool enable);
836 void * _mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer);
837 void _mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer);
838 int _mmplayer_set_pcm_spec(MMHandleType hplayer, int samplerate, int channel);
839 int __mmplayer_gst_set_state (mm_player_t* player, GstElement * pipeline,  GstState state, gboolean async, gint timeout );
840 int __mmplayer_set_state(mm_player_t* player, int state);
841 gboolean __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data);
842 int __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command);
843 gboolean __mmplayer_dump_pipeline_state( mm_player_t* player );
844 GstBusSyncReply __mmplayer_bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data);
845 void __mmplayer_remove_g_source_from_context(GMainContext *context, guint source_id);
846
847 #ifdef __cplusplus
848         }
849 #endif
850
851 #endif  /* __MM_PLAYER_PRIV_H__ */