tizen 2.3.1 release
[framework/multimedia/libmm-player.git] / src / include / mm_player_priv.h
1 /*
2  * libmm-player
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __MM_PLAYER_PRIV_H__
24 #define __MM_PLAYER_PRIV_H__
25
26 /*===========================================================================================
27 |                                                                                                                                                                                       |
28 |  INCLUDE FILES                                                                                                                                                        |
29 |                                                                                                                                                                                       |
30 ========================================================================================== */
31 #include <glib.h>
32 #include <gst/gst.h>
33 #include <mm_attrs.h>
34 #include <mm_debug.h>
35 #include <math.h>
36
37 #include "mm_player.h"
38 #include "mm_player_internal.h"
39 #include "mm_player_audioeffect.h"
40 #include "mm_message.h"
41 #include "mm_player_ini.h"
42 #include "mm_player_asm.h"
43 #include "mm_player_pd.h"
44 #include "mm_player_streaming.h"
45
46 /*===========================================================================================
47 |                                                                                                                                                                                       |
48 |  GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                       |
49 |                                                                                                                                                                                       |
50 ========================================================================================== */
51
52 /*---------------------------------------------------------------------------
53 |    GLOBAL #defines:                                                                                                           |
54 ---------------------------------------------------------------------------*/
55
56 #define MM_PLAYER_IMGB_MPLANE_MAX       4
57 #define MM_PLAYER_STREAM_COUNT_MAX      3
58
59 #define MM_PLAYER_CAST(x_player)                ((mm_player_t *)(x_player))
60 /**
61  * @x_player: MMHandleType of player
62  *
63  * Get the PD downloader of this player.
64  */
65 #define MM_PLAYER_GET_PD(x_player)      (MM_PLAYER_CAST(x_player)->pd_downloader)
66 /**
67  * @x_player: MMHandleType of player
68  *
69  * Get the attributes handle of this player.
70  */
71 #define MM_PLAYER_GET_ATTRS(x_player)   (MM_PLAYER_CAST(x_player)->attrs)
72
73 /*---------------------------------------------------------------------------
74 |    GLOBAL CONSTANT DEFINITIONS:                                                                                       |
75 ---------------------------------------------------------------------------*/
76 enum tag_info
77 {
78         TAG_AUDIO_CODEC = 0x0001,
79         TAG_VIDEO_CODEC = 0x0002,
80         TAG_ARTIST              = 0x0004,
81         TAG_TITLE               = 0x0008,
82         TAG_ALBUM               = 0x0010,
83         TAG_GENRE               = 0x0020,
84         TAG_COPYRIGHT   = 0x0040,
85         TAG_DATE                = 0x0080,
86         TAG_DESCRIPTION = 0x0100,
87         TAG_TRACK_NUMBER = 0x0200
88 };
89
90 enum content_attr_flag
91 {
92         ATTR_MISSING_ONLY = 0x0001,
93         ATTR_DURATION = 0x0002,
94         ATTR_AUDIO  = 0x0004,
95         ATTR_VIDEO = 0x0008,
96         ATTR_BITRATE = 0x0010,
97         ATTR_ALL = 0x0020,
98 };
99
100 /* async mode makes trouble. alsasink sometimes fails to pause. */
101 enum alassink_sync
102 {
103         ALSASINK_SYNC,
104         ALSASINK_ASYNC
105 };
106
107
108 /**
109  * Enumerations of Player Mode
110  */
111 enum MMPlayerMode {
112         MM_PLAYER_MODE_NONE,                    /**< Player mode None */
113         MM_PLAYER_MODE_MIDI,                    /**< Player mode Midi */
114         MM_PLAYER_MODE_GST,                     /**< Player mode Gstreamer */
115 };
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_HLS,                 /**< Player URI type http live streaming */
132         MM_PLAYER_URI_TYPE_SS,                  /**< Player URI type Smooth streaming */
133         MM_PLAYER_URI_TYPE_DASH,                        /**< Player URI type Mpeg Dash */
134         MM_PLAYER_URI_TYPE_NO_PERMISSION,/**< Player URI type No Permission  */
135         MM_PLAYER_URI_TYPE_TEMP,                        /**< Player URI type Temp */
136 };
137
138 typedef enum _MissingCodec
139 {
140         MISSING_PLUGIN_NONE                     = 0x00,
141         MISSING_PLUGIN_AUDIO                    = 0x01,
142         MISSING_PLUGIN_VIDEO                    = 0x02
143 }MissingCodec;
144
145
146 typedef enum _FoundCodec
147 {
148         FOUND_PLUGIN_NONE                       = 0x00,
149         FOUND_PLUGIN_AUDIO                      = 0x01,
150         FOUND_PLUGIN_VIDEO                      = 0x02
151 }FoundCodec;
152
153 typedef enum
154 {
155         MMPLAYER_DISPLAY_STATUS_NULL = 0,
156         MMPLAYER_DISPLAY_STATUS_HDMI_ACTIVE,
157         MMPLAYER_DISPLAY_STATUS_UNKNOWN_ACTIVE,
158 }MMPlayerDisplayStatus;
159
160 /**
161  * Enumeration of signal type
162  */
163 typedef enum {
164         MM_PLAYER_SIGNAL_TYPE_AUTOPLUG = 0,
165         MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
166         MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
167         MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
168         MM_PLAYER_SIGNAL_TYPE_OTHERS,
169         MM_PLAYER_SIGNAL_TYPE_ALL,
170         MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
171 }MMPlayerSignalType;
172
173 /* main pipeline's element id */
174 enum MainElementID
175 {
176         MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
177         MMPLAYER_M_SRC,
178         MMPLAYER_M_SUBSRC,
179
180         /* it could be a decodebin or could be a typefind. depends on player ini */
181         MMPLAYER_M_TYPEFIND,
182         MMPLAYER_M_AUTOPLUG,
183
184         /* NOTE : we need two fakesink to autoplug without decodebin.
185          * first one will hold whole pipeline state. and second one will hold state of
186          * a sink-decodebin for an elementary stream. no metter if there's more then one
187          * elementary streams because MSL reuse it.
188          */
189         MMPLAYER_M_SRC_FAKESINK,
190         MMPLAYER_M_SRC_2ND_FAKESINK,
191
192         /* streaming plugin */
193         MMPLAYER_M_MUXED_S_BUFFER,
194         MMPLAYER_M_DEMUXED_S_BUFFER,
195         MMPLAYER_M_ID3DEMUX,
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_DEMUX_EX,
204         MMPLAYER_M_V_INPUT_SELECTOR,    // video input_select   // not yet
205         MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
206         MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
207         MMPLAYER_M_T_SUBMUX_EXTERNAL,
208         MMPLAYER_M_T_SUBMUX_INTERNAL,
209         MMPLAYER_M_A_TEE,
210         MMPLAYER_M_A_Q1,
211         MMPLAYER_M_A_Q2,
212         MMPLAYER_M_A_CONV,
213         MMPLAYER_M_A_FILTER,
214         MMPLAYER_M_A_DEINTERLEAVE,
215         MMPLAYER_M_A_SELECTOR,
216         MMPLAYER_M_NUM
217 };
218
219 /* audio pipeline's element id */
220 enum AudioElementID
221 {
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_NUM
233 };
234
235 /* video pipeline's element id */
236 enum VideoElementID
237 {
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 {
250         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
251         MMPLAYER_T_TEXT_FAKE_QUEUE,
252         MMPLAYER_T_TEXT_QUEUE,
253         MMPLAYER_T_VIDEO_QUEUE,
254         MMPLAYER_T_VIDEO_CONVERTER,
255         MMPLAYER_T_OVERLAY,
256         MMPLAYER_T_FAKE_SINK,
257         MMPLAYER_T_VIDEO_SINK,
258         MMPLAYER_T_TEE,
259         MMPLAYER_T_RENDER,
260         MMPLAYER_T_CAPSFILTER,
261         MMPLAYER_T_TEXT_FAKE_IDENTITY,
262         MMPLAYER_T_TEXT_IDENTITY,
263         MMPLAYER_T_NUM
264 };
265
266 /* midi main pipeline's element id */
267 enum MidiElementID
268 {
269         MMPLAYER_MIDI_PIPE,
270         MMPLAYER_MIDI_PLAYER,
271         MMPLAYER_MIDI_NUM
272 };
273
274 enum PlayerCommandState
275 {
276         MMPLAYER_COMMAND_NONE,
277         MMPLAYER_COMMAND_CREATE,
278         MMPLAYER_COMMAND_DESTROY,
279         MMPLAYER_COMMAND_UNREALIZE,
280         MMPLAYER_COMMAND_START,
281         MMPLAYER_COMMAND_REALIZE,
282         MMPLAYER_COMMAND_STOP,
283         MMPLAYER_COMMAND_PAUSE,
284         MMPLAYER_COMMAND_RESUME,
285         MMPLAYER_COMMAND_NUM
286 };
287
288 /* Note : StreamingSrcError is error enum for streaming source which post error message
289  *      using custom message made by itself. The enum value must start with zero,
290  *      because the streaming source(secrtspsrc) also does.
291  */
292 enum StreamingSrcError
293 {
294         MMPLAYER_STREAMING_ERROR_NONE = 0,
295         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
296         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
297         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
298         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
299         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
300         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
301         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
302         MMPLAYER_STREAMING_ERROR_INVALID_URL,
303         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
304         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
305         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
306         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
307         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
308         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
309         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
310         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
311         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
312         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
313         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
314         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
315         MMPLAYER_STREAMING_ERROR_GONE,
316         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
317         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
318         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
319         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
320         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
321         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
322         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
323         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
324         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
325         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
326         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
327         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
328         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
329         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
330         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
331         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
332         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
333         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
334         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
335         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
336         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
337         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
338         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
339         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
340 };
341
342 /*---------------------------------------------------------------------------
343 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
344 ---------------------------------------------------------------------------*/
345
346 typedef struct
347 {
348         int id;
349         GstElement *gst;
350 } MMPlayerGstElement;
351
352 typedef struct
353 {
354         GstTagList                      *tag_list;
355         MMPlayerGstElement      *mainbin;
356         MMPlayerGstElement      *audiobin;
357         MMPlayerGstElement      *videobin;
358         MMPlayerGstElement      *textbin;
359 } MMPlayerGstPipelineInfo;
360
361 typedef struct
362 {
363         float volume;
364         int mute;
365         int bluetooth;  /* enable/disable */
366 } MMPlayerSoundInfo;
367
368 typedef struct {
369         char *buf;
370         int len;
371         int offset;
372
373 } tBuffer; /* FIXIT : choose better name */
374
375 typedef struct {
376         int uri_type;
377         int     play_mode;
378         void *mem;
379         int     mem_size;
380         char uri[MM_MAX_URL_LEN];
381         char urgent[MM_MAX_FILENAME_LEN];
382 } MMPlayerParseProfile;
383
384 typedef struct {
385         bool is_pending;
386         MMPlayerPosFormatType format;
387         unsigned long pos;
388 }MMPlayerPendingSeek;
389
390 typedef struct {
391         GObject* obj;
392         gulong sig;
393 } MMPlayerSignalItem;
394
395 typedef struct {
396         bool rich_audio;
397         bool safety_volume;
398         bool pcm_extraction;
399         bool video_zc; // video zero-copy
400         bool subtitle_off;
401         bool media_packet_video_stream;
402 }MMPlayerSetMode;
403
404 typedef struct {
405         GMainContext *global_default;
406         GMainContext *thread_default;
407 }MMPlayerGMainContext;
408
409 typedef struct {
410         gint uri_idx;
411         GList *uri_list;
412 }MMPlayerUriList;
413
414 /* image buffer definition ***************************************************
415
416     +------------------------------------------+ ---
417     |                                          |  ^
418     |     a[], p[]                             |  |
419     |     +---------------------------+ ---    |  |
420     |     |                           |  ^     |  |
421     |     |<---------- w[] ---------->|  |     |  |
422     |     |                           |  |     |  |
423     |     |                           |        |
424     |     |                           |  h[]   |  e[]
425     |     |                           |        |
426     |     |                           |  |     |  |
427     |     |                           |  |     |  |
428     |     |                           |  v     |  |
429     |     +---------------------------+ ---    |  |
430     |                                          |  v
431     +------------------------------------------+ ---
432
433     |<----------------- s[] ------------------>|
434 */
435 typedef struct
436 {
437         /* width of each image plane */
438         int w[MM_PLAYER_IMGB_MPLANE_MAX];
439         /* height of each image plane */
440         int h[MM_PLAYER_IMGB_MPLANE_MAX];
441         /* stride of each image plane */
442         int s[MM_PLAYER_IMGB_MPLANE_MAX];
443         /* elevation of each image plane */
444         int e[MM_PLAYER_IMGB_MPLANE_MAX];
445         /* user space address of each image plane */
446         void *a[MM_PLAYER_IMGB_MPLANE_MAX];
447         /* physical address of each image plane, if needs */
448         void *p[MM_PLAYER_IMGB_MPLANE_MAX];
449         /* color space type of image */
450         int cs;
451         /* left postion, if needs */
452         int x;
453         /* top position, if needs */
454         int y;
455         /* to align memory */
456         int __dummy2;
457         /* arbitrary data */
458         int data[16];
459         /* dmabuf or ion fd */
460         int fd[MM_PLAYER_IMGB_MPLANE_MAX];
461         /* flag for buffer share */
462         int buf_share_method;
463         /* Y plane size */
464         int y_size;
465         /* UV plane size */
466         int uv_size;
467         /* Tizen buffer object of each image plane */
468         void *bo[MM_PLAYER_IMGB_MPLANE_MAX];
469         /* JPEG data */
470         void *jpeg_data;
471         /* JPEG size */
472         int jpeg_size;
473         /* tzmem buffer */
474         int tz_enable;
475 } MMPlayerMPlaneImage;
476
477 typedef struct {
478         gint active_pad_index;
479         gint total_track_num;
480         GPtrArray *channels;
481 } mm_player_selector_t;
482
483 /* Things needed to be done after output device has changed */
484 typedef struct {
485         gboolean need_async;
486         gboolean need_seek;
487         gboolean need_pause_and_resume;
488         guint cb_score;
489         guint required_cb_score;
490         guint id;
491 } mm_player_post_proc_t;
492
493 typedef struct {
494         /* STATE */
495         int state;                                      // player current state
496         int prev_state;                         // player previous state
497         int pending_state;                      // player state which is going to now
498         int target_state;                               // player state which user want to go to
499         guint state_change_timeout;
500
501         gboolean section_repeat;
502         gint section_repeat_start;
503         gint section_repeat_end;
504         guint play_count;
505
506         gchar *album_art;
507
508         int cmd;
509
510         /* command lock */
511         GMutex* cmd_lock;
512         GMutex* playback_lock;
513
514         /* repeat thread lock */
515         GCond* repeat_thread_cond;
516         GMutex* repeat_thread_mutex;
517         GThread* repeat_thread;
518         gboolean repeat_thread_exit;
519
520         /* next play thread */
521         GThread* next_play_thread;
522         gboolean next_play_thread_exit;
523         GCond* next_play_thread_cond;
524         GMutex* next_play_thread_mutex;
525
526         /* capture thread */
527         GThread* capture_thread;
528         gboolean capture_thread_exit;
529         GCond* capture_thread_cond;
530         GMutex* capture_thread_mutex;
531         MMPlayerVideoCapture capture;
532         MMPlayerVideoColorspace video_cs;
533         MMPlayerMPlaneImage captured;
534
535         /* fakesink handling lock */
536         GMutex* fsink_lock;
537
538         /* player attributes */
539         MMHandleType attrs;
540
541         /* message callback */
542         MMMessageCallback msg_cb;
543         void* msg_cb_param;
544         GMutex* msg_cb_lock;
545
546         /* progressive download */
547         mm_player_pd_t *pd_downloader;
548         gchar *pd_file_save_path;
549         MMPlayerPDMode pd_mode;
550
551         /* streaming player */
552         mm_player_streaming_t *streamer;
553
554         /* gstreamer pipeline */
555         MMPlayerGstPipelineInfo *pipeline;
556
557         /* pad */
558         GstPad *ghost_pad_for_videobin;
559
560         /* buffering support cbs*/
561         mm_player_buffer_need_data_callback need_data_cb;
562         mm_player_buffer_enough_data_callback enough_data_cb;
563         mm_player_buffer_seek_data_callback seek_data_cb;
564
565         void* buffer_cb_user_param;
566
567         /* video stream callback */
568         mm_player_video_stream_callback video_stream_cb;
569         void* video_stream_cb_user_param;
570         int use_video_stream;
571
572         /* audio stram callback */
573         mm_player_audio_stream_callback audio_stream_cb;
574         void* audio_stream_cb_user_param;
575
576         /* video capture callback*/
577         gulong video_capture_cb_probe_id;
578
579         /* video frame render error callback */
580         mm_player_video_frame_render_error_callback video_frame_render_error_cb;
581         void* video_frame_render_error_cb_user_param;
582
583         /* sound info */
584         MMPlayerSoundInfo       sound;
585
586         /* type string */
587         gchar *type;
588
589         /* video stream caps parsed by demuxer */
590         GstCaps* v_stream_caps;
591
592         /* audio effect infomation */
593         MMAudioEffectInfo audio_effect_info;
594         gboolean bypass_audio_effect;
595
596         gulong audio_cb_probe_id;
597         gulong video_cb_probe_id;
598
599         /* for appsrc */
600         tBuffer mem_buf;
601
602         /* content profile */
603         MMPlayerParseProfile profile;
604
605         /* streaming service type */
606         MMStreamingType streaming_type;
607
608         /* autoplugging */
609         GList* factories;
610         gboolean have_dynamic_pad;
611         GList* parsers; // list of linked parser name
612         GList* audio_decoders; // list of linked audio name
613         gboolean no_more_pad;
614         gint num_dynamic_pad;
615         gboolean has_many_types;
616
617         /* progress callback timer */
618         /* FIXIT : since duplicated functionality with get_position
619          * this function will be deprecated after fixing all application
620          * which are using it.
621          */
622         guint progress_timer;
623
624         /* timer for sending delayed EOS */
625         guint eos_timer;
626
627         /* last point (msec) that player is paused or seeking */
628         gint64 last_position;
629
630         /* duration */
631         gint64 duration;
632
633         /* data size of http streaming  */
634         guint64 http_content_size;
635
636         /* last error */
637         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
638
639         gboolean needed_v_parser;
640         gboolean smooth_streaming;
641
642         gint videodec_linked;
643         gint audiodec_linked;
644         gint videosink_linked;
645         gint audiosink_linked;
646         gint textsink_linked;
647
648         /* missing plugin during autoplugging */
649         MissingCodec not_supported_codec;
650
651         /*unlinked audio/video mime type */
652         gchar *unlinked_video_mime;
653         gchar *unlinked_audio_mime;
654         gchar *unlinked_demuxer_mime;
655
656         /* found codec during autoplugging */
657         FoundCodec can_support_codec;
658
659         gboolean not_found_demuxer;
660
661         /* support seek even though player is not start */
662         MMPlayerPendingSeek pending_seek;
663
664         gboolean doing_seek;
665
666         /* prevent to post msg over and over */
667         gboolean msg_posted;
668
669         /* list of sink elements */
670         GList* sink_elements;
671
672         /* signal notifiers */
673         GList* signals[MM_PLAYER_SIGNAL_TYPE_MAX];
674         guint bus_watcher;
675         MMPlayerGMainContext context;
676         MMPlayerUriList uri_info;
677
678         gboolean is_sound_extraction;
679
680         gfloat playback_rate;
681
682         /* player state resumed by fast rewind */
683         gboolean resumed_by_rewind;
684
685         gboolean is_nv12_tiled;
686         gboolean is_drm_file;
687
688         MMPlayerASM     sm;
689
690         gboolean is_subtitle_off;
691         gboolean is_external_subtitle_present;
692
693         /* contents bitrate for buffering management */
694         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
695         guint total_bitrate;
696         guint updated_bitrate_count;
697         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
698         guint total_maximum_bitrate;
699         guint updated_maximum_bitrate_count;
700
701         /* prevent it from posting duplicatly*/
702         gboolean sent_bos;
703
704         /* timeout source for lazy pause */
705         guint lazy_pause_event_id;
706         guint resume_event_id;
707         guint resumable_cancel_id;
708
709         gboolean keep_detecting_vcodec;
710
711         gboolean play_subtitle;
712         gboolean use_textoverlay;
713         MMPlayerDisplayStatus display_stat;
714         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
715
716         /* PD downloader message callback and param */
717         MMMessageCallback pd_msg_cb;
718         void* pd_msg_cb_param;
719
720         /* adjust subtitle position store */
721         gint64 adjust_subtitle_pos;
722         GList *subtitle_language_list;
723
724         /* To store the current multiwindow status */
725         gboolean last_multiwin_status;
726
727         /* To store the current running audio pad index of demuxer */
728         gint demux_pad_index;
729
730         mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
731         mm_player_selector_t audio_mode;
732         gboolean use_deinterleave;
733         guint max_audio_channels;
734
735         guint internal_text_idx;
736         guint external_text_idx;
737
738         MMPlayerSetMode set_mode;
739
740         /* decodbin usage */
741         gboolean use_decodebin;
742
743         /* initialize values */
744         mm_player_ini_t ini;
745
746         /* check to use h/w codec */
747         GstCaps* state_tune_caps;
748         gboolean ignore_asyncdone;
749
750         /* video share sync */
751         gint64 video_share_api_delta;
752         gint64 video_share_clock_delta;
753
754         /* subtitle option */
755         gchar *font_desc;
756         guint font_color;
757         guint font_bg_color;
758         gboolean subtitle_ignore_markup;
759
760         /* just for native app (video hub) */
761         gboolean video_hub_download_mode;
762         gboolean sync_handler;
763
764         /* seamless next playing */
765         gboolean src_changed;
766         gboolean pp_rebuilding;
767
768         /* store dump pad list */
769         GList* dump_list;
770
771
772         /* audio/video deivce change handling */
773         mm_player_post_proc_t post_proc;
774
775         /* whether a video has closed caption or not */
776         gboolean has_closed_caption;
777
778         GstElement *video_fakesink;
779 } mm_player_t;
780
781 typedef struct
782 {
783         gchar *language_code;
784         gchar *language_key;
785         gboolean active;
786 }MMPlayerLangStruct;
787
788 typedef struct
789 {
790         GstPad *dump_pad;
791         gulong probe_handle_id;
792         FILE *dump_element_file;
793 } mm_player_dump_t;
794
795 /*===========================================================================================
796 |                                                                                                                                                                                       |
797 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
798 |                                                                                                                                                                                       |
799 ========================================================================================== */
800 #ifdef __cplusplus
801         extern "C" {
802 #endif
803
804 int _mmplayer_create_player(MMHandleType hplayer);
805 int _mmplayer_destroy(MMHandleType hplayer);
806 int _mmplayer_realize(MMHandleType hplayer);
807 int _mmplayer_unrealize(MMHandleType hplayer);
808 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
809 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
810 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
811 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
812 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
813 int _mmplayer_start(MMHandleType hplayer);
814 int _mmplayer_stop(MMHandleType hplayer);
815 int _mmplayer_pause(MMHandleType hplayer);
816 int _mmplayer_resume(MMHandleType hplayer);
817 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
818 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
819 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
820 int _mmplayer_adjust_video_postion(MMHandleType hplayer,int offset);
821 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
822 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
823 int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size);
824 int _mmplayer_set_buffer_need_data_cb(MMHandleType hplayer,mm_player_buffer_need_data_callback callback, void *user_param);
825 int _mmplayer_set_buffer_enough_data_cb(MMHandleType hplayer,mm_player_buffer_enough_data_callback callback, void *user_param);
826 int _mmplayer_set_buffer_seek_data_cb(MMHandleType hplayer,mm_player_buffer_seek_data_callback callback, void *user_param);
827 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate);
828 int _mmplayer_set_playspeed_ex(MMHandleType hplayer, gdouble rate);
829 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
830 int _mmplayer_set_videostream_cb(MMHandleType hplayer,mm_player_video_stream_callback callback, void *user_param);
831 int _mmplayer_set_audiostream_cb(MMHandleType hplayer,mm_player_audio_stream_callback callback, void *user_param);
832 int _mmplayer_set_videoframe_render_error_cb(MMHandleType hplayer, mm_player_video_frame_render_error_callback callback, void *user_param);
833 int _mmplayer_set_subtitle_silent (MMHandleType hplayer, int silent);
834 int _mmplayer_get_subtitle_silent (MMHandleType hplayer, int* silent);
835 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char* filepath);
836 int _mmplayer_set_external_subtitle_font(MMHandleType hplayer, char *font_desc);
837 int _mmplayer_set_external_subtitle_font_color(MMHandleType hplayer, unsigned int font_color, unsigned int font_bg_color);
838 int _mmplayer_external_subtitle_ignore_markup_tags(MMHandleType hplayer, bool ignore_markup);
839 int _mmplayer_external_subtitle_set_alignment_in_line(MMHandleType hplayer, unsigned int alignment);
840 int _mmplayer_external_subtitle_set_alignment_horizontal(MMHandleType hplayer, unsigned int alignment);
841 int _mmplayer_external_subtitle_apply_alignment_right_away(MMHandleType hplayer);
842 int _mmplayer_set_external_subtitle_edge(MMHandleType hplayer, MMPlayerSubtitleEdge edge_mode);
843 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
844 int _mmplayer_keep_external_video_fullscreen(MMHandleType hplayer);
845
846 /* test API for tuning audio gain. this API should be
847  * deprecated before the day of final release
848  */
849 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
850 int _mmplayer_update_video_param(mm_player_t* player);
851 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
852 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
853 int _mmplayer_audio_effect_custom_apply(mm_player_t *player);
854
855 gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype, MMMessageParamType* param);
856 gboolean __mmplayer_is_streaming(mm_player_t* player);
857
858
859 int _mmplayer_gst_set_audio_channel(MMHandleType hplayer, MMPlayerAudioChannel ch_idx);
860 int _mmplayer_change_track_language (MMHandleType hplayer, MMPlayerTrackType type, int index);
861 int _mmplayer_sync_subtitle_pipeline(mm_player_t* player);
862 int _mmplayer_set_prepare_buffering_time(MMHandleType hplayer, int second);
863 int _mmplayer_set_runtime_buffering_mode(MMHandleType hplayer, MMPlayerBufferingMode mode, int second);
864 int _mmplayer_set_display_zoom(MMHandleType hplayer, float level, int x, int y);
865 int _mmplayer_get_display_zoom(MMHandleType hplayer, float *level, int *x, int *y);
866 int _mmplayer_set_video_hub_download_mode(MMHandleType hplayer, bool mode);
867 int _mmplayer_use_system_clock (MMHandleType hplayer);
868 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);
869 int _mmplayer_get_video_share_master_clock(MMHandleType hplayer, long long *video_time, long long *media_clock, long long *audio_time);
870 int _mmplayer_get_video_rotate_angle(MMHandleType hplayer, int *angle);
871 int _mmplayer_enable_sync_handler(MMHandleType hplayer, bool enable);
872 int _mmplayer_set_uri(MMHandleType hplayer, const char* uri);
873 int _mmplayer_set_next_uri(MMHandleType hplayer, const char* uri, bool is_first_path);
874 int _mmplayer_get_next_uri(MMHandleType hplayer, char** uri);
875 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool* exist);
876 int _mmplayer_enable_media_packet_video_stream(MMHandleType hplayer, bool enable);
877 #ifdef __cplusplus
878         }
879 #endif
880
881 #endif  /* __MM_PLAYER_PRIV_H__ */