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