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