4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MM_PLAYER_PRIV_H__
23 #define __MM_PLAYER_PRIV_H__
25 /*===========================================================================================
29 ========================================================================================== */
37 #include "mm_player.h"
38 #include "mm_player_internal.h"
39 #include "mm_player_audioeffect.h"
40 #include "mm_message.h"
41 #include "mm_player_utils.h"
42 #include "mm_player_asm.h"
43 #include "mm_player_pd.h"
44 #include "mm_player_streaming.h"
46 /*===========================================================================================
48 | GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE |
50 ========================================================================================== */
52 /*---------------------------------------------------------------------------
54 ---------------------------------------------------------------------------*/
56 #define MM_PLAYER_IMGB_MPLANE_MAX 4
57 #define MM_PLAYER_STREAM_COUNT_MAX 3
59 #define MM_PLAYER_CAST(x_player) ((mm_player_t *)(x_player))
61 * @x_player: MMHandleType of player
63 * Get the PD downloader of this player.
65 #define MM_PLAYER_GET_PD(x_player) (MM_PLAYER_CAST(x_player)->pd_downloader)
67 * @x_player: MMHandleType of player
69 * Get the attributes handle of this player.
71 #define MM_PLAYER_GET_ATTRS(x_player) (MM_PLAYER_CAST(x_player)->attrs)
73 /*---------------------------------------------------------------------------
74 | GLOBAL CONSTANT DEFINITIONS: |
75 ---------------------------------------------------------------------------*/
78 TAG_AUDIO_CODEC = 0x0001,
79 TAG_VIDEO_CODEC = 0x0002,
84 TAG_COPYRIGHT = 0x0040,
86 TAG_DESCRIPTION = 0x0100,
87 TAG_TRACK_NUMBER = 0x0200
90 /* async mode makes trouble. alsasink sometimes fails to pause. */
99 * Enumerations of Player Mode
102 MM_PLAYER_MODE_NONE, /**< Player mode None */
103 MM_PLAYER_MODE_MIDI, /**< Player mode Midi */
104 MM_PLAYER_MODE_GST, /**< Player mode Gstreamer */
109 * Enumerations of Player Uri type
111 enum MMPlayerUriType {
112 MM_PLAYER_URI_TYPE_NONE, /**< Player URI type None */
113 MM_PLAYER_URI_TYPE_URL_RTSP, /**< Player URI type RTSP */
114 MM_PLAYER_URI_TYPE_URL_HTTP,/**< Player URI type HTTP */
115 MM_PLAYER_URI_TYPE_URL_MMS,/**< Player URI type MMS */
116 MM_PLAYER_URI_TYPE_MEM, /**< Player URI type Mem */
117 MM_PLAYER_URI_TYPE_FILE, /**< Player URI type File */
118 MM_PLAYER_URI_TYPE_URL, /**< Player URI type URL */
119 MM_PLAYER_URI_TYPE_BUFF, /**< Player URI type Buffer */
120 MM_PLAYER_URI_TYPE_HLS, /**< Player URI type http live streaming */
121 MM_PLAYER_URI_TYPE_TEMP, /**< Player URI type Temp */
124 typedef enum _MissingCodec
126 MISSING_PLUGIN_NONE = 0x00,
127 MISSING_PLUGIN_AUDIO = 0x01,
128 MISSING_PLUGIN_VIDEO = 0x02
132 typedef enum _FoundCodec
134 FOUND_PLUGIN_NONE = 0x00,
135 FOUND_PLUGIN_AUDIO = 0x01,
136 FOUND_PLUGIN_VIDEO = 0x02
139 /* main pipeline's element id */
142 MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
146 /* it could be a decodebin or could be a typefind. depends on player ini */
149 /* NOTE : we need two fakesink to autoplug without decodebin.
150 * first one will hold whole pipeline state. and second one will hold state of
151 * a sink-decodebin for an elementary stream. no metter if there's more then one
152 * elementary streams because MSL reuse it.
154 MMPLAYER_M_SRC_FAKESINK,
155 MMPLAYER_M_SRC_2ND_FAKESINK,
157 /* streaming plugin */
162 /* FIXIT : if there's really no usage for following IDs. remove it */
172 /* audio pipeline's element id */
175 MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
180 MMPLAYER_A_CAPS_DEFAULT,
182 MMPLAYER_A_RESAMPLER,
186 /* video pipeline's element id */
189 MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
198 /* text pipeline's element id */
201 MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
202 MMPLAYER_T_TEXT_QUEUE,
203 MMPLAYER_T_VIDEO_QUEUE,
204 MMPLAYER_T_VIDEO_CONVERTER,
210 /* midi main pipeline's element id */
214 MMPLAYER_MIDI_PLAYER,
218 enum PlayerCommandState
220 MMPLAYER_COMMAND_NONE,
221 MMPLAYER_COMMAND_CREATE,
222 MMPLAYER_COMMAND_DESTROY,
223 MMPLAYER_COMMAND_UNREALIZE,
224 MMPLAYER_COMMAND_START,
225 MMPLAYER_COMMAND_REALIZE,
226 MMPLAYER_COMMAND_STOP,
227 MMPLAYER_COMMAND_PAUSE,
228 MMPLAYER_COMMAND_RESUME,
232 /* Note : StreamingSrcError is error enum for streaming source which post error message
233 * using custom message made by itself. The enum value must start with zero,
234 * because the streaming source(secrtspsrc) also does.
236 enum StreamingSrcError
238 MMPLAYER_STREAMING_ERROR_NONE = 0,
239 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
240 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
241 MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
242 MMPLAYER_STREAMING_ERROR_DNS_FAIL,
243 MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
244 MMPLAYER_STREAMING_ERROR_BAD_SERVER,
245 MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
246 MMPLAYER_STREAMING_ERROR_INVALID_URL,
247 MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
248 MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
249 MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
250 MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
251 MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
252 MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
253 MMPLAYER_STREAMING_ERROR_FORBIDDEN,
254 MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
255 MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
256 MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
257 MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
258 MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
259 MMPLAYER_STREAMING_ERROR_GONE,
260 MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
261 MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
262 MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
263 MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
264 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
265 MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
266 MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
267 MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
268 MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
269 MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
270 MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
271 MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
272 MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
273 MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
274 MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
275 MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
276 MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
277 MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
278 MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
279 MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
280 MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
281 MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT ,
282 MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
283 MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
287 /*---------------------------------------------------------------------------
288 | GLOBAL DATA TYPE DEFINITIONS: |
289 ---------------------------------------------------------------------------*/
295 } MMPlayerGstElement;
299 GstTagList *tag_list;
300 MMPlayerGstElement *mainbin;
301 MMPlayerGstElement *audiobin;
302 MMPlayerGstElement *videobin;
303 MMPlayerGstElement *textbin;
304 } MMPlayerGstPipelineInfo;
308 char device[MAX_SOUND_DEVICE_LEN];
311 int bluetooth; /* enable/disable */
319 } tBuffer; /* FIXIT : choose better name */
326 char uri[MM_MAX_URL_LEN];
327 char urgent[MM_MAX_FILENAME_LEN];
328 } MMPlayerParseProfile;
332 MMPlayerPosFormatType format;
334 }MMPlayerPendingSeek;
339 } MMPlayerSignalItem;
341 /* image buffer definition ***************************************************
343 +------------------------------------------+ ---
346 | +---------------------------+ --- | |
348 | |<---------- w[] ---------->| | | |
356 | +---------------------------+ --- | |
358 +------------------------------------------+ ---
360 |<----------------- s[] ------------------>|
364 /* width of each image plane */
365 int w[MM_PLAYER_IMGB_MPLANE_MAX];
366 /* height of each image plane */
367 int h[MM_PLAYER_IMGB_MPLANE_MAX];
368 /* stride of each image plane */
369 int s[MM_PLAYER_IMGB_MPLANE_MAX];
370 /* elevation of each image plane */
371 int e[MM_PLAYER_IMGB_MPLANE_MAX];
372 /* user space address of each image plane */
373 void *a[MM_PLAYER_IMGB_MPLANE_MAX];
374 /* physical address of each image plane, if needs */
375 void *p[MM_PLAYER_IMGB_MPLANE_MAX];
376 /* color space type of image */
378 /* left postion, if needs */
380 /* top position, if needs */
382 /* to align memory */
388 int fd[MM_PLAYER_IMGB_MPLANE_MAX];
390 /* flag for buffer share */
391 int buf_share_method;
393 /*y, cbcr size for bookmark */
396 } MMPlayerMPlaneImage;
400 int state; // player current state
401 int prev_state; // player previous state
402 int pending_state; // player state which is going to now
403 int target_state; // player state which user want to go to
404 guint state_change_timeout;
406 gboolean section_repeat;
407 gint section_repeat_start;
408 gint section_repeat_end;
417 /* repeat thread lock */
418 GCond* repeat_thread_cond;
419 GMutex* repeat_thread_mutex;
420 GThread* repeat_thread;
421 gboolean repeat_thread_exit;
424 GThread* capture_thread;
425 gboolean capture_thread_exit;
426 GCond* capture_thread_cond;
427 GMutex* capture_thread_mutex;
428 MMPlayerVideoCapture capture;
429 MMPlayerVideoColorspace video_cs;
430 MMPlayerMPlaneImage captured;
432 /* fakesink handling lock */
435 /* player attributes */
438 /* message callback */
439 MMMessageCallback msg_cb;
443 /* progressive download */
444 mm_player_pd_t *pd_downloader;
445 gchar *pd_file_save_path;
446 MMPlayerPDMode pd_mode;
448 /* streaming player */
449 mm_player_streaming_t *streamer;
451 /* gstreamer pipeline */
452 MMPlayerGstPipelineInfo *pipeline;
453 gboolean pipeline_is_constructed;
455 /* Buffering support cbs*/
456 mm_player_buffer_need_data_callback need_data_cb;
457 mm_player_buffer_enough_data_callback enough_data_cb;
458 mm_player_buffer_seek_data_callback seek_data_cb;
460 void* buffer_cb_user_param;
462 /* for video stream callback */
463 mm_player_video_stream_callback video_stream_cb;
464 void* video_stream_cb_user_param;
465 int use_video_stream;
467 /* audio stram callback */
468 mm_player_audio_stream_callback audio_stream_cb;
469 void* audio_stream_cb_user_param;
471 /* audio buffer callback */
472 mm_player_audio_stream_callback audio_buffer_cb;
473 void* audio_buffer_cb_user_param;
475 /* video capture callback*/
476 gulong video_capture_cb_probe_id;
479 MMPlayerSoundInfo sound;
484 /* video stream caps parsed by demuxer */
485 GstCaps* v_stream_caps;
487 /* audio effect infomation */
488 MMAudioEffectInfo audio_effect_info;
489 gboolean bypass_audio_effect;
491 gulong audio_cb_probe_id;
496 /* content profile */
497 MMPlayerParseProfile profile;
499 /* streaming service type */
500 MMStreamingType streaming_type;
504 gboolean have_dynamic_pad;
505 GList* parsers; // list of linked parser name
506 gboolean no_more_pad;
507 gint num_dynamic_pad;
508 gboolean has_many_types;
510 /* progress callback timer */
511 /* FIXIT : since duplicated functionality with get_position
512 * this function will be deprecated after fixing all application
513 * which are using it.
515 guint progress_timer;
517 /* timer for sending delayed EOS */
520 /* last point (msec) that player is paused or seeking */
521 gint64 last_position;
526 /* data size of http streaming */
527 guint64 http_content_size;
530 gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
532 gint videodec_linked;
533 gint audiodec_linked;
534 gint videosink_linked;
535 gint audiosink_linked;
536 gint textsink_linked;
538 /* missing plugin during autoplugging */
539 MissingCodec not_supported_codec;
541 /*unlinked audio/video mime type */
542 gchar *unlinked_video_mime;
543 gchar *unlinked_audio_mime;
544 gchar *unlinked_demuxer_mime;
546 /* found codec during autoplugging */
547 FoundCodec can_support_codec;
549 gboolean not_found_demuxer;
551 /* support seek even though player is not start */
552 MMPlayerPendingSeek pending_seek;
556 /* prevent to post msg over and over */
559 /* list of sink elements */
560 GList* sink_elements;
562 /* signal notifiers */
566 /* NOTE : if sink elements receive flush start event then it's state will be lost.
567 * this can happen when doing buffering in streaming pipeline since all control operation
568 * (play/pause/resume/seek) is requiring server interaction. during 'state lost' situation
569 * _set_state will not work correctely and state transition message will not posted to our
571 * So. we need to do some special care on the situation.
575 gboolean need_update_content_attrs;
576 gboolean need_update_content_dur;
578 gboolean is_sound_extraction;
580 gdouble playback_rate;
581 /* player state resumed by fast rewind */
582 gboolean resumed_by_rewind;
584 gboolean is_nv12_tiled;
588 gboolean is_subtitle_off;
590 /* contents bitrate for buffering management */
591 guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
593 guint updated_bitrate_count;
594 guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
595 guint total_maximum_bitrate;
596 guint updated_maximum_bitrate_count;
598 /* prevent it from posting duplicatly*/
601 /* timeout source for lazy pause */
602 guint lazy_pause_event_id;
604 gboolean keep_detecting_vcodec;
606 gboolean play_subtitle;
607 gboolean use_textoverlay;
609 /* PD downloader message callback and param */
610 MMMessageCallback pd_msg_cb;
611 void* pd_msg_cb_param;
614 /*===========================================================================================
616 | GLOBAL FUNCTION PROTOTYPES |
618 ========================================================================================== */
623 int _mmplayer_create_player(MMHandleType hplayer);
624 int _mmplayer_destroy(MMHandleType hplayer);
625 int _mmplayer_realize(MMHandleType hplayer);
626 int _mmplayer_unrealize(MMHandleType hplayer);
627 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
628 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
629 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
630 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
631 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
632 int _mmplayer_start(MMHandleType hplayer);
633 int _mmplayer_stop(MMHandleType hplayer);
634 int _mmplayer_pause(MMHandleType hplayer);
635 int _mmplayer_resume(MMHandleType hplayer);
636 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
637 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
638 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int pos);
639 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
640 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
641 int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size);
642 int _mmplayer_set_buffer_need_data_cb(MMHandleType hplayer,mm_player_buffer_need_data_callback callback, void *user_param);
643 int _mmplayer_set_buffer_enough_data_cb(MMHandleType hplayer,mm_player_buffer_enough_data_callback callback, void *user_param);
644 int _mmplayer_set_buffer_seek_data_cb(MMHandleType hplayer,mm_player_buffer_seek_data_callback callback, void *user_param);
645 int _mmplayer_set_playspeed(MMHandleType hplayer, gdouble rate);
646 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
647 int _mmplayer_set_videostream_cb(MMHandleType hplayer,mm_player_video_stream_callback callback, void *user_param);
648 int _mmplayer_set_audiostream_cb(MMHandleType hplayer,mm_player_audio_stream_callback callback, void *user_param);
649 int _mmplayer_set_subtitle_silent (MMHandleType hplayer, int silent);
650 int _mmplayer_get_subtitle_silent (MMHandleType hplayer, int* silent);
651 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
652 gboolean _mmplayer_update_content_attrs(mm_player_t* player);
653 /* test API for tuning audio gain. this API should be
654 * deprecated before the day of final release
656 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
657 int _mmplayer_update_video_param(mm_player_t* player);
658 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
664 #endif /* __MM_PLAYER_PRIV_H__ */