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>,
7 * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #ifndef __MM_PLAYER_PRIV_H__
24 #define __MM_PLAYER_PRIV_H__
26 /*===========================================================================================
30 ========================================================================================== */
38 #include "mm_player.h"
39 #include "mm_player_internal.h"
40 #include "mm_player_sndeffect.h"
41 #include "mm_message.h"
42 #include "mm_player_utils.h"
43 #include "mm_player_asm.h"
44 #include "mm_player_ahs.h"
45 #include "mm_player_pd.h"
46 #include "mm_player_streaming.h"
48 /*===========================================================================================
50 | GLOBAL DEFINITIONS AND DECLARATIONS FOR MODULE |
52 ========================================================================================== */
54 /*---------------------------------------------------------------------------
56 ---------------------------------------------------------------------------*/
58 #define MM_PLAYER_IMGB_MPLANE_MAX 4
59 #define MM_PLAYER_STREAM_COUNT_MAX 3
61 #define MM_PLAYER_CAST(x_player) ((mm_player_t *)(x_player))
63 * @x_player: MMHandleType of player
65 * Get the PD downloader of this player.
67 #define MM_PLAYER_GET_PD(x_player) (MM_PLAYER_CAST(x_player)->pd_downloader)
69 * @x_player: MMHandleType of player
71 * Get the attributes handle of this player.
73 #define MM_PLAYER_GET_ATTRS(x_player) (MM_PLAYER_CAST(x_player)->attrs)
75 /*---------------------------------------------------------------------------
76 | GLOBAL CONSTANT DEFINITIONS: |
77 ---------------------------------------------------------------------------*/
80 TAG_AUDIO_CODEC = 0x0001,
81 TAG_VIDEO_CODEC = 0x0002,
86 TAG_COPYRIGHT = 0x0040,
88 TAG_DESCRIPTION = 0x0100,
89 TAG_TRACK_NUMBER = 0x0200
92 /* async mode makes trouble. alsasink sometimes fails to pause. */
101 * Enumerations of Player Mode
104 MM_PLAYER_MODE_NONE, /**< Player mode None */
105 MM_PLAYER_MODE_MIDI, /**< Player mode Midi */
106 MM_PLAYER_MODE_GST, /**< Player mode Gstreamer */
111 * Enumerations of Player Uri type
113 enum MMPlayerUriType {
114 MM_PLAYER_URI_TYPE_NONE, /**< Player URI type None */
115 MM_PLAYER_URI_TYPE_URL_RTSP, /**< Player URI type RTSP */
116 MM_PLAYER_URI_TYPE_URL_HTTP,/**< Player URI type HTTP */
117 MM_PLAYER_URI_TYPE_URL_MMS,/**< Player URI type MMS */
118 MM_PLAYER_URI_TYPE_MEM, /**< Player URI type Mem */
119 MM_PLAYER_URI_TYPE_FILE, /**< Player URI type File */
120 MM_PLAYER_URI_TYPE_URL, /**< Player URI type URL */
121 MM_PLAYER_URI_TYPE_BUFF, /**< Player URI type Buffer */
122 MM_PLAYER_URI_TYPE_HLS, /**< Player URI type http live streaming */
123 MM_PLAYER_URI_TYPE_TEMP, /**< Player URI type Temp */
126 typedef enum _MissingCodec
128 MISSING_PLUGIN_NONE = 0x00,
129 MISSING_PLUGIN_AUDIO = 0x01,
130 MISSING_PLUGIN_VIDEO = 0x02
134 typedef enum _FoundCodec
136 FOUND_PLUGIN_NONE = 0x00,
137 FOUND_PLUGIN_AUDIO = 0x01,
138 FOUND_PLUGIN_VIDEO = 0x02
141 /* main pipeline's element id */
144 MMPLAYER_M_PIPE = 0, /* NOTE : MMPLAYER_M_PIPE should be zero */
147 /* it could be a decodebin or could be a typefind. depends on player ini */
150 /* NOTE : we need two fakesink to autoplug without decodebin.
151 * first one will hold whole pipeline state. and second one will hold state of
152 * a sink-decodebin for an elementary stream. no metter if there's more then one
153 * elementary streams because MSL reuse it.
155 MMPLAYER_M_SRC_FAKESINK,
156 MMPLAYER_M_SRC_2ND_FAKESINK,
158 /* streaming plugin */
163 /* 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 */
199 /* text pipeline's element id */
202 MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
209 /* subtitle pipeline's element id */
210 enum SubtitleElementID
212 MMPLAYER_SUB_PIPE = 0, /* NOTE : MMPLAYER_SUB_PIPE should be zero */
215 MMPLAYER_SUB_SUBPARSE,
216 MMPLAYER_SUB_TEXTRENDER,
225 /* midi main pipeline's element id */
229 MMPLAYER_MIDI_PLAYER,
233 enum PlayerCommandState
235 MMPLAYER_COMMAND_NONE,
236 MMPLAYER_COMMAND_CREATE,
237 MMPLAYER_COMMAND_DESTROY,
238 MMPLAYER_COMMAND_REALIZE,
239 MMPLAYER_COMMAND_UNREALIZE,
240 MMPLAYER_COMMAND_START,
241 MMPLAYER_COMMAND_STOP,
242 MMPLAYER_COMMAND_PAUSE,
243 MMPLAYER_COMMAND_RESUME,
247 /* Note : StreamingSrcError is error enum for streaming source which post error message
248 * using custom message made by itself. The enum value must start with zero,
249 * because the streaming source(secrtspsrc) also does.
251 enum StreamingSrcError
253 MMPLAYER_STREAMING_ERROR_NONE = 0,
254 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
255 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
256 MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
257 MMPLAYER_STREAMING_ERROR_DNS_FAIL,
258 MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
259 MMPLAYER_STREAMING_ERROR_BAD_SERVER,
260 MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
261 MMPLAYER_STREAMING_ERROR_INVALID_URL,
262 MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
263 MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
264 MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
265 MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
266 MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
267 MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
268 MMPLAYER_STREAMING_ERROR_FORBIDDEN,
269 MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
270 MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
271 MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
272 MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
273 MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
274 MMPLAYER_STREAMING_ERROR_GONE,
275 MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
276 MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
277 MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
278 MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
279 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
280 MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
281 MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
282 MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
283 MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
284 MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
285 MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
286 MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
287 MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
288 MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
289 MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
290 MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
291 MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
292 MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
293 MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
294 MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
295 MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
296 MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT ,
297 MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
298 MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
302 /*---------------------------------------------------------------------------
303 | GLOBAL DATA TYPE DEFINITIONS: |
304 ---------------------------------------------------------------------------*/
310 } MMPlayerGstElement;
314 GstTagList *tag_list;
315 MMPlayerGstElement *mainbin;
316 MMPlayerGstElement *subtitlebin;
317 MMPlayerGstElement *audiobin;
318 MMPlayerGstElement *videobin;
319 MMPlayerGstElement *textbin;
320 } MMPlayerGstPipelineInfo;
324 char device[MAX_SOUND_DEVICE_LEN];
327 int bluetooth; /* enable/disable */
335 } tBuffer; /* FIXIT : choose better name */
342 char uri[MM_MAX_URL_LEN];
343 char urgent[MM_MAX_FILENAME_LEN];
344 } MMPlayerParseProfile;
348 MMPlayerPosFormatType format;
350 }MMPlayerPendingSeek;
355 } MMPlayerSignalItem;
357 /* image buffer definition ***************************************************
359 +------------------------------------------+ ---
362 | +---------------------------+ --- | |
364 | |<---------- w[] ---------->| | | |
372 | +---------------------------+ --- | |
374 +------------------------------------------+ ---
376 |<----------------- s[] ------------------>|
380 /* width of each image plane */
381 int w[MM_PLAYER_IMGB_MPLANE_MAX];
382 /* height of each image plane */
383 int h[MM_PLAYER_IMGB_MPLANE_MAX];
384 /* stride of each image plane */
385 int s[MM_PLAYER_IMGB_MPLANE_MAX];
386 /* elevation of each image plane */
387 int e[MM_PLAYER_IMGB_MPLANE_MAX];
388 /* user space address of each image plane */
389 void *a[MM_PLAYER_IMGB_MPLANE_MAX];
390 /* physical address of each image plane, if needs */
391 void *p[MM_PLAYER_IMGB_MPLANE_MAX];
392 /* color space type of image */
394 /* left postion, if needs */
396 /* top position, if needs */
398 /* to align memory */
402 } MMPlayerMPlaneImage;
406 int state; // player current state
407 int prev_state; // player previous state
408 int pending_state; // player state which is going to now
409 int target_state; // player state which user want to go to
410 guint state_change_timeout;
412 gboolean section_repeat;
413 gint section_repeat_start;
414 gint section_repeat_end;
423 /* handle of adaptive http streaming */
424 mm_player_ahs_t *ahs_player;
426 /* repeat thread lock */
427 GCond* repeat_thread_cond;
428 GMutex* repeat_thread_mutex;
429 GThread* repeat_thread;
430 gboolean repeat_thread_exit;
433 GThread* capture_thread;
434 gboolean capture_thread_exit;
435 GCond* capture_thread_cond;
436 GMutex* capture_thread_mutex;
437 MMPlayerVideoCapture capture;
438 MMPlayerVideoColorspace video_cs;
439 MMPlayerMPlaneImage captured;
441 /* fakesink handling lock */
444 /* player attributes */
447 /* message callback */
448 MMMessageCallback msg_cb;
452 /* progressive download */
453 mm_player_pd_t *pd_downloader;
454 gchar *pd_file_location;
455 MMPlayerPDMode pd_mode;
457 /* streaming player */
458 mm_player_streaming_t *streamer;
460 /* gstreamer pipeline */
461 MMPlayerGstPipelineInfo *pipeline;
462 gboolean pipeline_is_constructed;
464 /* Buffering support cbs*/
465 mm_player_buffer_need_data_callback need_data_cb;
466 mm_player_buffer_enough_data_callback enough_data_cb;
467 mm_player_buffer_seek_data_callback seek_data_cb;
469 void* buffer_cb_user_param;
471 /* for video stream callback */
472 mm_player_video_stream_callback video_stream_cb;
473 void* video_stream_cb_user_param;
474 int use_video_stream;
476 /* audio stram callback */
477 mm_player_audio_stream_callback audio_stream_cb;
478 void* audio_stream_cb_user_param;
480 /* audio buffer callback */
481 mm_player_audio_stream_callback audio_buffer_cb;
482 void* audio_buffer_cb_user_param;
484 /* video capture callback*/
485 gulong video_capture_cb_probe_id;
488 MMPlayerSoundInfo sound;
493 /* video stream caps parsed by demuxer */
494 GstCaps* v_stream_caps;
496 /* audio filter infomation */
497 MMAudioFilterInfo audio_filter_info;
498 gboolean bypass_sound_effect;
500 gulong audio_cb_probe_id;
505 /* content profile */
506 MMPlayerParseProfile profile;
508 /* streaming service type */
509 MMStreamingType streaming_type;
513 gboolean have_dynamic_pad;
514 GList* parsers; // list of linked parser name
515 gboolean no_more_pad;
516 gint num_dynamic_pad;
517 gboolean has_many_types;
519 /* progress callback timer */
520 /* FIXIT : since duplicated functionality with get_position
521 * this function will be deprecated after fixing all application
522 * which are using it.
524 guint progress_timer;
526 /* timer for sending delayed EOS */
529 /* last point (msec) that player is paused or seeking */
530 gint64 last_position;
535 /* data size of http streaming */
536 guint64 http_content_size;
539 gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
541 gint videodec_linked;
542 gint audiodec_linked;
543 gint videosink_linked;
544 gint audiosink_linked;
545 gint textsink_linked;
547 /* missing plugin during autoplugging */
548 MissingCodec not_supported_codec;
550 /*unlinked audio/video mime type */
551 gchar *unlinked_video_mime;
552 gchar *unlinked_audio_mime;
553 gchar *unlinked_demuxer_mime;
555 /* found codec during autoplugging */
556 FoundCodec can_support_codec;
558 gboolean not_found_demuxer;
560 /* support seek even though player is not start */
561 MMPlayerPendingSeek pending_seek;
565 /* prevent to post msg over and over */
568 /* list of sink elements */
569 GList* sink_elements;
571 /* signal notifiers */
575 /* NOTE : if sink elements receive flush start event then it's state will be lost.
576 * this can happen when doing buffering in streaming pipeline since all control operation
577 * (play/pause/resume/seek) is requiring server interaction. during 'state lost' situation
578 * _set_state will not work correctely and state transition message will not posted to our
580 * So. we need to do some special care on the situation.
584 gboolean need_update_content_attrs;
585 gboolean need_update_content_dur;
587 gboolean is_sound_extraction;
589 gdouble playback_rate;
590 /* player state resumed by fast rewind */
591 gboolean resumed_by_rewind;
593 gboolean is_nv12_tiled;
597 gboolean is_subtitle_off;
599 /* contents bitrate for buffering management */
600 guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
602 guint updated_bitrate_count;
603 guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
604 guint total_maximum_bitrate;
605 guint updated_maximum_bitrate_count;
607 /* prevent it from posting duplicatly*/
610 /* timeout source for lazy pause */
611 guint lazy_pause_event_id;
613 gboolean keep_detecting_vcodec;
615 gboolean play_subtitle;
617 /* PD downloader message callback and param */
618 MMMessageCallback pd_msg_cb;
619 void* pd_msg_cb_param;
622 /*===========================================================================================
624 | GLOBAL FUNCTION PROTOTYPES |
626 ========================================================================================== */
631 int _mmplayer_create_player(MMHandleType hplayer);
632 int _mmplayer_destroy(MMHandleType hplayer);
633 int _mmplayer_realize(MMHandleType hplayer);
634 int _mmplayer_unrealize(MMHandleType hplayer);
635 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
636 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
637 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
638 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
639 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
640 int _mmplayer_start(MMHandleType hplayer);
641 int _mmplayer_stop(MMHandleType hplayer);
642 int _mmplayer_pause(MMHandleType hplayer);
643 int _mmplayer_resume(MMHandleType hplayer);
644 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
645 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
646 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int pos);
647 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
648 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
649 int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size);
650 int _mmplayer_set_buffer_need_data_cb(MMHandleType hplayer,mm_player_buffer_need_data_callback callback, void *user_param);
651 int _mmplayer_set_buffer_enough_data_cb(MMHandleType hplayer,mm_player_buffer_enough_data_callback callback, void *user_param);
652 int _mmplayer_set_buffer_seek_data_cb(MMHandleType hplayer,mm_player_buffer_seek_data_callback callback, void *user_param);
653 int _mmplayer_set_playspeed(MMHandleType hplayer, gdouble rate);
654 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
655 int _mmplayer_set_videostream_cb(MMHandleType hplayer,mm_player_video_stream_callback callback, void *user_param);
656 int _mmplayer_set_audiostream_cb(MMHandleType hplayer,mm_player_audio_stream_callback callback, void *user_param);
657 int _mmplayer_set_subtitle_silent (MMHandleType hplayer, int silent);
658 int _mmplayer_get_subtitle_silent (MMHandleType hplayer, int* silent);
659 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
660 gboolean _mmplayer_update_content_attrs(mm_player_t* player);
661 /* test API for tuning audio gain. this API should be
662 * deprecated before the day of final release
664 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
665 int _mmplayer_update_video_param(mm_player_t* player);
666 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
672 #endif /* __MM_PLAYER_PRIV_H__ */