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