[0.6.173] support audio pitch control
[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 <storage.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_resource_manager.h>
47 #include "mm_player_streaming.h"
48
49 /*===========================================================================================
50 |                                                                                                                                                                                       |
51 |  GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE                                                                                       |
52 |                                                                                                                                                                                       |
53 ========================================================================================== */
54
55 /*---------------------------------------------------------------------------
56 |    GLOBAL #defines:                                                                                                           |
57 ---------------------------------------------------------------------------*/
58 #define MM_PLAYER_IMGB_MPLANE_MAX       4
59 #define MM_PLAYER_STREAM_COUNT_MAX      3
60
61 #define MM_PLAYER_CAST(x_player)                ((mm_player_t *)(x_player))
62 /**
63  * @x_player: MMHandleType of player
64  *
65  * Get the attributes handle of this player.
66  */
67 #define MM_PLAYER_GET_ATTRS(x_player)   (MM_PLAYER_CAST(x_player)->attrs)
68
69 #define MM_MAX_STRING_LENGTH    4000 /* have to be less than MUSE_MSG_MAX_LENGTH */
70
71 #define VIDEO360_MAX_ZOOM       10.0f
72
73 /*---------------------------------------------------------------------------
74 |    GLOBAL CONSTANT DEFINITIONS:                                                                                       |
75 ---------------------------------------------------------------------------*/
76 enum latency_mode {
77         AUDIO_LATENCY_MODE_LOW = 0,     /**< Low audio latency mode */
78         AUDIO_LATENCY_MODE_MID,         /**< Middle audio latency mode */
79         AUDIO_LATENCY_MODE_HIGH,        /**< High audio latency mode */
80 };
81
82 enum tag_info {
83         TAG_AUDIO_CODEC = 0x0001,
84         TAG_VIDEO_CODEC = 0x0002,
85         TAG_ARTIST              = 0x0004,
86         TAG_TITLE               = 0x0008,
87         TAG_ALBUM               = 0x0010,
88         TAG_GENRE               = 0x0020,
89         TAG_COPYRIGHT   = 0x0040,
90         TAG_DATE                = 0x0080,
91         TAG_DESCRIPTION = 0x0100,
92         TAG_TRACK_NUMBER = 0x0200
93 };
94
95 enum content_attr_flag {
96         ATTR_MISSING_ONLY = 0x0001,
97         ATTR_DURATION = 0x0002,
98         ATTR_AUDIO  = 0x0004,
99         ATTR_VIDEO = 0x0008,
100         ATTR_BITRATE = 0x0010,
101         ATTR_ALL = 0x0020,
102 };
103
104 enum MMPlayerSinkType {
105         MMPLAYER_VIDEO_SINK = 0x01,
106         MMPLAYER_AUDIO_SINK = 0x02,
107         MMPLAYER_TEXT_SINK = 0x04,
108         MMPLAYER_SINK_ALL = 0x07,
109 };
110
111 /**
112  * Enumerations of Player Uri type
113  */
114 enum MMPlayerUriType {
115         MM_PLAYER_URI_TYPE_NONE,                        /**< Player URI type None */
116         MM_PLAYER_URI_TYPE_URL_RTSP,            /**< Player URI type RTSP */
117         MM_PLAYER_URI_TYPE_URL_HTTP,            /**< Player URI type HTTP */
118         MM_PLAYER_URI_TYPE_URL_MMS,                     /**< Player URI type MMS */
119         MM_PLAYER_URI_TYPE_MEM,                         /**< Player URI type Mem */
120         MM_PLAYER_URI_TYPE_FILE,                        /**< Player URI type File */
121         MM_PLAYER_URI_TYPE_URL,                         /**< Player URI type URL */
122         MM_PLAYER_URI_TYPE_MS_BUFF,                     /**< Player URI type Media Stream Buffer */
123         MM_PLAYER_URI_TYPE_HLS,                         /**< Player URI type http live streaming */
124         MM_PLAYER_URI_TYPE_SS,                          /**< Player URI type Smooth streaming */
125         MM_PLAYER_URI_TYPE_DASH,                        /**< Player URI type Mpeg Dash */
126         MM_PLAYER_URI_TYPE_NO_PERMISSION,       /**< Player URI type No Permission  */
127         MM_PLAYER_URI_TYPE_TEMP,                        /**< Player URI type Temp */
128 };
129
130 typedef enum _MissingCodec {
131         MISSING_PLUGIN_NONE = 0x00,
132         MISSING_PLUGIN_AUDIO = 0x01,
133         MISSING_PLUGIN_VIDEO = 0x02
134 } MissingCodec;
135
136
137 typedef enum _FoundCodec {
138         FOUND_PLUGIN_NONE = 0x00,
139         FOUND_PLUGIN_AUDIO = 0x01,
140         FOUND_PLUGIN_VIDEO = 0x02
141 } FoundCodec;
142
143 /**
144  * Enumeration of signal type
145  */
146 typedef enum {
147         MM_PLAYER_SIGNAL_TYPE_AUTOPLUG = 0,
148         MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
149         MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
150         MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
151         MM_PLAYER_SIGNAL_TYPE_OTHERS,
152         MM_PLAYER_SIGNAL_TYPE_ALL,
153         MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
154 } MMPlayerSignalType;
155
156 /* main pipeline's element id */
157 enum MainElementID {
158         MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
159         MMPLAYER_M_SRC,
160         MMPLAYER_M_2ND_SRC,     /* 2nd Source Element for es buff src */
161         MMPLAYER_M_SUBSRC,
162
163         /* it could be a decodebin or could be a typefind. depends on player ini */
164         MMPLAYER_M_TYPEFIND,
165         MMPLAYER_M_AUTOPLUG,
166
167         MMPLAYER_M_AUTOPLUG_V_DEC,
168         MMPLAYER_M_AUTOPLUG_A_DEC,
169
170         /*fakesink will hold whole pipeline state. */
171         MMPLAYER_M_SRC_FAKESINK,
172
173         /* streaming plugin */
174         MMPLAYER_M_MUXED_S_BUFFER,
175         MMPLAYER_M_DEMUXED_S_BUFFER,
176         MMPLAYER_M_ID3DEMUX,
177         MMPLAYER_M_ADAPTIVE_DEMUX,
178
179         /* es buff src queue */
180         MMPLAYER_M_V_BUFFER,
181         MMPLAYER_M_A_BUFFER,
182         MMPLAYER_M_S_BUFFER,
183
184         /* FIXIT : if there's really no usage for following IDs. remove it */
185         MMPLAYER_M_DEC1,
186         MMPLAYER_M_DEC2,
187         MMPLAYER_M_Q1,
188         MMPLAYER_M_Q2,
189         MMPLAYER_M_DEMUX,
190         MMPLAYER_M_SUBPARSE,
191         MMPLAYER_M_V_INPUT_SELECTOR,    // video input_select
192         MMPLAYER_M_A_INPUT_SELECTOR,    // audio input_select
193         MMPLAYER_M_T_INPUT_SELECTOR,    // text input_select
194         MMPLAYER_M_NUM
195 };
196
197 /* audio pipeline's element id */
198 enum AudioElementID {
199         MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
200         MMPLAYER_A_CONV,
201         MMPLAYER_A_VOL,
202         MMPLAYER_A_FILTER,
203         MMPLAYER_A_FILTER_SEC,
204         MMPLAYER_A_CAPS_DEFAULT,
205         MMPLAYER_A_CONV_BFORMAT,
206         MMPLAYER_A_CAPS_360,
207         MMPLAYER_A_SINK,
208         MMPLAYER_A_RESAMPLER,
209         MMPLAYER_A_DEINTERLEAVE,
210         MMPLAYER_A_RGVOL,
211         MMPLAYER_A_CONV_PITCH,
212         MMPLAYER_A_PITCH,
213         MMPLAYER_A_NUM
214 };
215
216 /* video pipeline's element id */
217 enum VideoElementID {
218         MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
219         MMPLAYER_V_FLIP,
220         MMPLAYER_V_CONV,
221         MMPLAYER_V_CAPS,
222         MMPLAYER_V_SINK,
223         MMPLAYER_V_360,
224         MMPLAYER_V_NUM
225 };
226
227 /* text pipeline's element id */
228 enum TextElementID {
229         MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
230         MMPLAYER_T_QUEUE,
231         MMPLAYER_T_VIDEO_QUEUE,
232         MMPLAYER_T_VIDEO_CONVERTER,
233         MMPLAYER_T_OVERLAY,
234         MMPLAYER_T_FAKE_SINK,
235         MMPLAYER_T_IDENTITY,
236         MMPLAYER_T_NUM
237 };
238
239 /* midi main pipeline's element id */
240 enum MidiElementID {
241         MMPLAYER_MIDI_PIPE,
242         MMPLAYER_MIDI_PLAYER,
243         MMPLAYER_MIDI_NUM
244 };
245
246 enum PlayerCommandState {
247         MMPLAYER_COMMAND_NONE,
248         MMPLAYER_COMMAND_CREATE,
249         MMPLAYER_COMMAND_DESTROY,
250         MMPLAYER_COMMAND_UNREALIZE,
251         MMPLAYER_COMMAND_START,
252         MMPLAYER_COMMAND_REALIZE,
253         MMPLAYER_COMMAND_STOP,
254         MMPLAYER_COMMAND_PAUSE,
255         MMPLAYER_COMMAND_RESUME,
256         MMPLAYER_COMMAND_NUM
257 };
258
259 /* Note : StreamingSrcError is error enum for streaming source which post error message
260  *      using custom message made by itself. The enum value must start with zero,
261  *      because the streaming source(secrtspsrc) also does.
262  */
263 enum StreamingSrcError {
264         MMPLAYER_STREAMING_ERROR_NONE = 0,
265         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
266         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
267         MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
268         MMPLAYER_STREAMING_ERROR_DNS_FAIL,
269         MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
270         MMPLAYER_STREAMING_ERROR_BAD_SERVER,
271         MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
272         MMPLAYER_STREAMING_ERROR_INVALID_URL,
273         MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
274         MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
275         MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
276         MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
277         MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
278         MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
279         MMPLAYER_STREAMING_ERROR_FORBIDDEN,
280         MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
281         MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
282         MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
283         MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
284         MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
285         MMPLAYER_STREAMING_ERROR_GONE,
286         MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
287         MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
288         MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
289         MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
290         MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
291         MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
292         MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
293         MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
294         MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
295         MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
296         MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
297         MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
298         MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
299         MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
300         MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
301         MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
302         MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
303         MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
304         MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
305         MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
306         MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
307         MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT       ,
308         MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
309         MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
310 };
311
312 typedef enum {
313         MMPLAYER_SEEK_NONE = 0,
314         MMPLAYER_SEEK_IN_PROGRESS,
315         MMPLAYER_SEEK_COMPLETED,        /* after getting async done but before posting seek complete */
316 } MMPlayerSeekState;
317
318 typedef enum {
319         MMPLAYER_PATH_VOD = 0,
320         MMPLAYER_PATH_TEXT,
321         MMPLAYER_PATH_MAX
322 } MMPlayerPathType;
323
324 /* Video360 related enums. These are duplication from video360.h from
325  * gst-plugins-tizen.
326  * */
327 typedef enum {
328         VIDEO360_MODE_UNKNOWN = -1,
329         VIDEO360_MODE_MONOSCOPIC = 0,
330         VIDEO360_MODE_STEREOSCOPIC_TOP_BOTTOM = 1,
331         VIDEO360_MODE_STEREOSCOPIC_LEFT_RIGHT = 2,
332         VIDEO360_MODE_STEREOSCOPIC_STEREO_MESH = 3,
333         VIDEO360_MODE_LAST_ITEM
334 } mm_player_stereo_mode_e;
335
336 typedef enum {
337         VIDEO360_PROJECTION_TYPE_UNKNOWN = -1,
338         VIDEO360_PROJECTION_TYPE_EQUIRECTANGULAR = 0,
339         VIDEO360_PROJECTION_TYPE_CUBEMAP = 1,
340         VIDEO360_PROJECTION_TYPE_MESH = 2,
341         VIDEO360_PROJECTION_TYPE_LAST_ITEM
342 } mm_player_projection_type_e;
343
344 /* Spatial audio related enums. These are duplication from mm_file.h from
345  * libmm-fileinfo.
346  * */
347 typedef enum {
348         MMFILE_AMBISONIC_TYPE_UNKNOWN = 0,
349         MMFILE_AMBISONIC_TYPE_PERIPHONIC = 1,           /**< To comply with Google's Spatial Audio RFC*/
350         MMFILE_AMBISONIC_TYPE_NON_PERIPHONIC = 2,
351 } MMFILE_AMBISONIC_TYPE;
352
353 typedef enum {
354         MMFILE_AMBISONIC_FORMAT_UNKNOWN = 0,
355         MMFILE_AMBISONIC_FORMAT_AMBIX = 1,              /**< AMBIX (Channel sequence: ACN, Normalization: SN3D) */
356         MMFILE_AMBISONIC_FORMAT_AMB = 2,                /**< .AMB, Tetraproc (Channel sequence: FuMa, Normalization: FuMa) */
357         MMFILE_AMBISONIC_FORMAT_UA = 3,                 /**< Universal Ambisonics (Channel sequence: SID, Normalization: N3D) */
358 } MMFILE_AMBISONIC_FORMAT;
359
360 typedef enum {
361         MMFILE_AMBISONIC_ORDER_UNKNOWN = 0,
362         MMFILE_AMBISONIC_ORDER_FOA = 1,                 /**< First order Ambisonics */
363         MMFILE_AMBISONIC_ORDER_SOA = 2,                 /**< Second order Ambisonics */
364         MMFILE_AMBISONIC_ORDER_TOA = 3,                 /**< Third order Ambisonics */
365 } MMFILE_AMBISONIC_ORDER;
366
367 /*---------------------------------------------------------------------------
368 |    GLOBAL DATA TYPE DEFINITIONS:                                                                                      |
369 ---------------------------------------------------------------------------*/
370
371 typedef struct {
372         int id;
373         GstElement *gst;
374 } MMPlayerGstElement;
375
376 typedef struct {
377         GstTagList *tag_list;
378         MMPlayerGstElement *mainbin;
379         MMPlayerGstElement *audiobin;
380         MMPlayerGstElement *videobin;
381         MMPlayerGstElement *textbin;
382 } MMPlayerGstPipelineInfo;
383
384 typedef struct {
385         float volume;
386         int mute;
387         int bluetooth;  /* enable/disable */
388         int focus_id;
389         bool rg_enable;
390 } MMPlayerSoundInfo;
391
392 typedef struct {
393         char *buf;
394         int len;
395         int offset;
396 } MMPlayerInputBuffer;
397
398 typedef struct {
399         int uri_type;
400         MMPlayerInputBuffer input_mem;
401         char uri[MM_MAX_URL_LEN];
402         char urgent[MM_MAX_FILENAME_LEN];
403 } MMPlayerParseProfile;
404
405 typedef struct {
406         storage_type_e type;
407         storage_state_e state;
408         int id;
409         char path[MM_MAX_URL_LEN];
410 } MMPlayerStorageInfo;
411
412 typedef struct {
413         bool is_pending;
414         gint64 pos;
415 } MMPlayerPendingSeek;
416
417 typedef struct {
418         GObject *obj;
419         gulong sig;
420 } MMPlayerSignalItem;
421
422 typedef struct {
423         bool rich_audio;
424         bool safety_volume;
425         bool video_zc; // video zero-copy
426         bool subtitle_off;
427         bool media_packet_video_stream;
428 } MMPlayerSetMode;
429
430 typedef struct {
431         GMainContext *global_default;
432         GMainContext *thread_default;
433 } MMPlayerGMainContext;
434
435 typedef struct {
436         gint uri_idx;
437         GList *uri_list;
438 } MMPlayerUriList;
439
440 typedef struct {
441         double scale_x;
442         double scale_y;
443         double scale_width;
444         double scale_height;
445 } MMPlayerVideoROI;
446
447 typedef struct {
448         gint active_pad_index;
449         gint total_track_num;
450         GPtrArray *channels;
451         gulong block_id;
452         gulong event_probe_id;
453 } mm_player_selector_t;
454
455 typedef struct {
456         gboolean running;
457
458         gboolean stream_changed;
459         gboolean reconfigure;
460
461         GstClockTime start_time[MM_PLAYER_TRACK_TYPE_MAX];      /* updated once get SEGMENT event */
462         GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
463         gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];
464
465 } mm_player_gapless_t;
466
467 typedef struct {
468         int channel;
469         int bitrate;
470         int depth;
471         bool is_little_endian;
472         guint64 channel_mask;
473         void *pcm_data;
474         int data_size;
475         int buff_size;
476 } mm_player_audio_stream_buff_t;
477
478 /**
479  * @brief data of video_bo_list
480  * @details this will be used when the sw codec is running.
481  * @since_tizen 3.0
482  */
483 typedef struct {
484         gboolean used;
485         void *bo;
486 } mm_player_video_bo_info_t;
487
488 typedef struct {
489         gint bandwidth;
490         gint width;
491         gint height;
492 } VariantData;
493
494 typedef struct {
495         GList *var_list;
496         VariantData limit;
497 } MMAdaptiveVariantInfo;
498
499 typedef struct {
500         int is_spherical;
501         int is_stitched;
502         char *stitching_software;
503         char *projection_type_string;
504         char *stereo_mode_string;
505         mm_player_projection_type_e projection_type;
506         mm_player_stereo_mode_e stereo_mode;
507         int source_count;
508         int init_view_heading;
509         int init_view_pitch;
510         int init_view_roll;
511         int timestamp;
512         int full_pano_width_pixels;
513         int full_pano_height_pixels;
514         int cropped_area_image_width;
515         int cropped_area_image_height;
516         int cropped_area_left;
517         int cropped_area_top;
518         int ambisonic_type;
519         int ambisonic_format;
520         int ambisonic_order;
521 } mm_player_spherical_metadata_t;
522
523 typedef struct {
524         /* STATE */
525         int state;                                      // player current state
526         int prev_state;                         // player previous state
527         int pending_state;                      // player state which is going to now
528         int target_state;                               // player state which user want to go to
529         guint state_change_timeout;
530
531         gchar *album_art;
532
533         int cmd;
534
535         /* command lock */
536         GMutex cmd_lock;
537         GMutex playback_lock;
538
539         /* gapless play thread */
540         GThread *gapless_play_thread;
541         gboolean gapless_play_thread_exit;
542         GCond gapless_play_thread_cond;
543         GMutex gapless_play_thread_mutex;
544         mm_player_gapless_t gapless;
545
546         /* capture thread */
547         GThread *capture_thread;
548         gboolean capture_thread_exit;
549         GCond capture_thread_cond;
550         GMutex capture_thread_mutex;
551         MMPlayerVideoCapture capture;
552         MMPlayerVideoColorspace video_cs;
553         MMVideoBuffer captured;
554
555         /* gst bus msg thread, create during realize */
556         GThread *bus_msg_thread;
557         gboolean bus_msg_thread_exit;
558         GCond bus_msg_thread_cond;
559         GMutex bus_msg_thread_mutex;
560
561         /* fakesink handling lock */
562         GMutex fsink_lock;
563
564         /* update tag lock */
565         GMutex update_tag_lock;
566
567         /* player attributes */
568         MMHandleType attrs;
569
570         /* message callback */
571         MMMessageCallback msg_cb;
572         void *msg_cb_param;
573
574         /* streaming player */
575         mm_player_streaming_t *streamer;
576
577         /* gstreamer pipeline */
578         MMPlayerGstPipelineInfo *pipeline;
579
580         /* pad */
581         GstPad *ghost_pad_for_videobin;
582
583         guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
584         guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];
585         mm_player_media_stream_buffer_status_callback media_stream_buffer_status_cb[MM_PLAYER_STREAM_TYPE_MAX];
586         mm_player_media_stream_seek_data_callback media_stream_seek_data_cb[MM_PLAYER_STREAM_TYPE_MAX];
587         GMutex media_stream_cb_lock;
588
589         int video_num_buffers;  /* total num of buffers in vcodec */
590         int video_extra_num_buffers; /* extra num of buffers in vcodec */
591
592         void *buffer_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
593         void *seek_cb_user_param[MM_PLAYER_STREAM_TYPE_MAX];
594
595         /* video stream changed callback */
596         mm_player_stream_changed_callback video_stream_changed_cb;
597         void *video_stream_changed_cb_user_param;
598
599         /* audio stream changed callback */
600         mm_player_stream_changed_callback audio_stream_changed_cb;
601         void *audio_stream_changed_cb_user_param;
602
603         /* video stream callback */
604         mm_player_video_stream_callback video_stream_cb;
605         void *video_stream_cb_user_param;
606         GCond video_bo_cond;
607         GMutex video_bo_mutex;
608         GList *video_bo_list; /* mm_player_video_bo_info_t, bo list for decoded video data by sw codec */
609         int video_bo_size;
610         bool video_stream_prerolled;
611
612         /* audio stream callback */
613         mm_player_audio_stream_callback audio_stream_render_cb;
614         void *audio_stream_cb_user_param;
615         bool audio_stream_sink_sync;
616         GList *audio_stream_buff_list; /* mm_player_audio_stream_buff_t, buff list of extract pcm data */
617
618         /* video capture callback*/
619         gulong video_capture_cb_probe_id;
620
621         /* sound info */
622         MMPlayerSoundInfo       sound;
623
624         /* type string */
625         gchar *type;
626
627         /* video stream caps parsed by demuxer */
628         GstCaps *v_stream_caps;
629
630         /* audio effect infomation */
631         MMAudioEffectInfo audio_effect_info;
632         gboolean bypass_audio_effect;
633
634         /* content profile */
635         MMPlayerParseProfile profile;
636         MMPlayerStorageInfo storage_info[MMPLAYER_PATH_MAX];
637
638         /* streaming service type */
639         MMStreamingType streaming_type;
640
641         /* autoplugging */
642         GList *factories;
643         GList *parsers; // list of linked parser name
644         GList *audio_decoders; // list of linked audio name
645         gboolean no_more_pad;
646         gint num_dynamic_pad;
647         gboolean has_many_types;
648
649         /* progress callback timer */
650         /* FIXIT : since duplicated functionality with get_position
651          * this function will be deprecated after fixing all application
652          * which are using it.
653          */
654         guint progress_timer;
655
656         /* timer for sending delayed EOS */
657         guint eos_timer;
658
659         /* last point that player is paused or seeking */
660         gint64 last_position;
661
662         /* duration */
663         gint64 duration;
664
665         /* data size of http streaming  */
666         guint64 http_content_size;
667
668         /* last error */
669         gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
670
671         gboolean smooth_streaming;
672
673         gint videodec_linked;
674         gint audiodec_linked;
675         gint textsink_linked;
676
677         /* missing plugin during autoplugging */
678         MissingCodec not_supported_codec;
679
680         /* unlinked audio/video mime type */
681         gchar *unlinked_video_mime;
682         gchar *unlinked_audio_mime;
683         gchar *unlinked_demuxer_mime;
684
685         /* found codec during autoplugging */
686         FoundCodec can_support_codec;
687
688         gboolean not_found_demuxer;
689
690         /* support seek even though player is not start */
691         MMPlayerPendingSeek pending_seek;
692         MMPlayerSeekState seek_state;
693
694         /* prevent to post msg over and over */
695         gboolean msg_posted;
696
697         /* list of sink elements */
698         GList *sink_elements;
699
700         /* signal notifiers */
701         GList *signals[MM_PLAYER_SIGNAL_TYPE_MAX];
702         guint bus_watcher;
703         GQueue *bus_msg_q;
704         GMutex bus_msg_q_lock;
705         MMPlayerGMainContext context;
706         MMPlayerUriList uri_info;
707
708         gboolean is_sound_extraction;
709
710         gfloat playback_rate;
711
712         /* player state resumed by fast rewind */
713         gboolean resumed_by_rewind;
714
715         gboolean is_nv12_tiled;
716
717         /* resource manager for H/W resources */
718         mm_resource_manager_h resource_manager;
719         mm_resource_manager_res_h video_overlay_resource;
720         mm_resource_manager_res_h video_decoder_resource;
721         gboolean interrupted_by_resource;
722
723         gboolean is_subtitle_off;
724         gboolean is_external_subtitle_present;
725         gboolean is_external_subtitle_added_now;
726         gboolean pending_resume;
727
728         /* contents bitrate for buffering management */
729         guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
730         guint total_bitrate;
731         guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
732         guint total_maximum_bitrate;
733
734         /* prevent it from posting duplicatly*/
735         gboolean sent_bos;
736
737         gboolean play_subtitle;
738         gboolean is_subtitle_force_drop;        // set TRUE after bus_cb get EOS
739
740         /* adjust subtitle position store */
741         gint64 adjust_subtitle_pos;
742         GList *subtitle_language_list;
743         GCond subtitle_info_cond;
744         GMutex subtitle_info_mutex;
745
746         /* To store the current multiwindow status */
747         gboolean last_multiwin_status;
748
749         /* To store the current running audio pad index of demuxer */
750         gint demux_pad_index;
751
752         mm_player_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];
753
754         guint internal_text_idx;
755         guint external_text_idx;
756
757         MMPlayerSetMode set_mode;
758
759         /* initialize values */
760         mm_player_ini_t ini;
761
762         /* store dump pad list */
763         GList *dump_list;
764
765         /* whether a video has closed caption or not */
766         gboolean has_closed_caption;
767
768
769         /* audio stream caps parsed by demuxer or set by external demuxer */
770         GstCaps *a_stream_caps;
771
772         /* subtitle stream caps parsed by demuxer or set by external demuxer */
773         GstCaps *s_stream_caps;
774
775         /* es player using feed-data callback or calling app_src_push_buffer directly*/
776         gboolean es_player_push_mode;
777
778         /* tmb buffer manager for s/w codec tmb_bo */
779         tbm_bufmgr bufmgr;
780
781         MMAdaptiveVariantInfo adaptive_info;
782
783         /* Video360 related stuff
784          * */
785         gboolean is_360_feature_enabled;
786         gboolean is_content_spherical;
787         mm_player_spherical_metadata_t video360_metadata;
788         gboolean is_openal_plugin_used;
789         /* User settable values */
790         gboolean is_video360_enabled;
791         float video360_yaw_radians;
792         float video360_pitch_radians;
793         float video360_zoom;
794         int video360_horizontal_fov;
795         int video360_vertical_fov;
796
797         /* Video ROI area scale value */
798         MMPlayerVideoROI video_roi;
799
800         /* build audio offload */
801         gboolean build_audio_offload;
802 } mm_player_t;
803
804 typedef struct {
805         gchar *language_code;
806         gchar *language_key;
807         gboolean active;
808 } MMPlayerLangStruct;
809
810 typedef struct {
811         GstPad *dump_pad;
812         gulong probe_handle_id;
813         FILE *dump_element_file;
814 } mm_player_dump_t;
815
816 typedef struct {
817         char *name;
818         int value_type;
819         int flags;                              // r, w
820         void *default_value;
821         int valid_type;                 // validity type
822         int value_min;                  //<- set validity value range
823         int value_max;          //->
824 } MMPlayerAttrsSpec;
825
826 /*===========================================================================================
827 |                                                                                                                                                                                       |
828 |  GLOBAL FUNCTION PROTOTYPES                                                                                                                           |
829 |                                                                                                                                                                                       |
830 ========================================================================================== */
831 #ifdef __cplusplus
832         extern "C" {
833 #endif
834
835 int _mmplayer_create_player(MMHandleType hplayer);
836 int _mmplayer_destroy(MMHandleType hplayer);
837 int _mmplayer_realize(MMHandleType hplayer);
838 int _mmplayer_unrealize(MMHandleType hplayer);
839 int _mmplayer_get_state(MMHandleType hplayer, int *pstate);
840 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
841 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
842 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
843 int _mmplayer_get_mute(MMHandleType hplayer, int *pmute);
844 int _mmplayer_start(MMHandleType hplayer);
845 int _mmplayer_stop(MMHandleType hplayer);
846 int _mmplayer_pause(MMHandleType hplayer);
847 int _mmplayer_abort_pause(MMHandleType hplayer);
848 int _mmplayer_resume(MMHandleType hplayer);
849 int _mmplayer_set_position(MMHandleType hplayer, gint64 pos);
850 int _mmplayer_get_position(MMHandleType hplayer, gint64 *pos);
851 int _mmplayer_get_duration(MMHandleType hplayer, gint64 *duration);
852 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format,  int pos);
853 int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
854 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
855 int _mmplayer_set_videostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
856 int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
857 int _mmplayer_set_videostream_cb(MMHandleType hplayer, mm_player_video_stream_callback callback, void *user_param);
858 int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
859 int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent);
860 int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath);
861 int _mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos);
862 int _mmplayer_update_video_param(mm_player_t *player, char *param_name);
863 int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, void *display_overlay);
864 int _mmplayer_audio_effect_custom_apply(mm_player_t *player);
865 int _mmplayer_set_audiostream_cb(MMHandleType hplayer, bool sync, mm_player_audio_stream_callback callback, void *user_param);
866 int _mmplayer_change_track_language(MMHandleType hplayer, MMPlayerTrackType type, int index);
867 int _mmplayer_sync_subtitle_pipeline(mm_player_t *player);
868 int _mmplayer_use_system_clock(MMHandleType hplayer);
869 int _mmplayer_set_uri(MMHandleType hplayer, const char *uri);
870 int _mmplayer_set_next_uri(MMHandleType hplayer, const char *uri, bool is_first_path);
871 int _mmplayer_get_next_uri(MMHandleType hplayer, char **uri);
872 int _mmplayer_has_closed_caption(MMHandleType hplayer, bool *exist);
873 void _mm_player_video_stream_internal_buffer_unref(void *buffer);
874 int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
875 int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
876 int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state);
877 int _mmplayer_video_stream_release_bo(mm_player_t *player, void *bo);
878 int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
879 int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
880 int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
881 int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
882 int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
883 int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *prebuffer_ms, int *rebuffer_ms);
884 int _mmplayer_set_codec_type(MMHandleType hplayer, MMPlayerStreamType stream_type, MMPlayerVideoCodecType codec_type);
885 int _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled);
886 int _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled);
887 int _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height);
888 int _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
889
890 /* internal */
891 void __mmplayer_bus_msg_thread_destroy(MMHandleType hplayer);
892
893 void __mmplayer_set_state(mm_player_t *player, int state);
894 int __mmplayer_check_state(mm_player_t *player, enum PlayerCommandState command);
895 gboolean __mmplayer_update_content_attrs(mm_player_t *player, enum content_attr_flag flag);
896 void __mmplayer_cancel_eos_timer(mm_player_t *player);
897 void __mmplayer_audio_stream_clear_buffer(mm_player_t *player, gboolean send_all);
898 MMStreamingType __mmplayer_get_stream_service_type(mm_player_t *player);
899 int __mmplayer_get_video_angle(mm_player_t *player, int *display_angle, int *orientations);
900 gboolean __mmplayer_gst_remove_fakesink(mm_player_t *player, MMPlayerGstElement *fakesink);
901 void __mmplayer_add_signal_connection(mm_player_t *player, GObject *object, MMPlayerSignalType type, const gchar *signal, GCallback cb_funct, gpointer u_data);
902 void __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data);
903 gint __mmplayer_gst_decode_autoplug_select(GstElement *bin,  GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer data);
904 gboolean __mmplayer_gst_create_decoder(mm_player_t *player, GstPad *srcpad, const GstCaps *caps);
905 void __mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data);
906 GstElement *__mmplayer_gst_make_decodebin(mm_player_t *player);
907 int __mmplayer_gst_element_add_bucket_to_bin(GstBin *bin, GList *element_bucket);
908 int __mmplayer_gst_element_link_bucket(GList *element_bucket);
909 void __mmplayer_typefind_have_type(GstElement *tf, guint probability, GstCaps *caps, gpointer data);
910 int __mmplayer_parse_profile(const char *uri, void *param, MMPlayerParseProfile *data);
911
912
913 #ifdef __cplusplus
914         }
915 #endif
916
917 #endif  /* __MM_PLAYER_PRIV_H__ */