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