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