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