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