Merge "apply tizen coding rules" into tizen
[platform/core/multimedia/libmm-player.git] / src / include / mm_player_priv.h
1 /*
2  * libmm-player
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __MM_PLAYER_PRIV_H__
24 #define __MM_PLAYER_PRIV_H__
25
26 /*===========================================================================================
27 |                                                                                                                                                                                       |
28 |  INCLUDE FILES                                                                                                                                                        |
29 |                                                                                                                                                                               |
30 ========================================================================================== */
31 #include <glib.h>
32 #include <gst/gst.h>
33 #include <mm_attrs.h>
34 #include <math.h>
35 #include <sys/stat.h>
36 #include <unistd.h>
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <tbm_bufmgr.h>
40 #include <Evas.h>
41 #include "mm_player.h"
42 #include "mm_player_internal.h"
43 #include "mm_player_audioeffect.h"
44 #include "mm_message.h"
45 #include "mm_player_ini.h"
46 #include "mm_player_resource.h"
47 #include "mm_player_sound_focus.h"
48 #include "mm_player_pd.h"
49 #include "mm_player_streaming.h"
50
51 /*===========================================================================================
52 |                                                                                                                                                                                       |
53 |  GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                       |
54 |                                                                                                                                                                                       |
55 ========================================================================================== */
56
57 /*---------------------------------------------------------------------------
58 |    GLOBAL #defines:                                                                                                           |
59 ---------------------------------------------------------------------------*/
60 #define MM_PLAYER_IMGB_MPLANE_MAX       4
61 #define MM_PLAYER_STREAM_COUNT_MAX      3
62
63 #define MM_PLAYER_CAST(x_player)                ((mm_player_t *)(x_player))
64 /**
65  * @x_player: MMHandleType of player
66  *
67  * Get the PD downloader of this player.
68  */
69 #define MM_PLAYER_GET_PD(x_player)      (MM_PLAYER_CAST(x_player)->pd_downloader)
70 /**
71  * @x_player: MMHandleType of player
72  *
73  * Get the attributes handle of this player.
74  */
75 #define MM_PLAYER_GET_ATTRS(x_player)   (MM_PLAYER_CAST(x_player)->attrs)
76
77 #define ROTATION_USING_SINK     0
78 #define ROTATION_USING_CUSTOM   1
79 #define ROTATION_USING_FLIP     2
80
81 /*---------------------------------------------------------------------------
82 |    GLOBAL CONSTANT DEFINITIONS:                                                                                       |
83 ---------------------------------------------------------------------------*/
84 enum latency_mode
85 {
86     AUDIO_LATENCY_MODE_LOW = 0,     /**< Low audio latency mode */
87     AUDIO_LATENCY_MODE_MID,         /**< Middle audio latency mode */
88     AUDIO_LATENCY_MODE_HIGH,        /**< High audio latency mode */
89 };
90
91 enum tag_info
92 {
93         TAG_AUDIO_CODEC = 0x0001,
94         TAG_VIDEO_CODEC = 0x0002,
95         TAG_ARTIST              = 0x0004,
96         TAG_TITLE               = 0x0008,
97         TAG_ALBUM               = 0x0010,
98         TAG_GENRE               = 0x0020,
99         TAG_COPYRIGHT   = 0x0040,
100         TAG_DATE                = 0x0080,
101         TAG_DESCRIPTION = 0x0100,
102         TAG_TRACK_NUMBER = 0x0200
103 };
104
105 enum content_attr_flag
106 {
107         ATTR_MISSING_ONLY = 0x0001,
108         ATTR_DURATION = 0x0002,
109         ATTR_AUDIO  = 0x0004,
110         ATTR_VIDEO = 0x0008,
111         ATTR_BITRATE = 0x0010,
112         ATTR_ALL = 0x0020,
113 };
114
115 /* async mode makes trouble. alsasink sometimes fails to pause. */
116 enum alassink_sync
117 {
118         ALSASINK_SYNC,
119         ALSASINK_ASYNC
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_MS_BUFF,             /**< Player URI type Media Stream 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_V_INPUT_SELECTOR,    // video input_select
213         MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
214         MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
215         MMPLAYER_M_A_TEE,
216         MMPLAYER_M_A_Q1,
217         MMPLAYER_M_A_Q2,
218         MMPLAYER_M_A_CONV,
219         MMPLAYER_M_A_FILTER,
220         MMPLAYER_M_A_DEINTERLEAVE,
221         MMPLAYER_M_A_SELECTOR,
222         MMPLAYER_M_V_SINK,
223         MMPLAYER_M_V_CONV,
224         MMPLAYER_M_NUM
225 };
226
227 /* audio pipeline's element id */
228 enum AudioElementID
229 {
230         MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
231         MMPLAYER_A_TP,
232         MMPLAYER_A_CONV,
233         MMPLAYER_A_VOL,
234         MMPLAYER_A_FILTER,
235         MMPLAYER_A_FILTER_SEC,
236         MMPLAYER_A_VSP,
237         MMPLAYER_A_CAPS_DEFAULT,
238         MMPLAYER_A_SINK,
239         MMPLAYER_A_RESAMPLER,
240         MMPLAYER_A_DEINTERLEAVE,
241         MMPLAYER_A_NUM
242 };
243
244 /* video pipeline's element id */
245 enum VideoElementID
246 {
247         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
248         MMPLAYER_V_FLIP,
249         MMPLAYER_V_CONV,
250         MMPLAYER_V_SCALE,
251         MMPLAYER_V_CAPS,
252         MMPLAYER_V_SINK,
253         MMPLAYER_V_NUM
254 };
255
256 /* text pipeline's element id */
257 enum TextElementID
258 {
259         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
260         MMPLAYER_T_QUEUE,
261         MMPLAYER_T_VIDEO_QUEUE,
262         MMPLAYER_T_VIDEO_CONVERTER,
263         MMPLAYER_T_OVERLAY,
264         MMPLAYER_T_FAKE_SINK,
265         MMPLAYER_T_IDENTITY,
266         MMPLAYER_T_NUM
267 };
268
269 /* midi main pipeline's element id */
270 enum MidiElementID
271 {
272         MMPLAYER_MIDI_PIPE,
273         MMPLAYER_MIDI_PLAYER,
274         MMPLAYER_MIDI_NUM
275 };
276
277 enum PlayerCommandState
278 {
279         MMPLAYER_COMMAND_NONE,
280         MMPLAYER_COMMAND_CREATE,
281         MMPLAYER_COMMAND_DESTROY,
282         MMPLAYER_COMMAND_UNREALIZE,
283         MMPLAYER_COMMAND_START,
284         MMPLAYER_COMMAND_REALIZE,
285         MMPLAYER_COMMAND_STOP,
286         MMPLAYER_COMMAND_PAUSE,
287         MMPLAYER_COMMAND_RESUME,
288         MMPLAYER_COMMAND_NUM
289 };
290
291 /* Note : StreamingSrcError is error enum for streaming source which post error message
292  *      using custom message made by itself. The enum value must start with zero,
293  *      because the streaming source(secrtspsrc) also does.
294  */
295 enum StreamingSrcError
296 {
297         MMPLAYER_STREAMING_ERROR_NONE = 0,
298         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
299         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
300         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
301         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
302         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
303         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
304         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
305         MMPLAYER_STREAMING_ERROR_INVALID_URL,
306         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
307         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
308         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
309         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
310         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
311         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
312         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
313         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
314         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
315         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
316         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
317         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
318         MMPLAYER_STREAMING_ERROR_GONE,
319         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
320         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
321         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
322         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
323         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
324         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
325         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
326         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
327         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
328         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
329         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
330         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
331         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
332         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
333         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
334         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
335         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
336         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
337         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
338         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
339         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
340         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
341         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
342         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
343 };
344
345 /*---------------------------------------------------------------------------
346 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
347 ---------------------------------------------------------------------------*/
348
349 typedef struct
350 {
351         int id;
352         GstElement *gst;
353 } MMPlayerGstElement;
354
355 typedef struct
356 {
357         GstTagList                      *tag_list;
358         MMPlayerGstElement      *mainbin;
359         MMPlayerGstElement      *audiobin;
360         MMPlayerGstElement      *videobin;
361         MMPlayerGstElement      *textbin;
362 } MMPlayerGstPipelineInfo;
363
364 typedef struct
365 {
366         float volume;
367         int mute;
368         int bluetooth;  /* enable/disable */
369 } MMPlayerSoundInfo;
370
371 typedef struct {
372         char *buf;
373         int len;
374         int offset;
375
376 } tBuffer; /* FIXIT : choose better name */
377
378 typedef struct {
379         int uri_type;
380         int     play_mode;
381         void *mem;
382         int     mem_size;
383         char uri[MM_MAX_URL_LEN];
384         char urgent[MM_MAX_FILENAME_LEN];
385 } MMPlayerParseProfile;
386
387 typedef struct {
388         bool is_pending;
389         MMPlayerPosFormatType format;
390         unsigned long pos;
391 }MMPlayerPendingSeek;
392
393 typedef struct {
394         GObject* obj;
395         gulong sig;
396 } MMPlayerSignalItem;
397
398 typedef struct {
399         bool rich_audio;
400         bool safety_volume;
401         bool pcm_extraction;
402         bool video_zc; // video zero-copy
403         bool subtitle_off;
404         bool media_packet_video_stream;
405 }MMPlayerSetMode;
406
407 typedef struct {
408         GMainContext *global_default;
409         GMainContext *thread_default;
410 }MMPlayerGMainContext;
411
412 typedef struct {
413         gint uri_idx;
414         GList *uri_list;
415 }MMPlayerUriList;
416
417 typedef struct {
418         gint active_pad_index;
419         gint total_track_num;
420         GPtrArray *channels;
421         gulong block_id;
422         gulong event_probe_id;
423 } mm_player_selector_t;
424
425 typedef struct {
426         gboolean running;
427
428         gboolean stream_changed;
429         gboolean reconfigure;
430
431         GstClockTime start_time[MM_PLAYER_TRACK_TYPE_MAX];      /* updated once get SEGMENT event */
432         GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
433         gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];
434
435 } mm_player_gapless_t;
436
437 typedef struct {
438         int channel;
439         int bitrate;
440         int depth;
441         bool is_little_endian;
442         guint64 channel_mask;
443         void *pcm_data;
444         int data_size;
445         int buff_size;
446 } mm_player_audio_stream_buff_t;
447
448 /**
449  * @brief data of video_bo_list
450  * @details this will be used when the sw codec is running.
451  * @since_tizen 3.0
452  */
453 typedef struct {
454         gboolean using;
455         void* bo;
456 } mm_player_video_bo_info_t;
457
458 typedef struct {
459         /* STATE */
460         int state;                                      // player current state
461         int prev_state;                         // player previous state
462         int pending_state;                      // player state which is going to now
463         int target_state;                               // player state which user want to go to
464         guint state_change_timeout;
465
466         gboolean section_repeat;
467         gint section_repeat_start;
468         gint section_repeat_end;
469         guint play_count;
470
471         gchar *album_art;
472
473         int cmd;
474
475         /* command lock */
476         GMutex cmd_lock;
477         GMutex playback_lock;
478
479         /* repeat thread lock */
480         GCond repeat_thread_cond;
481         GMutex repeat_thread_mutex;
482         GThread* repeat_thread;
483         gboolean repeat_thread_exit;
484
485         /* next play thread */
486         GThread* next_play_thread;
487         gboolean next_play_thread_exit;
488         GCond next_play_thread_cond;
489         GMutex next_play_thread_mutex;
490         mm_player_gapless_t gapless;
491
492         /* capture thread */
493         GThread* capture_thread;
494         gboolean capture_thread_exit;
495         GCond capture_thread_cond;
496         GMutex capture_thread_mutex;
497         MMPlayerVideoCapture capture;
498         MMPlayerVideoColorspace video_cs;
499         MMVideoBuffer captured;
500
501         /* fakesink handling lock */
502         GMutex fsink_lock;
503
504         /* player attributes */
505         MMHandleType attrs;
506
507         /* message callback */
508         MMMessageCallback msg_cb;
509         void* msg_cb_param;
510
511         /* progressive download */
512         mm_player_pd_t *pd_downloader;
513         gchar *pd_file_save_path;
514         MMPlayerPDMode pd_mode;
515
516         /* streaming player */
517         mm_player_streaming_t *streamer;
518         gchar *http_file_buffering_path;
519
520         /* gstreamer pipeline */
521         MMPlayerGstPipelineInfo *pipeline;
522
523         /* pad */
524         GstPad *ghost_pad_for_videobin;
525
526         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
527         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
528         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
529         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
530         int video_num_buffers;  /* total num of buffers in vcodec */
531         int video_extra_num_buffers; /* extra num of buffers in vcodec */
532
533         void* buffer_cb_user_param;
534
535         /* video stream changed callback */
536         mm_player_stream_changed_callback video_stream_changed_cb;
537         void* video_stream_changed_cb_user_param;
538
539         /* audio stream changed callback */
540         mm_player_stream_changed_callback audio_stream_changed_cb;
541         void* audio_stream_changed_cb_user_param;
542
543         /* video stream callback */
544         mm_player_video_stream_callback video_stream_cb;
545         void* video_stream_cb_user_param;
546         GCond video_bo_cond;
547         GMutex video_bo_mutex;
548         GList* video_bo_list; /* mm_player_video_bo_info_t, bo list for decoded video data by sw codec */
549         int video_bo_size;
550         bool video_stream_prerolled;
551
552         /* audio stram callback */
553         mm_player_audio_stream_callback audio_stream_cb;
554         void* audio_stream_cb_user_param;
555         bool audio_stream_sink_sync;
556         GList* audio_stream_buff_list; /* mm_player_audio_stream_buff_t, buff list of extract pcm data */
557
558         /* audio buffer callback */
559         mm_player_audio_stream_callback_ex audio_stream_render_cb_ex;
560
561         /* video capture callback*/
562         gulong video_capture_cb_probe_id;
563
564         /* sound info */
565         MMPlayerSoundInfo       sound;
566
567         /* type string */
568         gchar *type;
569
570         /* video stream caps parsed by demuxer */
571         GstCaps* v_stream_caps;
572
573         /* audio effect infomation */
574         MMAudioEffectInfo audio_effect_info;
575         gboolean bypass_audio_effect;
576
577         gulong audio_cb_probe_id;
578
579         /* for appsrc */
580         tBuffer mem_buf;
581
582         /* content profile */
583         MMPlayerParseProfile profile;
584
585         /* streaming service type */
586         MMStreamingType streaming_type;
587
588         /* autoplugging */
589         GList* factories;
590         gboolean have_dynamic_pad;
591         GList* parsers; // list of linked parser name
592         GList* audio_decoders; // list of linked audio name
593         gboolean no_more_pad;
594         gint num_dynamic_pad;
595         gboolean has_many_types;
596
597         /* progress callback timer */
598         /* FIXIT : since duplicated functionality with get_position
599          * this function will be deprecated after fixing all application
600          * which are using it.
601          */
602         guint progress_timer;
603
604         /* timer for sending delayed EOS */
605         guint eos_timer;
606
607         /* last point (msec) that player is paused or seeking */
608         gint64 last_position;
609
610         /* duration */
611         gint64 duration;
612
613         /* data size of http streaming  */
614         guint64 http_content_size;
615
616         /* last error */
617         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
618
619         gboolean smooth_streaming;
620
621         gint videodec_linked;
622         gint audiodec_linked;
623         gint videosink_linked;
624         gint audiosink_linked;
625         gint textsink_linked;
626
627         /* missing plugin during autoplugging */
628         MissingCodec not_supported_codec;
629
630         /* unlinked audio/video mime type */
631         gchar *unlinked_video_mime;
632         gchar *unlinked_audio_mime;
633         gchar *unlinked_demuxer_mime;
634
635         /* found codec during autoplugging */
636         FoundCodec can_support_codec;
637
638         gboolean not_found_demuxer;
639
640         /* support seek even though player is not start */
641         MMPlayerPendingSeek pending_seek;
642
643         gboolean doing_seek;
644
645         /* prevent to post msg over and over */
646         gboolean msg_posted;
647
648         /* list of sink elements */
649         GList* sink_elements;
650
651         /* signal notifiers */
652         GList* signals[MM_PLAYER_SIGNAL_TYPE_MAX];
653         guint bus_watcher;
654         MMPlayerGMainContext context;
655         MMPlayerUriList uri_info;
656
657         gboolean is_sound_extraction;
658
659         gfloat playback_rate;
660
661         /* player state resumed by fast rewind */
662         gboolean resumed_by_rewind;
663
664         gboolean is_nv12_tiled;
665
666         /* resource manager for H/W resources */
667         MMPlayerResourceManager resource_manager;
668
669         /* sound focus for being compatible with legacy session policy internally */
670         MMPlayerSoundFocus sound_focus;
671
672         gboolean is_subtitle_off;
673         gboolean is_external_subtitle_present;
674
675         /* contents bitrate for buffering management */
676         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
677         guint total_bitrate;
678         guint updated_bitrate_count;
679         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
680         guint total_maximum_bitrate;
681         guint updated_maximum_bitrate_count;
682
683         /* prevent it from posting duplicatly*/
684         gboolean sent_bos;
685
686         /* timeout source for lazy pause */
687         guint lazy_pause_event_id;
688         guint resume_event_id;
689         guint resumable_cancel_id;
690
691         gboolean keep_detecting_vcodec;
692
693         gboolean play_subtitle;
694         gboolean use_textoverlay;
695         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
696
697         /* PD downloader message callback and param */
698         MMMessageCallback pd_msg_cb;
699         void* pd_msg_cb_param;
700
701         /* adjust subtitle position store */
702         gint64 adjust_subtitle_pos;
703         GList *subtitle_language_list;
704
705         /* To store the current multiwindow status */
706         gboolean last_multiwin_status;
707
708         /* To store the current running audio pad index of demuxer */
709         gint demux_pad_index;
710
711         mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
712         mm_player_selector_t audio_mode;
713         gboolean use_deinterleave;
714         guint max_audio_channels;
715
716         guint internal_text_idx;
717         guint external_text_idx;
718
719         MMPlayerSetMode set_mode;
720
721         /* decodbin usage */
722         gboolean use_decodebin;
723
724         /* initialize values */
725         mm_player_ini_t ini;
726
727         /* check to use h/w codec */
728         GstCaps* state_tune_caps;
729         gboolean ignore_asyncdone;
730
731         /* video share sync */
732         gint64 video_share_api_delta;
733         gint64 video_share_clock_delta;
734
735         /* just for native app (video hub) */
736         gboolean video_hub_download_mode;
737         gboolean sync_handler;
738
739         /* store dump pad list */
740         GList* dump_list;
741
742         /* whether a video has closed caption or not */
743         gboolean has_closed_caption;
744
745         GstElement *video_fakesink;
746
747         /* audio stream caps parsed by demuxer or set by external demuxer */
748         GstCaps* a_stream_caps;
749
750         /* subtitle stream caps parsed by demuxer or set by external demuxer */
751         GstCaps* s_stream_caps;
752
753         /* es player using feed-data callback or calling app_src_push_buffer directly*/
754         gboolean es_player_push_mode;
755
756         /* tmb buffer manager for s/w codec tmb_bo */
757         tbm_bufmgr bufmgr;
758
759         int pcm_samplerate;
760         int pcm_channel;
761 } mm_player_t;
762
763 typedef struct
764 {
765         gchar *language_code;
766         gchar *language_key;
767         gboolean active;
768 }MMPlayerLangStruct;
769
770 typedef struct
771 {
772         GstPad *dump_pad;
773         gulong probe_handle_id;
774         FILE *dump_element_file;
775 } mm_player_dump_t;
776
777 typedef struct{
778         char *name;
779         int value_type;
780         int flags;                              // r, w
781         void *default_value;
782         int valid_type;                 // validity type
783         int value_min;                  //<- set validity value range
784         int value_max;          //->
785 }MMPlayerAttrsSpec;
786
787 /*===========================================================================================
788 |                                                                                                                                                                                       |
789 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
790 |                                                                                                                                                                                       |
791 ========================================================================================== */
792 #ifdef __cplusplus
793         extern "C" {
794 #endif
795
796 int _mmplayer_create_player(MMHandleType hplayer);
797 int _mmplayer_destroy(MMHandleType hplayer);
798 int _mmplayer_realize(MMHandleType hplayer);
799 int _mmplayer_unrealize(MMHandleType hplayer);
800 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
801 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
802 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
803 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
804 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
805 int _mmplayer_start(MMHandleType hplayer);
806 int _mmplayer_stop(MMHandleType hplayer);
807 int _mmplayer_pause(MMHandleType hplayer);
808 int _mmplayer_resume(MMHandleType hplayer);
809 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
810 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
811 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
812 int _mmplayer_adjust_video_postion(MMHandleType hplayer,int offset);
813 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
814 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
815 int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size);
816 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
817 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
818 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
819 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
820 int _mmplayer_set_videostream_cb(MMHandleType hplayer,mm_player_video_stream_callback callback, void *user_param);
821 int _mmplayer_set_audiostream_cb(MMHandleType hplayer,mm_player_audio_stream_callback callback, void *user_param);
822 int _mmplayer_set_subtitle_silent (MMHandleType hplayer, int silent);
823 int _mmplayer_get_subtitle_silent (MMHandleType hplayer, int* silent);
824 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filepath);
825 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
826
827 /* test API for tuning audio gain. this API should be
828  * deprecated before the day of final release
829  */
830 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
831 int _mmplayer_update_video_param(mm_player_t* player, char *param_name);
832 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
833 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
834 int _mmplayer_audio_effect_custom_apply(mm_player_t *player);
835
836 int _mmplayer_set_audiostream_cb_ex(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback_ex callback, void *user_param);
837 gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessageParamType* param);
838
839 int _mmplayer_gst_set_audio_channel(MMHandleType hplayer, MMPlayerAudioChannel ch_idx);
840 int _mmplayer_change_track_language (MMHandleType hplayer, MMPlayerTrackType type, int index);
841 int _mmplayer_sync_subtitle_pipeline(mm_player_t* player);
842 int _mmplayer_set_prepare_buffering_time(MMHandleType hplayer, int second);
843 int _mmplayer_set_runtime_buffering_mode(MMHandleType hplayer, MMPlayerBufferingMode mode, int second);
844 int _mmplayer_set_display_zoom(MMHandleType hplayer, float level, int x, int y);
845 int _mmplayer_get_display_zoom(MMHandleType hplayer, float *level, int *x, int *y);
846 int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode);
847 int _mmplayer_use_system_clock (MMHandleType hplayer);
848 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);
849 int _mmplayer_get_video_share_master_clock(MMHandleType hplayer, long long *video_time, long long *media_clock, long long *audio_time);
850 int _mmplayer_get_video_rotate_angle(MMHandleType hplayer, int *angle);
851 int _mmplayer_enable_sync_handler(MMHandleType hplayer, bool enable);
852 int _mmplayer_set_file_buffering_path(MMHandleType hplayer, const char* file_path);
853 int _mmplayer_set_uri(MMHandleType hplayer, const char* uri);
854 int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_path);
855 int _mmplayer_get_next_uri(MMHandleType hplayer, char** uri);
856 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool* exist);
857 void * _mm_player_media_packet_video_stream_internal_buffer_ref(void *buffer);
858 void _mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer);
859 int _mmplayer_set_pcm_spec(MMHandleType hplayer, int samplerate, int channel);
860 int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
861 int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
862 int __mmplayer_gst_set_state (mm_player_t* player, GstElement * pipeline,  GstState state, gboolean async, gint timeout );
863 int __mmplayer_set_state(mm_player_t* player, int state);
864 int __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command);
865 gboolean __mmplayer_dump_pipeline_state( mm_player_t* player );
866 void __mmplayer_remove_g_source_from_context(GMainContext *context, guint source_id);
867 /* util */
868 const gchar * __get_state_name ( int state );
869 gboolean __mmplayer_can_do_interrupt(mm_player_t *player);
870 gboolean __is_streaming( mm_player_t* player );
871 gboolean __is_rtsp_streaming( mm_player_t* player );
872 gboolean __is_wfd_streaming( mm_player_t* player );
873 gboolean __is_live_streaming ( mm_player_t* player );
874 gboolean __is_http_streaming( mm_player_t* player );
875 gboolean __is_http_live_streaming( mm_player_t* player );
876 gboolean __is_dash_streaming( mm_player_t* player );
877 gboolean __is_smooth_streaming( mm_player_t* player );
878 gboolean __is_http_progressive_down(mm_player_t* player);
879
880 gboolean __mmplayer_check_useful_message(mm_player_t *player, GstMessage * message);
881 gboolean __mmplayer_handle_gst_error ( mm_player_t* player, GstMessage * message, GError* error );
882 gint __gst_handle_core_error( mm_player_t* player, int code );
883 gint __gst_handle_library_error( mm_player_t* player, int code );
884 gint __gst_handle_resource_error( mm_player_t* player, int code );
885 gint __gst_handle_stream_error( mm_player_t* player, GError* error, GstMessage * message );
886 int _mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid);
887 int _mmplayer_get_client_pid(MMHandleType hplayer, int* pid);
888 int __mmplayer_get_video_angle(mm_player_t* player, int *user_angle, int *org_angle);
889 int _mmplayer_video_stream_release_bo(mm_player_t* player, void* bo);
890
891 #ifdef __cplusplus
892         }
893 #endif
894
895 #endif  /* __MM_PLAYER_PRIV_H__ */