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