summaryrefslogtreecommitdiff
path: root/src/include/mm_player_priv.h
blob: c74063f0741d2546d6cca5102cacc2fbf4804aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
/*
 * libmm-player
 *
 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
 * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#ifndef __MM_PLAYER_PRIV_H__
#define	__MM_PLAYER_PRIV_H__

/*===========================================================================================
|																							|
|  INCLUDE FILES																			|
|																						|
========================================================================================== */
#include <glib.h>
#include <gst/gst.h>
#include <mm_attrs.h>
#include <math.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <tbm_bufmgr.h>
#include <storage.h>
#include "mm_player.h"
#include "mm_player_audioeffect.h"
#include "mm_message.h"
#include "mm_player_ini.h"
#include <mm_resource_manager.h>
#include "mm_player_streaming.h"
#include "mm_player_attrs.h"

/*===========================================================================================
|																							|
|  GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE											|
|																							|
========================================================================================== */

/*---------------------------------------------------------------------------
|    GLOBAL #defines:														|
---------------------------------------------------------------------------*/
#define MM_PLAYER_IMGB_MPLANE_MAX	4
#define MM_PLAYER_STREAM_COUNT_MAX	3

#define MM_PLAYER_CAST(x_player)		((mmplayer_t *)(x_player))
/**
 * @x_player: MMHandleType of player
 *
 * Get the attributes handle of this player.
 */
#define MM_PLAYER_GET_ATTRS(x_player)	(MM_PLAYER_CAST(x_player)->attrs)

#define MM_MAX_STRING_LENGTH    4000 /* have to be less than MUSE_MSG_MAX_LENGTH */

#define VIDEO360_MAX_ZOOM	10.0f

#define DEFAULT_NUM_OF_V_OUT_BUFFER		3

/*---------------------------------------------------------------------------
|    GLOBAL CONSTANT DEFINITIONS:											|
---------------------------------------------------------------------------*/
enum latency_mode {
	AUDIO_LATENCY_MODE_LOW = 0,     /**< Low audio latency mode */
	AUDIO_LATENCY_MODE_MID,         /**< Middle audio latency mode */
	AUDIO_LATENCY_MODE_HIGH,        /**< High audio latency mode */
};

enum tag_info {
	TAG_AUDIO_CODEC	= 0x0001,
	TAG_VIDEO_CODEC	= 0x0002,
	TAG_ARTIST		= 0x0004,
	TAG_TITLE		= 0x0008,
	TAG_ALBUM		= 0x0010,
	TAG_GENRE		= 0x0020,
	TAG_COPYRIGHT	= 0x0040,
	TAG_DATE		= 0x0080,
	TAG_DESCRIPTION	= 0x0100,
	TAG_TRACK_NUMBER = 0x0200
};

enum content_attr_flag {
	ATTR_MISSING_ONLY = 0x0001,
	ATTR_DURATION = 0x0002,
	ATTR_AUDIO  = 0x0004,
	ATTR_VIDEO = 0x0008,
	ATTR_BITRATE = 0x0010,
	ATTR_ALL = 0x0020,
};

enum mmplayer_sink_type {
	MMPLAYER_VIDEO_SINK = 0x01,
	MMPLAYER_AUDIO_SINK = 0x02,
	MMPLAYER_TEXT_SINK = 0x04,
	MMPLAYER_SINK_ALL = 0x07,
};

/**
 * Enumerations of Player Uri type
 */
enum mmplayer_uri_type {
	MM_PLAYER_URI_TYPE_NONE,			/**< Player URI type None */
	MM_PLAYER_URI_TYPE_URL_RTSP,		/**< Player URI type RTSP */
	MM_PLAYER_URI_TYPE_URL_HTTP,		/**< Player URI type HTTP */
	MM_PLAYER_URI_TYPE_URL_MMS,			/**< Player URI type MMS */
	MM_PLAYER_URI_TYPE_MEM,				/**< Player URI type Mem */
	MM_PLAYER_URI_TYPE_FILE,			/**< Player URI type File */
	MM_PLAYER_URI_TYPE_URL,				/**< Player URI type URL */
	MM_PLAYER_URI_TYPE_MS_BUFF,			/**< Player URI type Media Stream Buffer */
	MM_PLAYER_URI_TYPE_HLS,				/**< Player URI type http live streaming */
	MM_PLAYER_URI_TYPE_SS,				/**< Player URI type Smooth streaming */
	MM_PLAYER_URI_TYPE_DASH,			/**< Player URI type Mpeg Dash */
	MM_PLAYER_URI_TYPE_NO_PERMISSION,	/**< Player URI type No Permission  */
	MM_PLAYER_URI_TYPE_TEMP,			/**< Player URI type Temp */
};

typedef enum {
	MISSING_PLUGIN_NONE = 0x00,
	MISSING_PLUGIN_AUDIO = 0x01,
	MISSING_PLUGIN_VIDEO = 0x02
} missing_codec_e;


typedef enum {
	FOUND_PLUGIN_NONE = 0x00,
	FOUND_PLUGIN_AUDIO = 0x01,
	FOUND_PLUGIN_VIDEO = 0x02
} found_codec_e;

/**
 * Enumeration of signal type
 */
typedef enum {
	MM_PLAYER_SIGNAL_TYPE_AUTOPLUG = 0,
	MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
	MM_PLAYER_SIGNAL_TYPE_AUDIOBIN,
	MM_PLAYER_SIGNAL_TYPE_TEXTBIN,
	MM_PLAYER_SIGNAL_TYPE_OTHERS,
	MM_PLAYER_SIGNAL_TYPE_ALL,
	MM_PLAYER_SIGNAL_TYPE_MAX = MM_PLAYER_SIGNAL_TYPE_ALL,
} mmplayer_signal_type_e;

/* main pipeline's element id */
typedef enum {
	MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
	MMPLAYER_M_SRC,
	MMPLAYER_M_2ND_SRC,	/* 2nd Source Element for es buff src */
	MMPLAYER_M_SUBSRC,

	/* it could be a decodebin or could be a typefind. depends on player ini */
	MMPLAYER_M_TYPEFIND,
	MMPLAYER_M_AUTOPLUG,

	MMPLAYER_M_AUTOPLUG_V_DEC,
	MMPLAYER_M_AUTOPLUG_A_DEC,

	/*fakesink will hold whole pipeline state. */
	MMPLAYER_M_SRC_FAKESINK,

	/* streaming plugin */
	MMPLAYER_M_MUXED_S_BUFFER,
	MMPLAYER_M_DEMUXED_S_BUFFER,
	MMPLAYER_M_ID3DEMUX,
	MMPLAYER_M_ADAPTIVE_DEMUX,

	/* es buff src queue */
	MMPLAYER_M_V_BUFFER,
	MMPLAYER_M_A_BUFFER,
	MMPLAYER_M_S_BUFFER,

	/* FIXIT : if there's really no usage for following IDs. remove it */
	MMPLAYER_M_DEC1,
	MMPLAYER_M_DEC2,
	MMPLAYER_M_Q1,
	MMPLAYER_M_Q2,
	MMPLAYER_M_DEMUX,
	MMPLAYER_M_SUBPARSE,
	MMPLAYER_M_V_INPUT_SELECTOR,	// video input_select
	MMPLAYER_M_A_INPUT_SELECTOR,	// audio input_select
	MMPLAYER_M_T_INPUT_SELECTOR,	// text input_select
	MMPLAYER_M_NUM
} main_element_id_e;

/* audio pipeline's element id */
enum audio_element_id {
	MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
	MMPLAYER_A_CONV,
	MMPLAYER_A_VOL,
	MMPLAYER_A_FILTER,
	MMPLAYER_A_FILTER_SEC,
	MMPLAYER_A_CONV_BFORMAT,
	MMPLAYER_A_CAPS_360,
	MMPLAYER_A_SINK,
	MMPLAYER_A_RESAMPLER,
	MMPLAYER_A_RGVOL,
	MMPLAYER_A_CONV_PITCH,
	MMPLAYER_A_PITCH,
	MMPLAYER_A_TEE,
	MMPLAYER_A_TEE_Q1,
	MMPLAYER_A_TEE_Q2,
	MMPLAYER_A_EXTRACT_CONV,
	MMPLAYER_A_EXTRACT_RESAMPLER,
	MMPLAYER_A_EXTRACT_CAPS,
	MMPLAYER_A_EXTRACT_DEINTERLEAVE,
	MMPLAYER_A_EXTRACT_SINK,
	MMPLAYER_A_NUM
};

/* video pipeline's element id */
enum video_element_id {
	MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
	MMPLAYER_V_CONV,
	MMPLAYER_V_CAPS,
	MMPLAYER_V_SINK,
	MMPLAYER_V_360,
	MMPLAYER_V_NUM
};

/* text pipeline's element id */
enum text_element_id {
	MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
	MMPLAYER_T_QUEUE,
	MMPLAYER_T_VIDEO_QUEUE,
	MMPLAYER_T_VIDEO_CONVERTER,
	MMPLAYER_T_OVERLAY,
	MMPLAYER_T_FAKE_SINK,
	MMPLAYER_T_IDENTITY,
	MMPLAYER_T_NUM
};

typedef enum {
	MMPLAYER_COMMAND_NONE,
	MMPLAYER_COMMAND_CREATE,
	MMPLAYER_COMMAND_DESTROY,
	MMPLAYER_COMMAND_UNREALIZE,
	MMPLAYER_COMMAND_START,
	MMPLAYER_COMMAND_REALIZE,
	MMPLAYER_COMMAND_STOP,
	MMPLAYER_COMMAND_PAUSE,
	MMPLAYER_COMMAND_RESUME,
	MMPLAYER_COMMAND_NUM
} mmplayer_command_state_e;

/* Note : mmplayer_streaming_src_error is error enum for streaming source which post error message
 *	using custom message made by itself. The enum value must start with zero,
 *	because the streaming source(secrtspsrc) also does.
 */
enum mmplayer_streaming_src_error {
	MMPLAYER_STREAMING_ERROR_NONE = 0,
	MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
	MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
	MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
	MMPLAYER_STREAMING_ERROR_DNS_FAIL,
	MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
	MMPLAYER_STREAMING_ERROR_BAD_SERVER,
	MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
	MMPLAYER_STREAMING_ERROR_INVALID_URL,
	MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
	MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
	MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
	MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
	MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
	MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
	MMPLAYER_STREAMING_ERROR_FORBIDDEN,
	MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
	MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
	MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
	MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
	MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
	MMPLAYER_STREAMING_ERROR_GONE,
	MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
	MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
	MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
	MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
	MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
	MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
	MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
	MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
	MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
	MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
	MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
	MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
	MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
	MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
	MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
	MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
	MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
	MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
	MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
	MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
	MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
	MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT	,
	MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
	MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
};

typedef enum {
	MMPLAYER_SEEK_NONE = 0,
	MMPLAYER_SEEK_IN_PROGRESS,
	MMPLAYER_SEEK_COMPLETED,	/* after getting async done but before posting seek complete */
} mmplayer_seek_state_e;

typedef enum {
	MMPLAYER_PATH_VOD = 0,
	MMPLAYER_PATH_TEXT,
	MMPLAYER_PATH_MAX
} mmplayer_path_type_e;

/* Video360 related enums. These are duplication from video360.h from
 * gst-plugins-tizen.
 * */
typedef enum {
	VIDEO360_MODE_UNKNOWN = -1,
	VIDEO360_MODE_MONOSCOPIC = 0,
	VIDEO360_MODE_STEREOSCOPIC_TOP_BOTTOM = 1,
	VIDEO360_MODE_STEREOSCOPIC_LEFT_RIGHT = 2,
	VIDEO360_MODE_STEREOSCOPIC_STEREO_MESH = 3,
	VIDEO360_MODE_LAST_ITEM
} mmplayer_stereo_mode_e;

typedef enum {
	VIDEO360_PROJECTION_TYPE_UNKNOWN = -1,
	VIDEO360_PROJECTION_TYPE_EQUIRECTANGULAR = 0,
	VIDEO360_PROJECTION_TYPE_CUBEMAP = 1,
	VIDEO360_PROJECTION_TYPE_MESH = 2,
	VIDEO360_PROJECTION_TYPE_LAST_ITEM
} mmplayer_projection_type_e;

/* Spatial audio related enums. These are duplication from mm_file.h from
 * libmm-fileinfo.
 * */
typedef enum {
	MMFILE_AMBISONIC_TYPE_UNKNOWN = 0,
	MMFILE_AMBISONIC_TYPE_PERIPHONIC = 1,		/**< To comply with Google's Spatial Audio RFC*/
	MMFILE_AMBISONIC_TYPE_NON_PERIPHONIC = 2,
} mmfile_ambisonic_type_e;

typedef enum {
	MMFILE_AMBISONIC_FORMAT_UNKNOWN = 0,
	MMFILE_AMBISONIC_FORMAT_AMBIX = 1,		/**< AMBIX (Channel sequence: ACN, Normalization: SN3D) */
	MMFILE_AMBISONIC_FORMAT_AMB = 2,		/**< .AMB, Tetraproc (Channel sequence: FuMa, Normalization: FuMa) */
	MMFILE_AMBISONIC_FORMAT_UA = 3,			/**< Universal Ambisonics (Channel sequence: SID, Normalization: N3D) */
} mmfile_ambisonic_format_e;

typedef enum {
	MMFILE_AMBISONIC_ORDER_UNKNOWN = 0,
	MMFILE_AMBISONIC_ORDER_FOA = 1,			/**< First order Ambisonics */
	MMFILE_AMBISONIC_ORDER_SOA = 2,			/**< Second order Ambisonics */
	MMFILE_AMBISONIC_ORDER_TOA = 3,			/**< Third order Ambisonics */
} mmfile_ambisonic_order_e;

typedef enum {
	MMPLAYER_RESOURCE_TYPE_VIDEO_DECODER,
	MMPLAYER_RESOURCE_TYPE_VIDEO_OVERLAY,
	MMPLAYER_RESOURCE_TYPE_AUDIO_OFFLOAD,
	MMPLAYER_RESOURCE_TYPE_MAX,
} mmplayer_resource_type_e;

/*---------------------------------------------------------------------------
|    GLOBAL DATA TYPE DEFINITIONS:											|
---------------------------------------------------------------------------*/

typedef struct {
	int id;
	GstElement *gst;
} mmplayer_gst_element_t;

typedef struct {
	GstTagList *tag_list;
	mmplayer_gst_element_t *mainbin;
	mmplayer_gst_element_t *audiobin;
	mmplayer_gst_element_t *videobin;
	mmplayer_gst_element_t *textbin;
} mmplayer_pipeline_info_t;

typedef struct {
	float volume;
	bool mute;
	bool rg_enable;
} mmplayer_sound_info_t;

typedef struct {
	char *buf;
	int len;
	int offset;
} mmplayer_input_buffer_t;

typedef struct {
	int uri_type;
	mmplayer_input_buffer_t input_mem;
	char uri[MM_MAX_URL_LEN];
	char urgent[MM_MAX_FILENAME_LEN];
} mmplayer_parse_profile_t;

typedef struct {
	storage_type_e type;
	storage_state_e state;
	int id;
	char path[MM_MAX_URL_LEN];
} mmplayer_storage_info_t;

typedef struct {
	bool is_pending;
	gint64 pos;
} mmplayer_pending_seek_t;

typedef struct {
	GObject *obj;
	gulong sig;
} mmplayer_signal_item_t;

typedef struct {
	bool rich_audio;
	bool video_zc; // video zero-copy
	bool subtitle_off;
	bool video_export;
} mmplayer_setting_mode_t; /* FIXME: renaming */

typedef struct {
	GMainContext *global_default;
	GMainContext *thread_default;
} mmplayer_context_info_t;

typedef struct {
	gint uri_idx;
	GList *uri_list;
} mmplayer_uri_list_t;

typedef struct {
	double scale_x;
	double scale_y;
	double scale_width;
	double scale_height;
} mmplayer_video_roi_t;

typedef struct {
	gint active_pad_index;
	gint total_track_num;
	GPtrArray *channels;
	gulong block_id;
	gulong event_probe_id;
} mmplayer_selector_t;

typedef struct {
	gboolean running;

	gboolean stream_changed;
	gboolean reconfigure;

	GstClockTime start_time[MM_PLAYER_TRACK_TYPE_MAX];	/* updated once get SEGMENT event */
	GstSegment segment[MM_PLAYER_TRACK_TYPE_MAX];
	gboolean update_segment[MM_PLAYER_TRACK_TYPE_MAX];

} mmplayer_gapless_t;

typedef struct {
	int channel;
	int bitrate;
	guint64 channel_mask;
	void *pcm_data;
	int data_size;
	int buff_size;
	media_format_mimetype_e pcm_format;
} mmplayer_audio_stream_buff_t;

/**
 * @brief data of video_bo_list
 * @details this will be used when the sw codec is running.
 * @since_tizen 3.0
 */
typedef struct {
	gboolean used;
	void *bo;
} mmplayer_video_bo_info_t;

typedef struct {
	gint bandwidth;
	gint width;
	gint height;
} stream_variant_t;

typedef struct {
	GList *var_list;
	stream_variant_t limit;
} mmplayer_adaptive_variant_info_t;

typedef struct {
	int is_spherical;
	int is_stitched;
	char *stitching_software;
	char *projection_type_string;
	char *stereo_mode_string;
	mmplayer_projection_type_e projection_type;
	mmplayer_stereo_mode_e stereo_mode;
	int source_count;
	int init_view_heading;
	int init_view_pitch;
	int init_view_roll;
	int timestamp;
	int full_pano_width_pixels;
	int full_pano_height_pixels;
	int cropped_area_image_width;
	int cropped_area_image_height;
	int cropped_area_left;
	int cropped_area_top;
	int ambisonic_type;
	int ambisonic_format;
	int ambisonic_order;
} mmplayer_spherical_metadata_t;

typedef struct {
	/* STATE */
	int state;					// player current state
	int prev_state;				// player previous state
	int pending_state;			// player state which is going to now
	int target_state;				// player state which user want to go to
	guint state_change_timeout;

	gchar *album_art;

	int cmd;

	/* command lock */
	GMutex cmd_lock;
	GMutex playback_lock;

	/* gapless play thread */
	GThread *gapless_play_thread;
	gboolean gapless_play_thread_exit;
	GCond gapless_play_thread_cond;
	GMutex gapless_play_thread_mutex;
	mmplayer_gapless_t gapless;

	/* capture thread */
	GThread *capture_thread;
	gboolean capture_thread_exit;
	GCond capture_thread_cond;
	GMutex capture_thread_mutex;
	mmplayer_video_capture_t capture;
	mmplayer_video_color_space_e video_cs;
	MMVideoBuffer captured;

	/* gst bus msg thread, create during realize */
	GThread *bus_msg_thread;
	gboolean bus_msg_thread_exit;
	GCond bus_msg_thread_cond;
	GMutex bus_msg_thread_mutex;

	/* fakesink handling lock */
	GMutex fsink_lock;

	/* update tag lock */
	GMutex update_tag_lock;

	/* player attributes */
	MMHandleType attrs;
	mmplayer_attrs_spec_t *default_attrs;

	/* message callback */
	MMMessageCallback msg_cb;
	void *msg_cb_param;

	/* streaming player */
	mmplayer_streaming_t *streamer;

	/* gstreamer pipeline */
	mmplayer_pipeline_info_t	*pipeline;

	/* pad */
	GstPad *ghost_pad_for_videobin;

	guint64 media_stream_buffer_max_size[MM_PLAYER_STREAM_TYPE_MAX];
	guint media_stream_buffer_min_percent[MM_PLAYER_STREAM_TYPE_MAX];

	/* audio stream changed callback */
	mm_player_stream_changed_callback audio_stream_changed_cb;
	void *audio_stream_changed_cb_user_param;

	/* video stream callback */
	mm_player_video_decoded_callback video_decoded_cb;
	void *video_decoded_cb_user_param;
	GCond video_bo_cond;
	GMutex video_bo_mutex;
	GList *video_bo_list; /* mmplayer_video_bo_info_t, bo list for decoded video data by sw codec */
	int video_bo_size;
	bool video_stream_prerolled;

	/* audio stream callback */
	mm_player_audio_decoded_callback audio_decoded_cb;
	void *audio_decoded_cb_user_param;
	GList *audio_stream_buff_list; /* mmplayer_audio_stream_buff_t, buff list of extract pcm data */
	mmplayer_audio_extract_opt_e audio_extract_opt;

	/* video capture callback*/
	gulong video_capture_cb_probe_id;

	/* sound info */
	mmplayer_sound_info_t	sound;

	/* type string */
	gchar *type;

	/* video stream caps parsed by demuxer */
	GstCaps *v_stream_caps;

	/* audio effect infomation */
	mm_audio_effect_info_t audio_effect_info;
	gboolean bypass_audio_effect;

	/* content profile */
	mmplayer_parse_profile_t profile;
	mmplayer_storage_info_t storage_info[MMPLAYER_PATH_MAX];

	/* streaming service type */
	MMStreamingType streaming_type;

	/* autoplugging */
	GList *factories;
	GList *audio_decoders; // list of linked audio name
	gboolean no_more_pad;
	gint num_dynamic_pad;
	gboolean has_many_types;

	/* progress callback timer */
	/* FIXIT : since duplicated functionality with get_position
	 * this function will be deprecated after fixing all application
	 * which are using it.
	 */
	guint progress_timer;

	/* timer for sending delayed EOS */
	guint eos_timer;

	/* last point that player is paused or seeking */
	gint64 last_position;

	/* duration */
	gint64 duration;

	/* data size of http streaming  */
	guint64 http_content_size;

	/* last error */
	gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */

	gboolean smooth_streaming;

	gint videodec_linked;
	gint audiodec_linked;
	gint textsink_linked;

	/* missing plugin during autoplugging */
	missing_codec_e not_supported_codec;

	/* unlinked audio/video mime type */
	gchar *unlinked_video_mime;
	gchar *unlinked_audio_mime;
	gchar *unlinked_demuxer_mime;

	/* found codec during autoplugging */
	found_codec_e can_support_codec;

	gboolean not_found_demuxer;

	/* support seek even though player is not start */
	mmplayer_pending_seek_t pending_seek;
	mmplayer_seek_state_e seek_state;

	/* prevent to post msg over and over */
	gboolean msg_posted;

	/* list of sink elements */
	GList *sink_elements;

	/* signal notifiers */
	GList *signals[MM_PLAYER_SIGNAL_TYPE_MAX];
	guint bus_watcher;
	GQueue *bus_msg_q;
	GMutex bus_msg_q_lock;
	mmplayer_context_info_t context;
	mmplayer_uri_list_t uri_info;

	gboolean is_sound_extraction;

	gfloat playback_rate;

	/* player state resumed by fast rewind */
	gboolean resumed_by_rewind;

	gboolean is_nv12_tiled;

	/* resource manager for H/W resources */
	mm_resource_manager_h resource_manager;
	mm_resource_manager_res_h hw_resource[MMPLAYER_RESOURCE_TYPE_MAX];
	gboolean interrupted_by_resource;

	gboolean is_subtitle_off;
	gboolean is_external_subtitle_present;
	gboolean is_external_subtitle_added_now;
	gboolean pending_resume;

	/* contents bitrate for buffering management */
	guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
	guint total_bitrate;
	guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
	guint total_maximum_bitrate;

	/* prevent it from posting duplicatly*/
	gboolean sent_bos;

	gboolean play_subtitle;
	gboolean is_subtitle_force_drop;	// set TRUE after bus_cb get EOS

	/* adjust subtitle position store */
	gint64 adjust_subtitle_pos;
	GList *subtitle_language_list;
	GCond subtitle_info_cond;
	GMutex subtitle_info_mutex;

	/* To store the current running audio pad index of demuxer */
	gint demux_pad_index;

	mmplayer_selector_t selector[MM_PLAYER_TRACK_TYPE_MAX];

	guint internal_text_idx;
	guint external_text_idx;

	mmplayer_setting_mode_t set_mode;

	/* initialize values */
	mmplayer_ini_t ini;

	/* store dump pad list */
	GList *dump_list;

	/* whether a video has closed caption or not */
	gboolean has_closed_caption;


	/* audio stream caps parsed by demuxer or set by external demuxer */
	GstCaps *a_stream_caps;

	/* subtitle stream caps parsed by demuxer or set by external demuxer */
	GstCaps *s_stream_caps;

	/* es player using feed-data callback or calling app_src_push_buffer directly*/
	gboolean es_player_push_mode;

	/* tmb buffer manager for s/w codec tmb_bo */
	tbm_bufmgr bufmgr;

	mmplayer_adaptive_variant_info_t adaptive_info;

	/* Video360 related stuff
	 * */
	gboolean is_360_feature_enabled;
	gboolean is_content_spherical;
	mmplayer_spherical_metadata_t video360_metadata;
	gboolean is_openal_plugin_used;
	/* User settable values */
	gboolean is_video360_enabled;
	float video360_yaw_radians;
	float video360_pitch_radians;
	float video360_zoom;
	int video360_horizontal_fov;
	int video360_vertical_fov;

	/* Video ROI area scale value */
	mmplayer_video_roi_t video_roi;

	/* build audio offload */
	gboolean build_audio_offload;
	guint audio_device_cb_id;

	int client_pid;
} mmplayer_t;

typedef struct {
	gchar *language_code;
	gchar *language_key;
	gboolean active;
} mmplayer_lang_info_t;

typedef struct {
	GstPad *dump_pad;
	gulong probe_handle_id;
	FILE *dump_element_file;
} mmplayer_dump_t;

/*===========================================================================================
|																							|
|  GLOBAL FUNCTION PROTOTYPES																|
|																							|
========================================================================================== */
#ifdef __cplusplus
	extern "C" {
#endif

int _mmplayer_create_player(MMHandleType hplayer);
int _mmplayer_destroy(MMHandleType hplayer);
int _mmplayer_realize(MMHandleType hplayer);
int _mmplayer_unrealize(MMHandleType hplayer);
int _mmplayer_get_state(MMHandleType hplayer, int *state);
int _mmplayer_set_volume(MMHandleType hplayer, float volume);
int _mmplayer_get_volume(MMHandleType hplayer, float *volume);
int _mmplayer_set_mute(MMHandleType hplayer, bool mute);
int _mmplayer_get_mute(MMHandleType hplayer, bool *mute);
int _mmplayer_start(MMHandleType hplayer);
int _mmplayer_stop(MMHandleType hplayer);
int _mmplayer_pause(MMHandleType hplayer);
int _mmplayer_abort_pause(MMHandleType hplayer);
int _mmplayer_resume(MMHandleType hplayer);
int _mmplayer_set_position(MMHandleType hplayer, gint64 pos);
int _mmplayer_get_duration(MMHandleType hplayer, gint64 *duration);
int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int pos);
int _mmplayer_set_playspeed(MMHandleType hplayer, float rate, bool streaming);
int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
int _mmplayer_set_audiostream_changed_cb(MMHandleType hplayer, mm_player_stream_changed_callback callback, void *user_param);
int _mmplayer_set_video_decoded_cb(MMHandleType hplayer, mm_player_video_decoded_callback callback, void *user_param);
int _mmplayer_set_subtitle_silent(MMHandleType hplayer, int silent);
int _mmplayer_get_subtitle_silent(MMHandleType hplayer, int *silent);
int _mmplayer_set_external_subtitle_path(MMHandleType hplayer, const char *filepath);
int _mmplayer_get_buffer_position(MMHandleType hplayer, int *start_pos, int *end_pos);
int _mmplayer_update_video_overlay_param(mmplayer_t *player, const char *param_name);
int _mmplayer_change_videosink(MMHandleType handle, MMDisplaySurfaceType surface_type, int wl_surface_id);
int _mmplayer_audio_effect_custom_apply(mmplayer_t *player);
int _mmplayer_set_audio_decoded_cb(MMHandleType hplayer, mmplayer_audio_extract_opt_e opt, mm_player_audio_decoded_callback callback, void *user_param);
int _mmplayer_change_track_language(MMHandleType hplayer, mmplayer_track_type_e type, int index);
int _mmplayer_sync_subtitle_pipeline(mmplayer_t *player);
int _mmplayer_use_system_clock(MMHandleType hplayer);
int _mmplayer_set_uri(MMHandleType hplayer, const char *uri);
int _mmplayer_set_next_uri(MMHandleType hplayer, const char *uri, bool is_first_path);
int _mmplayer_get_next_uri(MMHandleType hplayer, char **uri);
int _mmplayer_has_closed_caption(MMHandleType hplayer, bool *exist);
void _mm_player_video_stream_internal_buffer_unref(void *buffer);
int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int id, int state);
int _mmplayer_video_stream_release_bo(mmplayer_t *player, void *bo);
int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **var_info);
int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth, int width, int height);
int _mmplayer_get_max_adaptive_variant_limit(MMHandleType hplayer, int *bandwidth, int *width, int *height);
int _mmplayer_set_audio_only(MMHandleType hplayer, bool audio_only);
int _mmplayer_get_audio_only(MMHandleType hplayer, bool *paudio_only);
int _mmplayer_get_streaming_buffering_time(MMHandleType hplayer, int *prebuffer_ms, int *rebuffer_ms);
int _mmplayer_set_codec_type(MMHandleType hplayer, mmplayer_stream_type_e stream_type, mmplayer_codec_type_e codec_type);
int _mmplayer_set_replaygain_enabled(MMHandleType hplayer, bool enabled);
int _mmplayer_is_replaygain_enabled(MMHandleType hplayer, bool *enabled);
int _mmplayer_set_video_roi_area(MMHandleType hplayer, double scale_x, double scale_y, double scale_width, double scale_height);
int _mmplayer_get_video_roi_area(MMHandleType hplayer, double *scale_x, double *scale_y, double *scale_width, double *scale_height);
int _mmplayer_audio_offload_is_activated(MMHandleType hplayer, bool *activated);
int _mmplayer_is_audio_control_available(MMHandleType hplayer, mmplayer_audio_control_opt_e opt, bool *available);

/* internal */
void _mmplayer_bus_msg_thread_destroy(MMHandleType hplayer);
void _mmplayer_set_state(mmplayer_t *player, int state);
int _mmplayer_check_state(mmplayer_t *player, mmplayer_command_state_e command);
gboolean _mmplayer_update_content_attrs(mmplayer_t *player, enum content_attr_flag flag);
void _mmplayer_cancel_eos_timer(mmplayer_t *player);
void _mmplayer_audio_stream_clear_buffer(mmplayer_t *player, gboolean send_all);
MMStreamingType _mmplayer_get_stream_service_type(mmplayer_t *player);
int _mmplayer_get_video_angle(mmplayer_t *player, int *display_angle, int *orientations);
gboolean _mmplayer_gst_remove_fakesink(mmplayer_t *player, mmplayer_gst_element_t *fakesink);
void _mmplayer_add_signal_connection(mmplayer_t *player, GObject *object, mmplayer_signal_type_e type, const gchar *signal, GCallback cb_funct, gpointer u_data);
void _mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data);
gint _mmplayer_gst_decode_autoplug_select(GstElement *bin,  GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer data);
gboolean _mmplayer_gst_create_decoder(mmplayer_t *player, GstPad *srcpad, const GstCaps *caps);
void _mmplayer_gst_element_added(GstElement *bin, GstElement *element, gpointer data);
GstElement *_mmplayer_gst_make_decodebin(mmplayer_t *player);
int _mmplayer_gst_element_add_bucket_to_bin(GstBin *bin, GList *element_bucket);
int _mmplayer_gst_element_link_bucket(GList *element_bucket);
void _mmplayer_typefind_have_type(GstElement *tf, guint probability, GstCaps *caps, gpointer data);
int _mmplayer_parse_profile(const char *uri, void *param, mmplayer_parse_profile_t *data);
int _mmplayer_set_client_pid(MMHandleType hplayer, int pid);

#ifdef __cplusplus
	}
#endif

#endif	/* __MM_PLAYER_PRIV_H__ */