From 830e9202cc06ed79a40092518754a1b1204875d3 Mon Sep 17 00:00:00 2001 From: Younghwan Ahn Date: Thu, 16 Feb 2012 18:14:25 +0900 Subject: [PATCH] update to latest code --- debian/changelog | 8 + src/include/mm_player.h | 35 ++ src/include/mm_player_ini.h | 114 ++-- src/include/mm_player_pd.h | 2 +- src/include/mm_player_priv.h | 55 +- src/include/mm_player_streaming.h | 76 +++ src/include/mm_player_utils.h | 3 +- src/mm_player.c | 24 + src/mm_player_ahs.c | 79 +-- src/mm_player_ahs_hls.c | 2 +- src/mm_player_asm.c | 45 +- src/mm_player_attrs.c | 20 +- src/mm_player_capture.c | 16 +- src/mm_player_ini.c | 96 +--- src/mm_player_m3u8.c | 118 +---- src/mm_player_pd.c | 16 - src/mm_player_priv.c | 1036 ++++++++++--------------------------- src/mm_player_streaming.c | 432 ++++++++++++++++ src/mm_player_utils.c | 25 +- test/mm_player_testsuite.c | 83 +-- 20 files changed, 1047 insertions(+), 1238 deletions(-) create mode 100755 src/include/mm_player_streaming.h create mode 100755 src/mm_player_streaming.c diff --git a/debian/changelog b/debian/changelog index 2fcae22..0c13864 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +libmm-player (0.2.12-0) unstable; urgency=low + + * update to latest code + * Git: pkgs/l/libmm-player + * Tag: libmm-player_0.2.12-0 + + -- Younghwan Ahn Thu, 16 Feb 2012 18:13:32 +0900 + libmm-player (0.2.11-27) unstable; urgency=low * Add license and COPYING for LGPL license issues diff --git a/src/include/mm_player.h b/src/include/mm_player.h index ad420cb..a32ca17 100755 --- a/src/include/mm_player.h +++ b/src/include/mm_player.h @@ -293,6 +293,11 @@ VALID TYPE + "content_video_found" + string + N/A + + "content_video_codec" string N/A @@ -303,6 +308,11 @@ range + "content_audio_found" + string + N/A + + "content_audio_codec" string N/A @@ -1237,6 +1247,31 @@ printf("mute status:%d\n", mute); int mm_player_get_mute(MMHandleType player, int *mute); /** + * This function is to adjust subtitle postion. So, subtitle can show at the adjusted position. \n + * If pos is negative, subtitle will be displayed previous time, the other hand forward time. \n + * + * @param player [in] Handle of player + * @param pos [in] postion to be adjusted + * + * @return This function returns zero on success, or negative value with error + * code + * @see mm_player_adjust_subtitle_position + * @remark None + * @par Example + * @code +int pos; + +pos = 5000; +if (mm_player_adjust_subtitle_position(g_player, MM_PLAYER_POS_FORMAT_TIME, pos) != MM_ERROR_NONE) +{ + printf("failed to adjust subtitle postion.\n"); +} + * @endcode + */ + +int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos); + +/** * This function is to set subtitle silent status. So, subtitle can show or hide during playback \n * by this value. But, one subtitle file should be set with "subtitle_uri" attribute before calling mm_player_realize(); \n * Player FW parses subtitle file and send text data including timestamp to application \n diff --git a/src/include/mm_player_ini.h b/src/include/mm_player_ini.h index e01be1b..57a3b9e 100755 --- a/src/include/mm_player_ini.h +++ b/src/include/mm_player_ini.h @@ -87,25 +87,17 @@ typedef struct __mm_player_ini /* http streaming */ gchar name_of_httpsrc[PLAYER_INI_MAX_STRLEN]; // @ - gchar http_temp_template[PLAYER_INI_MAX_STRLEN]; - gboolean http_use_buffering; - guint http_buffering_low_limit; - guint http_buffering_high_limit; + gchar http_file_buffer_path[PLAYER_INI_MAX_STRLEN]; + gdouble http_buffering_limit; guint http_max_size_bytes; - guint http_timeout; - gint http_blocksize; gdouble http_buffering_time; + guint http_timeout; /* rtsp streaming */ gchar name_of_rtspsrc[PLAYER_INI_MAX_STRLEN]; // @ guint rtsp_buffering_time; guint rtsp_rebuffering_time; - guint rtsp_audio_packet_drop_rate; - guint rtsp_video_packet_drop_rate; - gboolean rtsp_dump_video_frame; - gboolean rtsp_dump_audio_frame; gboolean rtsp_do_typefinding; - gboolean rtsp_stack_debug; gboolean rtsp_error_concealment; /* testing purpose */ /* hw accelation */ @@ -117,57 +109,42 @@ typedef struct __mm_player_ini gint audiosink_priority; gint videosink_priority; gint ringbuffer_priority; - - /* subtitle */ - gboolean use_subtitle_setting; - gchar subtitle_uri[PLAYER_INI_MAX_STRLEN]; // @ - gboolean subtitle_silent; - } mm_player_ini_t; /* default values if each values are not specified in inifile */ /* general */ -#define DEFAULT_USE_DECODEBIN FALSE -#define DEFAULT_USE_AUDIO_FILTER FALSE -#define DEFAULT_USE_SINK_HANDLER TRUE -#define DEFAULT_SKIP_RESCAN TRUE -#define DEFAULT_GENERATE_DOT FALSE -#define DEFAULT_PROVIDE_CLOCK TRUE -#define DEFAULT_DELAY_BEFORE_REPEAT 50 /* msec */ +#define DEFAULT_USE_DECODEBIN FALSE +#define DEFAULT_USE_AUDIO_FILTER FALSE +#define DEFAULT_USE_SINK_HANDLER TRUE +#define DEFAULT_SKIP_RESCAN TRUE +#define DEFAULT_GENERATE_DOT FALSE +#define DEFAULT_PROVIDE_CLOCK TRUE +#define DEFAULT_DELAY_BEFORE_REPEAT 50 /* msec */ #define DEFAULT_EOS_DELAY 150 /* msec */ #define DEFAULT_DRMSRC "drmsrc" #define DEFAULT_VIDEOSINK PLAYER_INI_VSINK_XVIMAGESINK #define DEFAULT_AUDIOSINK "avsysaudiosink" #define DEFAULT_GST_PARAM "" -#define DEFAULT_EXCLUDE_KEYWORD "" -#define DEFAULT_ASYNC_START TRUE -#define DEFAULT_DISABLE_SEGTRAP TRUE -#define DEFAULT_VIDEO_CONVERTER "" -#define DEFAULT_MULTIPLE_CODEC_SUPPORTED TRUE -#define DEFAULT_LIVE_STATE_CHANGE_TIMEOUT 30 /* sec */ +#define DEFAULT_EXCLUDE_KEYWORD "" +#define DEFAULT_ASYNC_START TRUE +#define DEFAULT_DISABLE_SEGTRAP TRUE +#define DEFAULT_VIDEO_CONVERTER "" +#define DEFAULT_MULTIPLE_CODEC_SUPPORTED TRUE +#define DEFAULT_LIVE_STATE_CHANGE_TIMEOUT 30 /* sec */ #define DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT 10 /* sec */ /* http streaming */ -#define DEFAULT_HTTPSRC "souphttpsrc" -#define DEFAULT_HTTP_TEMP_TEMPLATE "" -#define DEFAULT_HTTP_USE_BUFFERING TRUE -#define DEFAULT_HTTP_BUFFERING_LOW_LIMIT 1 /* percent */ -#define DEFAULT_HTTP_BUFFERING_HIGH_LIMIT 15 /* percent */ -#define DEFAULT_HTTP_MAX_SIZE_BYTES 4194304 /* bytes : 4 MBytes */ -#define DEFAULT_HTTP_TIMEOUT 30 /* sec */ -#define DEFAULT_HTTP_BLOCKSIZE 1048576 /* bytes : 1 MBytes */ -#define DEFAULT_HTTP_BUFFERING_TIME 1.2 /* sec */ +#define DEFAULT_HTTPSRC "souphttpsrc" +#define DEFAULT_HTTP_FILE_BUFFER_PATH "" +#define DEFAULT_HTTP_BUFFERING_LIMIT 99.0 /* percent */ +#define DEFAULT_HTTP_MAX_SIZE_BYTES 1048576 /* bytes : 1 MBytes */ +#define DEFAULT_HTTP_BUFFERING_TIME 3.0 /* sec */ +#define DEFAULT_HTTP_TIMEOUT 30 /* sec */ /* rtsp streaming */ -#define DEFAULT_RTSPSRC "secrtspsrc" -#define DEFAULT_RTSP_LATENCY 7000 /* msec */ -#define DEFAULT_RTSP_BUFFERING 5000 /* msec */ -#define DEFAULT_RTSP_REBUFFERING 15000 /* msec */ -#define DEFAULT_RTSP_AUDIO_PACKET_DROP_RATE 0 /* percent */ -#define DEFAULT_RTSP_VIDEO_PACKET_DROP_RATE 0 /* percent */ -#define DEFAULT_RTSP_DO_TYPEFINDING FALSE -#define DEFAULT_RTSP_DUMP_VIDEO_FRAME FALSE -#define DEFAULT_RTSP_DUMP_AUDIO_FRAME FALSE -#define DEFAULT_RTSP_STACK_DEBUG FALSE -#define DEFAULT_RTSP_ERROR_CONCEALMENT TRUE +#define DEFAULT_RTSPSRC "secrtspsrc" +#define DEFAULT_RTSP_BUFFERING 5000 /* msec */ +#define DEFAULT_RTSP_REBUFFERING 15000 /* msec */ +#define DEFAULT_RTSP_DO_TYPEFINDING FALSE +#define DEFAULT_RTSP_ERROR_CONCEALMENT TRUE /* hw accel */ #define DEFAULT_USE_VIDEO_HW_ACCEL FALSE /* priority */ @@ -176,11 +153,6 @@ typedef struct __mm_player_ini #define DEFAULT_PRIORITY_VIDEO_SINK 97 #define DEFAULT_PRIORITY_AUDIO_SINK 98 #define DEFAULT_PRIORITY_RINGBUFFER 99 -/* subtitle */ -#define DEFAULT_USE_SUBTITLE_SETTING FALSE -#define DEFAULT_SUBTITLE_URI "" -#define DEFAULT_SUBTITLE_SILENT FALSE - /* NOTE : following content should be same with above default values */ /* FIXIT : need smarter way to generate default ini file. */ @@ -244,22 +216,16 @@ eos delay = 150 ; msec \n\ httppsrc element = souphttpsrc \n\ \n\ ; if set, use file or not use memory for buffering\n\ -http temp template = /opt/media/XXXXXX\n\ +http file buffer path = /opt/media\n\ \n\ -http use buffering = yes \n\ +http buffering limit = 99 ; percent\n\ \n\ -http buffering low limit = 1 ; percent\n\ +http max size bytes = 1048576 ; bytes\n\ \n\ -http buffering high limit = 15 ; percent\n\ -\n\ -http max size bytes = 4194304 ; bytes\n\ +http buffering time = 3.0 \n\ \n\ http timeout = 30 ; sec \n\ \n\ -http blocksize = 1048576 ; bytes \n\ -\n\ -http buffering time = 1.2 \n\ -\n\ \n\ [rtsp streaming] \n\ \n\ @@ -269,18 +235,8 @@ rtsp buffering time = 5000; msec \n\ \n\ rtsp rebuffering time = 15000; msec \n\ \n\ -rtsp audio packet drop rate = 0; percent \n\ -\n\ -rtsp video packet drop rate = 0; percent \n\ -\n\ rtsp do typefinding = no; if no, caps on rtspsrc:src pad will be used for autoplugging \n\ \n\ -rtsp dump video frame = no \n\ -\n\ -rtsp dump audio frame = no \n\ -\n\ -rtsp stack debug = no \n\ -\n\ rtsp error concealment = yes \n\ \n\ \n\ @@ -305,14 +261,6 @@ audiosink = 97\n\ \n\ ringbuffer = 98 \n\ \n\ -[subtitle]\n\ -\n\ -use subtitle setting = no\n\ -\n\ -subtitle uri = \n\ -\n\ -subtitle silent = no\n\ -\n\ " int diff --git a/src/include/mm_player_pd.h b/src/include/mm_player_pd.h index 8e8acb3..bcb7ccc 100755 --- a/src/include/mm_player_pd.h +++ b/src/include/mm_player_pd.h @@ -5,7 +5,7 @@ * * Contact: JongHyuk Choi , YeJin Cho , * Seungbae Shin , YoungHwan An , - * naveen cherukuri + * naveen cherukuri * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index b3ff3d0..f6db799 100755 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -43,6 +43,7 @@ #include "mm_player_asm.h" #include "mm_player_ahs.h" #include "mm_player_pd.h" +#include "mm_player_streaming.h" /*=========================================================================================== | | @@ -55,6 +56,7 @@ ---------------------------------------------------------------------------*/ #define MM_PLAYER_IMGB_MPLANE_MAX 4 +#define MM_PLAYER_STREAM_COUNT_MAX 3 /*--------------------------------------------------------------------------- | GLOBAL CONSTANT DEFINITIONS: | @@ -73,7 +75,7 @@ enum tag_info TAG_TRACK_NUMBER = 0x0200 }; -/* bw.jang :+: 080607 async mode makes trouble. alsasink sometimes fails to pause. */ +/* async mode makes trouble. alsasink sometimes fails to pause. */ enum alassink_sync { ALSASINK_SYNC, @@ -180,7 +182,7 @@ enum VideoElementID /* text pipeline's element id */ enum SubtitleElementID { - MMPLAYER_T_BIN = 0, /* NOTE : MMPLAYER_SUB_BIN should be zero */ + MMPLAYER_T_PIPE = 0, /* NOTE : MMPLAYER_T_PIPE should be zero */ MMPLAYER_T_SRC, MMPLAYER_T_QUEUE, MMPLAYER_T_SUBPARSE, @@ -201,8 +203,6 @@ enum MidiElementID MMPLAYER_MIDI_NUM }; - -/* bw.jang :+: for state management */ enum PlayerCommandState { MMPLAYER_COMMAND_NONE, @@ -217,8 +217,6 @@ enum PlayerCommandState MMPLAYER_COMMAND_NUM }; - -/* yhahn:+: */ enum FilterActionType { MM_PLAYER_FILTER_NONE, @@ -335,24 +333,6 @@ typedef struct { gulong sig; } MMPlayerSignalItem; - -typedef struct { - gboolean is_buffering; - gboolean audio_only; - gboolean need_update; - guint buffering_repeat_cnt; - gint buffering_percent; - guint buffer_size_byte; - guint buffer_limit_criterion_byte; - guint buffer_high_limit_byte; - guint buffer_low_limit_byte; - guint buffer_high_limit_percent; - guint buffer_low_limit_percent; - gint buffer_avg_in_byterate; - gint buffer_avg_out_byterate; - gdouble buffering_time; -}MMPlayerBufferingInfo; - /* image buffer definition *************************************************** +------------------------------------------+ --- @@ -450,6 +430,9 @@ typedef struct { gchar *pd_file_location; MMPlayerPDMode pd_mode; + /* streaming player */ + mm_player_streaming_t *streamer; + /* gstreamer pipeline */ MMPlayerGstPipelineInfo *pipeline; gboolean pipeline_is_constructed; @@ -461,7 +444,7 @@ typedef struct { void* buffer_cb_user_param; - /* cs78.lee :+: for video stream callback */ + /* for video stream callback */ mm_player_video_stream_callback video_stream_cb; void* video_stream_cb_user_param; int use_video_stream; @@ -477,13 +460,13 @@ typedef struct { /* video capture callback*/ gulong video_capture_cb_probe_id; - /* sound info sbs:+:20090311 */ + /* sound info */ MMPlayerSoundInfo sound; /* application client id for dnse */ MMAudioFilterClient app_id_set_up_dnse; - /* me.kim :+: 090406 audio filter infomation */ + /* audio filter infomation */ MMAudioFilterInfo audio_filter_info; gboolean DNSeBypass; /* FIXIT : please use '_' rather than big character */ gboolean isAMR; @@ -527,9 +510,6 @@ typedef struct { /* last error */ gchar last_error_msg[1024]; /* FIXIT : should it be dynamic ? */ -// gint64 acc_time; -//int64 total_time; - gint videodec_linked; gint audiodec_linked; gint videosink_linked; @@ -587,16 +567,22 @@ typedef struct { gboolean is_subtitle_off; /* contents bitrate for buffering management */ - guint bitrate; - guint maximum_bitrate; - - MMPlayerBufferingInfo buffering_info; + guint bitrate[MM_PLAYER_STREAM_COUNT_MAX]; + guint total_bitrate; + guint updated_bitrate_count; + guint maximum_bitrate[MM_PLAYER_STREAM_COUNT_MAX]; + guint total_maximum_bitrate; + guint updated_maximum_bitrate_count; /* prevent it from posting duplicatly*/ gboolean sent_bos; /* timeout source for lazy pause */ guint lazy_pause_event_id; + + gboolean keep_detecting_vcodec; + + gboolean play_subtitle; } mm_player_t; /*=========================================================================================== @@ -625,6 +611,7 @@ int _mmplayer_pause(MMHandleType hplayer); int _mmplayer_resume(MMHandleType hplayer); int _mmplayer_set_position(MMHandleType hplayer, int format, int pos); int _mmplayer_get_position(MMHandleType hplayer, int format, unsigned long *pos); +int _mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int pos); int _mmplayer_activate_section_repeat(MMHandleType hplayer, unsigned long start, unsigned long end); int _mmplayer_deactivate_section_repeat(MMHandleType hplayer); int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size); diff --git a/src/include/mm_player_streaming.h b/src/include/mm_player_streaming.h new file mode 100755 index 0000000..7889d84 --- /dev/null +++ b/src/include/mm_player_streaming.h @@ -0,0 +1,76 @@ +/* + * libmm-player + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi , YeJin Cho , + * Seungbae Shin , YoungHwan An + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __MM_PLAYER_STREAMING_H__ +#define __MM_PLAYER_STREAMING_H__ + +#include +#include +#include +#include "mm_debug.h" + +#define MAX_FILE_BUFFER_NAME_LEN 256 + +#define MIN_BUFFER_PERCENT 0.0 +#define MAX_BUFFER_PERCENT 100.0 +#define MIN_BUFFERING_TIME 2.0 +#define MAX_BUFFERING_TIME 10.0 + +#define DEFAULT_BUFFER_SIZE 4194304 // 4 MBytes +#define DEFAULT_BUFFER_LOW_PERCENT 1.0 // 1% +#define DEFAULT_BUFFER_HIGH_PERCENT 99.0 // 15% +#define DEFAULT_BUFFERING_TIME 3.0 // about 3sec + +#define DEFAULT_FILE_BUFFER_PATH "/opt/media" + +#define STREAMING_USE_FILE_BUFFER +#define STREAMING_USE_MEMORY_BUFFER + +typedef struct +{ + GstElement *buffer; /* buffering element of playback pipeline */ + + gboolean is_buffering; + gint buffering_percent; + + gboolean need_update; + guint buffer_size; + gdouble buffer_high_percent; + gdouble buffer_low_percent; + gdouble buffering_time; + guint buffer_max_bitrate; + guint buffer_avg_bitrate; +}mm_player_streaming_t; + + +mm_player_streaming_t *__mm_player_streaming_create (); +void __mm_player_streaming_initialize (mm_player_streaming_t* streaming_player); +void __mm_player_streaming_deinitialize (mm_player_streaming_t* streaming_player); +void __mm_player_streaming_destroy(mm_player_streaming_t* streaming_player); + +void __mm_player_streaming_set_buffer(mm_player_streaming_t* streaming_player, GstElement * buffer, + gboolean use_buffering, guint buffer_size, gdouble low_percent, gdouble high_percent, gdouble buffering_time, + gboolean use_file, gchar * file_path, guint64 content_size); +void __mm_player_streaming_set_content_bitrate(mm_player_streaming_t* streaming_player, guint max_bitrate, guint avg_bitrate); +void __mm_player_streaming_buffering (mm_player_streaming_t* streaming_player , GstMessage *buffering_msg); + +#endif diff --git a/src/include/mm_player_utils.h b/src/include/mm_player_utils.h index 3824705..e8067ff 100755 --- a/src/include/mm_player_utils.h +++ b/src/include/mm_player_utils.h @@ -232,9 +232,8 @@ int util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2); // @ bool util_exist_file_path(const char *file_path); bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_size); -bool util_remove_file_backup(const char *backup_path); /* tskim:Midi:+:For Midi Player */ +bool util_remove_file_backup(const char *backup_path); /* For Midi Player */ -/* sbs:+:080903 */ int util_is_midi_type_by_mem(void *mem, int size); int util_is_midi_type_by_file(const char *file_path); diff --git a/src/mm_player.c b/src/mm_player.c index e728b1d..f629cd6 100755 --- a/src/mm_player.c +++ b/src/mm_player.c @@ -632,6 +632,30 @@ int mm_player_get_buffer_position(MMHandleType player, MMPlayerPosFormatType for return result; } +int mm_player_adjust_subtitle_position(MMHandleType player, MMPlayerPosFormatType format, int pos) +{ + int result = MM_ERROR_NONE; + + debug_log("\n"); + + return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + if (format >= MM_PLAYER_POS_FORMAT_NUM) + { + debug_error("wrong format\n"); + return MM_ERROR_COMMON_INVALID_ARGUMENT; + } + + MMPLAYER_CMD_LOCK( player ); + + result = _mmplayer_adjust_subtitle_postion(player, format, pos); + + MMPLAYER_CMD_UNLOCK( player ); + + return result; +} + + int mm_player_set_subtitle_silent(MMHandleType player, int silent) { int result = MM_ERROR_NONE; diff --git a/src/mm_player_ahs.c b/src/mm_player_ahs.c index e507167..7f58787 100755 --- a/src/mm_player_ahs.c +++ b/src/mm_player_ahs.c @@ -77,8 +77,6 @@ on_new_buffer_from_appsink (GstElement * appsink, void* data) { ahs_player->seg_size = ahs_player->seg_size + GST_BUFFER_SIZE (InBuf); - //g_print ("******** Pushing buffer size = %d and total_seg_size = %"G_GUINT64_FORMAT"\n", GST_BUFFER_SIZE (InBuf), ahs_player->seg_size); - if (ahs_player->cur_key_uri) { GstBuffer *OutBuf = NULL; @@ -94,15 +92,13 @@ on_new_buffer_from_appsink (GstElement * appsink, void* data) if (ahs_is_buffer_discontinuous(ahs_player)) { - g_print ("\n\n\n\nMarking fragment as discontinuous...\n\n\n\n\n"); GST_BUFFER_FLAG_SET (OutBuf, GST_BUFFER_FLAG_DISCONT); - ahs_clear_discontinuous (ahs_player); + ahs_clear_discontinuous (ahs_player); } fret = gst_app_src_push_buffer ((GstAppSrc *)ahs_player->appsrc, OutBuf); if (fret != GST_FLOW_OK) { - g_print ("\n\nError in pushing buffer to appsrc: reason - %s\n\n", gst_flow_get_name(fret)); __mm_player_ahs_stop (ahs_player); } @@ -116,7 +112,6 @@ on_new_buffer_from_appsink (GstElement * appsink, void* data) if (ahs_is_buffer_discontinuous(ahs_player)) { - g_print ("\n\n\n\n \t\t((((((((((((((((((((((( Marking fragment as discontinuous... ))))))))))))))))))))))))\n\n\n\n\n"); GST_BUFFER_FLAG_SET (InBuf, GST_BUFFER_FLAG_DISCONT); ahs_clear_discontinuous (ahs_player); } @@ -124,7 +119,6 @@ on_new_buffer_from_appsink (GstElement * appsink, void* data) fret = gst_app_src_push_buffer ((GstAppSrc *)ahs_player->appsrc, InBuf); if (fret != GST_FLOW_OK) { - g_print ("\n\nError in pushing buffer to appsrc: reason - %s\n\n", gst_flow_get_name(fret)); __mm_player_ahs_stop (ahs_player); } } @@ -201,7 +195,6 @@ manifest_update_thread(gpointer data) bret = g_cond_timed_wait (ahs_player->manifest_update_cond, ahs_player->manifest_mutex, &next_update); g_mutex_unlock (ahs_player->manifest_mutex); -#if 0 tmp_update.tv_sec = 0; tmp_update.tv_usec = 0; @@ -209,15 +202,14 @@ manifest_update_thread(gpointer data) if (bret == TRUE) { - g_print ("\n\n@@@@@@@@@ Sombody signalled manifest waiting... going to update current manifest file and diff = %d\n\n\n", - ((next_update.tv_sec * 1000000)+ next_update.tv_usec) - ((tmp_update.tv_sec * 1000000)+ tmp_update.tv_usec)); + debug_log ("\n\n@@@@@@@@@ Sombody signalled manifest waiting... going to update current manifest file and diff = %d\n\n\n", + ((next_update.tv_sec * 1000000)+ next_update.tv_usec) - ((tmp_update.tv_sec * 1000000)+ tmp_update.tv_usec)); } else { - g_print ("\n\n\n~~~~~~~~~~~Timeout happened, need to update current manifest file and diff = %d\n\n\n", - ((next_update.tv_sec * 1000000)+ next_update.tv_usec) - ((tmp_update.tv_sec * 1000000)+ tmp_update.tv_usec)); + debug_log ("\n\n\n~~~~~~~~~~~Timeout happened, need to update current manifest file and diff = %d\n\n\n", + ((next_update.tv_sec * 1000000)+ next_update.tv_usec) - ((tmp_update.tv_sec * 1000000)+ tmp_update.tv_usec)); } -#endif } else { @@ -227,7 +219,6 @@ manifest_update_thread(gpointer data) g_mutex_unlock (ahs_player->manifest_mutex); goto exit; } - g_print ("NOT-LIVE : Waiting for trigger to start downloading manifest...\n"); g_cond_wait (ahs_player->manifest_update_cond, ahs_player->manifest_mutex); g_mutex_unlock (ahs_player->manifest_mutex); @@ -302,7 +293,7 @@ media_download_thread (gpointer data) fret = gst_app_src_end_of_stream ((GstAppSrc *)ahs_player->appsrc); if (GST_FLOW_OK != fret) { - g_print ("Error in pushing EOS to appsrc : reason - %s", gst_flow_get_name (fret)); + debug_error("Error in pushing EOS to appsrc : reason - %s", gst_flow_get_name (fret)); } goto exit; } @@ -326,11 +317,10 @@ media_download_thread (gpointer data) else { ahs_player->media_thread_exit = TRUE; - g_print ("media download thread exiting...."); fret = gst_app_src_end_of_stream ((GstAppSrc *)ahs_player->appsrc); if (GST_FLOW_OK != fret) { - g_print ("Error in pushing EOS to appsrc : reason - %s", gst_flow_get_name (fret)); + debug_error("Error in pushing EOS to appsrc : reason - %s", gst_flow_get_name (fret)); } goto exit; } @@ -350,26 +340,29 @@ media_download_thread (gpointer data) memcpy (ahs_player->cur_iv, iv, 16); + g_mutex_lock (ahs_player->media_mutex); ahs_create_key_download_pipeline (ahs_player); g_cond_wait (ahs_player->key_eos_cond, ahs_player->media_mutex); - g_print ("Downloaded key url.. and key data is = %s\n", ahs_player->cur_key_data); + g_mutex_unlock (ahs_player->media_mutex); + + debug_log("Downloaded key url.. and key data is = %s\n", ahs_player->cur_key_data); } ahs_player->cur_media_uri = g_strdup (media_uri); g_free (media_uri); media_uri = NULL; - - bret = ahs_create_media_download_pipeline (ahs_player); - if (FALSE == bret) - { - goto exit; - } /* note down segment start time */ g_get_current_time (&time); ahs_player->seg_start_time = (time.tv_sec * 1000000)+ time.tv_usec; debug_log ("start time in usec = %"G_GUINT64_FORMAT"\n", ahs_player->seg_start_time); - + + bret = ahs_create_media_download_pipeline (ahs_player); + if (FALSE == bret) + { + goto exit; + } + /* waiting for media file to be downloaded */ g_mutex_lock (ahs_player->media_mutex); if (ahs_player->media_thread_exit) @@ -482,8 +475,6 @@ ahs_create_manifest_download_pipeline (mm_player_ahs_t *ahs_player) debug_log ("src location = %s, save location = %s\n", ahs_player->cur_mf_uri, ahs_player->ahs_manifest_dmp_location); - g_print ("Going to download manifest-uri -> %s\n", ahs_player->cur_mf_uri); - /* Start to download */ sret = gst_element_set_state (ahs_player->manifest_download_pipeline, GST_STATE_PLAYING); @@ -964,7 +955,7 @@ ahs_media_download_callback(GstBus *bus, GstMessage *msg, gpointer data) ahs_player->cache_frag_count++; - g_print("*********** frag_cnt = %d and download rate = %d bps **************\n", ahs_player->cache_frag_count, ahs_player->download_rate); + debug_log("*********** frag_cnt = %d and download rate = %d bps **************\n", ahs_player->cache_frag_count, ahs_player->download_rate); /* first initial fragments go with least possible bit-rate */ if (ahs_player->cache_frag_count == DEFAULT_FRAGMENTS_CACHE) @@ -981,7 +972,10 @@ ahs_media_download_callback(GstBus *bus, GstMessage *msg, gpointer data) ahs_player->seg_size = 0; - g_cond_signal (ahs_player->media_eos_cond); + g_mutex_lock (ahs_player->media_mutex); + g_cond_broadcast (ahs_player->media_eos_cond); + g_mutex_unlock (ahs_player->media_mutex); + debug_log ("Signaled media ts EOS...\n"); } @@ -1266,8 +1260,6 @@ mm_player_ahs_t * __mm_player_ahs_create () ahs_player->hls_is_wait_for_reload = FALSE; - g_print ("\n >>>>>>>>>>>CREATE AHS download DONE\n"); - return ahs_player; ERROR: @@ -1315,8 +1307,6 @@ gboolean __mm_player_ahs_initialize (mm_player_ahs_t *ahs_player, int uri_type, return FALSE; } - g_print ("\n\n Initialize \n\n"); - /* initialize ahs common variables */ ahs_player->uri_type = uri_type; ahs_player->main_mf_uri = g_strdup (uri); @@ -1355,8 +1345,6 @@ gboolean __mm_player_ahs_start (mm_player_ahs_t *ahs_player) return FALSE; } - g_print ("\n >>>>>>>>>>> AHS download START\n"); - /* download manifest file */ if (!ahs_create_manifest_download_pipeline (ahs_player)) return FALSE; @@ -1380,8 +1368,6 @@ gboolean __mm_player_ahs_start (mm_player_ahs_t *ahs_player) goto ERROR; } - g_print ("\n >>>>>>>>>>> AHS download START DONE\n"); - debug_log (">>>\n"); return bret; @@ -1415,8 +1401,6 @@ gboolean __mm_player_ahs_pause (mm_player_ahs_t *ahs_player) return FALSE; } - g_print ("\n\n\n PAUSED \n\n\n"); - g_mutex_lock (ahs_player->state_lock); if (AHS_STATE_MEDIA_STREAMING != ahs_player->ahs_state) { @@ -1428,7 +1412,7 @@ gboolean __mm_player_ahs_pause (mm_player_ahs_t *ahs_player) if (ahs_client_is_live (ahs_player)) { - g_print ("Live playlist flush now"); + debug_log("Live playlist flush now"); } return bret; @@ -1439,8 +1423,6 @@ gboolean __mm_player_ahs_deinitialize (mm_player_ahs_t *ahs_player) { debug_log ("<<<\n"); - g_print ("\n >>>>>>>>>>> AHS deinitalize \n"); - if (NULL == ahs_player) { debug_error (" Invalid argument\n"); @@ -1450,7 +1432,6 @@ gboolean __mm_player_ahs_deinitialize (mm_player_ahs_t *ahs_player) if (FALSE == ahs_player->is_initialized) { debug_log ("already de-initlialized\n"); - g_print ("\n\n######## already de-initlialized\n"); return TRUE; } @@ -1485,7 +1466,6 @@ gboolean __mm_player_ahs_deinitialize (mm_player_ahs_t *ahs_player) if (ahs_player->ahs_manifest_dmp_location) g_unlink(ahs_player->ahs_manifest_dmp_location); - g_print ("\n >>>>>>>>>>> AHS deinitalize DONE \n"); debug_log (">>>\n"); return TRUE; @@ -1571,13 +1551,11 @@ gboolean __mm_player_ahs_stop (mm_player_ahs_t *ahs_player) gboolean __mm_player_ahs_destroy (mm_player_ahs_t *ahs_player) { - g_print ("\n >>>>>>>>>>>Destroying AHS download\n"); debug_log ("<<<<<\n"); if (NULL == ahs_player) { debug_error ("Invalid argument...\n"); - g_print ("Invalid argument...\n"); return TRUE; } @@ -1598,19 +1576,15 @@ gboolean __mm_player_ahs_destroy (mm_player_ahs_t *ahs_player) if (ahs_player->key_eos_cond) g_cond_broadcast (ahs_player->key_eos_cond); - - g_print ("waiting for manifest thread to finish from destroy\n"); if (ahs_player->manifest_thread) { g_thread_join (ahs_player->manifest_thread); } - g_print ("waiting for media thread to finish from destroy\n"); if (ahs_player->media_thread) { g_thread_join (ahs_player->media_thread); } - g_print ("DESTROY threads are DEAD \n"); /* initialize ahs common variables */ if (ahs_player->main_mf_uri) @@ -1687,12 +1661,7 @@ gboolean __mm_player_ahs_destroy (mm_player_ahs_t *ahs_player) free (ahs_player); ahs_player = NULL; - g_print ("\n >>>>>>>>>>>Destroying AHS download DONE\n"); - debug_log (">>>>>\n"); return TRUE; - } - - diff --git a/src/mm_player_ahs_hls.c b/src/mm_player_ahs_hls.c index e31703b..bc71731 100755 --- a/src/mm_player_ahs_hls.c +++ b/src/mm_player_ahs_hls.c @@ -133,7 +133,7 @@ gboolean hls_parse_playlist_update_client (void *hls_handle, char* playlist) } else { - g_print ("\n\n!!!!!!!!!!!!!!!! RELOADED but NO changes!!!!!!\n\n"); + debug_log("\n\n!!!!!!!!!!!!!!!! RELOADED but NO changes!!!!!!\n\n"); } /* clean up */ diff --git a/src/mm_player_asm.c b/src/mm_player_asm.c index 4111bbf..10765d4 100755 --- a/src/mm_player_asm.c +++ b/src/mm_player_asm.c @@ -127,25 +127,6 @@ gint mmplayer_asm_deregister(MMPlayerASM* sm) { debug_log("no pid has assigned. using default(current) context\n"); } -#if 0 - /* read session type */ - errorcode = _mm_session_util_read_type(pid, &sessionType); - if ( errorcode ) - { - debug_error("MMSessionReadType Fail %s\n",__func__); - return MM_ERROR_POLICY_INTERNAL; - } - - /* check if it's CALL */ - if ( sessionType == MM_SESSION_TYPE_CALL || sessionType == MM_SESSION_TYPE_VIDEOCALL ) - { - debug_log("session type is VOICE or VIDEO CALL (%d)\n", sessionType); - return MM_ERROR_NONE; - } - - /* interpret session type */ - event_type = __mmplayer_asm_get_event_type(sessionType); -#else /* check if it's CALL */ if(sm->event == ASM_EVENT_CALL || sm->event == ASM_EVENT_VIDEOCALL) { @@ -153,7 +134,7 @@ gint mmplayer_asm_deregister(MMPlayerASM* sm) return MM_ERROR_NONE; } event_type = sm->event; -#endif + if( ! ASM_unregister_sound( sm->handle, event_type, &errorcode) ) { debug_error("Unregister sound failed 0x%X\n", errorcode); @@ -187,45 +168,23 @@ gint mmplayer_asm_set_state(MMHandleType hplayer, ASM_sound_states_t state) { debug_log("no pid has assigned. using default(current) context\n"); } -#if 0 - /* read session type */ - errorcode = _mm_session_util_read_type(pid, &sessionType); - if ( errorcode ) - { - debug_error("MMSessionReadType Fail\n"); - return MM_ERROR_POLICY_INTERNAL; - } - - /* check if it's CALL */ - if ( sessionType == MM_SESSION_TYPE_CALL || sessionType == MM_SESSION_TYPE_VIDEOCALL) - { - debug_log("session type is VOICE or VIDEO CALL (%d)\n", sessionType); - return MM_ERROR_NONE; - } -#else /* check if it's CALL */ if(sm->event == ASM_EVENT_CALL || sm->event == ASM_EVENT_VIDEOCALL) { debug_log("session type is VOICE or VIDEO CALL (%d)\n", sm->event); return MM_ERROR_NONE; } -#endif - if ( ! sm->by_asm_cb )//|| sm->state == ASM_STATE_PLAYING ) + if ( ! sm->by_asm_cb ) { int ret = 0; -#if 0 - event_type = __mmplayer_asm_get_event_type(sessionType); -#else event_type = sm->event; -#endif /* check if there is video */ /* NOTE: resource can be set as NONE when it's not occupied or unknown resource is used. */ if(ASM_STATE_PLAYING == state || ASM_STATE_PAUSE == state) { if(player->pipeline && player->pipeline->videobin) - //resource = ASM_RESOURCE_VIDEO_OVERLAY | ASM_RESOURCE_HW_DECODER; resource = ASM_RESOURCE_VIDEO_OVERLAY | ASM_RESOURCE_HW_DECODER; } diff --git a/src/mm_player_attrs.c b/src/mm_player_attrs.c index dc27d62..543ccc6 100755 --- a/src/mm_player_attrs.c +++ b/src/mm_player_attrs.c @@ -92,15 +92,6 @@ _mmplayer_get_attribute(MMHandleType hplayer, char **err_atr_name, const char * return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); return_val_if_fail(attribute_name, MM_ERROR_COMMON_INVALID_ARGUMENT); -#if 0 - /* update duration for VBR */ - if (strcmp(attribute_name, "content_duration") == 0 && player->can_support_codec == FOUND_PLUGIN_AUDIO) - { - player->need_update_content_attrs = TRUE; - _mmplayer_update_content_attrs(player); - } -#endif - attrs = MMPLAYER_GET_ATTRS(hplayer); return_val_if_fail(attrs, MM_ERROR_COMMON_INVALID_ARGUMENT); @@ -330,12 +321,14 @@ _mmplayer_construct_attribute(mm_player_t* player) {"content_duration", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_bitrate", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_max_bitrate", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, + {"content_video_found", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_video_codec", MM_ATTRS_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL}, {"content_video_bitrate", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_video_fps", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_video_width", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_video_height", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_video_track_num", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, + {"content_audio_found", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_audio_codec", MM_ATTRS_TYPE_STRING, MM_ATTRS_FLAG_RW, (void *)NULL}, {"content_audio_bitrate", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, {"content_audio_channels", MM_ATTRS_TYPE_INT, MM_ATTRS_FLAG_RW, (void *)0}, @@ -424,6 +417,15 @@ _mmplayer_construct_attribute(mm_player_t* player) mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE); mmf_attrs_set_valid_range (attrs, idx, 0, MMPLAYER_MAX_INT); + /* content */ + mm_attrs_get_index (attrs, "content_video_found", &idx); + mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE); + mmf_attrs_set_valid_range (attrs, idx, 0, 1); + + mm_attrs_get_index (attrs, "content_audio_found", &idx); + mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE); + mmf_attrs_set_valid_range (attrs, idx, 0, 1); + /* display */ mm_attrs_get_index (attrs, "display_zoom", &idx); mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE); diff --git a/src/mm_player_capture.c b/src/mm_player_capture.c index 72333bc..dbe0680 100755 --- a/src/mm_player_capture.c +++ b/src/mm_player_capture.c @@ -179,17 +179,29 @@ __mmplayer_capture_thread(gpointer data) debug_log("e[0]=%d, e[1]=%d\n", player->captured.e[0], player->captured.e[1]); debug_log("a[0]=%p, a[1]=%p\n", player->captured.a[0], player->captured.a[1]); + if (mm_attrs_get_int_by_name(player->attrs, "content_video_width", &(player->captured.w[0])) != MM_ERROR_NONE) + { + debug_error("failed to get content width attribute\n"); + goto ERROR; + } + + if (mm_attrs_get_int_by_name(player->attrs, "content_video_height", &(player->captured.h[0])) != MM_ERROR_NONE) + { + debug_error("failed to get content height attribute\n"); + goto ERROR; + } + linear_y_plane_size = (player->captured.w[0] * player->captured.h[0]); linear_uv_plane_size = (player->captured.w[0] * player->captured.h[0]/2); - linear_y_plane = (unsigned char*) g_try_malloc(linear_y_plane_size); + linear_y_plane = (unsigned char*) g_try_malloc(linear_y_plane_size); if (linear_y_plane == NULL) { msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE; goto ERROR; } - linear_uv_plane = (unsigned char*) g_try_malloc(linear_uv_plane_size); + linear_uv_plane = (unsigned char*) g_try_malloc(linear_uv_plane_size); if (linear_uv_plane == NULL) { msg.code = MM_ERROR_PLAYER_NO_FREE_SPACE; diff --git a/src/mm_player_ini.c b/src/mm_player_ini.c index 760137f..adaac94 100755 --- a/src/mm_player_ini.c +++ b/src/mm_player_ini.c @@ -142,25 +142,17 @@ mm_player_ini_load(void) /* http streaming */ MMPLAYER_INI_GET_STRING( g_player_ini.name_of_httpsrc, "http streaming:httpsrc element", DEFAULT_HTTPSRC ); - MMPLAYER_INI_GET_STRING( g_player_ini.http_temp_template, "http streaming:http temp template", DEFAULT_HTTP_TEMP_TEMPLATE ); - g_player_ini.http_use_buffering = iniparser_getboolean(dict, "http streaming:http use buffering", DEFAULT_HTTP_USE_BUFFERING); - g_player_ini.http_buffering_low_limit = iniparser_getint(dict, "http streaming:http buffering low limit", DEFAULT_HTTP_BUFFERING_LOW_LIMIT); - g_player_ini.http_buffering_high_limit = iniparser_getint(dict, "http streaming:http buffering high limit", DEFAULT_HTTP_BUFFERING_HIGH_LIMIT); + MMPLAYER_INI_GET_STRING( g_player_ini.http_file_buffer_path, "http streaming:http file buffer path", DEFAULT_HTTP_FILE_BUFFER_PATH ); + g_player_ini.http_buffering_limit = iniparser_getdouble(dict, "http streaming:http buffering high limit", DEFAULT_HTTP_BUFFERING_LIMIT); g_player_ini.http_max_size_bytes = iniparser_getint(dict, "http streaming:http max size bytes", DEFAULT_HTTP_MAX_SIZE_BYTES); - g_player_ini.http_timeout = iniparser_getint(dict, "http streaming:http timeout", DEFAULT_HTTP_TIMEOUT); - g_player_ini.http_blocksize = iniparser_getint(dict, "http streaming:http blocksize", DEFAULT_HTTP_BLOCKSIZE); g_player_ini.http_buffering_time = iniparser_getdouble(dict, "http streaming:http buffering time", DEFAULT_HTTP_BUFFERING_TIME); + g_player_ini.http_timeout = iniparser_getint(dict, "http streaming:http timeout", DEFAULT_HTTP_TIMEOUT); /* rtsp streaming */ MMPLAYER_INI_GET_STRING( g_player_ini.name_of_rtspsrc, "rtsp streaming:rtspsrc element", DEFAULT_RTSPSRC ); g_player_ini.rtsp_buffering_time = iniparser_getint(dict, "rtsp streaming:rtsp buffering time", DEFAULT_RTSP_BUFFERING); g_player_ini.rtsp_rebuffering_time = iniparser_getint(dict, "rtsp streaming:rtsp rebuffering time", DEFAULT_RTSP_REBUFFERING); - g_player_ini.rtsp_audio_packet_drop_rate = iniparser_getint(dict, "rtsp streaming:rtsp audio packet drop rate", DEFAULT_RTSP_AUDIO_PACKET_DROP_RATE); - g_player_ini.rtsp_video_packet_drop_rate = iniparser_getint(dict, "rtsp streaming:rtsp video packet drop rate", DEFAULT_RTSP_VIDEO_PACKET_DROP_RATE); g_player_ini.rtsp_do_typefinding = iniparser_getboolean(dict, "rtsp streaming:rtsp do typefinding", DEFAULT_RTSP_DO_TYPEFINDING); - g_player_ini.rtsp_dump_video_frame = iniparser_getboolean(dict, "rtsp streaming:rtsp dump video frame", DEFAULT_RTSP_DUMP_VIDEO_FRAME); - g_player_ini.rtsp_dump_audio_frame = iniparser_getboolean(dict, "rtsp streaming:rtsp dump audio frame", DEFAULT_RTSP_DUMP_AUDIO_FRAME); - g_player_ini.rtsp_stack_debug = iniparser_getboolean(dict, "rtsp streaming:rtsp stack debug", DEFAULT_RTSP_STACK_DEBUG); g_player_ini.rtsp_error_concealment = iniparser_getboolean(dict, "rtsp streaming:rtsp error concealment", DEFAULT_RTSP_ERROR_CONCEALMENT); /* hw accelation */ @@ -172,12 +164,6 @@ mm_player_ini_load(void) g_player_ini.videosink_priority = iniparser_getint(dict, "priority:videosink", DEFAULT_PRIORITY_VIDEO_SINK); g_player_ini.audiosink_priority = iniparser_getint(dict, "priority:audiosink", DEFAULT_PRIORITY_AUDIO_SINK); g_player_ini.ringbuffer_priority = iniparser_getint(dict, "priority:ringbuffer", DEFAULT_PRIORITY_RINGBUFFER); - - - /* subtitle */ - g_player_ini.use_subtitle_setting = iniparser_getboolean(dict, "subtitle:use subtitle setting", DEFAULT_USE_SUBTITLE_SETTING); - MMPLAYER_INI_GET_STRING( g_player_ini.subtitle_uri, "subtitle:subtitle uri", DEFAULT_SUBTITLE_URI ); - g_player_ini.subtitle_silent = iniparser_getboolean(dict, "subtitle:use subtitle silent", DEFAULT_SUBTITLE_SILENT); } else /* if dict is not available just fill the structure with default value */ { @@ -217,25 +203,17 @@ mm_player_ini_load(void) /* http streaming */ strcpy( g_player_ini.name_of_httpsrc, DEFAULT_HTTPSRC ); - strcpy( g_player_ini.http_temp_template, DEFAULT_HTTP_TEMP_TEMPLATE ); - g_player_ini.http_use_buffering = DEFAULT_HTTP_USE_BUFFERING; - g_player_ini.http_buffering_low_limit = DEFAULT_HTTP_BUFFERING_LOW_LIMIT; - g_player_ini.http_buffering_high_limit = DEFAULT_HTTP_BUFFERING_HIGH_LIMIT; + strcpy( g_player_ini.http_file_buffer_path, DEFAULT_HTTP_FILE_BUFFER_PATH ); + g_player_ini.http_buffering_limit = DEFAULT_HTTP_BUFFERING_LIMIT; g_player_ini.http_max_size_bytes = DEFAULT_HTTP_MAX_SIZE_BYTES; - g_player_ini.http_timeout = DEFAULT_HTTP_TIMEOUT; - g_player_ini.http_blocksize = DEFAULT_HTTP_BLOCKSIZE; g_player_ini.http_buffering_time = DEFAULT_HTTP_BUFFERING_TIME; + g_player_ini.http_timeout = DEFAULT_HTTP_TIMEOUT; /* rtsp streaming */ strcpy( g_player_ini.name_of_rtspsrc, DEFAULT_RTSPSRC ); g_player_ini.rtsp_buffering_time = DEFAULT_RTSP_BUFFERING; g_player_ini.rtsp_rebuffering_time = DEFAULT_RTSP_REBUFFERING; - g_player_ini.rtsp_audio_packet_drop_rate = DEFAULT_RTSP_AUDIO_PACKET_DROP_RATE; - g_player_ini.rtsp_video_packet_drop_rate = DEFAULT_RTSP_VIDEO_PACKET_DROP_RATE; g_player_ini.rtsp_do_typefinding = DEFAULT_RTSP_DO_TYPEFINDING; - g_player_ini.rtsp_dump_video_frame = DEFAULT_RTSP_DUMP_VIDEO_FRAME; - g_player_ini.rtsp_dump_audio_frame = DEFAULT_RTSP_DUMP_AUDIO_FRAME; - g_player_ini.rtsp_stack_debug = DEFAULT_RTSP_STACK_DEBUG; g_player_ini.rtsp_error_concealment = DEFAULT_RTSP_ERROR_CONCEALMENT; /* hw accelation */ @@ -247,11 +225,6 @@ mm_player_ini_load(void) g_player_ini.videosink_priority = DEFAULT_PRIORITY_VIDEO_SINK; g_player_ini.audiosink_priority = DEFAULT_PRIORITY_AUDIO_SINK; g_player_ini.ringbuffer_priority = DEFAULT_PRIORITY_RINGBUFFER; - - /* subtitle */ - g_player_ini.use_subtitle_setting = DEFAULT_USE_SUBTITLE_SETTING; - strcpy( g_player_ini.subtitle_uri, DEFAULT_SUBTITLE_URI ); - g_player_ini.subtitle_silent = DEFAULT_SUBTITLE_SILENT; } /* free dict as we got our own structure */ @@ -298,25 +271,17 @@ mm_player_ini_load(void) /* http streaming */ debug_log("name_of_httpsrc : %s\n", g_player_ini.name_of_httpsrc); - debug_log("http_temp_template : %s \n", g_player_ini.http_temp_template); - debug_log("http_use_buffering : %d \n", g_player_ini.http_use_buffering); - debug_log("http_buffering_low_limit : %d \n", g_player_ini.http_buffering_low_limit); - debug_log("http_buffering_high_limit : %d \n", g_player_ini.http_buffering_high_limit); + debug_log("http_file_buffer_path : %s \n", g_player_ini.http_file_buffer_path); + debug_log("http_buffering_limit : %f \n", g_player_ini.http_buffering_limit); debug_log("http_max_size_bytes : %d \n", g_player_ini.http_max_size_bytes); - debug_log("http_timeout : %d \n", g_player_ini.http_timeout); - debug_log("http_blocksize : %d \n", g_player_ini.http_blocksize); debug_log("http_buffering_time : %f \n", g_player_ini.http_buffering_time); + debug_log("http_timeout : %d \n", g_player_ini.http_timeout); /* rtsp streaming */ debug_log("name_of_rtspsrc : %s\n", g_player_ini.name_of_rtspsrc); debug_log("rtsp_buffering_time(msec) : %d\n", g_player_ini.rtsp_buffering_time); debug_log("rtsp_rebuffering_time(msec) : %d\n", g_player_ini.rtsp_rebuffering_time); - debug_log("rtsp_audio_packet_drop_rate : %d \n", g_player_ini.rtsp_audio_packet_drop_rate); - debug_log("rtsp_video_packet_drop_rate : %d \n", g_player_ini.rtsp_video_packet_drop_rate); debug_log("rtsp_do_typefinding : %d \n", g_player_ini.rtsp_do_typefinding); - debug_log("rtsp_dump_video_frame : %d \n", g_player_ini.rtsp_dump_video_frame); - debug_log("rtsp_dump_audio_frame : %d \n", g_player_ini.rtsp_dump_audio_frame); - debug_log("rtsp_stack_debug : %d \n", g_player_ini.rtsp_stack_debug); debug_log("rtsp_error_concealment : %d \n", g_player_ini.rtsp_error_concealment); /* hw accel */ @@ -329,11 +294,6 @@ mm_player_ini_load(void) debug_log("videosink_priority : %d\n", g_player_ini.videosink_priority); debug_log("ringbuffer_priority : %d\n", g_player_ini.ringbuffer_priority); - /* subtitle */ - debug_log("use_subtitle_setting : %d\n", g_player_ini.use_subtitle_setting); - debug_log("subtitle_uri : %s\n", g_player_ini.subtitle_uri); - debug_log("subtitle_silent : %d\n", g_player_ini.subtitle_silent); - debug_log("---------------------------------------------------\n"); return MM_ERROR_NONE; @@ -364,7 +324,6 @@ static void __mm_player_ini_force_setting(void) { /* FIXIT : remove it when all other elements are available on simulator, SDK */ - #if ! defined(__arm__) debug_warning("player is running on simulator. force to use ximagesink\n"); g_player_ini.videosink_element = PLAYER_INI_VSINK_XIMAGESINK; @@ -372,45 +331,10 @@ void __mm_player_ini_force_setting(void) strcpy( g_player_ini.name_of_drmsrc, "filesrc" ); - // Force setting for simulator :+:091218 + // Force setting for simulator strcpy( g_player_ini.name_of_audiosink, "alsasink" ); - -// __get_string_list( (gchar**) g_player_ini.exclude_element_keyword, ""); - #endif - - #if defined(VDF_SDK) || defined (SEC_SDK) - debug_warning("player is running on SDK.\n"); - debug_warning("So, it seems like that some plugin values are not same with those\n"); - debug_warning("which are written in default ini file.\n"); - - g_player_ini.videosink_element = PLAYER_INI_VSINK_XIMAGESINK; - g_player_ini.use_audio_filter = FALSE; - - strcpy( g_player_ini.name_of_drmsrc, "filesrc" ); - #endif - - #if defined(NEW_SOUND) - strcpy (g_player_ini.name_of_audiosink, "soundsink"); // :+:090707 - #endif - - /* FIXIT : The HW quality of volans is not better than protector. - * So, it can't use same timeout value because state change(resume) is sometimes failed in volans. - * Thus, it should be set more than 10sec. - */ - #if defined(_MM_PROJECT_VOLANS) - g_player_ini.localplayback_state_change_timeout = 10; - debug_log("localplayback_state_change_timeout is set as 30sec by force\n"); - #endif - - #if 0 - #if defined(_MM_PROJECT_VOLANS) - debug_warning("player is running on VOLANS\n"); - g_player_ini.use_audio_filter = FALSE; // (+)090702, disabled temporally - #endif - #endif - } mm_player_ini_t* diff --git a/src/mm_player_m3u8.c b/src/mm_player_m3u8.c index a9159d1..4ada577 100755 --- a/src/mm_player_m3u8.c +++ b/src/mm_player_m3u8.c @@ -96,8 +96,6 @@ gst_m3u8_media_file_new (gchar * uri, gchar * title, gint duration, gchar *key_ file->sequence = sequence; memset (file->key, 0x00, sizeof (file->key)); - //g_print (" uri = %s / ", uri); - if (key_url != NULL) { file->key_url = g_strdup (key_url); @@ -163,7 +161,6 @@ int_from_string (gchar * ptr, gchar ** endptr, gint * val, gint base) *val = strtol (ptr, &end, base); if ((errno == ERANGE && (*val == LONG_MAX || *val == LONG_MIN)) || (errno != 0 && *val == 0)) { -// debug_warning (g_strerror (errno)); return FALSE; } @@ -243,7 +240,6 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) /* check if the data changed since last update */ if (self->last_data && g_str_equal (self->last_data, data)) { - g_print ("\n\n\n\t\t ############ Playlist is the same as previous one ############\n\n\n\n"); *updated = FALSE; g_free (data); return TRUE; @@ -272,15 +268,10 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) data += 7; //data += 8; while (TRUE) { - //g_print ("====================================\n"); - //g_print ("data = [%s]\n", data); end = g_utf8_strchr (data, -1, '\n'); /* FIXME: support \r\n */ if (end) *end = '\0'; - //g_print ("end = [%s]\n", end); - - if (data[0] != '#') { if (duration < 0 && list == NULL) { debug_log ("%s: got line without EXTINF or EXTSTREAMINF, dropping\n", data); @@ -383,10 +374,6 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) } else if (g_str_has_prefix (data, "#EXT-X-TARGETDURATION:")) { if (int_from_string (data + 22, &data, &val, 10)) self->targetduration = val; - // g_print ("\n\n\t\t#########################\n"); - //g_print ("\t\tTarget duration = %d\n", val); - // g_print ("\n\n\t\t#########################\n"); - } else if (g_str_has_prefix (data, "#EXT-X-MEDIA-SEQUENCE:")) { if (int_from_string (data + 22, &data, &val, 10)) self->mediasequence = val; @@ -441,10 +428,27 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) else if (g_str_equal (attr, "URI")) { gchar *end_dq = NULL; + + if (val == NULL) + { + debug_error ("val is NULL"); + break; + } val = val + 1; /* eliminating first double quote in url */ + if (val == NULL) + { + debug_error ("val is NULL"); + break; + } end_dq = g_utf8_strrchr (val, -1, '"'); + if (!end_dq) + { + debug_error ("end_dq is NULL"); + break; + } + *end_dq = '\0'; g_print ("Key URI = %s\n", val); @@ -516,90 +520,6 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) } } } - -#if 0 - if (g_str_has_prefix (data, "METHOD=")) - { - data = data + 7; - if (g_str_has_prefix (data, "AES-128")) - { - g_print ("AES-128 encrypted media...\n\n"); - data = data + 8; - if (g_str_has_prefix (data, "URI=")) - { - gchar *dob_qu = NULL; - gchar *tmp_key_url = NULL; - - data = data+5; - - dob_qu = g_utf8_strrchr (data, -1, '"'); - *dob_qu = '\0'; - - tmp_key_url = g_strdup (data); - *dob_qu = '"'; - - g_print ("URI attribute = %s\n\n", tmp_key_url); - - if (!gst_uri_is_valid (tmp_key_url)) - { - gchar *slash; - if (!self->uri) { - debug_warning ("uri not set, can't build a valid uri"); - goto next_line; - } - slash = g_utf8_strrchr (self->uri, -1, '/'); - if (!slash) - { - debug_warning ("Can't build a valid uri"); - goto next_line; - } - - *slash = '\0'; - key_url = g_strdup_printf ("%s/%s", self->uri, tmp_key_url); - *slash = '/'; - } - else - key_url = g_strdup (tmp_key_url); - - g_print ("\n\n======= Final key url = %s\n\n\n\n", key_url); - - data = dob_qu; - data = data + 2; - - if ((g_str_has_prefix (data, "IV=0x")) && (g_str_has_prefix (data, "IV=0X"))) - { - data = data + 5; - g_print ("\n\nSize of IV = %d\n\n", sizeof (data)); - memcpy (IV, data, sizeof (IV)); - } - else - { - g_print ("\n\n\n Need to generate IV from media sequence...\n\n"); - } - } - else - { - g_print ("No URI specified...\n\n"); - return FALSE; - } - } - else if (g_str_has_prefix (data, "NONE")) - { - g_print ("\n\nNot encrypted.....\n\n\n"); - } - else - { - g_print ("\n\nUnknown EXT-X-KEY METHOD attri = %s\n\n", data); - return FALSE; - } - } - - else - { - g_print ("\n\nEXT-X-KEY without METHOD attribute...\n\n"); - return FALSE; - } -#endif } else { debug_warning ("Ignored line: %s", data); @@ -667,13 +587,9 @@ gst_m3u8_client_update (GstM3U8Client * self, gchar * data) m3u8 = self->current ? self->current : self->main; - // g_print ("\n\n"); - if (!gst_m3u8_update (m3u8, data, &updated)) return FALSE; - // g_print ("\n\n"); - if (!updated) { self->update_failed_count++; return FALSE; diff --git a/src/mm_player_pd.c b/src/mm_player_pd.c index 269e956..c3a8d48 100755 --- a/src/mm_player_pd.c +++ b/src/mm_player_pd.c @@ -65,8 +65,6 @@ pd_download_callback(GstBus *bus, GstMessage *msg, gpointer data) ret = gst_element_post_message (pd_downloader->pushsrc, new_msg); __mm_player_pd_stop (pd_downloader); - - g_print ("\n\n\nError posting msg = %d\n\n\n\n", ret); } break; @@ -96,8 +94,6 @@ pd_download_callback(GstBus *bus, GstMessage *msg, gpointer data) mm_player_pd_t * __mm_player_pd_create () { - g_print (">>>>>>>>>>>CREATE PD downloader\n"); - mm_player_pd_t *pd_downloader = NULL; pd_downloader = (mm_player_pd_t *) malloc (sizeof (mm_player_pd_t)); @@ -106,7 +102,6 @@ mm_player_pd_t * __mm_player_pd_create () debug_error ("Failed to create pd_downloader handle...\n"); return NULL; } - g_print (">>>>>>>>>>>CREATE PD downloader DONE\n"); return pd_downloader; @@ -114,13 +109,11 @@ mm_player_pd_t * __mm_player_pd_create () gboolean __mm_player_pd_destroy (mm_player_pd_t *pd_downloader) { - g_print ("\n >>>>>>>>>>>Destroying PD download\n"); debug_log ("<<<<<\n"); if (NULL == pd_downloader) { debug_error ("Invalid argument...\n"); - g_print ("Invalid argument...\n"); return TRUE; } @@ -130,9 +123,6 @@ gboolean __mm_player_pd_destroy (mm_player_pd_t *pd_downloader) free (pd_downloader); pd_downloader = NULL; - g_print ("\n >>>>>>>>>>>Destroying PD download DONE\n"); - debug_log (">>>>>\n"); - return TRUE; } @@ -146,8 +136,6 @@ gboolean __mm_player_pd_initialize (mm_player_pd_t *pd_downloader, gchar *src_ur return FALSE; } - g_print (">>>>>>> PD Initialize...\n"); - pd_downloader->download_uri = g_strdup (src_uri); pd_downloader->pd_file_dmp_location = g_strdup (dst_uri); pd_downloader->pushsrc = pushsrc; @@ -225,8 +213,6 @@ gboolean __mm_player_pd_start (mm_player_pd_t *pd_downloader) debug_log ("src location = %s, save location = %s\n", pd_downloader->download_uri, pd_downloader->pd_file_dmp_location); - g_print ("Going to download PD-uri -> %s\n", pd_downloader->download_uri); - /* Start to download */ sret = gst_element_set_state (pd_downloader->download_pipe, GST_STATE_PLAYING); if (GST_STATE_CHANGE_FAILURE == sret) @@ -246,8 +232,6 @@ gboolean __mm_player_pd_start (mm_player_pd_t *pd_downloader) debug_log ("get-state :: sret = %d\n", sret); - g_print ("\n\n\nPD downloader :: cur_state = %d and pending_state = %d\n\n\n", cur_state, pending_state); - debug_log (">>>\n"); return TRUE; diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 9f94a96..8aa2d1f 100755 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -85,7 +84,8 @@ /* video capture callback*/ gulong ahs_appsrc_cb_probe_id = 0; -#define MMPLAYER_USE_FILE_FOR_BUFFERING(player) (((player)->profile.uri_type != MM_PLAYER_URI_TYPE_HLS) && (PLAYER_INI()->http_temp_template) && (strlen(PLAYER_INI()->http_temp_template) > 0) ) +#define MMPLAYER_USE_FILE_FOR_BUFFERING(player) (((player)->profile.uri_type != MM_PLAYER_URI_TYPE_HLS) && (PLAYER_INI()->http_file_buffer_path) && (strlen(PLAYER_INI()->http_file_buffer_path) > 0) ) +#define MMPLAYER_PLAY_SUBTITLE(player) ((player)->play_subtitle) #define LAZY_PAUSE_TIMEOUT_MSEC 700 @@ -136,7 +136,7 @@ static gboolean __mmplayer_close_link(mm_player_t* player, GstPad *srcpad, GstEl static gboolean __mmplayer_feature_filter(GstPluginFeature *feature, gpointer data); static void __mmplayer_add_new_pad(GstElement *element, GstPad *pad, gpointer data); -static void __mmplayer_gst_rtp_no_more_pads (GstElement *element, gpointer data); //yejin.cho : 090312 :+: Add to change the state of the player when all the pads of the rrtspsrc are created. +static void __mmplayer_gst_rtp_no_more_pads (GstElement *element, gpointer data); static void __mmplayer_gst_rtp_dynamic_pad (GstElement *element, GstPad *pad, gpointer data); static gboolean __mmplayer_update_stream_service_type( mm_player_t* player ); static gboolean __mmplayer_update_subtitle( GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data); @@ -154,12 +154,6 @@ static gboolean __mmplayer_gst_remove_fakesink(mm_player_t* player, MMPlayerGstE static int __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command); static gboolean __mmplayer_audio_stream_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data); -#ifdef USE_PROGRESS_TIMER /* not in use */ -static void __mmplayer_start_progress_timer(mm_player_t* player); -static void __mmplayer_stop_progress_timer(mm_player_t* player); -static gboolean __mmplayer_progress_timer_cb(gpointer u_data); -#endif - static gboolean __mmplayer_dump_pipeline_state( mm_player_t* player ); static gboolean __mmplayer_check_subtitle( mm_player_t* player ); static gboolean __mmplayer_handle_gst_error ( mm_player_t* player, GstMessage * message, GError* error ); @@ -191,6 +185,7 @@ static int __gst_pending_seek ( mm_player_t* player ); static int __gst_set_position(mm_player_t* player, int format, unsigned long position); static int __gst_get_position(mm_player_t* player, int format, unsigned long *position); static int __gst_get_buffer_position(mm_player_t* player, int format, unsigned long* start_pos, unsigned long* stop_pos); +static int __gst_adjust_subtitle_position(mm_player_t* player, int format, int position); static int __gst_set_message_callback(mm_player_t* player, MMMessageCallback callback, gpointer user_param); static void __gst_set_async_state_change(mm_player_t* player, gboolean async); @@ -200,7 +195,6 @@ static gint __gst_handle_resource_error( mm_player_t* player, int code ); static gint __gst_handle_stream_error( mm_player_t* player, GError* error, GstMessage * message ); static gint __gst_transform_gsterror( mm_player_t* player, GstMessage * message, GError* error); static gboolean __gst_send_event_to_sink( mm_player_t* player, GstEvent* event ); -static void __mmplayer_handle_buffering_message ( mm_player_t* player , GstMessage *buffering_msg); static int __mmplayer_set_harmony_filter(mm_player_t* player, GstElement * filter_element, MMAudioFilterInfo* info); static int __mmplayer_set_disharmony_filter(GstElement * filter_element, MMAudioFilterType filtertype); @@ -208,18 +202,13 @@ static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffe static int __mmplayer_set_pcm_extraction(mm_player_t* player); static gboolean __mmplayer_set_up_segment_extraction(mm_player_t* player, int dst_start, int dst_end); static gboolean __mmplayer_can_extract_pcm( mm_player_t* player ); + /*fadeout */ static void __mmplayer_do_sound_fadedown(mm_player_t* player, unsigned int time); static void __mmplayer_undo_sound_fadedown(mm_player_t* player); - static void __mmplayer_add_new_caps(GstPad* pad, GParamSpec* unused, gpointer data); static void __mmplayer_set_unlinked_mime_type(mm_player_t* player, GstCaps *caps); - -static guint64 __mmplayer_get_file_ring_buffer_size(mm_player_t* player); -static void __mmplayer_init_buffering_information ( mm_player_t* player ); -static void __mmplayer_update_buffering_limit_criterion_byte ( mm_player_t* player, guint buffer_limit_criterion_byte ); -static void __mmplayer_update_buffering_information ( mm_player_t* player, GstMessage *buffering_msg ); static void __mmplayer_set_videosink_type(mm_player_t* player); /* util */ @@ -239,7 +228,6 @@ static gboolean __mmplayer_warm_up_video_codec( mm_player_t* player, GstElement | | ========================================================================================== */ - /* implementing player FSM */ /* FIXIT : We need to handle state transition also at here since start api is no more sync */ static int @@ -454,8 +442,6 @@ ALREADY_GOING: return MM_ERROR_PLAYER_NO_OP; } - -/* bw.jang :+: 060809 INTERNAL_STATE_CHANGE */ int __mmplayer_gst_set_state (mm_player_t* player, GstElement * element, GstState state, gboolean async, gint timeout) // @ { @@ -844,11 +830,6 @@ __mmplayer_set_state(mm_player_t* player, int state) // @ { if (player->cmd == MMPLAYER_COMMAND_STOP) { - /* FIXIT : progress timer will be dprecated */ - #ifdef USE_PROGRESS_TIMER - __mmplayer_stop_progress_timer( player ); - #endif - asm_result = mmplayer_asm_set_state((MMHandleType)player, ASM_STATE_STOP); if ( asm_result != MM_ERROR_NONE ) { @@ -861,11 +842,6 @@ __mmplayer_set_state(mm_player_t* player, int state) // @ case MM_PLAYER_STATE_PAUSED: { - /* FIXIT : progress timer will be dprecated */ - #ifdef USE_PROGRESS_TIMER - __mmplayer_stop_progress_timer( player ); - #endif - /* special care for local playback. normaly we can get some content attribute * when the demuxer is changed to PAUSED. so we are trying it. it will be tried again * when PLAYING state has signalled if failed. @@ -889,11 +865,6 @@ __mmplayer_set_state(mm_player_t* player, int state) // @ case MM_PLAYER_STATE_PLAYING: { - /* FIXIT : progress timer will be dprecated */ - #ifdef USE_PROGRESS_TIMER - __mmplayer_start_progress_timer( player ); - #endif - /* update attributes which are only available on playing status */ _mmplayer_update_content_attrs ( player ); @@ -937,11 +908,6 @@ __mmplayer_set_state(mm_player_t* player, int state) // @ MMPLAYER_POST_MSG ( player, MM_MESSAGE_BEGIN_OF_STREAM, NULL ); player->sent_bos = TRUE; } - - /* FIXIT : progress timer will be dprecated */ - #ifdef USE_PROGRESS_TIMER - __mmplayer_start_progress_timer( player ); - #endif } break; @@ -1113,9 +1079,8 @@ static gpointer __mmplayer_repeat_thread(gpointer data) return NULL; } - -static void -__mmplayer_handle_buffering_message ( mm_player_t* player , GstMessage *buffering_msg) +static void +__mmplayer_handle_buffering_message ( mm_player_t* player ) { MMPlayerStateType prev_state = MM_PLAYER_STATE_NONE; MMPlayerStateType current_state = MM_PLAYER_STATE_NONE; @@ -1123,30 +1088,20 @@ __mmplayer_handle_buffering_message ( mm_player_t* player , GstMessage *bufferin MMPlayerStateType pending_state = MM_PLAYER_STATE_NONE; return_if_fail ( player ); - return_if_fail ( buffering_msg ); - return_if_fail ( GST_IS_MESSAGE ( buffering_msg ) ); - return_if_fail ( GST_MESSAGE_TYPE ( buffering_msg ) == GST_MESSAGE_BUFFERING ); - - /* update buffering information with buffering message */ - __mmplayer_update_buffering_information ( player, buffering_msg ); prev_state = MMPLAYER_PREV_STATE(player), current_state = MMPLAYER_CURRENT_STATE(player); target_state = MMPLAYER_TARGET_STATE(player); pending_state = MMPLAYER_PENDING_STATE(player); - #define BUFFERING_START_PERCENT 0 - #define BUFFERING_STOP_PERCENT 100 - - if ( player->buffering_info.buffering_percent == BUFFERING_STOP_PERCENT ) + if ( !player->streamer->is_buffering ) { - debug_log( "player state : prev %s, current %s, pending %s, target %s \n", + debug_log( "player state : prev %s, current %s, pending %s, target %s \n", MMPLAYER_STATE_GET_NAME(prev_state), MMPLAYER_STATE_GET_NAME(current_state), MMPLAYER_STATE_GET_NAME(pending_state), MMPLAYER_STATE_GET_NAME(target_state)); - /* NOTE : if buffering has done, player has to go to target state. */ switch ( target_state ) { @@ -1183,22 +1138,21 @@ __mmplayer_handle_buffering_message ( mm_player_t* player , GstMessage *bufferin debug_warning("invalid pending state [%s].\n", MMPLAYER_STATE_GET_NAME(pending_state) ); } break; - } } break; - + case MM_PLAYER_STATE_PLAYING : { - if ( MMPLAYER_IS_RTSP_STREAMING(player) ) - { + if ( MMPLAYER_IS_RTSP_STREAMING(player) ) + { __gst_resume ( player ); /* now we can overcome 'state-lost' situation */ player->state_lost = FALSE; - + return; - } + } switch ( pending_state ) { @@ -1227,7 +1181,7 @@ __mmplayer_handle_buffering_message ( mm_player_t* player , GstMessage *bufferin { debug_warning("invalid pending state [%s].\n", MMPLAYER_STATE_GET_NAME(pending_state) ); } - break; + break; } } break; @@ -1244,28 +1198,18 @@ __mmplayer_handle_buffering_message ( mm_player_t* player , GstMessage *bufferin } else { - /* NOTE : in case of rtsp streaming, the src plugin provide the pipeline clock. - * the src plugin is buffering, the pipeline clock stop automatically. + /* NOTE : in case of rtsp streaming, the src plugin provide the pipeline clock. + * the src plugin is buffering, the pipeline clock stop automatically. * so don't need to pause the player. */ if ( MMPLAYER_IS_RTSP_STREAMING(player) ) { - /* NOTE : secrtspsrc plugin post 0%-buffering message when only if initial buffering situation. - * in case of rebuffering situation, 0%-buffering message is not posted. - */ - if ( player->buffering_info.buffering_percent == BUFFERING_START_PERCENT ) - __mmplayer_update_stream_service_type ( player ); - /* NOTE : 'state-lost' situation. - * buffering has being progressing, the sink elements would go state-lost situation. - */ - else - player->state_lost = TRUE; - + player->state_lost = TRUE; return; } - /* NOTE : during the buffering, pause the player for stopping pipeline clock. - * it's for stopping the pipeline clock to prevent dropping the data in sink element. + /* NOTE : during the buffering, pause the player for stopping pipeline clock. + * it's for stopping the pipeline clock to prevent dropping the data in sink element. */ switch ( pending_state ) { @@ -1295,357 +1239,8 @@ __mmplayer_handle_buffering_message ( mm_player_t* player , GstMessage *bufferin debug_warning("invalid pending state [%s].\n", MMPLAYER_STATE_GET_NAME(pending_state) ); } break; - } - } - - #undef BUFFERING_START_PERCENT - #undef BUFFERING_STOP_PERCENT -} - -static guint64 __mmplayer_get_file_ring_buffer_size (mm_player_t* player) -{ - GstFormat fmt = GST_FORMAT_BYTES; - guint64 contents_size = 0L; //bytes - guint64 storage_available_size = 0L; //bytes - guint64 file_ring_buffer_size = 0L; //bytes - struct statfs buf = {0}; - gchar *path = NULL; - - debug_fenter(); - - return_val_if_fail ( player && - player->pipeline && - player->pipeline->mainbin && - player->pipeline->mainbin[MMPLAYER_M_SRC].gst, - 0L ); - - /* Note : if file_ring_buffer_size is larger than 0, the file buffer operate like the ring buffer. - * else player uses the file for fully downloading streaming contents. - * 1. get the path of the file which is for buffering contents. - * 2. calculate the storage avaiable capacity of that path. - * 3. get the duration in bytes format of the contents. - * 4. compare the content's duration with the storage capacity. - * 4-1. if the duration is larger than the storage capacity, the file_ring_buffer_size is set to storage capacity. - * 4-2. else the file_ring_buffer_size is set to 0, not use file ring buffer. - */ - - if ( PLAYER_INI()->http_temp_template && strlen( PLAYER_INI()->http_temp_template)>strlen("/XXXXXX") ) - path = g_strndup((const gchar*)PLAYER_INI()->http_temp_template, strlen(PLAYER_INI()->http_temp_template)-strlen("/XXXXXX")); - - if (path) - { - debug_log("the buffering file path is %s.\n", path); - - if (statfs((const char *)path, &buf) < 0) - { - debug_warning ("fail to get availabe storage capacity. \n"); - storage_available_size = 0L; - } - else - { - storage_available_size = (guint64)buf.f_bavail * (guint64)buf.f_bsize; //bytes - - debug_log ("the number of available blocks : %"G_GUINT64_FORMAT", the block size is %"G_GUINT64_FORMAT".\n", - (guint64)buf.f_bavail, (guint64)buf.f_bsize); - debug_log ("calculated availabe storage size is %"G_GUINT64_FORMAT" Bytes.\n", storage_available_size); - } - } - else - { - debug_warning("the buffering file path is not set properly.\n"); - storage_available_size = 0L; - } - - - if (gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, &fmt, (gint64 *)&contents_size)) - { - if (contents_size>0 && contents_sizebuffering_info.is_buffering = FALSE; - player->buffering_info.audio_only = FALSE; - player->buffering_info.need_update = FALSE; - player->buffering_info.buffering_repeat_cnt = 0; - player->buffering_info.buffering_percent = -1; - player->buffering_info.buffer_size_byte = PLAYER_INI()->http_max_size_bytes; - player->buffering_info.buffer_low_limit_percent = PLAYER_INI()->http_buffering_low_limit; - player->buffering_info.buffer_high_limit_percent = PLAYER_INI()->http_buffering_high_limit; - player->buffering_info.buffer_low_limit_byte = ( PLAYER_INI()->http_buffering_low_limit * PLAYER_INI()->http_max_size_bytes ) / 100; - player->buffering_info.buffer_high_limit_byte = ( PLAYER_INI()->http_buffering_high_limit * PLAYER_INI()->http_max_size_bytes ) / 100; - player->buffering_info.buffer_avg_in_byterate = 0; - player->buffering_info.buffer_avg_out_byterate = 0; - player->buffering_info.buffering_time = PLAYER_INI()->http_buffering_time; - player->buffering_info.buffer_limit_criterion_byte = 0; - - debug_fleave(); -} - -static void -__mmplayer_update_buffering_limit_criterion_byte ( mm_player_t* player, guint buffer_limit_criterion_byte ) -{ - MMPlayerGstElement *audiobin = NULL; - MMPlayerGstElement *videobin = NULL; - - debug_fenter(); - - return_if_fail ( player && player->pipeline ); - - audiobin = player->pipeline->audiobin; - videobin = player->pipeline->videobin; - - #define DEFAULT_AUDIO_ONLY_BUFFER_SIZE 1048576 // 1 MButes - - if ( audiobin && !videobin ) - { - debug_log ("This is audio only streaming, need to fix the buffer size smaller than video streaming.\n"); - - player->buffering_info.audio_only = TRUE; - - /* Note : Use 1 MBytes buffer for audio only streaming. It could be updated. */ - if ( player->buffering_info.audio_only && player->pipeline->mainbin && player->pipeline->mainbin[MMPLAYER_M_S_BUFFER].gst ) - { - player->buffering_info.buffer_size_byte = DEFAULT_AUDIO_ONLY_BUFFER_SIZE; - g_object_set ( G_OBJECT(player->pipeline->mainbin[MMPLAYER_M_S_BUFFER].gst), "max-size-bytes", DEFAULT_AUDIO_ONLY_BUFFER_SIZE, NULL ); } } - else - { - player->buffering_info.audio_only = FALSE; - - /* Note : Use 4 MBytes buffer for video streaming. It could be updated. */ - debug_log ("This is video streaming, use default buffer size.\n"); - } - - debug_log("This is %s streaming.\n", player->buffering_info.audio_only ? "audio" : "video"); - - - if ( player->buffering_info.buffer_limit_criterion_byte != buffer_limit_criterion_byte ) - { - debug_log ( "update buffer limit criterion : %d[bytes] --> %d[bytes]\n", - player->buffering_info.buffer_limit_criterion_byte, buffer_limit_criterion_byte ); - - player->buffering_info.buffer_limit_criterion_byte = buffer_limit_criterion_byte; - player->buffering_info.need_update = TRUE; - } - - #undef DEFAULT_AUDIO_ONLY_BUFFER_SIZE - - debug_fleave(); -} - -static void -__mmplayer_update_buffering_information ( mm_player_t* player, GstMessage *buffering_msg ) -{ - MMMessageParamType msg_param = {0, }; - GstElement *buffering_element = NULL; - GstBufferingMode mode = GST_BUFFERING_STREAM; - gint avg_in = 0; - gint avg_out = 0; - gint64 buffering_left = -1; - gdouble buffering_time = 1.0; - guint low_limit_percent = 0; - guint high_limit_percent = 0; - guint low_limit_byte = 0; - guint high_limit_byte = 0; - gint buffer_percent = 0; - - return_if_fail ( player ); - return_if_fail ( buffering_msg ); - return_if_fail ( GST_IS_MESSAGE ( buffering_msg ) ); - return_if_fail ( GST_MESSAGE_TYPE ( buffering_msg ) == GST_MESSAGE_BUFFERING ); - - #define BUFFERING_START_PERCENT 0 - #define BUFFERING_STOP_PERCENT 100 - #define MIN_BUFFERING_TIME PLAYER_INI()->http_buffering_time - #define MAX_BUFFERING_TIME 10.0 - - /* update when buffering has started. */ - if ( !player->buffering_info.is_buffering ) - { - debug_log ( "buffering has started.\n" ); - - player->buffering_info.is_buffering = TRUE; - player->buffering_info.need_update = TRUE; - player->buffering_info.buffering_repeat_cnt ++; - player->buffering_info.buffering_percent = -1; - } - - /* update buffer percent */ - gst_message_parse_buffering ( buffering_msg, &buffer_percent ); - - if ( player->buffering_info.buffering_percent < buffer_percent ) - { - if (player->pipeline_is_constructed || MMPLAYER_IS_RTSP_STREAMING(player)) - { - debug_log ( "buffering %d%%....\n", buffer_percent ); - - player->buffering_info.buffering_percent = buffer_percent; - msg_param.connection.buffering = player->buffering_info.buffering_percent; - - MMPLAYER_POST_MSG ( player, MM_MESSAGE_BUFFERING, &msg_param ); - } - } - - if ( player->buffering_info.buffering_percent == BUFFERING_STOP_PERCENT ) - { - debug_log ( "buffering had done.\n" ); - player->buffering_info.is_buffering = FALSE; - } - - if ( !player->buffering_info.need_update ) - goto update_done; - - - /* Note : Parse the buffering message to get the in/out throughput. - * avg_in is the network throughput and avt_out is the consumed throughtput by the linkded element. - */ - gst_message_parse_buffering_stats ( buffering_msg, &mode, &avg_in, &avg_out, &buffering_left ); - - - /* update average in/out rate */ - debug_log ( "average in rate is changed : %d --> %d.\n", player->buffering_info.buffer_avg_in_byterate, avg_in ); - debug_log ( "average out rate is changed : %d --> %d.\n", player->buffering_info.buffer_avg_out_byterate, avg_out ); - player->buffering_info.buffer_avg_in_byterate = avg_in; - player->buffering_info.buffer_avg_out_byterate = avg_out; - - /* Note : In case of http streaming, the buffering element is queue2. */ - buffering_element = GST_ELEMENT_CAST ( GST_MESSAGE_SRC ( buffering_msg ) ); - if ( buffering_element ) - debug_log ( "buffering element name is %s.\n", gst_element_get_name( buffering_element ) ); - - if ( player->buffering_info.buffering_repeat_cnt == 1 ) - { - /* in case of initial buffering, use the default buffering time.*/ - buffering_time = MIN_BUFFERING_TIME; - } - else - { - if ( avg_in > 0 && avg_out == 0) - buffering_time = MIN_BUFFERING_TIME; - else if ( avg_in == 0 && avg_out > 0) - buffering_time = MAX_BUFFERING_TIME; - else if ( avg_in >= avg_out ) - buffering_time = MIN_BUFFERING_TIME; - else - { - buffering_time = ( avg_out * 2.0 ) / avg_in; - debug_log ( "avg_out/avg_in = %2.1f .\n", buffering_time ); - } - - if ( buffering_time <= MIN_BUFFERING_TIME ) - buffering_time = MIN_BUFFERING_TIME; - else if ( buffering_time >= MAX_BUFFERING_TIME ) - buffering_time = MAX_BUFFERING_TIME; - } - - if ( player->buffering_info.buffering_time != buffering_time ) - { - debug_log ( "buffering time is changed : %2.1f --> %2.1f .\n", player->buffering_info.buffering_time, buffering_time ); - player->buffering_info.buffering_time = buffering_time; - } - - low_limit_byte = player->buffering_info.buffer_low_limit_byte; - if ( player->buffering_info.buffer_limit_criterion_byte > 0 ) - high_limit_byte = player->buffering_info.buffer_limit_criterion_byte * player->buffering_info.buffering_time; - else - high_limit_byte = ( PLAYER_INI()->http_buffering_high_limit * PLAYER_INI()->http_max_size_bytes ) * player->buffering_info.buffering_time / 100; - - - if ( player->buffering_info.buffer_size_byte < high_limit_byte ) - { - debug_log ( "buffer size[%d bytes] is smaller than high threshold[%d bytes]. update it. \n", - player->buffering_info.buffer_size_byte, high_limit_byte ); - player->buffering_info.buffer_size_byte = high_limit_byte; - - if ( buffering_element ) - g_object_set ( G_OBJECT ( buffering_element ), "max-size-bytes", player->buffering_info.buffer_size_byte, NULL ); - } - - low_limit_percent = ( low_limit_byte * 100 ) / player->buffering_info.buffer_size_byte; - high_limit_percent = ( high_limit_byte * 100 ) / player->buffering_info.buffer_size_byte; - - if ( low_limit_percent <= 0 ) - low_limit_percent = 1; - - if ( high_limit_percent >= 100 ) - high_limit_percent = 99; - - debug_log ( "calculated buffer low/higin thresholds[%d%%~%d%%].\n", low_limit_percent, high_limit_percent ); - - if ( low_limit_percent >= high_limit_percent ) - { - debug_log ( "calculated buffer low/higin thresholds have some problem. keep before values.\n"); - goto update_done; - } - - if ( player->buffering_info.buffer_low_limit_percent != low_limit_percent ) - { - debug_log ( "Low threshold for buffering to start is changed : %d%%[%d bytes] --> %d%%[%d bytes] \n", - player->buffering_info.buffer_low_limit_percent, player->buffering_info.buffer_low_limit_byte, - low_limit_percent, low_limit_byte ); - - player->buffering_info.buffer_low_limit_byte = low_limit_byte; - player->buffering_info.buffer_low_limit_percent = low_limit_percent; - - if ( buffering_element ) - g_object_set ( G_OBJECT ( buffering_element ), "low-percent", player->buffering_info.buffer_low_limit_percent, NULL ); - } - - if ( player->buffering_info.buffer_high_limit_percent != high_limit_percent ) - { - debug_log ( "High threshold for buffering to finish is changed : %d%%[%d bytes] --> %d%%[%d bytes].\n", - player->buffering_info.buffer_high_limit_percent, player->buffering_info.buffer_high_limit_byte, - high_limit_percent, high_limit_byte ); - - player->buffering_info.buffer_high_limit_byte = high_limit_byte; - player->buffering_info.buffer_high_limit_percent = high_limit_percent; - - if ( buffering_element ) - g_object_set ( G_OBJECT ( buffering_element ), "high-percent", player->buffering_info.buffer_high_limit_percent, NULL ); - } - -update_done: - player->buffering_info.need_update = FALSE; - - #undef BUFFERING_START_PERCENT - #undef BUFFERING_STOP_PERCENT - #undef MIN_BUFFERING_TIME - #undef MAX_BUFFERING_TIME - - return; } static gboolean @@ -1653,6 +1248,7 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ { mm_player_t* player = (mm_player_t*) data; gboolean ret = TRUE; + static gboolean async_done = FALSE; return_val_if_fail ( player, FALSE ); return_val_if_fail ( msg && GST_IS_MESSAGE(msg), FALSE ); @@ -1852,7 +1448,21 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ case GST_MESSAGE_BUFFERING: { - __mmplayer_handle_buffering_message ( player, msg); + MMMessageParamType msg_param = {0, }; + gboolean update_buffering_percent = TRUE; + + if (!MMPLAYER_IS_STREAMING(player)) + break; + + __mm_player_streaming_buffering (player->streamer, msg); + __mmplayer_handle_buffering_message ( player ); + + update_buffering_percent = player->pipeline_is_constructed || MMPLAYER_IS_RTSP_STREAMING(player) || MMPLAYER_IS_HTTP_LIVE_STREAMING(player); + if (update_buffering_percent) + { + msg_param.connection.buffering = player->streamer->buffering_percent; + MMPLAYER_POST_MSG ( player, MM_MESSAGE_BUFFERING, &msg_param ); + } } break; @@ -1913,8 +1523,7 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ if ( MMPLAYER_IS_STREAMING(player) ) { - if ( player->maximum_bitrate ) - __mmplayer_update_buffering_limit_criterion_byte ( player, player->maximum_bitrate /8 ); + __mm_player_streaming_set_content_bitrate(player->streamer, player->total_maximum_bitrate, player->total_bitrate); /* check pending seek and do now */ if ( player->pending_seek.is_pending ) @@ -1924,6 +1533,14 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ break; case GST_STATE_PLAYING: + + if (player->is_seeking && async_done) + { + MMPLAYER_POST_MSG ( player, MM_MESSAGE_SEEK_COMPLETED, NULL ); + player->is_seeking = FALSE; + async_done = FALSE; + } + MMPLAYER_SET_STATE ( player, MM_PLAYER_STATE_PLAYING ); break; @@ -1970,21 +1587,6 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ { debug_log("GST_MESSAGE_ELEMENT\n"); - #if defined(VDF_SDK) || defined(SEC_SDK) - { - GstStructure *s; - - s = msg->structure; - if (gst_structure_has_name (s, "missing-plugin")) - { - syslog(LOG_INFO, "Not supported in simulator(Codec not supported)"); - - __gst_unrealize( player ); - ret = FALSE; - } - } - #endif /* VDF_SDK || SEC_SDK */ - } break; @@ -2011,8 +1613,15 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ if (player->is_seeking) { - MMPLAYER_POST_MSG ( player, MM_MESSAGE_SEEK_COMPLETED, NULL ); - player->is_seeking = FALSE; + if (MMPLAYER_TARGET_STATE(player) == MM_PLAYER_STATE_PAUSED) + { + MMPLAYER_POST_MSG ( player, MM_MESSAGE_SEEK_COMPLETED, NULL ); + player->is_seeking = FALSE; + } + else if (MMPLAYER_TARGET_STATE(player) == MM_PLAYER_STATE_PLAYING) + { + async_done = TRUE; + } } } break; @@ -2059,18 +1668,30 @@ if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint))\ {\ if(gsttag==GST_TAG_BITRATE)\ {\ - debug_log ( "update bitrate from %d[bps] to %d[bps]\n", player->bitrate, player->bitrate+v_uint );\ - player->bitrate+=v_uint;\ - mm_attrs_set_int_by_name(attribute, playertag, player->bitrate); \ + if (player->updated_bitrate_countbitrate[player->updated_bitrate_count] = v_uint;\ + player->total_bitrate += player->bitrate[player->updated_maximum_bitrate_count]; \ + player->updated_bitrate_count++; \ + mm_attrs_set_int_by_name(attribute, playertag, player->total_bitrate);\ + debug_log ( "update bitrate %d[bps] of stream #%d.\n", v_uint, player->updated_bitrate_count);\ + }\ }\ else if (gsttag==GST_TAG_MAXIMUM_BITRATE)\ {\ - debug_log ( "update maximum bitrate %d[bps] to %d[bps]\n", player->maximum_bitrate, player->maximum_bitrate+v_uint );\ - player->maximum_bitrate+=v_uint;\ - mm_attrs_set_int_by_name(attribute, playertag, player->maximum_bitrate); \ + if (player->updated_maximum_bitrate_countmaximum_bitrate[player->updated_maximum_bitrate_count] = v_uint;\ + player->total_maximum_bitrate += player->maximum_bitrate[player->updated_maximum_bitrate_count]; \ + player->updated_maximum_bitrate_count++; \ + mm_attrs_set_int_by_name(attribute, playertag, player->total_maximum_bitrate); \ + debug_log ( "update maximum bitrate %d[bps] of stream #%d\n", v_uint, player->updated_maximum_bitrate_count);\ + }\ }\ else\ + {\ mm_attrs_set_int_by_name(attribute, playertag, v_uint); \ + }\ v_uint = 0;\ }\ } @@ -2188,10 +1809,6 @@ if(gst_tag_list_get_double(tag_list, gsttag, &v_double))\ return TRUE; } - -/* yejin.cho : 090211 :+: Add to change the state of the - * player when all the pads of the RTSPSrc are created. - */ static void __mmplayer_gst_rtp_no_more_pads (GstElement *element, gpointer data) // @ { @@ -2329,30 +1946,12 @@ __mmplayer_gst_rtp_dynamic_pad (GstElement *element, GstPad *pad, gpointer data) /* video packet */ debug_log("is video stream. take it.\n"); element_id = MMPLAYER_M_S_VDEC; - - if ( PLAYER_INI()->rtsp_dump_video_frame ) - { - debug_warning("video frame dump enabled. storing location : /tmp/rtp-video.dump\n"); - new_element = gst_element_factory_make( "filesink", NULL ); - - g_object_set(G_OBJECT(new_element), "sync", TRUE, NULL); - g_object_set(G_OBJECT(new_element), "location", "/tmp/rtp-video.dump", NULL); - } } else if ( MMPLAYER_PT_IS_AUDIO( GST_PAD_NAME( pad ) ) ) { /* audio packet */ debug_log("is audio stream. take it.\n"); element_id = MMPLAYER_M_S_ADEC; - - if ( PLAYER_INI()->rtsp_dump_audio_frame ) - { - debug_warning("audio frame dump enabled. storing location : /tmp/rtp-audio.dump\n"); - new_element = gst_element_factory_make( "filesink", NULL ); - - g_object_set(G_OBJECT(new_element), "sync", TRUE, NULL); - g_object_set(G_OBJECT(new_element), "location", "/tmp/rtp-audio.dump", NULL); - } } else { @@ -2750,13 +2349,12 @@ _mmplayer_update_video_param(mm_player_t* player) // @ if (g_strrstr(ename, "fimcconvert")) { - if (width) g_object_set(player->pipeline->videobin[MMPLAYER_V_CONV].gst, "src-width", width, NULL); if (height) g_object_set(player->pipeline->videobin[MMPLAYER_V_CONV].gst, "src-height", height, NULL); - + switch (degree) { case MM_DISPLAY_ROTATION_NONE: @@ -3108,6 +2706,7 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) { MMPlayerGstElement* first_element = NULL; MMPlayerGstElement* audiobin = NULL; + MMHandleType attrs = 0; GstPad *pad = NULL; GstPad *ghostpad = NULL; GList* element_bucket = NULL; @@ -3128,6 +2727,7 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) return MM_ERROR_PLAYER_NO_FREE_SPACE; } + attrs = MMPLAYER_GET_ATTRS(player); /* create bin */ audiobin[MMPLAYER_A_BIN].id = MMPLAYER_A_BIN; @@ -3214,9 +2814,6 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) gint audio_route = 0; gint sound_priority = FALSE; gint is_spk_out_only = 0; - MMHandleType attrs = 0; - - attrs = MMPLAYER_GET_ATTRS(player); //mm_attrs_get_int_by_name(attrs, "sound_bgm_mode", &isBgm); if ( player->app_id_set_up_dnse == MM_AUDIO_FILTER_CLIENT_MUSIC_PLAYER ) // music player @@ -3249,7 +2846,6 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) debug_log("audiosink property status...volume type:%d, route:%d, priority=%d, user-route=%d\n", volume_type, audio_route, sound_priority, is_spk_out_only); - } /* Antishock can be enabled when player is resumed by soundCM. @@ -3307,7 +2903,6 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) MMPLAYER_ADD_PROBE( gst_element_get_static_pad(GST_ELEMENT(audiobin[MMPLAYER_A_SINK].gst), "sink" ), MM_PROBE_TIMESTAMP ); #endif - /* adding created elements to bin */ debug_log("adding created elements to bin\n"); if( !__mmplayer_gst_element_add_bucket_to_bin( GST_BIN(audiobin[MMPLAYER_A_BIN].gst), element_bucket )) @@ -3316,7 +2911,6 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) goto ERROR; } - /* linking elements in the bucket by added order. */ debug_log("Linking elements in the bucket by added order.\n"); if ( __mmplayer_gst_element_link_bucket(element_bucket) == -1 ) @@ -3350,10 +2944,7 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) gst_object_unref(pad); - - /* mekim:+:applying stored DNSe setting */ if ( PLAYER_INI()->use_audio_filter && (! player->DNSeBypass)) - { _mmplayer_apply_sound_filter((MMHandleType) player , &player->audio_filter_info); } @@ -3362,6 +2953,10 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) MMPLAYER_FREEIF( device_name ); g_list_free(element_bucket); + mm_attrs_set_int_by_name(attrs, "content_audio_found", TRUE); + if ( mmf_attrs_commit ( attrs ) ) /* return -1 if error */ + debug_error("failed to commit attribute ""content_audio_found"".\n"); + debug_fleave(); return MM_ERROR_NONE; @@ -3619,6 +3214,10 @@ __mmplayer_gst_create_video_pipeline(mm_player_t* player) /* done. free allocated variables */ g_list_free(element_bucket); + mm_attrs_set_int_by_name(attrs, "content_video_found", TRUE); + if ( mmf_attrs_commit ( attrs ) ) /* return -1 if error */ + debug_error("failed to commit attribute ""content_video_found"".\n"); + debug_fleave(); return MM_ERROR_NONE; @@ -3648,7 +3247,7 @@ ERROR: static int __mmplayer_gst_create_text_pipeline(mm_player_t* player) { - GstElement *pipeline = NULL; + GstBus *bus = NULL; MMPlayerGstElement* textbin = NULL; MMHandleType attrs = 0; gchar *subtitle_uri =NULL; @@ -3664,12 +3263,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player) debug_fenter(); /* get mainbin */ - return_val_if_fail ( player && - player->pipeline && - player->pipeline->mainbin, - MM_ERROR_PLAYER_NOT_INITIALIZED); - - pipeline = player->pipeline->mainbin[MMPLAYER_M_PIPE].gst; + return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED); attrs = MMPLAYER_GET_ATTRS(player); if ( !attrs ) @@ -3696,11 +3290,11 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player) } /* create bin */ - textbin[MMPLAYER_T_BIN].id = MMPLAYER_T_BIN; - textbin[MMPLAYER_T_BIN].gst = gst_bin_new("textbin"); - if ( !textbin[MMPLAYER_T_BIN].gst ) + textbin[MMPLAYER_T_PIPE].id = MMPLAYER_T_PIPE; + textbin[MMPLAYER_T_PIPE].gst = gst_pipeline_new("textbin"); + if ( !textbin[MMPLAYER_T_PIPE].gst ) { - debug_error("failed to create textbin\n"); + debug_error("failed to create text pipeline\n"); goto ERROR; } player->pipeline->textbin = textbin; @@ -3722,11 +3316,9 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player) mm_attrs_get_int_by_name(attrs,"width", &width); mm_attrs_get_int_by_name(attrs,"height", &height); mm_attrs_get_int_by_name(attrs,"silent", &silent); - g_object_set ( G_OBJECT (textbin[MMPLAYER_T_TEXTRENDER].gst), - "width", width, - "height", height, - "silent", silent, - NULL ); + g_object_set ( G_OBJECT (textbin[MMPLAYER_T_TEXTRENDER].gst),"width", width, NULL); + g_object_set ( G_OBJECT (textbin[MMPLAYER_T_TEXTRENDER].gst),"height", height, NULL); + g_object_set ( G_OBJECT (textbin[MMPLAYER_T_TEXTRENDER].gst),"silent", silent, NULL); debug_log ( "subtitle winow size is [%dX%d].\n", width, height ); debug_log ( "subtitle silent is [%d].\n", silent ); @@ -3734,14 +3326,12 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player) /* converter1 */ MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_CONV1, "ffmpegcolorspace", "text_converter1", TRUE); - /* videofliper */ MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_FLIP, "videoflip", "text_fliper", TRUE); /* converter2 */ MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_CONV2, "ffmpegcolorspace", "text_converter2", TRUE); - /* text sink */ MMPLAYER_CREATE_ELEMENT(textbin, MMPLAYER_T_SINK, "ximagesink", "text_sink", TRUE); @@ -3771,7 +3361,7 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player) #endif /* adding created elements to bin */ - if( ! __mmplayer_gst_element_add_bucket_to_bin(GST_BIN(textbin[MMPLAYER_T_BIN].gst), element_bucket) ) + if( ! __mmplayer_gst_element_add_bucket_to_bin(GST_BIN(textbin[MMPLAYER_T_PIPE].gst), element_bucket) ) { debug_error("failed to add elements\n"); goto ERROR; @@ -3784,39 +3374,25 @@ __mmplayer_gst_create_text_pipeline(mm_player_t* player) goto ERROR; } - - /* warm up textbin */ - if ( GST_STATE_CHANGE_FAILURE == gst_element_set_state( GST_ELEMENT(textbin[MMPLAYER_T_BIN].gst), GST_STATE_READY ) ) - { - debug_error("failed to set state(READY) to textbin\n"); - goto ERROR; - } - - /* add textbin to pipeline */ - if ( FALSE == gst_bin_add( GST_BIN(pipeline), GST_ELEMENT(textbin[MMPLAYER_T_BIN].gst) ) ) - { - debug_error("failed to add textbin to pipeline\n"); - goto ERROR; - } - - /* done. free allocated variables */ g_list_free(element_bucket); + player->play_subtitle = TRUE; + debug_fleave(); return MM_ERROR_NONE; ERROR: - debug_error("ERROR : releasing textbin\n"); + debug_error("ERROR : releasing text pipeline\n"); g_list_free( element_bucket ); /* release textbin with it's childs */ - if ( textbin[MMPLAYER_T_BIN].gst ) + if ( textbin[MMPLAYER_T_PIPE].gst ) { - gst_object_unref(GST_OBJECT(textbin[MMPLAYER_T_BIN].gst)); + gst_object_unref(GST_OBJECT(textbin[MMPLAYER_T_PIPE].gst)); } MMPLAYER_FREEIF( textbin ); @@ -3868,6 +3444,82 @@ __mmplayer_update_subtitle( GstElement* object, GstBuffer *buffer, GstPad *pad, } +static int __gst_adjust_subtitle_position(mm_player_t* player, int format, int position) +{ + GstEvent* event = NULL; + gint64 current_pos = 0L; + gint64 adusted_pos = 0L; + gboolean ret = TRUE; + + debug_fenter(); + + /* check video sinkbin is created */ + return_val_if_fail ( player && + player->pipeline && + player->pipeline->textbin && + player->pipeline->textbin[MMPLAYER_T_PIPE].gst, + MM_ERROR_PLAYER_NOT_INITIALIZED ); + + if (position == 0) + return MM_ERROR_NONE; + + switch (format) + { + case MM_PLAYER_POS_FORMAT_TIME: + { + /* check current postion */ + ret = gst_element_query_position( GST_ELEMENT(player->pipeline->textbin[MMPLAYER_T_PIPE].gst), &format, ¤t_pos ); + if ( !ret ) + { + debug_warning("fail to query current postion.\n"); + return MM_ERROR_PLAYER_SEEK; + } + else + { + adusted_pos = current_pos + ((gint64)position * G_GINT64_CONSTANT(1000000)); + if (adusted_pos < 0) + adusted_pos = 0L; + debug_log("adjust subtitle postion : %lu -> %lu [msec]\n", GST_TIME_AS_MSECONDS(current_pos), GST_TIME_AS_MSECONDS(adusted_pos)); + } + + event = gst_event_new_seek (1.0, GST_FORMAT_TIME, + ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), + GST_SEEK_TYPE_SET, adusted_pos, + GST_SEEK_TYPE_SET, -1); + } + break; + + case MM_PLAYER_POS_FORMAT_PERCENT: + { + debug_warning("percent format is not supported yet.\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + break; + + default: + { + debug_warning("invalid format.\n"); + return MM_ERROR_INVALID_ARGUMENT; + } + } + + /* keep ref to the event */ + gst_event_ref (event); + + debug_log("sending event[%s] to sink element [%s]\n", + GST_EVENT_TYPE_NAME(event), GST_ELEMENT_NAME(player->pipeline->textbin[MMPLAYER_T_SINK].gst) ); + + if ( (ret = gst_element_send_event (player->pipeline->textbin[MMPLAYER_T_SINK].gst, event)) ) + { + debug_log("sending event[%s] to sink element [%s] success!\n", + GST_EVENT_TYPE_NAME(event), GST_ELEMENT_NAME(player->pipeline->textbin[MMPLAYER_T_SINK].gst) ); + } + + debug_fleave(); + + return MM_ERROR_NONE; + +} static void __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) // @ @@ -4091,12 +3743,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ gint udp_timeout, network_bandwidth; gchar *user_agent, *wap_profile; - /* create rtspsrc element and set properties */ - #if defined ( IS_SDK ) - element = gst_element_factory_make("rtspsrc", "streaming_source"); - #else element = gst_element_factory_make(PLAYER_INI()->name_of_rtspsrc, "streaming_source"); - #endif if ( !element ) { @@ -4104,11 +3751,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ break; } - #if defined ( IS_SDK ) - debug_log("using streamming source [rtspsrc].\n"); - #else debug_log("using streamming source [%s].\n", PLAYER_INI()->name_of_rtspsrc); - #endif /* make it zero */ udp_timeout = network_bandwidth = 0; @@ -4127,9 +3770,6 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ debug_log("network_bandwidth : %d\n", network_bandwidth); debug_log("buffering time : %d\n", PLAYER_INI()->rtsp_buffering_time); debug_log("rebuffering time : %d\n", PLAYER_INI()->rtsp_rebuffering_time); - debug_log("rtsp_audio_packet_drop_rate : %d\n", PLAYER_INI()->rtsp_audio_packet_drop_rate); - debug_log("rtsp_video_packet_drop_rate : %d\n", PLAYER_INI()->rtsp_video_packet_drop_rate); - debug_log("rtsp_stack_debug : %d\n", PLAYER_INI()->rtsp_stack_debug); debug_log("-----------------------------------------\n"); /* setting property to streaming source */ @@ -4138,9 +3778,6 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ g_object_set(G_OBJECT(element), "bandwidth", network_bandwidth, NULL); g_object_set(G_OBJECT(element), "buffering_time", PLAYER_INI()->rtsp_buffering_time, NULL); g_object_set(G_OBJECT(element), "rebuffering_time", PLAYER_INI()->rtsp_rebuffering_time, NULL); - g_object_set(G_OBJECT(element), "audio_packet_drop_rate", PLAYER_INI()->rtsp_audio_packet_drop_rate, NULL); - g_object_set(G_OBJECT(element), "video_packet_drop_rate", PLAYER_INI()->rtsp_video_packet_drop_rate, NULL); - g_object_set(G_OBJECT(element), "stack_debug", PLAYER_INI()->rtsp_stack_debug, NULL); if ( user_agent ) g_object_set(G_OBJECT(element), "user_agent", user_agent, NULL); if ( wap_profile ) @@ -4202,13 +3839,11 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ debug_log("proxy : %s\n", proxy); debug_log("user_agent : %s\n", user_agent); debug_log("timeout : %d\n", PLAYER_INI()->http_timeout); - debug_log("blocksize : %d\n", PLAYER_INI()->http_blocksize); debug_log("-----------------------------------------\n"); /* setting property to streaming source */ g_object_set(G_OBJECT(element), "location", player->profile.uri, NULL); g_object_set(G_OBJECT(element), "timeout", PLAYER_INI()->http_timeout, NULL); - g_object_set(G_OBJECT(element), "blocksize", PLAYER_INI()->http_blocksize, NULL); /* check if prosy is vailid or not */ if ( util_check_valid_url ( proxy ) ) g_object_set(G_OBJECT(element), "proxy", proxy, NULL); @@ -4245,7 +3880,6 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ else { /* TODO */ - //player->pd_file_location = ; } element = gst_element_factory_make("pdpushsrc", "PD_pushsrc"); @@ -4255,7 +3889,6 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ break; } - g_print ("\n\n\n\n \t\t ======== >>>>PD File will be stored in %s location\n\n\n\n", player->pd_file_location); g_object_set(G_OBJECT(element), "location", player->pd_file_location, NULL); } @@ -4379,6 +4012,12 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ MMPLAYER_ADD_PROBE( gst_element_get_static_pad(GST_ELEMENT(mainbin[MMPLAYER_M_SRC].gst), "src" ), MM_PROBE_TIMESTAMP ); #endif + if (MMPLAYER_IS_STREAMING(player) || (player->profile.uri_type == MM_PLAYER_URI_TYPE_HLS)) + { + player->streamer = __mm_player_streaming_create(); + __mm_player_streaming_initialize(player->streamer); + } + if ( player->profile.uri_type == MM_PLAYER_URI_TYPE_HLS ) { debug_log ("adding appsrc's pad probe...\n"); @@ -4403,16 +4042,21 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ goto INIT_ERROR; } - g_object_set ( G_OBJECT (element), "max-size-bytes", PLAYER_INI()->http_max_size_bytes, NULL ); - g_object_set ( G_OBJECT (element), "low-percent", PLAYER_INI()->http_buffering_low_limit, NULL ); - //g_object_set ( G_OBJECT (element), "high-percent", PLAYER_INI()->http_buffering_high_limit, NULL ); - g_object_set ( G_OBJECT (element), "high-percent", 5, NULL ); - g_object_set ( G_OBJECT (element), "use-buffering", PLAYER_INI()->http_use_buffering, NULL ); - /* take it */ mainbin[MMPLAYER_M_S_BUFFER].id = MMPLAYER_M_S_BUFFER; mainbin[MMPLAYER_M_S_BUFFER].gst = element; element_bucket = g_list_append(element_bucket, &mainbin[MMPLAYER_M_S_BUFFER]); + + __mm_player_streaming_set_buffer(player->streamer, + element, + TRUE, + PLAYER_INI()->http_max_size_bytes, + 1.0, + 5.0, + PLAYER_INI()->http_buffering_time, + MMPLAYER_USE_FILE_FOR_BUFFERING(player), + NULL, + 0); } /* create autoplugging element if src element is not a streamming src */ @@ -4497,11 +4141,9 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ } } - /* now we have completed mainbin. take it */ player->pipeline->mainbin = mainbin; - /* connect bus callback */ bus = gst_pipeline_get_bus(GST_PIPELINE(mainbin[MMPLAYER_M_PIPE].gst)); if ( !bus ) @@ -4575,17 +4217,6 @@ INIT_ERROR: MMPLAYER_FREEIF( mainbin ); return MM_ERROR_PLAYER_INTERNAL; - -#if defined(VDF_SDK) || defined (SEC_SDK) -NOT_IMPLEMENTED: - - MMPLAYER_FREEIF(player->pipeline ); - MMPLAYER_FREEIF( mainbin ); - g_list_free(element_bucket); - - return MM_ERROR_NOT_IMPLEMENTED; -#endif - } @@ -4615,8 +4246,6 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player) // @ player->pending_seek.format = MM_PLAYER_POS_FORMAT_TIME; player->pending_seek.pos = 0; - __mmplayer_init_buffering_information ( player ); - if (ahs_appsrc_cb_probe_id ) { GstPad *pad = NULL; @@ -4640,10 +4269,6 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player) // @ /* cleanup running stuffs */ __mmplayer_cancel_delayed_eos( player ); - #ifdef USE_PROGRESS_TIMER - __mmplayer_stop_progress_timer( player ); - #endif - /* cleanup gst stuffs */ if ( player->pipeline ) { @@ -4670,7 +4295,6 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player) // @ timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player); ret = __mmplayer_gst_set_state ( player, mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_NULL, FALSE, timeout ); - if ( ret != MM_ERROR_NONE ) { debug_error("fail to change state to NULL\n"); @@ -4722,7 +4346,6 @@ static int __gst_realize(mm_player_t* player) // @ MMPLAYER_PRINT_STATE(player); __ta__("__mmplayer_gst_create_pipeline", - ret = __mmplayer_gst_create_pipeline(player); if ( ret ) { @@ -4737,6 +4360,9 @@ static int __gst_realize(mm_player_t* player) // @ ret = __mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_READY, FALSE, timeout); + if (MMPLAYER_PLAY_SUBTITLE(player)) + ret = __mmplayer_gst_set_state(player, + player->pipeline->textbin[MMPLAYER_T_PIPE].gst, GST_STATE_READY, FALSE, timeout); /* create dot before error-return. for debugging */ MMPLAYER_GENERATE_DOT_IF_ENABLED ( player, "pipeline-status-realize" ); @@ -4785,9 +4411,6 @@ static int __gst_unrealize(mm_player_t* player) // @ player->sent_bos = FALSE; player->playback_rate = DEFAULT_PLAYBACK_RATE; - /* initialize buffering information */ - __mmplayer_init_buffering_information ( player ); - /* initialize pending seek */ player->pending_seek.is_pending = FALSE; player->pending_seek.format = MM_PLAYER_POS_FORMAT_TIME; @@ -4866,8 +4489,8 @@ static int __gst_start(mm_player_t* player) // @ /* get sound_extraction property */ mm_attrs_get_int_by_name(player->attrs, "pcm_extraction", &sound_extraction); /* NOTE : if SetPosition was called before Start. do it now */ - /* NOTE : 2009-07-07 : streaming doesn't support it. so it should be always sync */ - /* FIXIT : 2009-07-07 : create one more api to check if there is pending seek rather than checking variables */ + /* streaming doesn't support it. so it should be always sync */ + /* !! create one more api to check if there is pending seek rather than checking variables */ if ( (player->pending_seek.is_pending || sound_extraction) && !MMPLAYER_IS_STREAMING(player)) { @@ -4907,21 +4530,22 @@ static int __gst_start(mm_player_t* player) // @ * application also not ready. thus, just for now. state transition to PLAYING will done in asyn mode. * please do not confused with async property hack which done by __gst_set_async_state_change() */ - /* NOTE : 2009-07-07 : testing async start when local playback also */ + /* NOTE : testing async start when local playback also */ if ( MMPLAYER_IS_STREAMING( player ) || PLAYER_INI()->async_start ) { debug_log("start player in async mode\n"); async = TRUE; } - if (player->pipeline->videobin && player->pipeline->videobin[MMPLAYER_V_BIN].gst && player->pipeline->videobin[MMPLAYER_V_SINK].gst) - g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "visible", TRUE, NULL); - /* set pipeline state to PLAYING */ timeout = MMPLAYER_STATE_CHANGE_TIMEOUT(player); ret = __mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PLAYING, async, timeout ); + if (MMPLAYER_PLAY_SUBTITLE(player)) + ret = __mmplayer_gst_set_state(player, + player->pipeline->textbin[MMPLAYER_T_PIPE].gst, GST_STATE_PLAYING, FALSE, timeout ); + /* generating debug info before returning error */ MMPLAYER_GENERATE_DOT_IF_ENABLED ( player, "pipeline-status-start" ); @@ -5020,6 +4644,10 @@ static int __gst_stop(mm_player_t* player) // @ ret = __mmplayer_gst_set_state( player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PAUSED, FALSE, timeout ); + if (MMPLAYER_PLAY_SUBTITLE(player)) + ret = __mmplayer_gst_set_state( player, + player->pipeline->textbin[MMPLAYER_T_PIPE].gst, GST_STATE_PAUSED, FALSE, timeout ); + /* disable fadeout */ if (fadewown) __mmplayer_undo_sound_fadedown(player); @@ -5051,9 +4679,6 @@ static int __gst_stop(mm_player_t* player) // @ } else { - if (player->pipeline->videobin && player->pipeline->videobin[MMPLAYER_V_BIN].gst && player->pipeline->videobin[MMPLAYER_V_SINK].gst) - g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "visible", FALSE, NULL); - /* rewind */ if ( ! __gst_seek( player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, @@ -5067,12 +4692,10 @@ static int __gst_stop(mm_player_t* player) // @ /* initialize */ player->sent_bos = FALSE; - /* initialize buffering information */ - __mmplayer_init_buffering_information ( player ); - - /* wait for seek to complete */ change_ret = gst_element_get_state (player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, NULL, NULL, timeout * GST_SECOND); + if (MMPLAYER_PLAY_SUBTITLE(player)) + change_ret = gst_element_get_state (player->pipeline->textbin[MMPLAYER_T_PIPE].gst, NULL, NULL, timeout * GST_SECOND); if ( change_ret == GST_STATE_CHANGE_SUCCESS || change_ret == GST_STATE_CHANGE_NO_PREROLL ) { @@ -5114,6 +4737,10 @@ int __gst_pause(mm_player_t* player) // @ ret = __mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PAUSED, async, timeout ); + if (MMPLAYER_PLAY_SUBTITLE(player)) + ret = __mmplayer_gst_set_state(player, + player->pipeline->textbin[MMPLAYER_T_PIPE].gst, GST_STATE_PAUSED, FALSE, timeout ); + /* NOTE : here we are setting state PAUSED to streaming source element again. because * main pipeline will not set the state of it's all childs if state of the pipeline * is already PAUSED for some reason. this situaition can happen when rebuffering or @@ -5188,6 +4815,10 @@ int __gst_resume(mm_player_t* player) // @ ret = __mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PLAYING, async, timeout ); + if (MMPLAYER_PLAY_SUBTITLE(player)) + ret = __mmplayer_gst_set_state(player, + player->pipeline->textbin[MMPLAYER_T_PIPE].gst, GST_STATE_PLAYING, FALSE, timeout ); + /* NOTE : same reason when pausing */ if ( MMPLAYER_IS_RTSP_STREAMING(player) && player->state_lost ) { @@ -5282,7 +4913,7 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position) // @ pos_msec = position * G_GINT64_CONSTANT(1000000); ret = __gst_seek ( player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, 1.0, - GST_FORMAT_TIME, ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_KEY_UNIT ), + GST_FORMAT_TIME, ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, pos_msec, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE ); if ( !ret ) @@ -5303,7 +4934,7 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position) // @ /* FIXIT : why don't we use 'GST_FORMAT_PERCENT' */ pos_msec = (gint64) ( ( position * player->duration ) / 100 ); ret = __gst_seek ( player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, 1.0, - GST_FORMAT_TIME, ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_KEY_UNIT ), + GST_FORMAT_TIME, ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, pos_msec, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE ); if ( !ret ) @@ -5550,6 +5181,10 @@ static gboolean __mmfplayer_parse_profile(const char *uri, void *param, MMPlayer } ret = TRUE; } + else + { + debug_warning("could access %s.\n", path); + } } else if ((path = strstr(uri, "buff://"))) { @@ -5917,6 +5552,7 @@ int _mmplayer_create_player(MMHandleType hplayer) // @ { mm_player_t* player = (mm_player_t*)hplayer; + gint i; debug_fenter(); @@ -6010,13 +5646,11 @@ _mmplayer_create_player(MMHandleType hplayer) // @ player->pd_file_location = NULL; } - /* mekim:+: give default value of DNSe setting */ + /* give default value of DNSe setting */ player->audio_filter_info.filter_type = MM_AUDIO_FILTER_NONE; player->audio_filter_info.output_mode = MM_AUDIO_FILTER_OUTPUT_EAR; player->DNSeBypass = TRUE; //mekim:+: 090717 - - /* sbs:+: */ player->sound.volume = MM_VOLUME_FACTOR_DEFAULT; /* initialize last position */ @@ -6051,8 +5685,15 @@ _mmplayer_create_player(MMHandleType hplayer) // @ player->ahs_player = NULL; /* set buffering parameter for streaming */ - player->bitrate = 0; - player->maximum_bitrate = 0; + for(i=0; ibitrate[i] = 0; + player->maximum_bitrate[i] = 0; + } + player->updated_bitrate_count = 0; + player->total_bitrate = 0; + player->updated_maximum_bitrate_count = 0; + player->total_maximum_bitrate = 0; /* initialize unlinked audio/video mime type */ player->unlinked_audio_mime = NULL; @@ -6066,8 +5707,9 @@ _mmplayer_create_player(MMHandleType hplayer) // @ player->lazy_pause_event_id = 0; - /* initialize buffering information */ - __mmplayer_init_buffering_information ( player ); + player->streamer = NULL; + + player->play_subtitle = FALSE; /* initialize pending seek */ player->pending_seek.is_pending = FALSE; @@ -6251,6 +5893,13 @@ __mmplayer_release_extended_streaming(mm_player_t* player) __mm_player_ahs_destroy(player->ahs_player); player->ahs_player = NULL; } + + if (MMPLAYER_IS_STREAMING(player)) + { + __mm_player_streaming_deinitialize (player->streamer); + __mm_player_streaming_destroy(player->streamer); + player->streamer = NULL; + } } int @@ -6462,7 +6111,6 @@ _mmplayer_realize(MMHandleType hplayer) // @ /* realize pipeline */ ret = __gst_realize( player ); - if ( ret != MM_ERROR_NONE ) { debug_error("fail to realize the player.\n"); @@ -7470,6 +7118,23 @@ _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* s return ret; } +int +_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int position) // @ +{ + mm_player_t* player = (mm_player_t*)hplayer; + int ret = MM_ERROR_NONE; + + debug_fenter(); + + return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); + + ret = __gst_adjust_subtitle_position(player, format, position); + + debug_fleave(); + + return ret; +} + int __mmplayer_set_harmony_filter(mm_player_t* player, GstElement * filter_element, MMAudioFilterInfo* info) @@ -7609,7 +7274,7 @@ _mmplayer_apply_sound_filter(MMHandleType hplayer, MMAudioFilterInfo* info) // @ return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); return_val_if_fail ( info, MM_ERROR_COMMON_INVALID_ARGUMENT ); - /* mekim :+: 090717 Music Player can set Dnse sound effect value before Audiobin is created. */ + /* Music Player can set Dnse sound effect value before Audiobin is created. */ if ( !player->pipeline->audiobin ) { debug_warning("filter element is not created yet.\n"); @@ -7628,7 +7293,7 @@ _mmplayer_apply_sound_filter(MMHandleType hplayer, MMAudioFilterInfo* info) // @ } - /* mekim:+ store DNSe setting in order to appling it when audio filter is created */ + /* store DNSe setting in order to appling it when audio filter is created */ memcpy( &player->audio_filter_info, info, sizeof(MMAudioFilterInfo) ); return MM_ERROR_NONE; @@ -7683,7 +7348,7 @@ _mmplayer_apply_sound_filter(MMHandleType hplayer, MMAudioFilterInfo* info) // @ } -/* hjkim, add function for Spectrum view */ +/* add function for Spectrum view */ int _mmplayer_get_sv_info(MMHandleType hplayer, short* graph_out) // @ { @@ -8425,10 +8090,8 @@ const char *padname, const GList *templlist) GstPad *pssrcpad = NULL; GstPad *qsrcpad = NULL, *qsinkpad = NULL; MMPlayerGstElement *mainbin = NULL; - const gchar* name = NULL; GstStructure* str = NULL; GstCaps* srccaps = NULL; - guint64 file_ring_buffer_size = 0L; debug_fenter(); @@ -8437,7 +8100,6 @@ const char *padname, const GList *templlist) player->pipeline->mainbin, FALSE ); - mainbin = player->pipeline->mainbin; debug_log("plugging pad %s:%s to newly create %s:%s\n", @@ -8624,6 +8286,9 @@ const char *padname, const GList *templlist) { if (MMPLAYER_IS_HTTP_STREAMING(player)) { + GstFormat fmt = GST_FORMAT_BYTES; + gint64 dur_bytes = 0L; + debug_log("creating http streaming buffering queue\n"); queue = gst_element_factory_make("queue2", "http_streaming_buffer"); @@ -8662,36 +8327,19 @@ const char *padname, const GList *templlist) mainbin[MMPLAYER_M_S_BUFFER].id = MMPLAYER_M_S_BUFFER; mainbin[MMPLAYER_M_S_BUFFER].gst = queue; - /* Note : if http_temp_template is not set, player use memory for buffering. or file is used. */ - if (MMPLAYER_USE_FILE_FOR_BUFFERING(player)) - { - debug_log("use file for buffering. streaming is played on pull-based. \n"); - g_object_set ( G_OBJECT (queue), "temp-template", PLAYER_INI()->http_temp_template, NULL ); - - file_ring_buffer_size = __mmplayer_get_file_ring_buffer_size(player); - if (file_ring_buffer_size>0) - { - debug_log ("use file ring buffer for buffering.\n"); - g_object_set ( G_OBJECT (queue), "file-buffer-max-size", file_ring_buffer_size, NULL ); - } - else - { - debug_log ("fully download the content using file buffer.\n"); - } - } - else - { - debug_log("use memory for buffering. streaming is played on push-based. \n" - "buffering position would not be updated.\n" - "buffered data would be flushed after played.\n" - "seeking and getting duration could be failed due to file format."); - } - - g_object_set ( G_OBJECT (queue), "max-size-bytes", PLAYER_INI()->http_max_size_bytes, NULL ); - g_object_set ( G_OBJECT (queue), "low-percent", PLAYER_INI()->http_buffering_low_limit, NULL ); - g_object_set ( G_OBJECT (queue), "high-percent", PLAYER_INI()->http_buffering_high_limit, NULL ); - g_object_set ( G_OBJECT (queue), "use-buffering", PLAYER_INI()->http_use_buffering, NULL ); - + if ( !gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, &fmt, &dur_bytes)) + debug_error("fail to get duration.\n"); + + __mm_player_streaming_set_buffer(player->streamer, + queue, + TRUE, + PLAYER_INI()->http_max_size_bytes, + 1.0, + PLAYER_INI()->http_buffering_limit, + PLAYER_INI()->http_buffering_time, + MMPLAYER_USE_FILE_FOR_BUFFERING(player), + PLAYER_INI()->http_file_buffer_path, + dur_bytes); } } } @@ -8886,18 +8534,6 @@ static gboolean __mmplayer_feature_filter(GstPluginFeature *feature, gpointer da { return FALSE; } - - /* FIXIT : what's this tweak for ? - * ANSWER : - */ -#if 0 - if(g_strrstr(klass,"Metadata")) - return FALSE; - - if(g_strrstr(name,"FFMPEG MPEG audio demuxer")) - return FALSE; -#endif - return TRUE; } @@ -9047,7 +8683,7 @@ static void __mmplayer_add_new_pad(GstElement *element, GstPad *pad, gpointer da player->num_dynamic_pad++; debug_log("stream count inc : %d\n", player->num_dynamic_pad); - if ((g_strrstr(name, "AMR")) || (g_strrstr(name, "amr"))) //mekim_temp + if ((g_strrstr(name, "AMR")) || (g_strrstr(name, "amr"))) // FIXIT { debug_log(" AMR is set in __mmplayer_typefind_have_type \n"); @@ -9092,109 +8728,6 @@ static void __mmplayer_add_new_pad(GstElement *element, GstPad *pad, gpointer da return; } -#ifdef USE_PROGRESS_TIMER -static void -__mmplayer_start_progress_timer(mm_player_t* player) // @ -{ - MMHandleType attrs = 0; - gint progress_interval = 0; - - debug_fenter(); - - return_if_fail( player ); - - attrs = MMPLAYER_GET_ATTRS(player); - if ( !attrs ) - { - debug_error("fail to get attributes.\n"); - return; - } - - mm_attrs_get_int_by_name(attrs, "profile_progress_interval", &progress_interval); - - debug_log("timeout for progress timer : %d\n", progress_interval); - - if ( progress_interval == 0 ) - { - debug_log("progress timer timeout is zero. means it's disabled\n"); - return; - } - - if ( MM_PLAYER_STATE_PLAYING != MMPLAYER_CURRENT_STATE(player) ) - { - debug_warning("player is not in PLAYING state\n"); - return; - } - - if ( player->progress_timer ) - { - g_source_remove( player->progress_timer ); - } - - player->progress_timer = g_timeout_add( progress_interval, - __mmplayer_progress_timer_cb, player ); - - debug_fleave(); -} - -static void -__mmplayer_stop_progress_timer(mm_player_t* player) // @ -{ - debug_fenter(); - - return_if_fail( player ); - - if ( player->progress_timer ) - { - g_source_remove( player->progress_timer ); - } - - player->progress_timer = 0; - - debug_fleave(); -} - - -/* jmlee:ProgressTimer:+:20080621 */ -static gboolean -__mmplayer_progress_timer_cb(gpointer u_data) // @ -{ - mm_player_t* player = NULL; - MMMessageParamType msg = {0, }; - unsigned long pos = 0; - unsigned long dur = 0; - - player = (mm_player_t*) u_data; - - return_val_if_fail( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); - - if ( MM_PLAYER_STATE_PLAYING != MMPLAYER_CURRENT_STATE(player) ) - { - debug_warning("player is not in PLAYING state\n"); - return TRUE; - } - - /* get position */ - if ( MM_ERROR_NONE != - __gst_get_position ( player, MM_PLAYER_POS_FORMAT_TIME, &pos ) ) - { - debug_warning("failed to get position\n"); - return TRUE; - } - - dur = GST_TIME_AS_MSECONDS( player->duration ); - - msg.time.elapsed = (int)(pos/1000); - msg.time.total = (int)(dur/1000); - - debug_log("elapsed [%d] total [%d]\n", msg.time.elapsed, msg.time.total); - - //MMPLAYER_POST_MSG( player, MM_MESSAGE_CURRENT_TIME, &msg ); - - return TRUE; -} -#endif /* USE_PROGRESS_TIMER */ - /* test API for tuning audio gain. this API should be * deprecated before the day of final release */ @@ -10393,10 +9926,9 @@ int _mmplayer_set_subtitle_silent (MMHandleType hplayer, int silent) debug_fenter(); /* check player handle */ - return_val_if_fail( - (player && + return_val_if_fail(player && player->pipeline && - player->pipeline->textbin), + player->pipeline->textbin, MM_ERROR_PLAYER_NOT_INITIALIZED ); player->is_subtitle_off = silent; @@ -10415,10 +9947,10 @@ int _mmplayer_get_subtitle_silent (MMHandleType hplayer, int* silent) debug_fenter(); - return_val_if_fail( - (player && + /* check player handle */ + return_val_if_fail(player && player->pipeline && - player->pipeline->textbin), + player->pipeline->textbin, MM_ERROR_PLAYER_NOT_INITIALIZED ); *silent = player->is_subtitle_off; diff --git a/src/mm_player_streaming.c b/src/mm_player_streaming.c new file mode 100755 index 0000000..b522f90 --- /dev/null +++ b/src/mm_player_streaming.c @@ -0,0 +1,432 @@ +/* + * libmm-player + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi , YeJin Cho , + * Seungbae Shin , YoungHwan An + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include "mm_player_utils.h" + +#include "mm_player_streaming.h" + +static void streaming_set_buffer_size(mm_player_streaming_t* streamer, guint buffer_size); +static void streaming_set_buffer_percent(mm_player_streaming_t* streamer, gdouble low_percent, gdouble high_percent); +static void streaming_set_buffer_type (mm_player_streaming_t* streamer, gboolean use_file, gchar * file_path, guint64 content_size); +static void streaming_set_buffering_time(mm_player_streaming_t* streamer, gdouble buffering_time); + + +mm_player_streaming_t * +__mm_player_streaming_create () +{ + mm_player_streaming_t *streamer = NULL; + + debug_fenter(); + + streamer = (mm_player_streaming_t *) malloc (sizeof (mm_player_streaming_t)); + if (!streamer) + { + debug_error ("fail to create streaming player handle..\n"); + return NULL; + } + + debug_fleave(); + + return streamer; +} + +void __mm_player_streaming_initialize (mm_player_streaming_t* streamer) +{ + debug_fenter(); + + streamer->buffer = NULL; + streamer->buffer_size = DEFAULT_BUFFER_SIZE; + streamer->buffer_low_percent = DEFAULT_BUFFER_LOW_PERCENT; + streamer->buffer_high_percent = DEFAULT_BUFFER_HIGH_PERCENT; + streamer->buffer_avg_bitrate = 0; + streamer->buffer_max_bitrate = 0; + streamer->need_update = FALSE; + + streamer->is_buffering = FALSE; + streamer->buffering_percent = -1; + streamer->buffering_time = DEFAULT_BUFFERING_TIME; + + debug_fleave(); + + return; +} + +void __mm_player_streaming_deinitialize (mm_player_streaming_t* streamer) +{ + debug_fenter(); + + streamer->buffer_size = DEFAULT_BUFFER_SIZE; + streamer->buffer_low_percent = DEFAULT_BUFFER_LOW_PERCENT; + streamer->buffer_high_percent = DEFAULT_BUFFER_HIGH_PERCENT; + streamer->buffer_avg_bitrate = 0; + streamer->buffer_max_bitrate = 0; + streamer->need_update = FALSE; + + streamer->is_buffering = FALSE; + streamer->buffering_percent = -1; + streamer->buffering_time = DEFAULT_BUFFERING_TIME; + + debug_fleave(); + + return; +} + + +void __mm_player_streaming_destroy (mm_player_streaming_t* streamer) +{ + debug_fenter(); + + free (streamer); + streamer = NULL; + + debug_fleave(); + + return; +} + + +void __mm_player_streaming_set_buffer(mm_player_streaming_t* streamer, GstElement * buffer, + gboolean use_buffering, guint buffer_size, gdouble low_percent, gdouble high_percent, gdouble buffering_time, + gboolean use_file, gchar * file_path, guint64 content_size) +{ + debug_fenter(); + + return_if_fail(streamer); + + if (buffer) + { + streamer->buffer = buffer; + + debug_log("buffer element is %s.", GST_ELEMENT_NAME(buffer)); + + g_object_set ( G_OBJECT (streamer->buffer), "use-buffering", use_buffering, NULL ); + } + + streaming_set_buffer_size(streamer, buffer_size); + streaming_set_buffer_percent(streamer, low_percent, high_percent); + streaming_set_buffer_type (streamer, use_file, file_path, content_size); + streaming_set_buffering_time(streamer, buffering_time); + + debug_fleave(); + + return; +} + + +void __mm_player_streaming_set_content_bitrate(mm_player_streaming_t* streamer, guint max_bitrate, guint avg_bitrate) +{ + debug_fenter(); + + return_if_fail(streamer); + + /* Note : Update buffering criterion bytes + * 1. maximum bitrate is considered first. + * 2. average bitrage * 3 is next. + * 3. if there are no updated bitrate, use default buffering limit. + */ + if (max_bitrate > 0 && streamer->buffer_max_bitrate != max_bitrate) + { + debug_log("set maximum bitrate(%dbps).\n", max_bitrate); + streamer->buffer_max_bitrate = max_bitrate; + + streamer->need_update = TRUE; + } + + if (avg_bitrate > 0 && streamer->buffer_avg_bitrate != avg_bitrate) + { + debug_log("set averate bitrate(%dbps).\n", avg_bitrate); + streamer->buffer_avg_bitrate = avg_bitrate; + + streamer->need_update = TRUE; + } + + debug_fleave(); + + return; +} + +static void +streaming_set_buffer_size(mm_player_streaming_t* streamer, guint buffer_size) +{ + debug_fenter(); + + return_if_fail(streamer); + return_if_fail(buffer_size>0); + + debug_log("set buffer size to %d.", buffer_size); + + streamer->buffer_size = buffer_size; + + if (streamer->buffer) + g_object_set (G_OBJECT(streamer->buffer), "max-size-bytes", buffer_size, NULL); + + debug_fleave(); + + return; +} + +static void +streaming_set_buffer_percent(mm_player_streaming_t* streamer, gdouble low_percent, gdouble high_percent) +{ + gdouble buffer_low_percent = DEFAULT_BUFFER_LOW_PERCENT; + gdouble buffer_high_percent = DEFAULT_BUFFER_HIGH_PERCENT; + + debug_fenter(); + + return_if_fail(streamer); + + if (low_percent <= MIN_BUFFER_PERCENT || low_percent >= MAX_BUFFER_PERCENT) + { + debug_warning("buffer low percent is out of range. use defaut value."); + buffer_low_percent = DEFAULT_BUFFER_LOW_PERCENT; + } + else + { + buffer_low_percent = low_percent; + } + + if (high_percent <= MIN_BUFFER_PERCENT || high_percent >= MAX_BUFFER_PERCENT) + { + debug_warning("buffer high percent is out of range. use defaut value."); + buffer_high_percent = DEFAULT_BUFFER_HIGH_PERCENT; + } + else + { + buffer_high_percent = high_percent; + } + + if (buffer_high_percent <= buffer_low_percent) + buffer_high_percent = buffer_low_percent + 1.0; + + debug_log("set buffer percent to %2.3f ~ %2.3f.", streamer->buffer_low_percent, streamer->buffer_high_percent); + + if (streamer->buffer) + { + if ( streamer->buffer_low_percent != buffer_low_percent ) + g_object_set (G_OBJECT(streamer->buffer), "low-percent", streamer->buffer_low_percent, NULL); + + if ( streamer->buffer_high_percent != buffer_high_percent ) + g_object_set (G_OBJECT(streamer->buffer), "high-percent", streamer->buffer_high_percent, NULL); + } + + streamer->buffer_low_percent = buffer_low_percent; + streamer->buffer_high_percent = buffer_high_percent; + + debug_fleave(); + + return; +} + +static void +streaming_set_buffering_time(mm_player_streaming_t* streamer, gdouble buffering_time) +{ + gdouble buffer_buffering_time = DEFAULT_BUFFERING_TIME; + + debug_fenter(); + + return_if_fail(streamer); + + if (buffering_time < MIN_BUFFERING_TIME) + buffer_buffering_time = MIN_BUFFERING_TIME; + else if (buffering_time > MAX_BUFFERING_TIME) + buffer_buffering_time = MAX_BUFFERING_TIME; + else + buffer_buffering_time = buffering_time; + + if (streamer->buffering_time != buffer_buffering_time) + { + debug_log("set buffer buffering time from %2.1f to %2.1f.", streamer->buffering_time, buffer_buffering_time); + + streamer->buffering_time = buffer_buffering_time; + } + + debug_fleave(); + + return; +} + +static void +streaming_set_buffer_type (mm_player_streaming_t* streamer, gboolean use_file, gchar * file_path, guint64 content_size) +{ + guint64 storage_available_size = 0L; //bytes + guint64 file_buffer_size = 0L; //bytes + gchar file_buffer_name[MAX_FILE_BUFFER_NAME_LEN] = {0}; + struct statfs buf = {0}; + + debug_fenter(); + + return_if_fail(streamer && streamer->buffer); + + if (!use_file) + { + debug_log("use memory for buffering. streaming is played on push-based. \n" + "buffering position would not be updated.\n" + "buffered data would be flushed after played.\n" + "seeking and getting duration could be failed due to file format."); + return; + } + + debug_log("use file for buffering. streaming is played on pull-based. \n"); + + if (!file_path || strlen(file_path) <= 0) + file_path = g_strdup(DEFAULT_FILE_BUFFER_PATH); + + sprintf( file_buffer_name, "%s/XXXXXX", file_path ); + debug_log("the buffering file name is %s.\n", file_buffer_name); + + if (statfs((const char *)file_path, &buf) < 0) + { + debug_warning ("fail to get availabe storage capacity. just use file buffer.\n"); + file_buffer_size = 0L; + } + else + { + storage_available_size = (guint64)buf.f_bavail * (guint64)buf.f_bsize; //bytes + + debug_log ("the number of available blocks : %"G_GUINT64_FORMAT", the block size is %"G_GUINT64_FORMAT".\n", + (guint64)buf.f_bavail, (guint64)buf.f_bsize); + debug_log ("calculated availabe storage size is %"G_GUINT64_FORMAT" Bytes.\n", storage_available_size); + + if (content_size <= 0 || content_size >= storage_available_size) + file_buffer_size = storage_available_size; + else + file_buffer_size = 0L; + } + + if (file_buffer_size>0) + debug_log("use file ring buffer for buffering."); + + g_object_set (G_OBJECT(streamer->buffer), "temp-template", file_buffer_name, NULL); + g_object_set (G_OBJECT(streamer->buffer), "file-buffer-max-size", file_buffer_size, NULL); + + debug_fleave(); + + return; +} + +#define GET_BYTE_FROM_BIT(bit) (bit/8) +void __mm_player_streaming_buffering(mm_player_streaming_t* streamer, GstMessage *buffering_msg) +{ + GstBufferingMode mode = GST_BUFFERING_STREAM; + gint byte_in_rate = 0; + gint byte_out_rate = 0; + gint64 buffering_left = -1; + gdouble buffering_time = DEFAULT_BUFFERING_TIME; + gdouble low_percent = 0.0; + gdouble high_percent = 0.0; + guint high_percent_byte = 0; + gint buffer_percent = 0; + guint buffer_criteria = 0; + + return_if_fail ( streamer ); + return_if_fail ( buffering_msg ); + return_if_fail ( GST_IS_MESSAGE ( buffering_msg ) ); + return_if_fail ( GST_MESSAGE_TYPE ( buffering_msg ) == GST_MESSAGE_BUFFERING ); + + /* update when buffering has started. */ + if ( !streamer->is_buffering ) + { + debug_log ( "buffering has started.\n" ); + + streamer->is_buffering = TRUE; + streamer->buffering_percent = -1; + streamer->need_update = TRUE; + } + + /* update buffer percent */ + gst_message_parse_buffering ( buffering_msg, &buffer_percent ); + + if ( streamer->buffering_percent < buffer_percent ) + { + debug_log ( "buffering %d%%....\n", buffer_percent ); + streamer->buffering_percent = buffer_percent; + } + + if ( streamer->buffering_percent == MAX_BUFFER_PERCENT ) + { + debug_log ( "buffering had done.\n" ); + streamer->is_buffering = FALSE; + } + + if (!streamer->need_update) + { + debug_log ( "don't need to update buffering stats during buffering.\n" ); + return; + } + + /* Note : Parse the buffering message to get the in/out throughput. + * avg_in is the network throughput and avg_out is the consumed throughtput by the linkded element. + */ + gst_message_parse_buffering_stats ( buffering_msg, &mode, &byte_in_rate, &byte_out_rate, &buffering_left ); + + if (streamer->buffer_max_bitrate > 0) + { + buffer_criteria = GET_BYTE_FROM_BIT(streamer->buffer_max_bitrate); + byte_out_rate = GET_BYTE_FROM_BIT(streamer->buffer_max_bitrate /3); + } + else if (streamer->buffer_avg_bitrate > 0) + { + buffer_criteria = GET_BYTE_FROM_BIT(streamer->buffer_avg_bitrate * 3); + byte_out_rate = GET_BYTE_FROM_BIT(streamer->buffer_avg_bitrate); + } + + debug_log ( "in rate is %d, out rate is %d (bytes/sec).\n", byte_in_rate, byte_out_rate ); + + if ( byte_in_rate > 0 && byte_out_rate > 0) + buffering_time = byte_out_rate / byte_in_rate; + else if (byte_in_rate <= 0 && byte_out_rate > 0) + buffering_time = MAX_BUFFERING_TIME; + else + buffering_time = DEFAULT_BUFFERING_TIME; + + streaming_set_buffering_time(streamer, buffering_time); + + /* calculate buffer low/high percent */ + low_percent = DEFAULT_BUFFER_LOW_PERCENT; + + if ( buffer_criteria > 0 ) + { + high_percent_byte = buffer_criteria * streamer->buffering_time; + high_percent = ( (gdouble)high_percent_byte * 100.0 ) / (gdouble)streamer->buffer_size; + } + else + { + high_percent_byte = streamer->buffer_high_percent * streamer->buffer_size / 100; + high_percent= streamer->buffer_high_percent; + } + + if ( streamer->buffer_size < high_percent_byte ) + { + debug_log ( "buffer size[%d bytes] is smaller than high threshold[%d bytes]. update it. \n", + streamer->buffer_size, high_percent_byte ); + + streaming_set_buffer_size(streamer, high_percent_byte * 1.1); + } + + streaming_set_buffer_percent(streamer, low_percent, high_percent); + + streamer->need_update = FALSE; + + return; +} + diff --git a/src/mm_player_utils.c b/src/mm_player_utils.c index 1fca5bf..80d1044 100755 --- a/src/mm_player_utils.c +++ b/src/mm_player_utils.c @@ -71,7 +71,6 @@ bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_si return TRUE; } -#if 1 //tskim:MidiModuleRequires:+: for Midi player bool util_remove_file_backup(const char *backup_path) { debug_log("\n"); @@ -79,16 +78,10 @@ bool util_remove_file_backup(const char *backup_path) if (!backup_path || !strlen(backup_path)) return FALSE; -/* - Prevent defect patch. CID:22389 Checker:TOTCU - int res = access(backup_path, R_OK); - if (!res) -*/ - remove(backup_path); + remove(backup_path); return TRUE; } -#endif #define DETECTION_PREFIX_SIZE 20 //bool util_is_midi_type_by_mem(void *mem, int size) @@ -99,20 +92,20 @@ int util_is_midi_type_by_mem(void *mem, int size) const char *p = (const char *)mem; if (size < DETECTION_PREFIX_SIZE) - return MM_AUDIO_CODEC_INVALID; //FALSE; // sbs:+:080903 + return MM_AUDIO_CODEC_INVALID; /* mmf file detection */ if (p[0] == 'M' && p[1] == 'M' && p[2] == 'M' && p[3] == 'D') { debug_log("MM_AUDIO_CODEC_MMF\n"); - return MM_AUDIO_CODEC_MMF; // TRUE;// sbs:+:080903 + return MM_AUDIO_CODEC_MMF; } /* midi file detection */ if (p[0] == 'M' && p[1] == 'T' && p[2] == 'h' && p[3] == 'd') { debug_log ("MM_AUDIO_CODEC_MIDI, %d\n", MM_AUDIO_CODEC_MIDI); - return MM_AUDIO_CODEC_MIDI;//TRUE;// sbs:+:080903 + return MM_AUDIO_CODEC_MIDI; } - /* mxmf file detection */ // sbs:+:080903 + /* mxmf file detection */ if (p[0] == 'X' && p[1] == 'M' && p[2] == 'F' && p[3] == '_') { debug_log ("MM_AUDIO_CODEC_MXMF\n"); return MM_AUDIO_CODEC_MXMF; @@ -123,19 +116,18 @@ int util_is_midi_type_by_mem(void *mem, int size) p[8] == 'W' && p[9] == 'A' && p[10] == 'V' && p[11] == 'E' && p[12] == 'f' && p[13] == 'm' && p[14] == 't') { debug_log ("MM_AUDIO_CODEC_WAVE\n"); - return MM_AUDIO_CODEC_WAVE;//TRUE;// sbs:+:080903 + return MM_AUDIO_CODEC_WAVE; } - /* i-melody file detection */ // sbs:+:080903 + /* i-melody file detection */ if (memcmp(p, "BEGIN:IMELODY", 13) == 0) { debug_log ("MM_AUDIO_CODEC_IMELODY\n"); return MM_AUDIO_CODEC_IMELODY; } - return MM_AUDIO_CODEC_INVALID;//FALSE; // sbs:+:080903 + return MM_AUDIO_CODEC_INVALID; } -//bool util_is_midi_type_by_file(const char *file_path) int util_is_midi_type_by_file(const char *file_path) { debug_log("\n"); @@ -148,7 +140,6 @@ int util_is_midi_type_by_file(const char *file_path) if (!file_path) return FALSE; - /* Prevent defect patch. CID: 22388 Checker: TOCTOU */ fp = fopen(file_path, "r"); if (!fp) diff --git a/test/mm_player_testsuite.c b/test/mm_player_testsuite.c index 0c6da89..c211e94 100755 --- a/test/mm_player_testsuite.c +++ b/test/mm_player_testsuite.c @@ -24,7 +24,7 @@ | INCLUDE FILES | | | ========================================================================================== */ -//#define MTRACE; +//#define TRACE; #include #include #include @@ -38,9 +38,9 @@ #include #include // video capture -#ifdef MTRACE -#include //mtrace -#include //mtrace +#ifdef TRACE +#include +#include #endif #include @@ -156,7 +156,7 @@ do \ free(x_err_attrs_name); -#define R2VS_TEST_EACH_FILTER_MODE //hjkim:+: 090309 +#define R2VS_TEST_EACH_FILTER_MODE //#define AUDIO_FILTER_EFFECT // temp for debianize @@ -205,6 +205,7 @@ enum #ifdef AUDIO_FILTER_EFFECT CURRENT_STATUS_R2VS, #endif + CURRENT_STATUS_ADJUST_SUBTITLE_POSITION, CURRENT_STATUS_SUBTITLE_FILENAME, CURRENT_STATUS_RESIZE_VIDEO, }; @@ -357,10 +358,10 @@ bool testsuite_sample_cb(void *stream, int stream_size, void *user_param); | FUNCTION DEFINITIONS | | | ========================================================================================== */ -#ifdef _USE_XVIMAGESINK //tskim:~:ImplementationFullscreen_090119 +#ifdef _USE_XVIMAGESINK void change_fullscreen(GtkWidget* widget); gboolean softkey_cb_select_and_back(GtkWidget *widget, SoftkeyPosition position, gpointer data); -#endif //tskim:~:ImplementationFullscreen_090119 +#endif /*--------------------------------------------------------------------------- @@ -475,8 +476,6 @@ static bool msg_callback(int message, MMMessageParamType *param, void *user_para g_print("error : code = %x\n", param->code); if (param->code == MM_ERROR_PLAYER_CODEC_NOT_FOUND) g_print("## error string = %s\n", param->data); - //g_print("Got MM_MESSAGE_ERROR, testsuite will be exit\n"); - //quit_program (); // 090519 break; case MM_MESSAGE_WARNING: @@ -485,24 +484,17 @@ static bool msg_callback(int message, MMMessageParamType *param, void *user_para case MM_MESSAGE_END_OF_STREAM: g_print("end of stream\n"); - mm_player_stop(g_player); //bw.jang :+: - //bw.jang :-: MMPlayerUnrealize(g_player); - //bw.jang :-: MMPlayerDestroy(g_player); - //bw.jang :-: g_player = 0; if (g_bArgPlay == TRUE ) { g_timeout_add(100, timeout_quit_program, 0); -// quit_program(); } break; case MM_MESSAGE_STATE_CHANGED: g_current_state = param->state.current; - //bw.jang :=: //g_print("current state : %d\n", g_current_state); - //--> switch(g_current_state) { case MM_PLAYER_STATE_NONE: @@ -518,7 +510,6 @@ static bool msg_callback(int message, MMMessageParamType *param, void *user_para g_print(" ==> [MediaPlayerApp] Player is [PAUSED]\n"); break; } - //:: break; case MM_MESSAGE_BEGIN_OF_STREAM: { @@ -784,6 +775,13 @@ static void toggle_subtitle_silent(bool silent) } } +static void adjust_subtitle_position(int position) +{ + if ( mm_player_adjust_subtitle_position(g_player, MM_PLAYER_POS_FORMAT_TIME, position) != MM_ERROR_NONE ) + { + g_print("failed to adjust subtitle position\n"); + } +} static void set_volume(MMPlayerVolumeType *pvolume) @@ -807,7 +805,7 @@ static void get_volume(MMPlayerVolumeType* pvolume) } } -#ifdef MTRACE +#ifdef TRACE static gboolean progress_timer_cb(gpointer u_data) // @ { @@ -840,7 +838,7 @@ static void player_play() int bRet = FALSE; bRet = mm_player_start(g_player); -#ifdef MTRACE +#ifdef TRACE g_timeout_add( 500, progress_timer_cb, g_player ); #endif } @@ -886,7 +884,7 @@ static void player_rotate() } -#ifdef MTRACE +#ifdef TRACE // usleep (1000000); // g_print ("aaaaa\n"); // g_timeout_add( 500, progress_timer_cb, g_player ); @@ -1091,7 +1089,6 @@ static int set_r2vs(char* char_mode) mode = mode |MM_AUDIO_FILTER_SV; r2vs_mode = 3; } -//hjkim:+:090203, Add for SPK mode test else if(strncmp(tmp_mode+idx_filter, "6", 1 ) == 0) { filter_info.output_mode = MM_AUDIO_FILTER_OUTPUT_EAR; @@ -1204,7 +1201,6 @@ static void print_info() #if 0 MMHandleType tag_prop = 0, content_prop = 0; -#if 1 // hcjeon:-:enable it later. // enabled!!!:+:100112 /* set player configuration */ MMPlayerGetAttrs(g_player, MM_PLAYER_ATTRS_TAG, &tag_prop); MMPlayerGetAttrs(g_player, MM_PLAYER_ATTRS_CONTENT, &content_prop); @@ -1296,7 +1292,6 @@ static void print_info() printf( "====================================================================================\n" ); printf("Time analysis...\n"); -#endif //MMTA_ACUM_ITEM_SHOW_RESULT(); #endif } @@ -1370,12 +1365,10 @@ void display_sub_basic() g_print("sr. Togle Section Play\n"); g_print("[display ]x. Change display geometry method\t"); g_print("dv. display visible\t"); - g_print("rv. resize video - fimcconvert only\n"); + g_print("rv. resize video - fimcconvert only\n"); g_print("[ sound ] k. Toggle Fadeup\t"); - g_print("z. Apply DNSE \t"); - - + g_print("z. Apply DNSE \t\n"); #if 0 // not available now g_print(" Progressive Download\n"); @@ -1387,7 +1380,8 @@ void display_sub_basic() #endif g_print("[subtitle] $. Set subtitle uri\t"); - g_print("%%. Toggle subtitle silent \n"); + g_print("%%. Toggle subtitle silent \t"); + g_print("<. Adjust subtitle postion \n"); g_print("[ etc ] j. Information\t"); g_print("l. Buffering Mode\n"); @@ -1498,6 +1492,10 @@ static void displaymenu() { g_print(" ** input subtitle file path.\n"); } + else if (g_menu_state == CURRENT_STATUS_ADJUST_SUBTITLE_POSITION) + { + g_print("*** input adjusted value(msec)\n"); + } else { g_print("*** unknown status.\n"); @@ -1782,7 +1780,7 @@ void _interpret_main_menu(char *cmd) } else if (strncmp(cmd, "j", 1) == 0) { - print_info(); // enabled!!!:+:100112 + print_info(); } else if (strncmp(cmd, "o", 1) == 0) { @@ -1816,7 +1814,7 @@ void _interpret_main_menu(char *cmd) { g_menu_state = CURRENT_STATUS_DISPLAYMETHOD; } -#ifdef _USE_XVIMAGESINK //tskim:~:ImplementationFullscreen_090119 +#ifdef _USE_XVIMAGESINK else if (strncmp (cmd, "x", 1) == 0) { change_fullscreen(overlay); @@ -1868,6 +1866,10 @@ void _interpret_main_menu(char *cmd) reset_menu_state(); } + else if(strncmp(cmd, "<", 1) == 0) + { + g_menu_state = CURRENT_STATUS_ADJUST_SUBTITLE_POSITION; + } else { g_print("unknown menu \n"); @@ -1907,8 +1909,7 @@ void _interpret_main_menu(char *cmd) else if (strncmp (cmd, "rv", 2) == 0) { g_menu_state = CURRENT_STATUS_RESIZE_VIDEO; - } - + } else if (strncmp(cmd, "help", 4) == 0) { g_timeout_add(100, timeout_menu_display, 0); @@ -2034,6 +2035,17 @@ static void interpret (char *cmd) reset_menu_state(); } + break; + + case CURRENT_STATUS_ADJUST_SUBTITLE_POSITION: + { + int position = atol(cmd); + g_printf("\n ------------------ %d \n", position); + adjust_subtitle_position(position); + + reset_menu_state(); + } + break; } @@ -2066,7 +2078,7 @@ static gboolean } #endif -#ifdef _USE_XVIMAGESINK //tskim:~:ImplementationFullscreen_090119 +#ifdef _USE_XVIMAGESINK GtkWidget *event_win; void change_fullscreen(GtkWidget* widget) @@ -2175,12 +2187,11 @@ void make_window() overlay = gtk_overlay_drawing_new(); gtk_overlay_drawing_set_type(overlay, GTK_OVERLAY_TYPE_YUV420); - gtk_widget_set_size_request(overlay, FULL_WIDTH, FULL_HEIGHT); // sbs:+:081203 + gtk_widget_set_size_request(overlay, FULL_WIDTH, FULL_HEIGHT); allocation.x = 0; allocation.y = 0; - // sbs:+:081203 allocation.width = FULL_WIDTH; allocation.height = FULL_HEIGHT; @@ -2209,7 +2220,7 @@ int main(int argc, char *argv[]) GIOChannel *stdin_channel; MMTA_INIT(); -#ifdef MTRACE +#ifdef TRACE mtrace(); MMHandleType prop; GError *error = NULL; -- 2.7.4