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