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