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