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_sndeffect.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 */
145 /* it could be a decodebin or could be a typefind. depends on player ini */
148 /* NOTE : we need two fakesink to autoplug without decodebin.
149 * first one will hold whole pipeline state. and second one will hold state of
150 * a sink-decodebin for an elementary stream. no metter if there's more then one
151 * elementary streams because MSL reuse it.
153 MMPLAYER_M_SRC_FAKESINK,
154 MMPLAYER_M_SRC_2ND_FAKESINK,
156 /* streaming plugin */
161 /* FIXIT : if there's really no usage for following IDs. remove it */
170 /* audio pipeline's element id */
173 MMPLAYER_A_BIN = 0, /* NOTE : MMPLAYER_A_BIN should be zero */
178 MMPLAYER_A_CAPS_DEFAULT,
180 MMPLAYER_A_RESAMPLER,
184 /* video pipeline's element id */
187 MMPLAYER_V_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
196 /* text pipeline's element id */
199 MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_V_BIN should be zero */
206 /* subtitle pipeline's element id */
207 enum SubtitleElementID
209 MMPLAYER_SUB_PIPE = 0, /* NOTE : MMPLAYER_SUB_PIPE should be zero */
212 MMPLAYER_SUB_SUBPARSE,
213 MMPLAYER_SUB_TEXTRENDER,
222 /* midi main pipeline's element id */
226 MMPLAYER_MIDI_PLAYER,
230 enum PlayerCommandState
232 MMPLAYER_COMMAND_NONE,
233 MMPLAYER_COMMAND_CREATE,
234 MMPLAYER_COMMAND_DESTROY,
235 MMPLAYER_COMMAND_REALIZE,
236 MMPLAYER_COMMAND_UNREALIZE,
237 MMPLAYER_COMMAND_START,
238 MMPLAYER_COMMAND_STOP,
239 MMPLAYER_COMMAND_PAUSE,
240 MMPLAYER_COMMAND_RESUME,
244 /* Note : StreamingSrcError is error enum for streaming source which post error message
245 * using custom message made by itself. The enum value must start with zero,
246 * because the streaming source(secrtspsrc) also does.
248 enum StreamingSrcError
250 MMPLAYER_STREAMING_ERROR_NONE = 0,
251 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_AUDIO,
252 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_VIDEO,
253 MMPLAYER_STREAMING_ERROR_CONNECTION_FAIL,
254 MMPLAYER_STREAMING_ERROR_DNS_FAIL,
255 MMPLAYER_STREAMING_ERROR_SERVER_DISCONNECTED,
256 MMPLAYER_STREAMING_ERROR_BAD_SERVER,
257 MMPLAYER_STREAMING_ERROR_INVALID_PROTOCOL,
258 MMPLAYER_STREAMING_ERROR_INVALID_URL,
259 MMPLAYER_STREAMING_ERROR_UNEXPECTED_MSG,
260 MMPLAYER_STREAMING_ERROR_OUT_OF_MEMORIES,
261 MMPLAYER_STREAMING_ERROR_RTSP_TIMEOUT,
262 MMPLAYER_STREAMING_ERROR_BAD_REQUEST,
263 MMPLAYER_STREAMING_ERROR_NOT_AUTHORIZED,
264 MMPLAYER_STREAMING_ERROR_PAYMENT_REQUIRED,
265 MMPLAYER_STREAMING_ERROR_FORBIDDEN,
266 MMPLAYER_STREAMING_ERROR_CONTENT_NOT_FOUND,
267 MMPLAYER_STREAMING_ERROR_METHOD_NOT_ALLOWED,
268 MMPLAYER_STREAMING_ERROR_NOT_ACCEPTABLE,
269 MMPLAYER_STREAMING_ERROR_PROXY_AUTHENTICATION_REQUIRED,
270 MMPLAYER_STREAMING_ERROR_SERVER_TIMEOUT,
271 MMPLAYER_STREAMING_ERROR_GONE,
272 MMPLAYER_STREAMING_ERROR_LENGTH_REQUIRED,
273 MMPLAYER_STREAMING_ERROR_PRECONDITION_FAILED,
274 MMPLAYER_STREAMING_ERROR_REQUEST_ENTITY_TOO_LARGE,
275 MMPLAYER_STREAMING_ERROR_REQUEST_URI_TOO_LARGE,
276 MMPLAYER_STREAMING_ERROR_UNSUPPORTED_MEDIA_TYPE,
277 MMPLAYER_STREAMING_ERROR_PARAMETER_NOT_UNDERSTOOD,
278 MMPLAYER_STREAMING_ERROR_CONFERENCE_NOT_FOUND,
279 MMPLAYER_STREAMING_ERROR_NOT_ENOUGH_BANDWIDTH,
280 MMPLAYER_STREAMING_ERROR_NO_SESSION_ID,
281 MMPLAYER_STREAMING_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
282 MMPLAYER_STREAMING_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
283 MMPLAYER_STREAMING_ERROR_INVALID_RANGE,
284 MMPLAYER_STREAMING_ERROR_PARAMETER_IS_READONLY,
285 MMPLAYER_STREAMING_ERROR_AGGREGATE_OP_NOT_ALLOWED,
286 MMPLAYER_STREAMING_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
287 MMPLAYER_STREAMING_ERROR_BAD_TRANSPORT,
288 MMPLAYER_STREAMING_ERROR_DESTINATION_UNREACHABLE,
289 MMPLAYER_STREAMING_ERROR_INTERNAL_SERVER_ERROR,
290 MMPLAYER_STREAMING_ERROR_NOT_IMPLEMENTED,
291 MMPLAYER_STREAMING_ERROR_BAD_GATEWAY,
292 MMPLAYER_STREAMING_ERROR_SERVICE_UNAVAILABLE,
293 MMPLAYER_STREAMING_ERROR_GATEWAY_TIME_OUT ,
294 MMPLAYER_STREAMING_ERROR_RTSP_VERSION_NOT_SUPPORTED,
295 MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
299 /*---------------------------------------------------------------------------
300 | GLOBAL DATA TYPE DEFINITIONS: |
301 ---------------------------------------------------------------------------*/
307 } MMPlayerGstElement;
311 GstTagList *tag_list;
312 MMPlayerGstElement *mainbin;
313 MMPlayerGstElement *subtitlebin;
314 MMPlayerGstElement *audiobin;
315 MMPlayerGstElement *videobin;
316 MMPlayerGstElement *textbin;
317 } MMPlayerGstPipelineInfo;
321 char device[MAX_SOUND_DEVICE_LEN];
324 int bluetooth; /* enable/disable */
332 } tBuffer; /* FIXIT : choose better name */
339 char uri[MM_MAX_URL_LEN];
340 char urgent[MM_MAX_FILENAME_LEN];
341 } MMPlayerParseProfile;
345 MMPlayerPosFormatType format;
347 }MMPlayerPendingSeek;
352 } MMPlayerSignalItem;
354 /* image buffer definition ***************************************************
356 +------------------------------------------+ ---
359 | +---------------------------+ --- | |
361 | |<---------- w[] ---------->| | | |
369 | +---------------------------+ --- | |
371 +------------------------------------------+ ---
373 |<----------------- s[] ------------------>|
377 /* width of each image plane */
378 int w[MM_PLAYER_IMGB_MPLANE_MAX];
379 /* height of each image plane */
380 int h[MM_PLAYER_IMGB_MPLANE_MAX];
381 /* stride of each image plane */
382 int s[MM_PLAYER_IMGB_MPLANE_MAX];
383 /* elevation of each image plane */
384 int e[MM_PLAYER_IMGB_MPLANE_MAX];
385 /* user space address of each image plane */
386 void *a[MM_PLAYER_IMGB_MPLANE_MAX];
387 /* physical address of each image plane, if needs */
388 void *p[MM_PLAYER_IMGB_MPLANE_MAX];
389 /* color space type of image */
391 /* left postion, if needs */
393 /* top position, if needs */
395 /* to align memory */
399 } MMPlayerMPlaneImage;
403 int state; // player current state
404 int prev_state; // player previous state
405 int pending_state; // player state which is going to now
406 int target_state; // player state which user want to go to
407 guint state_change_timeout;
409 gboolean section_repeat;
410 gint section_repeat_start;
411 gint section_repeat_end;
420 /* repeat thread lock */
421 GCond* repeat_thread_cond;
422 GMutex* repeat_thread_mutex;
423 GThread* repeat_thread;
424 gboolean repeat_thread_exit;
427 GThread* capture_thread;
428 gboolean capture_thread_exit;
429 GCond* capture_thread_cond;
430 GMutex* capture_thread_mutex;
431 MMPlayerVideoCapture capture;
432 MMPlayerVideoColorspace video_cs;
433 MMPlayerMPlaneImage captured;
435 /* fakesink handling lock */
438 /* player attributes */
441 /* message callback */
442 MMMessageCallback msg_cb;
446 /* progressive download */
447 mm_player_pd_t *pd_downloader;
448 gchar *pd_file_save_path;
449 MMPlayerPDMode pd_mode;
451 /* streaming player */
452 mm_player_streaming_t *streamer;
454 /* gstreamer pipeline */
455 MMPlayerGstPipelineInfo *pipeline;
456 gboolean pipeline_is_constructed;
458 /* Buffering support cbs*/
459 mm_player_buffer_need_data_callback need_data_cb;
460 mm_player_buffer_enough_data_callback enough_data_cb;
461 mm_player_buffer_seek_data_callback seek_data_cb;
463 void* buffer_cb_user_param;
465 /* for video stream callback */
466 mm_player_video_stream_callback video_stream_cb;
467 void* video_stream_cb_user_param;
468 int use_video_stream;
470 /* audio stram callback */
471 mm_player_audio_stream_callback audio_stream_cb;
472 void* audio_stream_cb_user_param;
474 /* audio buffer callback */
475 mm_player_audio_stream_callback audio_buffer_cb;
476 void* audio_buffer_cb_user_param;
478 /* video capture callback*/
479 gulong video_capture_cb_probe_id;
482 MMPlayerSoundInfo sound;
487 /* video stream caps parsed by demuxer */
488 GstCaps* v_stream_caps;
490 /* audio filter infomation */
491 MMAudioFilterInfo audio_filter_info;
492 gboolean bypass_sound_effect;
494 gulong audio_cb_probe_id;
499 /* content profile */
500 MMPlayerParseProfile profile;
502 /* streaming service type */
503 MMStreamingType streaming_type;
507 gboolean have_dynamic_pad;
508 GList* parsers; // list of linked parser name
509 gboolean no_more_pad;
510 gint num_dynamic_pad;
511 gboolean has_many_types;
513 /* progress callback timer */
514 /* FIXIT : since duplicated functionality with get_position
515 * this function will be deprecated after fixing all application
516 * which are using it.
518 guint progress_timer;
520 /* timer for sending delayed EOS */
523 /* last point (msec) that player is paused or seeking */
524 gint64 last_position;
529 /* data size of http streaming */
530 guint64 http_content_size;
533 gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */
535 gint videodec_linked;
536 gint audiodec_linked;
537 gint videosink_linked;
538 gint audiosink_linked;
539 gint textsink_linked;
541 /* missing plugin during autoplugging */
542 MissingCodec not_supported_codec;
544 /*unlinked audio/video mime type */
545 gchar *unlinked_video_mime;
546 gchar *unlinked_audio_mime;
547 gchar *unlinked_demuxer_mime;
549 /* found codec during autoplugging */
550 FoundCodec can_support_codec;
552 gboolean not_found_demuxer;
554 /* support seek even though player is not start */
555 MMPlayerPendingSeek pending_seek;
559 /* prevent to post msg over and over */
562 /* list of sink elements */
563 GList* sink_elements;
565 /* signal notifiers */
569 /* NOTE : if sink elements receive flush start event then it's state will be lost.
570 * this can happen when doing buffering in streaming pipeline since all control operation
571 * (play/pause/resume/seek) is requiring server interaction. during 'state lost' situation
572 * _set_state will not work correctely and state transition message will not posted to our
574 * So. we need to do some special care on the situation.
578 gboolean need_update_content_attrs;
579 gboolean need_update_content_dur;
581 gboolean is_sound_extraction;
583 gdouble playback_rate;
584 /* player state resumed by fast rewind */
585 gboolean resumed_by_rewind;
587 gboolean is_nv12_tiled;
591 gboolean is_subtitle_off;
593 /* contents bitrate for buffering management */
594 guint bitrate[MM_PLAYER_STREAM_COUNT_MAX];
596 guint updated_bitrate_count;
597 guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX];
598 guint total_maximum_bitrate;
599 guint updated_maximum_bitrate_count;
601 /* prevent it from posting duplicatly*/
604 /* timeout source for lazy pause */
605 guint lazy_pause_event_id;
607 gboolean keep_detecting_vcodec;
609 gboolean play_subtitle;
611 /* PD downloader message callback and param */
612 MMMessageCallback pd_msg_cb;
613 void* pd_msg_cb_param;
616 /*===========================================================================================
618 | GLOBAL FUNCTION PROTOTYPES |
620 ========================================================================================== */
625 int _mmplayer_create_player(MMHandleType hplayer);
626 int _mmplayer_destroy(MMHandleType hplayer);
627 int _mmplayer_realize(MMHandleType hplayer);
628 int _mmplayer_unrealize(MMHandleType hplayer);
629 int _mmplayer_get_state(MMHandleType hplayer, int* pstate);
630 int _mmplayer_set_volume(MMHandleType hplayer, MMPlayerVolumeType volume);
631 int _mmplayer_get_volume(MMHandleType hplayer, MMPlayerVolumeType *volume);
632 int _mmplayer_set_mute(MMHandleType hplayer, int mute);
633 int _mmplayer_get_mute(MMHandleType hplayer, int* pmute);
634 int _mmplayer_start(MMHandleType hplayer);
635 int _mmplayer_stop(MMHandleType hplayer);
636 int _mmplayer_pause(MMHandleType hplayer);
637 int _mmplayer_resume(MMHandleType hplayer);
638 int _mmplayer_set_position(MMHandleType hplayer, int format, int pos);
639 int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos);
640 int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int pos);
641 int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end);
642 int _mmplayer_deactivate_section_repeat(MMHandleType hplayer);
643 int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size);
644 int _mmplayer_set_buffer_need_data_cb(MMHandleType hplayer,mm_player_buffer_need_data_callback callback, void *user_param);
645 int _mmplayer_set_buffer_enough_data_cb(MMHandleType hplayer,mm_player_buffer_enough_data_callback callback, void *user_param);
646 int _mmplayer_set_buffer_seek_data_cb(MMHandleType hplayer,mm_player_buffer_seek_data_callback callback, void *user_param);
647 int _mmplayer_set_playspeed(MMHandleType hplayer, gdouble rate);
648 int _mmplayer_set_message_callback(MMHandleType hplayer, MMMessageCallback callback, void *user_param);
649 int _mmplayer_set_videostream_cb(MMHandleType hplayer,mm_player_video_stream_callback callback, void *user_param);
650 int _mmplayer_set_audiostream_cb(MMHandleType hplayer,mm_player_audio_stream_callback callback, void *user_param);
651 int _mmplayer_set_subtitle_silent (MMHandleType hplayer, int silent);
652 int _mmplayer_get_subtitle_silent (MMHandleType hplayer, int* silent);
653 int _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* start_pos, unsigned long* stop_pos);
654 gboolean _mmplayer_update_content_attrs(mm_player_t* player);
655 /* test API for tuning audio gain. this API should be
656 * deprecated before the day of final release
658 int _mmplayer_set_volume_tune(MMHandleType hplayer, MMPlayerVolumeType volume);
659 int _mmplayer_update_video_param(mm_player_t* player);
660 int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param);
666 #endif /* __MM_PLAYER_PRIV_H__ */