From: Andrey Shelest Date: Fri, 27 Jun 2014 08:48:01 +0000 (+0300) Subject: Updated to version 0.2.27 X-Git-Tag: accepted/tizen/common/20150109.133757~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F51%2F23551%2F2;p=platform%2Fcore%2Fmultimedia%2Flibmm-player.git Updated to version 0.2.27 Removed dependency of gstreamer-0.10 Change-Id: If5a945ab33b1d67f8e15e9b7dd717bca0dbdb1bc --- diff --git a/configure.ac b/configure.ac index 76f0f53..3c5f029 100755 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([libmm-player],[0.0.1]) +AC_INIT([libmm-player],[0.3.0]) AC_CONFIG_SRCDIR([src/mm_player_priv.c]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE([-Wall foreign]) @@ -57,43 +57,21 @@ PKG_CHECK_MODULES(GLIB, glib-2.0) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) -if test "$use_gstreamer_1" = "1"; then - PKG_CHECK_MODULES(GST, gstreamer-1.0) - AC_SUBST(GST_CFLAGS) - AC_SUBST(GST_LIBS) -else - PKG_CHECK_MODULES(GST, gstreamer-0.10) - AC_SUBST(GST_CFLAGS) - AC_SUBST(GST_LIBS) -fi - -if test "$use_gstreamer_1" = "1"; then - PKG_CHECK_MODULES(GST_PLUGIN_BASE, gstreamer-plugins-base-1.0 ) - AC_SUBST(GST_PLUGIN_BASE_CFLAGS) - AC_SUBST(GST_PLUGIN_BASE_LIBS) -else - PKG_CHECK_MODULES(GST_PLUGIN_BASE, gstreamer-plugins-base-0.10 >= 0.10) - AC_SUBST(GST_PLUGIN_BASE_CFLAGS) - AC_SUBST(GST_PLUGIN_BASE_LIBS) - - PKG_CHECK_MODULES(GST_INTERFACE, gstreamer-interfaces-0.10 >= 0.10) - AC_SUBST(GST_INTERFACE_CFLAGS) - AC_SUBST(GST_INTERFACE_LIBS) -fi - -if test "$use_gstreamer_1" = "1"; then - PKG_CHECK_MODULES(GST_APP, gstreamer-app-1.0 ) - AC_SUBST(GST_APP_CFLAGS) - AC_SUBST(GST_APP_LIBS) - - PKG_CHECK_MODULES(GST_VIDEO, gstreamer-video-1.0 ) - AC_SUBST(GST_VIDEO_CFLAGS) - AC_SUBST(GST_VIDEO_LIBS) -else - PKG_CHECK_MODULES(GST_APP, gstreamer-app-0.10 >= 0.10 ) - AC_SUBST(GST_APP_CFLAGS) - AC_SUBST(GST_APP_LIBS) -fi +PKG_CHECK_MODULES(GST, gstreamer-1.0 >= 1.2.0) +AC_SUBST(GST_CFLAGS) +AC_SUBST(GST_LIBS) + +PKG_CHECK_MODULES(GST_PLUGIN_BASE, gstreamer-plugins-base-1.0 >= 1.2.0) +AC_SUBST(GST_PLUGIN_BASE_CFLAGS) +AC_SUBST(GST_PLUGIN_BASE_LIBS) + +PKG_CHECK_MODULES(GST_VIDEO, gstreamer-video-1.0 >= 1.2.0) +AC_SUBST(GST_VIDEO_CFLAGS) +AC_SUBST(GST_LIBS) + +PKG_CHECK_MODULES(GST_APP, gstreamer-app-1.0 >= 1.2.0) +AC_SUBST(GST_APP_CFLAGS) +AC_SUBST(GST_APP_LIBS) PKG_CHECK_MODULES(MMSESSION, mm-session) AC_SUBST(MMSESSION_CFLAGS) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index 7c79a45..654267a 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.2.19 +Version: 0.2.27 Release: 0 Group: System/Libraries License: Apache-2.0 @@ -10,17 +10,10 @@ Source1001: libmm-player.manifest BuildRequires: pkgconfig(mm-ta) BuildRequires: pkgconfig(mm-common) BuildRequires: pkgconfig(mm-sound) - -%if %{defined with_Gstreamer0.10} -BuildRequires: pkgconfig(gstreamer-0.10) -BuildRequires: pkgconfig(gstreamer-plugins-base-0.10) -BuildRequires: pkgconfig(gstreamer-interfaces-0.10) -BuildRequires: pkgconfig(gstreamer-app-0.10) -%else BuildRequires: pkgconfig(gstreamer-1.0) BuildRequires: pkgconfig(gstreamer-plugins-base-1.0) +BuildRequires: pkgconfig(gstreamer-video-1.0) BuildRequires: pkgconfig(gstreamer-app-1.0) -%endif BuildRequires: pkgconfig(mm-session) BuildRequires: pkgconfig(mmutil-imgp) @@ -49,13 +42,6 @@ cp %{SOURCE1001} . ## %autogen.sh -%if %{defined with_Gstreamer0.10} -export GSTREAMER_API="" -%else -export GSTREAMER_API="-DGST_API_VERSION_1=1" -export use_gstreamer_1=1 -%endif - CFLAGS+=" -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" $GSTREAMER_API" ; export CFLAGS LDFLAGS+="-Wl,--rpath=%{_libdir} -lgstvideo-1.0 -Wl,--hash-style=both -Wl,--as-needed"; export LDFLAGS diff --git a/src/Makefile.am b/src/Makefile.am index 4081fe4..1184863 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,7 +25,7 @@ libmmfplayer_la_CFLAGS = -I$(srcdir)/include \ $(MMTA_CFLAGS) \ $(MMUTIL_CFLAGS) \ $(GST_CFLAGS) \ - $(GST_INTERFACE_CFLAGS) \ + $(GST_VIDEO_CFLAGS) \ $(GST_APP_CFLAGS) \ $(MMSESSION_CFLAGS) \ $(MMSOUND_CFLAGS) \ @@ -46,7 +46,7 @@ libmmfplayer_la_LIBADD = $(GST_LIBS) \ $(MMCOMMON_LIBS) \ $(MMTA_LIBS) \ $(MMUTIL_LIBS) \ - $(GST_INTERFACE_LIBS) \ + $(GST_VIDEO_LIBS) \ $(GST_APP_LIBS) \ $(INIPARSER_LIBS) \ $(MMSESSION_LIBS) \ diff --git a/src/include/mm_player.h b/src/include/mm_player.h index 4200347..12211d3 100644 --- a/src/include/mm_player.h +++ b/src/include/mm_player.h @@ -1544,8 +1544,73 @@ printf("audio track count : %d \n", audio_count); */ int mm_player_get_track_count(MMHandleType player, MMPlayerTrackType track_type, int *count); +/** + * This function is to ignore session + * + * @param player [in] handle of player + * + * @return This function returns MM_ERROR_NONE on success, or negative value with error code. + */ +int mm_player_ignore_session(MMHandleType player); + +/** + * This function is to set zoom level. + * + * @param player [in] handle of player. + * @param level [in] level of zoom + * + * @return This function returns zero on success, or negative value with error + * code. + * + * @see + * @remark None + */ +int mm_player_set_display_zoom(MMHandleType player, float level); /** + * This function is to get zoom level. + * + * @param player [in] handle of player. + * @param type [out] current level of zoom + * + * @return This function returns zero on success, or negative value with error + * code. + * + * @see + * @remark None + */ +int mm_player_get_display_zoom(MMHandleType player, float *level); + +/** + * This function is to set the start position of zoom + * + * @param player [in] handle of player + * @param x [in] start x position + * @param y [in] start y position + * + * @return This function returns zero on success, or negative value with error + * code. + * + * @see + * @remark None + */ +int mm_player_set_display_zoom_start_position(MMHandleType player, int x, int y); + +/** + * This function is to get the start position of zoom + * + * @param player [in] handle of player + * @param x [out] start x position + * @param y [out] start y position + * + * @return This function returns zero on success, or negative value with error + * code. + * + * @see + * @remark None + */ +int mm_player_get_display_zoom_start_position(MMHandleType player, int *x, int *y); +/** @} */ diff --git a/src/include/mm_player_attrs.h b/src/include/mm_player_attrs.h index 846bbba..a752297 100644 --- a/src/include/mm_player_attrs.h +++ b/src/include/mm_player_attrs.h @@ -63,7 +63,7 @@ int _mmplayer_get_attribute(MMHandleType handle, char **err_atr_name, const cha * @see * */ -int _mmplayer_get_attribute_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *info); +int _mmplayer_get_attributes_info(MMHandleType handle, const char *attribute_name, MMPlayerAttrsInfo *info); /** * This function allocates structure of attributes and sets initial values. * diff --git a/src/include/mm_player_ini.h b/src/include/mm_player_ini.h index c8c095e..4f6e1a8 100644 --- a/src/include/mm_player_ini.h +++ b/src/include/mm_player_ini.h @@ -248,6 +248,8 @@ mm_player_ini_load(void); mm_player_ini_t* mm_player_ini_get_structure(void); +int +mm_player_audio_effect_ini_load(void); #ifdef __cplusplus } diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index 3658b33..709f9dd 100755 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -618,6 +618,8 @@ typedef struct { gboolean play_subtitle; gboolean use_textoverlay; + const gchar *temp_encode_name; + /* PD downloader message callback and param */ MMMessageCallback pd_msg_cb; void* pd_msg_cb_param; @@ -647,7 +649,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_adjust_subtitle_postion(MMHandleType hplayer, int format, unsigned long 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); @@ -671,6 +673,10 @@ int _mmplayer_update_video_param(mm_player_t* player); int _mmplayer_set_audiobuffer_cb(MMHandleType hplayer, mm_player_audio_stream_callback callback, void *user_param); int _mmplayer_audio_effect_preset_apply(mm_player_t *player, MMAudioEffectPresetType effect_type); int _mmplayer_audio_effect_custom_apply(mm_player_t *player); +int _mmplayer_set_display_zoom(MMHandleType hplayer, float level); +int _mmplayer_get_display_zoom(MMHandleType hplayer, float *level); +int _mmplayer_set_display_zoom_start_pos(MMHandleType hplayer, int x, int y); +int _mmplayer_get_display_zoom_start_pos(MMHandleType hplayer, int *x, int *y); #ifdef __cplusplus } diff --git a/src/include/mm_player_priv_locl_func.h b/src/include/mm_player_priv_locl_func.h index 972625d..62f654a 100755 --- a/src/include/mm_player_priv_locl_func.h +++ b/src/include/mm_player_priv_locl_func.h @@ -82,7 +82,7 @@ gboolean __gst_send_event_to_sink( mm_player_t* player, GstEvent* event ); gboolean __gst_seek(mm_player_t* player, GstElement * element, gdouble rate, GstFormat format, GstSeekFlags flags, GstSeekType cur_type, gint64 cur, GstSeekType stop_type, gint64 stop); -int __gst_adjust_subtitle_position(mm_player_t* player, int format, int position); +int __gst_adjust_subtitle_position(mm_player_t* player, int format, unsigned long position); void __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data); gboolean __gst_appsrc_seek_data_mem(GstElement *element, guint64 size, gpointer user_data); void __gst_appsrc_feed_data(GstElement *element, guint size, gpointer user_data); diff --git a/src/include/mm_player_utils.h b/src/include/mm_player_utils.h index 89be772..3856a89 100644 --- a/src/include/mm_player_utils.h +++ b/src/include/mm_player_utils.h @@ -183,7 +183,6 @@ gboolean __util_gst_pad_probe(GstPad *pad, GstBuffer *buffer, gpointer u_data); /* messages are treated as warnings bcz those code should not be checked in. * and no error handling will supported for same manner. */ -#ifndef GST_API_VERSION_1 #define MMPLAYER_ADD_PROBE(x_pad, x_flag) \ debug_warning("adding pad probe\n"); \ if ( ! gst_pad_add_buffer_probe(x_pad, \ @@ -192,16 +191,6 @@ if ( ! gst_pad_add_buffer_probe(x_pad, \ { \ debug_error("failed to add pad probe\n"); \ } -#else -#define MMPLAYER_ADD_PROBE(x_pad, x_flag) \ -debug_warning("adding pad probe\n"); \ -if ( ! gst_pad_add_probe(x_pad, \ - __util_gst_pad_probe, \ - (gpointer)x_flag), NULL ) \ -{ \ - debug_error("failed to add pad probe\n"); \ -} -#endif /* generating dot */ @@ -265,6 +254,16 @@ debug_log("------------------------------------------------------------\n"); #define MMPLAYER_PT_IS_AUDIO( x_pt ) ( strstr(x_pt, "_97") || strstr(x_pt, "audio") ) #define MMPLAYER_PT_IS_VIDEO( x_pt ) ( strstr(x_pt, "_96") || strstr(x_pt, "video") ) +#define MMPLAYER_VIDEO_SINK_CHECK(x_player) \ +do \ +{ \ + return_val_if_fail ( x_player && \ + x_player->pipeline && \ + x_player->pipeline->videobin && \ + x_player->pipeline->videobin[MMPLAYER_V_SINK].gst, \ + MM_ERROR_PLAYER_NOT_INITIALIZED ); \ +} while(0); + bool util_is_sdp_file ( const char *path ); int64_t uti_get_time ( void ); int util_get_rank_increase ( const char *factory_class ); @@ -281,7 +280,7 @@ int util_is_midi_type_by_file(const char *file_path); char** util_get_cookie_list ( const char *cookies ); bool util_check_valid_url ( const char *proxy ); -char* util_get_charset(const char *file_path); +const char* util_get_charset(const char *file_path); #ifdef __cplusplus } diff --git a/src/mm_player.c b/src/mm_player.c index 7188050..278f2fa 100644 --- a/src/mm_player.c +++ b/src/mm_player.c @@ -42,6 +42,9 @@ int mm_player_create(MMHandleType *player) return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + if (!g_thread_supported ()) + g_thread_init (NULL); + MMTA_INIT(); __ta__("mm_player_ini_load", @@ -440,8 +443,6 @@ int mm_player_get_state(MMHandleType player, MMPlayerStateType *state) /* NOTE : Not supported */ int mm_player_change_videosink(MMHandleType player, MMDisplaySurfaceType display_surface_type, void *display_overlay) { - int result = MM_ERROR_NONE; - debug_log("\n"); return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); @@ -799,3 +800,63 @@ int mm_player_ignore_session(MMHandleType player) return result; } + +int mm_player_set_display_zoom(MMHandleType player, float level) +{ + int result = MM_ERROR_NONE; + return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK( player ); + + result = _mmplayer_set_display_zoom(player, level); + + MMPLAYER_CMD_UNLOCK( player ); + + return result; +} + +int mm_player_get_display_zoom(MMHandleType player, float *level) +{ + int result = MM_ERROR_NONE; + + return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + return_val_if_fail(level, MM_ERROR_COMMON_INVALID_ARGUMENT); + + MMPLAYER_CMD_LOCK( player ); + + result = _mmplayer_get_display_zoom(player, level); + + MMPLAYER_CMD_UNLOCK( player ); + + return result; +} + +int mm_player_set_display_zoom_start_position(MMHandleType player, int x, int y) +{ + int result = MM_ERROR_NONE; + + return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK( player ); + + result = _mmplayer_set_display_zoom_start_pos(player, x, y); + + MMPLAYER_CMD_UNLOCK( player ); + + return result; +} + +int mm_player_get_display_zoom_start_position(MMHandleType player, int *x, int *y) +{ + int result = MM_ERROR_NONE; + + return_val_if_fail(player, MM_ERROR_PLAYER_NOT_INITIALIZED); + + MMPLAYER_CMD_LOCK( player ); + + result = _mmplayer_get_display_zoom_start_pos(player, x, y); + + MMPLAYER_CMD_UNLOCK( player ); + + return result; +} diff --git a/src/mm_player_attrs.c b/src/mm_player_attrs.c index 1077e00..3d94ac6 100644 --- a/src/mm_player_attrs.c +++ b/src/mm_player_attrs.c @@ -27,11 +27,8 @@ #include #include #include -#ifndef GST_API_VERSION_1 -#include -#else + #include -#endif #include "mm_player_priv.h" #include "mm_player_attrs.h" @@ -685,12 +682,12 @@ _mmplayer_construct_attribute(MMHandleType handle) }, { "display_zoom", - MM_ATTRS_TYPE_INT, + MM_ATTRS_TYPE_DOUBLE, MM_ATTRS_FLAG_RW, (void *) 1, - MM_ATTRS_VALID_TYPE_INT_RANGE, - 1, - MMPLAYER_MAX_INT + MM_ATTRS_VALID_TYPE_DOUBLE_RANGE, + 1.0, + 9.0 }, { "display_surface_type", @@ -934,6 +931,15 @@ _mmplayer_construct_attribute(MMHandleType handle) MM_ATTRS_VALID_TYPE_NONE, 0, 0 + }, + { + "accurate_seek", + MM_ATTRS_TYPE_INT, + MM_ATTRS_FLAG_RW, + (void *) 0, + MM_ATTRS_VALID_TYPE_INT_RANGE, + 0, + 1 } }; @@ -983,7 +989,7 @@ _mmplayer_construct_attribute(MMHandleType handle) mmf_attrs_set_valid_range (attrs, idx, player_attrs[idx].value_min, player_attrs[idx].value_max, - player_attrs[idx].default_value); + (int)player_attrs[idx].default_value); } break; diff --git a/src/mm_player_capture.c b/src/mm_player_capture.c index 8b0e29c..e9880f0 100755 --- a/src/mm_player_capture.c +++ b/src/mm_player_capture.c @@ -18,7 +18,7 @@ * limitations under the License. * */ - + /*=========================================================================================== | | | INCLUDE FILES | @@ -28,6 +28,7 @@ #include "mm_player_priv.h" #include +#include /*--------------------------------------------------------------------------- | LOCAL VARIABLE DEFINITIONS for internal | @@ -36,8 +37,8 @@ /*--------------------------------------------------------------------------- | LOCAL FUNCTION PROTOTYPES: | ---------------------------------------------------------------------------*/ -static gboolean __mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data); -//static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer); +static GstPadProbeReturn __mmplayer_video_capture_probe (GstPad *pad, GstPadProbeInfo *info, gpointer u_data); +static int __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuffer *buffer); static gpointer __mmplayer_capture_thread(gpointer data); static void __csc_tiled_to_linear_crop(unsigned char *yuv420_dest, unsigned char *nv12t_src, int yuv420_width, int yuv420_height, int left, int top, int right, int buttom); static int __tile_4x2_read(int x_size, int y_size, int x_pos, int y_pos); @@ -48,7 +49,7 @@ static int __mm_player_convert_colorspace(mm_player_t* player, unsigned char* sr | FUNCTION DEFINITIONS | | | ========================================================================================== */ -int +int _mmplayer_initialize_video_capture(mm_player_t* player) { return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); @@ -140,18 +141,23 @@ _mmplayer_do_video_capture(MMHandleType hplayer) return MM_ERROR_PLAYER_INVALID_STATE; } + pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" ); if (player->state != MM_PLAYER_STATE_PLAYING) { if (player->state == MM_PLAYER_STATE_PAUSED) // get last buffer from video sink { + GstSample *sample = NULL; + g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-sample", &sample, NULL); + if (sample) + { GstBuffer *buf = NULL; - g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-buffer", &buf, NULL); - - + buf = gst_sample_get_buffer(sample); if (buf) { - //ret = __mmplayer_get_video_frame_from_buffer(player, buf); + ret = __mmplayer_get_video_frame_from_buffer(player, pad, buf); gst_buffer_unref(buf); + } + gst_sample_unref(sample); } return ret; } @@ -162,16 +168,9 @@ _mmplayer_do_video_capture(MMHandleType hplayer) } } - pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" ); - /* register probe */ -#ifndef GST_API_VERSION_1 - player->video_capture_cb_probe_id = gst_pad_add_buffer_probe (pad, - G_CALLBACK (__mmplayer_video_capture_probe), player); -#else player->video_capture_cb_probe_id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, __mmplayer_video_capture_probe, player, NULL); -#endif gst_object_unref(GST_OBJECT(pad)); pad = NULL; @@ -205,7 +204,7 @@ __mmplayer_capture_thread(gpointer data) debug_log("capture thread is recieved signal"); /* NOTE: Don't use MMPLAYER_CMD_LOCK() here. - * Because deadlock can be happened if other player api is used in message callback. + * Because deadlock can be happened if other player api is used in message callback. */ if (player->video_cs == MM_PLAYER_COLORSPACE_NV12_TILED) { @@ -322,17 +321,17 @@ EXIT: /** * The output is fixed as RGB888 */ -#ifdef GST_API_VERSION_1 static int -__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer) +__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstPad *pad, GstBuffer *buffer) { gint yplane_size = 0; gint uvplane_size = 0; gint src_width = 0; gint src_height = 0; - guint32 fourcc = 0; GstCaps *caps = NULL; GstStructure *structure = NULL; + GstMapInfo mapinfo = GST_MAP_INFO_INIT; + GstMemory *memory = 0; mm_util_img_format src_fmt = MM_UTIL_IMG_FMT_YUV420; mm_util_img_format dst_fmt = MM_UTIL_IMG_FMT_RGB888; // fixed @@ -342,7 +341,7 @@ __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer) return_val_if_fail ( buffer, MM_ERROR_INVALID_ARGUMENT ); /* get fourcc */ - caps = GST_BUFFER_CAPS(buffer); + caps = gst_pad_get_current_caps(pad); return_val_if_fail ( caps, MM_ERROR_INVALID_ARGUMENT ); debug_log("caps to capture: %s\n", gst_caps_to_string(caps)); @@ -358,287 +357,75 @@ __mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer) gst_structure_get_int (structure, "height", &src_height); /* check rgb or yuv */ - if (gst_structure_has_name(structure, "video/x-raw-yuv")) - { - gst_structure_get_fourcc (structure, "format", &fourcc); - switch(fourcc) - { - /* NV12T */ - case GST_MAKE_FOURCC ('S', 'T', '1', '2'): - { - debug_msg ("captured format is ST12\n"); - - MMPlayerMPlaneImage *proved = NULL; - player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED; - - /* get video frame info from proved buffer */ - proved = (MMPlayerMPlaneImage *)GST_BUFFER_MALLOCDATA(buffer); - - if ( !proved || !proved->a[0] || !proved->a[1] ) - return MM_ERROR_PLAYER_INTERNAL; - - yplane_size = (proved->s[0] * proved->e[0]); - uvplane_size = (proved->s[1] * proved->e[1]); - - memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage)); - memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage)); - - player->captured.a[0] = g_try_malloc(yplane_size); - if ( !player->captured.a[0] ) - return MM_ERROR_SOUND_NO_FREE_SPACE; - - player->captured.a[1] = g_try_malloc(uvplane_size); - if ( !player->captured.a[1] ) - return MM_ERROR_SOUND_NO_FREE_SPACE; - - memcpy(player->captured.a[0], proved->a[0], yplane_size); - memcpy(player->captured.a[1], proved->a[1], uvplane_size); - goto DONE; - } - break; - - case GST_MAKE_FOURCC ('I', '4', '2', '0'): - { - src_fmt = MM_UTIL_IMG_FMT_I420; - } - break; - - default: - { - goto UNKNOWN; - } - break; - } - } - else if (gst_structure_has_name(structure, "video/x-raw-rgb")) + if (gst_structure_has_name(structure, "video/x-raw")) { - gint bpp; - gint depth; - gint endianess; - gint blue_mask; - gboolean bigendian = FALSE; - gboolean isbluefirst = FALSE; - - /** - - * The followings will be considered. - * RGBx, xRGB, BGRx, xBGR - * RGB888, BGR888 - * RGB565 - * - */ - gst_structure_get_int (structure, "bpp", &bpp); - gst_structure_get_int (structure, "depth", &depth); - gst_structure_get_int (structure, "endianness", &endianess); - gst_structure_get_int (structure, "blue_mask", &blue_mask); - - if (endianess == 4321) - bigendian = TRUE; - - if (blue_mask == -16777216) - isbluefirst = TRUE; - - switch(bpp) + /* NV12T */ + if(!g_strcmp0(gst_structure_get_string(structure, "format"), "ST12")) { - case 32: - { - switch(depth) - { - case 32: - if (bigendian && isbluefirst) - src_fmt = MM_UTIL_IMG_FMT_BGRA8888; - case 24: - if (bigendian && isbluefirst) - src_fmt = MM_UTIL_IMG_FMT_BGRX8888; - break; - default: - goto UNKNOWN; - break; - } - } - break; - - case 24: - default: - { - goto UNKNOWN; - } - break; + debug_msg ("captured format is ST12\n"); + + MMPlayerMPlaneImage *proved = NULL; + player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED; + + /* get video frame info from proved buffer */ + memory = gst_buffer_get_memory(buffer, 1); + gst_memory_map(memory, &mapinfo, GST_MAP_READ); + proved = (MMPlayerMPlaneImage *)mapinfo.data; + gst_memory_unmap(memory, &mapinfo); + + if ( !proved || !proved->a[0] || !proved->a[1] ) + return MM_ERROR_PLAYER_INTERNAL; + + yplane_size = proved->y_size; + uvplane_size = proved->uv_size; + + debug_msg ("yplane_size=%d, uvplane_size=%d\n",yplane_size,uvplane_size); + memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage)); + memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage)); + + player->captured.a[0] = g_try_malloc(yplane_size); + if ( !player->captured.a[0] ) + return MM_ERROR_SOUND_NO_FREE_SPACE; + + player->captured.a[1] = g_try_malloc(uvplane_size); + if ( !player->captured.a[1] ) + return MM_ERROR_SOUND_NO_FREE_SPACE; + + memcpy(player->captured.a[0], proved->a[0], yplane_size); + memcpy(player->captured.a[1], proved->a[1], uvplane_size); + goto DONE; } - } - else - { - goto UNKNOWN; - } - GstMapInfo info; - gst_buffer_map (buffer, &info, GST_MAP_WRITE); - __mm_player_convert_colorspace(player, info.data, src_fmt, src_width, src_height, dst_fmt); - gst_buffer_unmap (buffer, &info); - -DONE: - /* do convert colorspace */ - g_cond_signal( player->capture_thread_cond ); - - debug_fleave(); - - return MM_ERROR_NONE; - -UNKNOWN: - debug_error("unknown format to capture\n"); - return MM_ERROR_PLAYER_INTERNAL; -} -#else -/** - * The output is fixed as RGB888 - */ -static int -__mmplayer_get_video_frame_from_buffer(mm_player_t* player, GstBuffer *buffer) -{ - gint yplane_size = 0; - gint uvplane_size = 0; - gint src_width = 0; - gint src_height = 0; - const gchar *fmt; - GstCaps *caps = NULL; - GstStructure *structure = NULL; - mm_util_img_format src_fmt = MM_UTIL_IMG_FMT_YUV420; - mm_util_img_format dst_fmt = MM_UTIL_IMG_FMT_RGB888; // fixed - - debug_fenter(); - - return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); - return_val_if_fail ( buffer, MM_ERROR_INVALID_ARGUMENT ); - - /* get fourcc */ - caps = GST_BUFFER_CAPS(buffer); - - return_val_if_fail ( caps, MM_ERROR_INVALID_ARGUMENT ); - debug_log("caps to capture: %s\n", gst_caps_to_string(caps)); - - structure = gst_caps_get_structure (caps, 0); - - return_val_if_fail (structure != NULL, MM_ERROR_PLAYER_INTERNAL); - - /* init capture image buffer */ - memset(&player->capture, 0x00, sizeof(MMPlayerVideoCapture)); - - gst_structure_get_int (structure, "width", &src_width); - gst_structure_get_int (structure, "height", &src_height); - - /* check rgb or yuv */ - if (gst_structure_has_name(structure, "video/x-raw-yuv")) - { - fmt = gst_structure_get_string (structure, "format"); - switch (GST_STR_FOURCC (fmt)) + else { - /* NV12T */ - case GST_MAKE_FOURCC ('S', 'T', '1', '2'): + GstVideoInfo format_info; + gst_video_info_from_caps(&format_info, caps); + switch (GST_VIDEO_INFO_FORMAT(&format_info)) { - debug_msg ("captured format is ST12\n"); - - MMPlayerMPlaneImage *proved = NULL; - player->video_cs = MM_PLAYER_COLORSPACE_NV12_TILED; - - /* get video frame info from proved buffer */ - proved = (MMPlayerMPlaneImage *)gst_buffer_copy (buffer); - - if ( !proved || !proved->a[0] || !proved->a[1] ) - return MM_ERROR_PLAYER_INTERNAL; - - yplane_size = proved->y_size; - uvplane_size = proved->uv_size; - - debug_msg ("yplane_size=%d, uvplane_size=%d\n",yplane_size,uvplane_size); - memset(&player->captured, 0x00, sizeof(MMPlayerMPlaneImage)); - memcpy(&player->captured, proved, sizeof(MMPlayerMPlaneImage)); - - player->captured.a[0] = g_try_malloc(yplane_size); - if ( !player->captured.a[0] ) - return MM_ERROR_SOUND_NO_FREE_SPACE; - - player->captured.a[1] = g_try_malloc(uvplane_size); - if ( !player->captured.a[1] ) - return MM_ERROR_SOUND_NO_FREE_SPACE; + case GST_VIDEO_FORMAT_I420: + src_fmt = MM_UTIL_IMG_FMT_I420; + break; - memcpy(player->captured.a[0], proved->a[0], yplane_size); - memcpy(player->captured.a[1], proved->a[1], uvplane_size); - goto DONE; - } - break; + case GST_VIDEO_FORMAT_BGRA: + src_fmt = MM_UTIL_IMG_FMT_BGRA8888; + break; - case GST_MAKE_FOURCC ('I', '4', '2', '0'): - { - src_fmt = MM_UTIL_IMG_FMT_I420; - } - break; + case GST_VIDEO_FORMAT_BGRx: + src_fmt = MM_UTIL_IMG_FMT_BGRX8888; + break; - default: - { - goto UNKNOWN; - } - break; - } - } - else if (gst_structure_has_name(structure, "video/x-raw-rgb")) - { - gint bpp; - gint depth; - gint endianess; - gint blue_mask; - gboolean bigendian = FALSE; - gboolean isbluefirst = FALSE; - - /** - * The followings will be considered. - * RGBx, xRGB, BGRx, xBGR - * RGB888, BGR888 - * RGB565 - * - */ - gst_structure_get_int (structure, "bpp", &bpp); - gst_structure_get_int (structure, "depth", &depth); - gst_structure_get_int (structure, "endianness", &endianess); - gst_structure_get_int (structure, "blue_mask", &blue_mask); - - if (endianess == 4321) - bigendian = TRUE; - - if (blue_mask == -16777216) - isbluefirst = TRUE; - - switch(bpp) - { - case 32: - { - switch(depth) - { - case 32: - if (bigendian && isbluefirst) - src_fmt = MM_UTIL_IMG_FMT_BGRA8888; - case 24: - if (bigendian && isbluefirst) - src_fmt = MM_UTIL_IMG_FMT_BGRX8888; - break; - default: - goto UNKNOWN; - break; - } - } - break; - - case 24: - default: - { - goto UNKNOWN; + default: + goto UNKNOWN; + break; } - break; } } else { - goto UNKNOWN; + goto UNKNOWN; } - __mm_player_convert_colorspace(player, GST_BUFFER_DATA(buffer), src_fmt, src_width, src_height, dst_fmt); + gst_buffer_map(buffer, &mapinfo, GST_MAP_READ); + __mm_player_convert_colorspace(player, mapinfo.data, src_fmt, src_width, src_height, dst_fmt); + gst_buffer_unmap(buffer, &mapinfo); DONE: /* do convert colorspace */ @@ -652,39 +439,36 @@ UNKNOWN: debug_error("unknown format to capture\n"); return MM_ERROR_PLAYER_INTERNAL; } -#endif -static gboolean -__mmplayer_video_capture_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data) +static GstPadProbeReturn +__mmplayer_video_capture_probe (GstPad *pad, GstPadProbeInfo *info, gpointer u_data) { mm_player_t* player = (mm_player_t*) u_data; + GstBuffer *buffer = NULL; int ret = MM_ERROR_NONE; - return_val_if_fail ( buffer, FALSE); + return_val_if_fail ( info->data, GST_PAD_PROBE_REMOVE); debug_fenter(); - //ret = __mmplayer_get_video_frame_from_buffer(player, buffer); + buffer = gst_pad_probe_info_get_buffer(info); + ret = __mmplayer_get_video_frame_from_buffer(player, pad, buffer); if ( ret != MM_ERROR_NONE) { debug_error("faild to get video frame. %x\n", ret); - return FALSE; + return GST_PAD_PROBE_REMOVE; } /* remove probe to be called at one time */ if (player->video_capture_cb_probe_id) { -#ifndef GST_API_VERSION_1 - gst_pad_remove_buffer_probe (pad, player->video_capture_cb_probe_id); -#else gst_pad_remove_probe (pad, player->video_capture_cb_probe_id); -#endif player->video_capture_cb_probe_id = 0; } debug_fleave(); - return TRUE; + return GST_PAD_PROBE_OK; } static int diff --git a/src/mm_player_pd.c b/src/mm_player_pd.c index d82f57c..9f7eafe 100644 --- a/src/mm_player_pd.c +++ b/src/mm_player_pd.c @@ -153,14 +153,10 @@ __pd_downloader_callback(GstBus *bus, GstMessage *msg, gpointer data) case GST_MESSAGE_DURATION: { -#ifndef GST_API_VERSION_1 - GstFormat fmt= GST_FORMAT_BYTES; -#endif gint64 size = 0LL; /* get total size of download file, (bytes) */ -#ifdef GST_API_VERSION_1 if ( ! gst_element_query_duration( pd->downloader_pipeline, GST_FORMAT_BYTES, &size ) ) { GError *err = NULL; @@ -180,27 +176,6 @@ __pd_downloader_callback(GstBus *bus, GstMessage *msg, gpointer data) debug_error("failed to query total size for download\n"); break; } -#else - if ( ! gst_element_query_duration( pd->downloader_pipeline, &fmt, &size ) ) - { - GError *err = NULL; - GstMessage *new_msg = NULL; - - err = g_error_new (GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, "can't get total size"); - new_msg = gst_message_new_error (GST_OBJECT_CAST (pd->playback_pipeline_src), err, NULL); - gst_element_post_message (pd->playback_pipeline_src, new_msg); - - g_error_free (err); - - // TODO: check if playback pipeline is closed well or not - g_object_set (G_OBJECT (pd->playback_pipeline_src), "eos", TRUE, NULL); - - _mmplayer_unrealize_pd_downloader ((MMHandleType)data); - - debug_error("failed to query total size for download\n"); - break; - } -#endif pd->total_size = size; diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 0e00372..ecf46be 100755 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -27,11 +27,7 @@ #include #include #include -#ifndef GST_API_VERSION_1 -#include -#else #include -#endif #include #include #include @@ -129,7 +125,7 @@ gboolean __mmplayer_post_message(mm_player_t* player, enum MMMessageType msgtype int __mmplayer_switch_audio_sink (mm_player_t* player); 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); +static GstPadProbeReturn __mmplayer_audio_stream_probe (GstPad *pad, GstPadProbeInfo *info, gpointer u_data); static gboolean __mmplayer_eos_timer_cb(gpointer u_data); static int __mmplayer_check_not_supported_codec(mm_player_t* player, gchar* mime); static gpointer __mmplayer_repeat_thread(gpointer data); @@ -145,6 +141,7 @@ static int __mmplayer_realize_streaming_ext(mm_player_t* player); static int __mmplayer_unrealize_streaming_ext(mm_player_t *player); static int __mmplayer_start_streaming_ext(mm_player_t *player); static int __mmplayer_destroy_streaming_ext(mm_player_t* player); +static void __mmplayer_remove_g_source_from_context(guint source_id); /*=========================================================================================== @@ -429,9 +426,6 @@ _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag) gboolean missing_only = FALSE; gboolean all = FALSE; -#ifndef GST_API_VERSION_1 - GstFormat fmt = GST_FORMAT_TIME; -#endif gint64 dur_nsec = 0; GstStructure* p = NULL; MMHandleType attrs = 0; @@ -489,19 +483,11 @@ _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag) debug_log("try to update duration"); has_duration = FALSE; -#ifdef GST_API_VERSION_1 if (gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec )) { player->duration = dur_nsec; debug_log("duration : %lld msec", GST_TIME_AS_MSECONDS(dur_nsec)); } -#else - if (gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &fmt, &dur_nsec )) - { - player->duration = dur_nsec; - debug_log("duration : %lld msec", GST_TIME_AS_MSECONDS(dur_nsec)); - } -#endif /* try to get streaming service type */ stream_service_type = __mmplayer_get_stream_service_type( player ); @@ -543,11 +529,7 @@ _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag) if ( pad ) { -#ifdef GST_API_VERSION_1 caps_a = gst_pad_get_current_caps( pad ); -#else - caps_a = gst_pad_get_negotiated_caps( pad ); -#endif if ( caps_a ) { @@ -598,11 +580,7 @@ _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag) pad = gst_element_get_static_pad( player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink" ); if ( pad ) { -#ifdef GST_API_VERSION_1 caps_v = gst_pad_get_current_caps( pad ); -#else - caps_v = gst_pad_get_negotiated_caps( pad ); -#endif if (caps_v) { p = gst_caps_get_structure (caps_v, 0); @@ -1323,6 +1301,10 @@ __mmplayer_get_property_value_for_rotation(mm_player_t* player, int rotation_ang { rotation_using_type = ROTATION_USING_FLIP; } + else if (!strcmp(PLAYER_INI()->videosink_element_evas,"evaspixmapsink")) + { + rotation_using_type = ROTATION_USING_X; + } else { debug_error("it should not be here.."); @@ -1467,10 +1449,7 @@ _mmplayer_update_video_param(mm_player_t* player) // @ } } - debug_log("check user angle: %d, org angle: %d", user_angle, org_angle); - - /* get rotation value to set */ - __mmplayer_get_property_value_for_rotation(player, org_angle+user_angle, &rotation_value); + debug_log("check user angle: %d, orientation: %d", user_angle, org_angle); /* check video stream callback is used */ if( player->use_video_stream ) @@ -1485,11 +1464,7 @@ _mmplayer_update_video_param(mm_player_t* player) // @ mm_attrs_get_int_by_name(attrs, "display_height", &height); /* resize video frame with requested values for fimcconvert */ -#ifdef GST_API_VERSION_1 - ename = GST_OBJECT (gst_element_get_factory(player->pipeline->videobin[MMPLAYER_V_CONV].gst)); -#else - ename = GST_PLUGIN_FEATURE_NAME(gst_element_get_factory(player->pipeline->videobin[MMPLAYER_V_CONV].gst)); -#endif + ename = GST_OBJECT_NAME(gst_element_get_factory(player->pipeline->videobin[MMPLAYER_V_CONV].gst)); if (g_strrstr(ename, "fimcconvert")) { @@ -1499,19 +1474,23 @@ _mmplayer_update_video_param(mm_player_t* player) // @ if (height) g_object_set(player->pipeline->videobin[MMPLAYER_V_CONV].gst, "dst-height", height, NULL); + /* NOTE: fimcconvert does not manage index of src buffer from upstream src-plugin, decoder gives frame information in output buffer with no ordering */ + g_object_set(player->pipeline->videobin[MMPLAYER_V_CONV].gst, "src-rand-idx", TRUE, NULL); + + /* get rotation value to set */ + __mmplayer_get_property_value_for_rotation(player, org_angle+user_angle, &rotation_value); + g_object_set(player->pipeline->videobin[MMPLAYER_V_CONV].gst, "rotate", rotation_value, NULL); debug_log("updating fimcconvert - r[%d], w[%d], h[%d]", rotation_value, width, height); } - else - { - debug_error("no available video converter"); - return MM_ERROR_PLAYER_INTERNAL; - } } else { debug_log("using video stream callback with memsink. player handle : [%p]", player); + /* get rotation value to set */ + __mmplayer_get_property_value_for_rotation(player, org_angle+user_angle, &rotation_value); + g_object_set(player->pipeline->videobin[MMPLAYER_V_FLIP].gst, "method", rotation_value, NULL); } @@ -1529,7 +1508,7 @@ _mmplayer_update_video_param(mm_player_t* player) // @ { /* ximagesink or xvimagesink */ void *xid = NULL; - int zoom = 0; + double zoom = 0; int display_method = 0; int roi_x = 0; int roi_y = 0; @@ -1551,11 +1530,7 @@ _mmplayer_update_video_param(mm_player_t* player) // @ } debug_log("set video param : xid %d", *(int*)xid); -#ifdef GST_API_VERSION_1 - gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY( player->pipeline->videobin[MMPLAYER_V_SINK].gst ), *(int*)xid ); -#else - gst_x_overlay_set_xwindow_id( GST_X_OVERLAY( player->pipeline->videobin[MMPLAYER_V_SINK].gst ), *(int*)xid ); -#endif + gst_video_overlay_set_window_handle( GST_VIDEO_OVERLAY( player->pipeline->videobin[MMPLAYER_V_SINK].gst ), *(int*)xid ); } else { @@ -1567,35 +1542,52 @@ _mmplayer_update_video_param(mm_player_t* player) // @ if (!strcmp(PLAYER_INI()->videosink_element_x,"xvimagesink")) { mm_attrs_get_int_by_name(attrs, "display_force_aspect_ration", &force_aspect_ratio); - mm_attrs_get_int_by_name(attrs, "display_zoom", &zoom); + mm_attrs_get_double_by_name(attrs, "display_zoom", &zoom); mm_attrs_get_int_by_name(attrs, "display_method", &display_method); mm_attrs_get_int_by_name(attrs, "display_roi_x", &roi_x); mm_attrs_get_int_by_name(attrs, "display_roi_y", &roi_y); mm_attrs_get_int_by_name(attrs, "display_roi_width", &roi_w); mm_attrs_get_int_by_name(attrs, "display_roi_height", &roi_h); mm_attrs_get_int_by_name(attrs, "display_visible", &visible); + #define DEFAULT_DISPLAY_MODE 2 // TV only, PRI_VIDEO_OFF_AND_SEC_VIDEO_FULL_SCREEN + + /* setting for ROI mode */ + if (display_method == 5) // 5 for ROI mode + { + int roi_mode = 0; + mm_attrs_get_int_by_name(attrs, "display_roi_mode", &roi_mode); + g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, + "dst-roi-mode", roi_mode, + "dst-roi-x", roi_x, + "dst-roi-y", roi_y, + "dst-roi-w", roi_w, + "dst-roi-h", roi_h, + NULL ); + /* get rotation value to set, + do not use org_angle because ROI mode in xvimagesink needs both a rotation value and an orientation value */ + __mmplayer_get_property_value_for_rotation(player, user_angle, &rotation_value); + } + else + { + /* get rotation value to set */ + __mmplayer_get_property_value_for_rotation(player, org_angle+user_angle, &rotation_value); + } g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "force-aspect-ratio", force_aspect_ratio, - "zoom", zoom, + "zoom", (float)zoom, + "orientation", org_angle/90, // setting for orientation of media, it is used for ROI/ZOOM feature in xvimagesink "rotate", rotation_value, "handle-events", TRUE, "display-geometry-method", display_method, "draw-borders", FALSE, - "dst-roi-x", roi_x, - "dst-roi-y", roi_y, - "dst-roi-w", roi_w, - "dst-roi-h", roi_h, "visible", visible, + "display-mode", DEFAULT_DISPLAY_MODE, NULL ); - debug_log("set video param : zoom %d", zoom); - debug_log("set video param : rotate %d", rotation_value); - debug_log("set video param : method %d", display_method); - debug_log("set video param : dst-roi-x: %d, dst-roi-y: %d, dst-roi-w: %d, dst-roi-h: %d", - roi_x, roi_y, roi_w, roi_h ); - debug_log("set video param : visible %d", visible); - debug_log("set video param : force aspect ratio %d", force_aspect_ratio); + debug_log("set video param : zoom %lf, rotate %d, method %d visible %d", zoom, rotation_value, display_method, visible); + debug_log("set video param : dst-roi-x: %d, dst-roi-y: %d, dst-roi-w: %d, dst-roi-h: %d", roi_x, roi_y, roi_w, roi_h ); + debug_log("set video param : force aspect ratio %d, display mode %d", force_aspect_ratio, DEFAULT_DISPLAY_MODE); } /* if vaapisink */ @@ -1624,8 +1616,7 @@ _mmplayer_update_video_param(mm_player_t* player) // @ "evas-object", object, "visible", visible, NULL); - debug_log("set video param : evas-object %x", object); - debug_log("set video param : visible %d", visible); + debug_log("set video param : evas-object %x, visible %d", object, visible); } else { @@ -1644,6 +1635,7 @@ _mmplayer_update_video_param(mm_player_t* player) // @ mm_attrs_get_int_by_name(attrs, "display_height", &height); /* NOTE: fimcconvert does not manage index of src buffer from upstream src-plugin, decoder gives frame information in output buffer with no ordering */ + g_object_set(player->pipeline->videobin[MMPLAYER_V_CONV].gst, "src-rand-idx", TRUE, NULL); g_object_set(player->pipeline->videobin[MMPLAYER_V_CONV].gst, "dst-buffer-num", 5, NULL); if (no_scaling) @@ -1686,8 +1678,12 @@ _mmplayer_update_video_param(mm_player_t* player) // @ mm_attrs_get_int_by_name(attrs, "display_roi_width", &roi_w); mm_attrs_get_int_by_name(attrs, "display_roi_height", &roi_h); + /* get rotation value to set */ + __mmplayer_get_property_value_for_rotation(player, org_angle+user_angle, &rotation_value); + g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "origin-size", origin_size, + "rotate", rotation_value, "dst-roi-x", roi_x, "dst-roi-y", roi_y, "dst-roi-w", roi_w, @@ -1700,7 +1696,6 @@ _mmplayer_update_video_param(mm_player_t* player) // @ roi_x, roi_y, roi_w, roi_h ); debug_log("set video param : display_evas_do_scaling %d (origin-size %d)", scaling, origin_size); } - g_object_set(player->pipeline->videobin[MMPLAYER_V_FLIP].gst, "method", rotation_value, NULL); } break; case MM_DISPLAY_SURFACE_X_EXT: /* NOTE : this surface type is used for the videoTexture(canvasTexture) overlay */ @@ -1721,6 +1716,7 @@ _mmplayer_update_video_param(mm_player_t* player) // @ mm_attrs_get_data_by_name(attrs, "display_overlay", &pixmap_id_cb); mm_attrs_get_data_by_name(attrs, "display_overlay_user_data", &pixmap_id_cb_user_data); mm_attrs_get_int_by_name(attrs, "display_method", &display_method); + mm_attrs_get_int_by_name(attrs, "display_visible", &visible); if ( pixmap_id_cb ) { @@ -1761,43 +1757,29 @@ _mmplayer_update_video_param(mm_player_t* player) // @ return MM_ERROR_NONE; } -static gboolean -__mmplayer_audio_stream_probe (GstPad *pad, GstBuffer *buffer, gpointer u_data) +static GstPadProbeReturn +__mmplayer_audio_stream_probe (GstPad *pad, GstPadProbeInfo *info, gpointer u_data) { mm_player_t* player = (mm_player_t*) u_data; - gint size; - guint8 *data; - -#ifdef GST_API_VERSION_1 - GstMapInfo info; - gst_buffer_map (buffer, &info, GST_MAP_WRITE); - data = info.data; - size = gst_buffer_get_size(buffer); + GstBuffer *pad_buffer = gst_pad_probe_info_get_buffer(info); + GstMapInfo probe_info = GST_MAP_INFO_INIT; - if (player->audio_stream_cb && size && data) - player->audio_stream_cb((void *)data, size, player->audio_stream_cb_user_param); + gst_buffer_map(pad_buffer, &probe_info, GST_MAP_READ); + if (player->audio_stream_cb && probe_info.size && probe_info.data) + player->audio_stream_cb(probe_info.data, probe_info.size, player->audio_stream_cb_user_param); + gst_buffer_unmap(pad_buffer, &probe_info); - gst_buffer_unmap (buffer, &info); -#else - data = GST_BUFFER_DATA(buffer); - size = GST_BUFFER_SIZE(buffer); - - if (player->audio_stream_cb && size && data) - player->audio_stream_cb((void *)data, size, player->audio_stream_cb_user_param); -#endif - - return TRUE; + return GST_PAD_PROBE_OK; } -#ifdef GST_API_VERSION_1 gboolean __mmplayer_update_subtitle( GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data) { mm_player_t* player = (mm_player_t*) data; MMMessageParamType msg = {0, }; GstClockTime duration = 0; - guint8 *text = NULL; + gpointer text = NULL; gboolean ret = TRUE; GstMapInfo info; @@ -1806,8 +1788,8 @@ __mmplayer_update_subtitle( GstElement* object, GstBuffer *buffer, GstPad *pad, return_val_if_fail ( player, FALSE ); return_val_if_fail ( buffer, FALSE ); - gst_buffer_map (buffer, &info, GST_MAP_WRITE); - text = info.data; + gst_buffer_map (buffer, &info, GST_MAP_READ); + text = g_memdup(info.data, info.size); gst_buffer_unmap (buffer, &info); duration = GST_BUFFER_DURATION(buffer); @@ -1835,56 +1817,12 @@ __mmplayer_update_subtitle( GstElement* object, GstBuffer *buffer, GstPad *pad, return ret; } -#else -gboolean -__mmplayer_update_subtitle( GstElement* object, GstBuffer *buffer, GstPad *pad, gpointer data) -{ - mm_player_t* player = (mm_player_t*) data; - MMMessageParamType msg = {0, }; - GstClockTime duration = 0; - guint8 *text = NULL; - gboolean ret = TRUE; - - debug_fenter(); - - return_val_if_fail ( player, FALSE ); - return_val_if_fail ( buffer, FALSE ); - - text = GST_BUFFER_DATA(buffer); - duration = GST_BUFFER_DURATION(buffer); - - if ( player->is_subtitle_off ) - { - debug_log("subtitle is OFF.\n" ); - return TRUE; - } - if ( !text ) - { - debug_log("There is no subtitle to be displayed.\n" ); - return TRUE; - } - - msg.data = (void *) text; - msg.subtitle.duration = GST_TIME_AS_MSECONDS(duration); - - debug_warning("update subtitle : [%ld msec] %s\n'", msg.subtitle.duration, (char*)msg.data ); - - MMPLAYER_POST_MSG( player, MM_MESSAGE_UPDATE_SUBTITLE, &msg ); - - debug_fleave(); - - return ret; -} -#endif - -#ifdef GST_API_VERSION_1 int _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size) // @ { mm_player_t* player = (mm_player_t*)hplayer; GstBuffer *buffer = NULL; - GstMapInfo info; GstFlowReturn gst_ret = GST_FLOW_OK; int ret = MM_ERROR_NONE; @@ -1925,9 +1863,7 @@ _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size) // @ return MM_ERROR_NONE; } - info.data = (guint8*)(buf); - gst_buffer_set_size(buffer, size); - gst_buffer_map (buffer, &info, GST_MAP_WRITE); + gst_buffer_insert_memory(buffer, -1, gst_memory_new_wrapped(0, (guint8*)buf, size, 0, size, (guint8*)buf, g_free)); debug_log("feed buffer %p, length %u\n", buf, size); g_signal_emit_by_name (player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "push-buffer", buffer, &gst_ret); @@ -1936,63 +1872,6 @@ _mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size) // @ return ret; } -#else -int -_mmplayer_push_buffer(MMHandleType hplayer, unsigned char *buf, int size) // @ -{ - mm_player_t* player = (mm_player_t*)hplayer; - GstBuffer *buffer = NULL; - GstFlowReturn gst_ret = GST_FLOW_OK; - int ret = MM_ERROR_NONE; - - debug_fenter(); - - return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); - - /* check current state */ -// MMPLAYER_CHECK_STATE_RETURN_IF_FAIL( player, MMPLAYER_COMMAND_START ); - - - /* NOTE : we should check and create pipeline again if not created as we destroy - * whole pipeline when stopping in streamming playback - */ - if ( ! player->pipeline ) - { - if ( MM_ERROR_NONE != __gst_realize( player ) ) - { - debug_error("failed to realize before starting. only in streamming\n"); - return MM_ERROR_PLAYER_INTERNAL; - } - } - - debug_msg("app-src: pushing data\n"); - - if ( buf == NULL ) - { - debug_error("buf is null\n"); - return MM_ERROR_NONE; - } - - buffer = gst_buffer_new (); - - if (size <= 0) - { - debug_log("call eos appsrc\n"); - g_signal_emit_by_name (player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "end-of-stream", &gst_ret); - return MM_ERROR_NONE; - } - - GST_BUFFER_DATA(buffer) = (guint8*)(buf); - GST_BUFFER_SIZE(buffer) = size; - - debug_log("feed buffer %p, length %u\n", buf, size); - g_signal_emit_by_name (player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "push-buffer", buffer, &gst_ret); - - debug_fleave(); - - return ret; -} -#endif GstBusSyncReply __mmplayer_bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data) @@ -2016,6 +1895,23 @@ __mmplayer_bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data) return GST_BUS_DROP; } +void __mmplayer_remove_g_source_from_context(guint source_id) +{ + GMainContext *context = g_main_context_get_thread_default (); + GSource *source = NULL; + + debug_fenter(); + + source = g_main_context_find_source_by_id (context, source_id); + + if (source != NULL) + { + debug_log("context : %x, source : %x", context, source); + g_source_destroy(source); + } + + debug_fleave(); +} void __mmplayer_do_sound_fadedown(mm_player_t* player, unsigned int time) { debug_fenter(); @@ -2774,7 +2670,7 @@ _mmplayer_destroy(MMHandleType handle) // @ if (player->lazy_pause_event_id) { - g_source_remove (player->lazy_pause_event_id); + __mmplayer_remove_g_source_from_context(player->lazy_pause_event_id); player->lazy_pause_event_id = 0; } @@ -3411,9 +3307,7 @@ int _mmplayer_pause(MMHandleType hplayer) // @ { mm_player_t* player = (mm_player_t*)hplayer; -#ifndef GST_API_VERSION_1 GstFormat fmt = GST_FORMAT_TIME; -#endif gint64 pos_msec = 0; gboolean async = FALSE; gint ret = MM_ERROR_NONE; @@ -3443,12 +3337,7 @@ _mmplayer_pause(MMHandleType hplayer) // @ * ( returning zero when getting current position in paused state) of some * elements */ -#ifdef GST_API_VERSION_1 - ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_msec); -#else - ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &fmt, &pos_msec); -#endif - if ( ! ret ) + if ( !gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, fmt, &pos_msec)) debug_warning("getting current position failed in paused\n"); player->last_position = pos_msec; @@ -3474,7 +3363,6 @@ _mmplayer_resume(MMHandleType hplayer) { mm_player_t* player = (mm_player_t*)hplayer; int ret = MM_ERROR_NONE; - gboolean async = FALSE; debug_fenter(); @@ -3578,9 +3466,7 @@ __mmplayer_set_pcm_extraction(mm_player_t* player) guint64 end_nsec = 0; guint64 dur_nsec = 0; guint64 dur_msec = 0; -#ifndef GST_API_VERSION_1 GstFormat fmt = GST_FORMAT_TIME; -#endif int required_start = 0; int required_end = 0; int ret = 0; @@ -3609,11 +3495,7 @@ __mmplayer_set_pcm_extraction(mm_player_t* player) } /* get duration */ -#ifdef GST_API_VERSION_1 - ret = gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec); -#else - ret = gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &fmt, &dur_nsec); -#endif + ret = gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, fmt, &dur_nsec); if ( !ret ) { debug_error("failed to get duration"); @@ -3654,9 +3536,7 @@ _mmplayer_deactivate_section_repeat(MMHandleType hplayer) { mm_player_t* player = (mm_player_t*)hplayer; gint64 cur_pos = 0; -#ifndef GST_API_VERSION_1 GstFormat fmt = GST_FORMAT_TIME; -#endif gint onetime = 1; debug_fenter(); @@ -3666,11 +3546,7 @@ _mmplayer_deactivate_section_repeat(MMHandleType hplayer) player->section_repeat = FALSE; __mmplayer_set_play_count( player, onetime ); -#ifdef GST_API_VERSION_1 - gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &cur_pos); -#else - gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &fmt, &cur_pos); -#endif + gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, fmt, &cur_pos); if ( (!__gst_seek( player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, 1.0, @@ -3696,9 +3572,7 @@ _mmplayer_set_playspeed(MMHandleType hplayer, gdouble rate) signed long long pos_msec = 0; int ret = MM_ERROR_NONE; int mute = FALSE; -#ifndef GST_API_VERSION_1 GstFormat format =GST_FORMAT_TIME; -#endif MMPlayerStateType current_state = MM_PLAYER_STATE_NONE; debug_fenter(); @@ -3722,13 +3596,9 @@ _mmplayer_set_playspeed(MMHandleType hplayer, gdouble rate) player->playback_rate = rate; current_state = MMPLAYER_CURRENT_STATE(player); -#ifdef GST_API_VERSION_1 - if ( current_state != MM_PLAYER_STATE_PAUSED ) - ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_msec); -#else + if ( current_state != MM_PLAYER_STATE_PAUSED ) - ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &format, &pos_msec); -#endif + ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, format, &pos_msec); debug_log ("pos_msec = %"GST_TIME_FORMAT" and ret = %d and state = %d", GST_TIME_ARGS (pos_msec), ret, current_state); @@ -3804,7 +3674,7 @@ _mmplayer_get_buffer_position(MMHandleType hplayer, int format, unsigned long* s } int -_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, int position) // @ +_mmplayer_adjust_subtitle_postion(MMHandleType hplayer, int format, unsigned long position) // @ { mm_player_t* player = (mm_player_t*)hplayer; int ret = MM_ERROR_NONE; @@ -3968,11 +3838,7 @@ __mmplayer_warm_up_video_codec( mm_player_t* player, GstElementFactory *factory if (ret != GST_STATE_CHANGE_SUCCESS) { -#ifdef GST_API_VERSION_1 - debug_error ("resource conflict so, %s unusable\n", gst_object_get_name (GST_OBJECT (factory))); -#else debug_error ("resource conflict so, %s unusable\n", GST_PLUGIN_FEATURE_NAME (factory)); -#endif usable = FALSE; } @@ -3995,6 +3861,7 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // GstPad* queue_pad = NULL; GstElement* queue = NULL; GstElement *element = NULL; + GstStructure *structure = NULL; debug_fenter(); @@ -4099,35 +3966,19 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // skip = FALSE; /* filtering exclude keyword */ -#ifdef GST_API_VERSION_1 for ( idx = 0; PLAYER_INI()->exclude_element_keyword[idx][0] != '\0'; idx++ ) { - if ( g_strrstr(gst_object_get_name (GST_OBJECT (factory)), - PLAYER_INI()->exclude_element_keyword[idx]) ) - { - debug_warning("skipping [%s] by exculde keyword [%s]\n", - gst_object_get_name (GST_OBJECT (factory)), - PLAYER_INI()->exclude_element_keyword[idx] ); - - skip = TRUE; - break; - } - } -#else - for ( idx = 0; PLAYER_INI()->exclude_element_keyword[idx][0] != '\0'; idx++ ) - { - if ( g_strrstr(GST_PLUGIN_FEATURE_NAME (factory), + if ( g_strrstr(GST_OBJECT_NAME (factory), PLAYER_INI()->exclude_element_keyword[idx] ) ) { debug_warning("skipping [%s] by exculde keyword [%s]\n", - GST_PLUGIN_FEATURE_NAME (factory), + GST_OBJECT_NAME (factory), PLAYER_INI()->exclude_element_keyword[idx] ); skip = TRUE; break; } } -#endif if ( skip ) continue; @@ -4139,13 +3990,7 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // */ if ( g_strrstr(klass, "Codec/Decoder/Image") ) { -#ifdef GST_API_VERSION_1 - debug_log("skipping [%s] by not required\n", - gst_object_get_name (GST_OBJECT (factory)) ); -#else - debug_log("skipping [%s] by not required\n", - GST_PLUGIN_FEATURE_NAME (factory) ); -#endif + debug_log("skipping [%s] by not required\n", GST_OBJECT_NAME (factory)); continue; } @@ -4160,10 +4005,10 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // temp1->presence != GST_PAD_ALWAYS) continue; - if ( GST_IS_CAPS( &temp1->static_caps.caps) ) + if ( GST_IS_CAPS( temp1->static_caps.caps) ) { /* using existing caps */ - static_caps = gst_caps_ref( &temp1->static_caps.caps ); + static_caps = gst_caps_ref( temp1->static_caps.caps ); } else { @@ -4171,38 +4016,35 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // static_caps = gst_caps_from_string ( temp1->static_caps.string ); } - res = gst_caps_intersect(caps, static_caps); - - gst_caps_unref( static_caps ); - static_caps = NULL; - - if( res && !gst_caps_is_empty(res) ) + if ( strcmp (GST_OBJECT_NAME(factory),"rtpamrdepay") ==0 ) { -#ifdef GST_API_VERSION_1 - GstElement *new_element; - GList *elements = player->parsers; - char *name_template = g_strdup(temp1->name_template); - gchar *name_to_plug = gst_object_get_name (GST_OBJECT (factory)); + /* store encoding-name */ + structure = gst_caps_get_structure (caps, 0); - gst_caps_unref(res); + /* figure out the mode first and set the clock rates */ + player->temp_encode_name = gst_structure_get_string (structure, "encoding-name"); - debug_log("found %s to plug\n", name_to_plug); - - new_element = gst_element_factory_create(GST_ELEMENT_FACTORY(factory), NULL); - if ( ! new_element ) + } + if (player->temp_encode_name != NULL) + { + if ((strcmp (player->temp_encode_name, "AMR") == 0) && (strcmp (GST_OBJECT_NAME(factory), "amrwbdec" ) == 0)) { - debug_error("failed to create element [%s]. continue with next.\n", - gst_object_get_name (GST_OBJECT (factory))); - - MMPLAYER_FREEIF(name_template); - + debug_log("skip AMR-WB dec\n"); continue; } -#else + } + + res = gst_caps_intersect((GstCaps*)caps, static_caps); + + gst_caps_unref( static_caps ); + static_caps = NULL; + + if( res && !gst_caps_is_empty(res) ) + { GstElement *new_element; GList *elements = player->parsers; char *name_template = g_strdup(temp1->name_template); - gchar *name_to_plug = GST_PLUGIN_FEATURE_NAME(factory); + gchar *name_to_plug = GST_OBJECT_NAME(factory); gst_caps_unref(res); @@ -4212,13 +4054,12 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // if ( ! new_element ) { debug_error("failed to create element [%s]. continue with next.\n", - GST_PLUGIN_FEATURE_NAME (factory)); + GST_OBJECT_NAME (factory)); MMPLAYER_FREEIF(name_template); continue; } -#endif /* check and skip it if it was already used. Otherwise, it can be an infinite loop * because parser can accept its own output as input. @@ -4296,6 +4137,7 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) // /* clean */ MMPLAYER_FREEIF( caps_type ); + gst_caps_unref (caps); gst_object_unref (src_pad); } else if (g_str_has_prefix(mime, "audio")) @@ -4470,11 +4312,7 @@ gboolean __mmplayer_configure_audio_callback(mm_player_t* player) { GstPad *pad = NULL; -#ifdef GST_API_VERSION_1 pad = gst_element_get_static_pad (player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "sink"); -#else - pad = gst_element_get_pad (player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "sink"); -#endif if ( !pad ) { @@ -4482,13 +4320,8 @@ gboolean __mmplayer_configure_audio_callback(mm_player_t* player) return FALSE; } -#ifdef GST_API_VERSION_1 player->audio_cb_probe_id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, __mmplayer_audio_stream_probe, player, NULL); -#else - player->audio_cb_probe_id = gst_pad_add_buffer_probe (pad, - G_CALLBACK (__mmplayer_audio_stream_probe), player); -#endif gst_object_unref (pad); @@ -4513,13 +4346,8 @@ __mmplayer_init_factories(mm_player_t* player) // @ return_if_fail ( player ); -#ifdef GST_API_VERSION_1 player->factories = gst_registry_feature_filter(gst_registry_get(), (GstPluginFeatureFilter)__mmplayer_feature_filter, FALSE, NULL); -#else - player->factories = gst_registry_feature_filter(gst_registry_get_default(), - (GstPluginFeatureFilter)__mmplayer_feature_filter, FALSE, NULL); -#endif player->factories = g_list_sort(player->factories, (GCompareFunc)util_factory_rank_compare); @@ -4583,6 +4411,7 @@ __mmplayer_release_misc(mm_player_t* player) player->pending_seek.pos = 0; player->msg_posted = FALSE; player->has_many_types = FALSE; + player->temp_encode_name = NULL; for (i = 0; i < MM_PLAYER_STREAM_COUNT_MAX; i++) { @@ -4715,7 +4544,7 @@ const char *padname, const GList *templlist) /* only decoder case and any of the video/audio still need to link*/ if(g_strrstr(klass, "Decoder") && __mmplayer_link_decoder(player,srcpad)) { - gchar *name = NULL; + const gchar *name = NULL; name = g_strdup(GST_ELEMENT_NAME( GST_PAD_PARENT ( srcpad ))); @@ -4725,11 +4554,7 @@ const char *padname, const GList *templlist) gchar *parser_name = NULL; GstCaps *dcaps = NULL; -#ifdef GST_API_VERSION_1 - dcaps = gst_pad_get_current_caps(srcpad); -#else - dcaps = gst_pad_get_caps(srcpad); -#endif + dcaps = gst_pad_query_caps(srcpad, NULL); demux_caps = gst_caps_to_string(dcaps); if (g_strrstr(demux_caps, "video/x-h264")) @@ -4783,15 +4608,15 @@ const char *padname, const GList *templlist) { mainbin[MMPLAYER_M_Q1].id = MMPLAYER_M_Q1; mainbin[MMPLAYER_M_Q1].gst = queue; - - g_object_set (G_OBJECT (mainbin[MMPLAYER_M_Q1].gst), "max-size-time", q_max_size_time * GST_SECOND, NULL); + if (!MMPLAYER_IS_RTSP_STREAMING(player)) + g_object_set (G_OBJECT (mainbin[MMPLAYER_M_Q1].gst), "max-size-time", q_max_size_time * GST_SECOND, NULL); } else if(mainbin[MMPLAYER_M_Q2].gst == NULL) { mainbin[MMPLAYER_M_Q2].id = MMPLAYER_M_Q2; mainbin[MMPLAYER_M_Q2].gst = queue; - - g_object_set (G_OBJECT (mainbin[MMPLAYER_M_Q2].gst), "max-size-time", q_max_size_time * GST_SECOND, NULL); + if (!MMPLAYER_IS_RTSP_STREAMING(player)) + g_object_set (G_OBJECT (mainbin[MMPLAYER_M_Q2].gst), "max-size-time", q_max_size_time * GST_SECOND, NULL); } else { @@ -4817,11 +4642,7 @@ const char *padname, const GList *templlist) /* to check the video/audio type set the proper flag*/ { -#ifdef GST_API_VERSION_1 - srccaps = gst_pad_get_current_caps( srcpad ); -#else - srccaps = gst_pad_get_caps( srcpad ); -#endif + srccaps = gst_pad_query_caps( srcpad, NULL ); if ( !srccaps ) goto ERROR; @@ -4875,9 +4696,7 @@ const char *padname, const GList *templlist) { if (MMPLAYER_IS_HTTP_STREAMING(player)) { -#ifndef GST_API_VERSION_1 GstFormat fmt = GST_FORMAT_BYTES; -#endif gint64 dur_bytes = 0L; gchar *file_buffering_path = NULL; gboolean use_file_buffer = FALSE; @@ -4921,13 +4740,8 @@ const char *padname, const GList *templlist) if ( !MMPLAYER_IS_HTTP_LIVE_STREAMING(player)) { -#ifdef GST_API_VERSION_1 - if ( !gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, GST_FORMAT_BYTES, &dur_bytes)) + if ( !gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, fmt, &dur_bytes)) debug_error("fail to get duration.\n"); -#else - if ( !gst_element_query_duration(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, &fmt, &dur_bytes)) - debug_error("fail to get duration.\n"); -#endif if (dur_bytes>0) { @@ -4998,14 +4812,10 @@ const char *padname, const GList *templlist) case GST_PAD_ALWAYS: { GstPad *srcpad = gst_element_get_static_pad(sinkelement, "src"); -#ifdef GST_API_VERSION_1 - GstCaps *caps = gst_pad_get_current_caps(srcpad); -#else - GstCaps *caps = gst_pad_get_caps(srcpad); -#endif + GstCaps *caps = gst_pad_query_caps(srcpad, NULL); /* Check whether caps has many types */ - if ( gst_caps_get_size (caps) > 1 && g_strrstr(klass, "Parser")) { + if ( !gst_caps_is_fixed (caps)) { debug_log ("has_many_types for this caps [%s]\n", gst_caps_to_string(caps)); has_many_types = TRUE; break; @@ -5170,11 +4980,7 @@ static void __mmplayer_add_new_caps(GstPad* pad, GParamSpec* unused, gpointer d return_if_fail ( unused ) return_if_fail ( data ) -#ifdef GST_API_VERSION_1 - caps = gst_pad_get_current_caps(pad); -#else - caps = gst_pad_get_caps(pad); -#endif + caps = gst_pad_query_caps(pad, NULL); if ( !caps ) return; @@ -5290,23 +5096,11 @@ static void __mmplayer_add_new_pad(GstElement *element, GstPad *pad, gpointer da return_if_fail ( player ); return_if_fail ( pad ); - GST_OBJECT_LOCK (pad); -#ifdef GST_API_VERSION_1 - if ((caps = gst_pad_get_current_caps (pad))) - gst_caps_ref(caps); -#else - if ((caps = GST_PAD_CAPS(pad))) - gst_caps_ref(caps); -#endif - GST_OBJECT_UNLOCK (pad); + caps = gst_pad_get_current_caps(pad); if ( NULL == caps ) { -#ifdef GST_API_VERSION_1 - caps = gst_pad_get_current_caps(pad); -#else - caps = gst_pad_get_caps(pad); -#endif + caps = gst_pad_query_caps(pad, NULL); if ( !caps ) return; } @@ -5699,3 +5493,71 @@ __get_state_name ( int state ) } } +int +_mmplayer_set_display_zoom(MMHandleType hplayer, float level) +{ + mm_player_t* player = (mm_player_t*) hplayer; + + return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); + + MMPLAYER_VIDEO_SINK_CHECK(player); + + debug_log("setting display zoom level = %f", level); + + g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "zoom", level, NULL); + + return MM_ERROR_NONE; +} + +int +_mmplayer_get_display_zoom(MMHandleType hplayer, float *level) +{ + mm_player_t* player = (mm_player_t*) hplayer; + + return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); + + MMPLAYER_VIDEO_SINK_CHECK(player); + + g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "zoom", level, NULL); + + debug_log("display zoom level = %f", *level); + + return MM_ERROR_NONE; +} + +int +_mmplayer_set_display_zoom_start_pos(MMHandleType hplayer, int x, int y) +{ + mm_player_t* player = (mm_player_t*) hplayer; + + return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); + + MMPLAYER_VIDEO_SINK_CHECK(player); + + debug_log("setting display zoom offset = %d, %d", x, y); + + g_object_set(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "zoom-pos-x", x, "zoom-pos-y", y, NULL); + + return MM_ERROR_NONE; +} + +int +_mmplayer_get_display_zoom_start_pos(MMHandleType hplayer, int *x, int *y) +{ + int _x = 0; + int _y = 0; + mm_player_t* player = (mm_player_t*) hplayer; + + return_val_if_fail ( player, MM_ERROR_PLAYER_NOT_INITIALIZED ); + + MMPLAYER_VIDEO_SINK_CHECK(player); + + g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "zoom-pos-x", &_x, "zoom-pos-y", &_y, NULL); + + debug_log("display zoom start off x = %d, y = %d", _x, _y); + + *x = _x; + *y = _y; + + return MM_ERROR_NONE; +} diff --git a/src/mm_player_priv_gst.c b/src/mm_player_priv_gst.c index 8f4fe65..46e8009 100755 --- a/src/mm_player_priv_gst.c +++ b/src/mm_player_priv_gst.c @@ -360,6 +360,7 @@ int __gst_pause(mm_player_t* player, gboolean async) // @ debug_fenter(); return_val_if_fail(player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED); + return_val_if_fail(player->pipeline->mainbin, MM_ERROR_PLAYER_NOT_INITIALIZED); debug_log("current state before doing transition"); MMPLAYER_PENDING_STATE(player) = MM_PLAYER_STATE_PAUSED; @@ -369,73 +370,78 @@ int __gst_pause(mm_player_t* player, gboolean async) // @ ret = __mmplayer_gst_set_state(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PAUSED, async, MMPLAYER_STATE_CHANGE_TIMEOUT(player)); - if ( FALSE == async && ret != MM_ERROR_NONE ) + if ( FALSE == async ) { - GstMessage *msg = NULL; - GTimer *timer = NULL; - gdouble MAX_TIMEOUT_SEC = 3; + if ( ret != MM_ERROR_NONE ) + { + GstMessage *msg = NULL; + GTimer *timer = NULL; + gdouble MAX_TIMEOUT_SEC = 3; - debug_error("failed to set state to PAUSED"); + debug_error("failed to set state to PAUSED"); - timer = g_timer_new(); - g_timer_start(timer); + timer = g_timer_new(); + g_timer_start(timer); - GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst)); - /* check if gst error posted or not */ - do - { - msg = gst_bus_timed_pop(bus, GST_SECOND /2); - if (msg) + GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst)); + gboolean got_msg = FALSE; + /* check if gst error posted or not */ + do { - if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR) + msg = gst_bus_timed_pop(bus, GST_SECOND /2); + if (msg) { - GError *error = NULL; - - debug_error("paring error posted from bus"); - /* parse error code */ - gst_message_parse_error(msg, &error, NULL); - - if (error->domain == GST_STREAM_ERROR) + if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR) { - ret = __gst_handle_stream_error( player, error, msg ); + GError *error = NULL; + + debug_error("parsing error posted from bus"); + /* parse error code */ + gst_message_parse_error(msg, &error, NULL); + + if (error->domain == GST_STREAM_ERROR) + { + ret = __gst_handle_stream_error( player, error, msg ); + } + else if (error->domain == GST_RESOURCE_ERROR) + { + ret = __gst_handle_resource_error( player, error->code ); + } + else if (error->domain == GST_LIBRARY_ERROR) + { + ret = __gst_handle_library_error( player, error->code ); + } + else if (error->domain == GST_CORE_ERROR) + { + ret = __gst_handle_core_error( player, error->code ); + } + got_msg = TRUE; + player->msg_posted = TRUE; } - else if (error->domain == GST_RESOURCE_ERROR) - { - ret = __gst_handle_resource_error( player, error->code ); - } - else if (error->domain == GST_LIBRARY_ERROR) - { - ret = __gst_handle_library_error( player, error->code ); - } - else if (error->domain == GST_CORE_ERROR) - { - ret = __gst_handle_core_error( player, error->code ); - } - player->msg_posted = TRUE; + gst_message_unref(msg); } - gst_message_unref(msg); - } - } while (g_timer_elapsed(timer, NULL) < MAX_TIMEOUT_SEC); + } while (!got_msg && (g_timer_elapsed(timer, NULL) < MAX_TIMEOUT_SEC)); - /* clean */ - gst_object_unref(bus); - g_timer_stop (timer); - g_timer_destroy (timer); + /* clean */ + gst_object_unref(bus); + g_timer_stop (timer); + g_timer_destroy (timer); - return ret; - } - else - { - if ( async == FALSE ) + return ret; + } + else if ((!player->has_many_types) && (!player->pipeline->videobin) && (!player->pipeline->audiobin) ) + { + if(MMPLAYER_IS_RTSP_STREAMING(player)) + return ret; + player->msg_posted = TRUE; // no need to post error by message callback + return MM_ERROR_PLAYER_CODEC_NOT_FOUND; + } + else if ( ret == MM_ERROR_NONE) { MMPLAYER_SET_STATE ( player, MM_PLAYER_STATE_PAUSED ); } } - /* FIXIT : analyze so called "async problem" */ - /* set async off */ - __gst_set_async_state_change( player, TRUE); - /* generate dot file before returning error */ MMPLAYER_GENERATE_DOT_IF_ENABLED ( player, "pipeline-status-pause" ); @@ -469,11 +475,7 @@ int __gst_resume(mm_player_t* player, gboolean async) // @ /* clean bus sync handler because it's not needed any more */ bus = gst_pipeline_get_bus (GST_PIPELINE(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst)); -#ifdef GST_API_VERSION_1 - gst_bus_set_sync_handler (bus, NULL, NULL, NULL); -#else - gst_bus_set_sync_handler (bus, NULL, NULL); -#endif + gst_bus_set_sync_handler (bus, NULL, NULL, NULL); gst_object_unref(bus); /* set pipeline state to PLAYING */ @@ -510,13 +512,13 @@ int __gst_resume(mm_player_t* player, gboolean async) // @ int __gst_set_position(mm_player_t* player, int format, unsigned long position, gboolean internal_called) // @ { -#ifndef GST_API_VERSION_1 GstFormat fmt = GST_FORMAT_TIME; -#endif unsigned long dur_msec = 0; gint64 dur_nsec = 0; gint64 pos_nsec = 0; gboolean ret = TRUE; + gboolean accurated = FALSE; + GstSeekFlags seek_flags = GST_SEEK_FLAG_FLUSH; debug_fenter(); return_val_if_fail ( player && player->pipeline, MM_ERROR_PLAYER_NOT_INITIALIZED ); @@ -532,17 +534,10 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo */ if ( !player->duration ) { -#ifdef GST_API_VERSION_1 - if ( !gst_element_query_duration( player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &dur_nsec )) + if ( !gst_element_query_duration( player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, fmt, &dur_nsec )) { goto SEEK_ERROR; } -#else - if ( !gst_element_query_duration( player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &fmt, &dur_nsec )) - { - goto SEEK_ERROR; - } -#endif player->duration = dur_nsec; } @@ -558,6 +553,16 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo debug_log("playback rate: %f\n", player->playback_rate); + mm_attrs_get_int_by_name(player->attrs,"accurate_seek", &accurated); + if (accurated) + { + seek_flags |= GST_SEEK_FLAG_ACCURATE; + } + else + { + seek_flags |= GST_SEEK_FLAG_KEY_UNIT; + } + /* do seek */ switch ( format ) { @@ -580,7 +585,7 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo pos_nsec = position * G_GINT64_CONSTANT(1000000); ret = __gst_seek ( player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, player->playback_rate, - GST_FORMAT_TIME, ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), + GST_FORMAT_TIME, seek_flags, GST_SEEK_TYPE_SET, pos_nsec, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE ); if ( !ret ) { @@ -606,7 +611,7 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo /* FIXIT : why don't we use 'GST_FORMAT_PERCENT' */ pos_nsec = (gint64) ( ( position * player->duration ) / 100 ); ret = __gst_seek ( player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, player->playback_rate, - GST_FORMAT_TIME, ( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), + GST_FORMAT_TIME, seek_flags, GST_SEEK_TYPE_SET, pos_nsec, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE ); if ( !ret ) { @@ -658,9 +663,7 @@ int __gst_get_position(mm_player_t* player, int format, unsigned long* position) // @ { MMPlayerStateType current_state = MM_PLAYER_STATE_NONE; -#ifndef GST_API_VERSION_1 GstFormat fmt = GST_FORMAT_TIME; -#endif signed long long pos_msec = 0; gboolean ret = TRUE; @@ -674,11 +677,7 @@ __gst_get_position(mm_player_t* player, int format, unsigned long* position) // */ if ( current_state != MM_PLAYER_STATE_PAUSED ) { -#ifdef GST_API_VERSION_1 - ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_msec); -#else - ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, &fmt, &pos_msec); -#endif + ret = gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, fmt, &pos_msec); } /* NOTE : get last point to overcome some bad operation of some elements @@ -861,6 +860,17 @@ __gst_send_event_to_sink( mm_player_t* player, GstEvent* event ) if (GST_IS_ELEMENT(sink)) { + /* in the case of some video/audio file, + * it's possible video sink don't consider same position seek + * with current postion + */ + if ( !MMPLAYER_IS_STREAMING(player) && player->pipeline->videobin + && player->pipeline->audiobin && (!g_strrstr(GST_ELEMENT_NAME(sink), "audiosink")) ) + { + sinks = g_list_next (sinks); + continue; + } + /* keep ref to the event */ gst_event_ref (event); @@ -934,12 +944,11 @@ __gst_seek(mm_player_t* player, GstElement * element, gdouble rate, return result; } -int __gst_adjust_subtitle_position(mm_player_t* player, int format, int position) +int __gst_adjust_subtitle_position(mm_player_t* player, int format, unsigned long position) { GstEvent* event = NULL; - gint64 current_pos = 0; - gint64 adusted_pos = 0; - gboolean ret = TRUE; + unsigned long current_pos = 0; + unsigned long adusted_pos = 0; debug_fenter(); @@ -957,13 +966,14 @@ int __gst_adjust_subtitle_position(mm_player_t* player, int format, int position { case MM_PLAYER_POS_FORMAT_TIME: { + /* check current postion */ if (__gst_get_position(player, MM_PLAYER_POS_FORMAT_TIME, ¤t_pos )) { debug_error("failed to get position"); return MM_ERROR_PLAYER_INTERNAL; } - adusted_pos = (gint64)current_pos + ((gint64)position * G_GINT64_CONSTANT(1000000)); + adusted_pos = current_pos + (position * G_GINT64_CONSTANT(1000000)); if (adusted_pos < 0) adusted_pos = G_GUINT64_CONSTANT(0); debug_log("adjust subtitle postion : %lu -> %lu [msec]\n", GST_TIME_AS_MSECONDS(current_pos), GST_TIME_AS_MSECONDS(adusted_pos)); @@ -1002,51 +1012,6 @@ int __gst_adjust_subtitle_position(mm_player_t* player, int format, int position return MM_ERROR_NONE; } -#ifdef GST_API_VERSION_1 -void -__gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) // @ -{ - GstElement *appsrc = element; - tBuffer *buf = (tBuffer *)user_data; - GstBuffer *buffer = NULL; - GstFlowReturn ret = GST_FLOW_OK; - gint len = size; - - return_if_fail ( element ); - return_if_fail ( buf ); - - //buffer = gst_buffer_new (); - - if (buf->offset >= buf->len) - { - debug_log("call eos appsrc\n"); - g_signal_emit_by_name (appsrc, "end-of-stream", &ret); - return; - } - - if ( buf->len - buf->offset < size) - { - len = buf->len - buf->offset + buf->offset; - } - - buffer = gst_buffer_new(); - GstMapInfo info; - - info.data = (guint8*)(buf->buf + buf->offset); - gst_buffer_set_size(buffer, len); - - //GST_BUFFER_DATA(buffer) = (guint8*)(buf->buf + buf->offset); - //GST_BUFFER_SIZE(buffer) = len; - GST_BUFFER_OFFSET(buffer) = buf->offset; - GST_BUFFER_OFFSET_END(buffer) = buf->offset + len; - gst_buffer_map (buffer, &info, GST_MAP_WRITE); - - debug_log("feed buffer %p, offset %u-%u length %u\n", buffer, buf->offset, buf->len,len); - g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret); - - buf->offset += len; -} -#else void __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) // @ { @@ -1064,8 +1029,8 @@ __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) if (buf->offset >= buf->len) { debug_log("call eos appsrc\n"); - g_signal_emit_by_name (appsrc, "end-of-stream", &ret); - return; + g_signal_emit_by_name (appsrc, "end-of-stream", &ret); + return; } if ( buf->len - buf->offset < size) @@ -1073,8 +1038,8 @@ __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) len = buf->len - buf->offset + buf->offset; } - GST_BUFFER_DATA(buffer) = (guint8*)(buf->buf + buf->offset); - GST_BUFFER_SIZE(buffer) = len; + gst_buffer_insert_memory(buffer, -1, gst_memory_new_wrapped(0, (guint8*)(buf->buf + buf->offset), len, 0, len, (guint8*)(buf->buf + buf->offset), g_free)); + GST_BUFFER_OFFSET(buffer) = buf->offset; GST_BUFFER_OFFSET_END(buffer) = buf->offset + len; @@ -1083,7 +1048,6 @@ __gst_appsrc_feed_data_mem(GstElement *element, guint size, gpointer user_data) buf->offset += len; } -#endif gboolean __gst_appsrc_seek_data_mem(GstElement *element, guint64 size, gpointer user_data) // @ @@ -1140,6 +1104,3 @@ __gst_appsrc_enough_data(GstElement *element, gpointer user_data) // @ return TRUE; } - - - diff --git a/src/mm_player_priv_gst_wrapper.c b/src/mm_player_priv_gst_wrapper.c index cef6bec..0024c33 100755 --- a/src/mm_player_priv_gst_wrapper.c +++ b/src/mm_player_priv_gst_wrapper.c @@ -113,11 +113,6 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ return_val_if_fail ( player, FALSE ); return_val_if_fail ( msg && GST_IS_MESSAGE(msg), FALSE ); -#ifdef GST_API_VERSION_1 - const GstStructure *structure; - structure = gst_message_get_structure (msg); -#endif - switch ( GST_MESSAGE_TYPE( msg ) ) { case GST_MESSAGE_UNKNOWN: @@ -148,11 +143,7 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ debug_error("release audio callback\n"); /* release audio callback */ -#ifdef GST_API_VERSION_1 gst_pad_remove_probe (pad, player->audio_cb_probe_id); -#else - gst_pad_remove_buffer_probe (pad, player->audio_cb_probe_id); -#endif player->audio_cb_probe_id = 0; /* audio callback should be free because it can be called even though probe remove.*/ player->audio_stream_cb = NULL; @@ -253,30 +244,7 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ gst_message_parse_error( msg, &error, &debug ); msg_src_element = GST_ELEMENT_NAME( GST_ELEMENT_CAST( msg->src ) ); -#ifdef GST_API_VERSION_1 - if ( gst_structure_has_name ( structure, "streaming_error" ) ) - { - /* Note : the streaming error from the streaming source is handled - * using __mmplayer_handle_streaming_error. - */ - __mmplayer_handle_streaming_error ( player, msg ); - - /* dump state of all element */ - __mmplayer_dump_pipeline_state( player ); - } - else - { - /* traslate gst error code to msl error code. then post it - * to application if needed - */ - __mmplayer_handle_gst_error( player, msg, error ); - - /* dump state of all element */ - __mmplayer_dump_pipeline_state( player ); - - } -#else - if ( gst_structure_has_name ( msg->structure, "streaming_error" ) ) + if ( gst_structure_has_name ( gst_message_get_structure(msg), "streaming_error" ) ) { /* Note : the streaming error from the streaming source is handled * using __mmplayer_handle_streaming_error. @@ -298,9 +266,6 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ } -#endif - - if (MMPLAYER_IS_HTTP_PD(player)) { _mmplayer_unrealize_pd_downloader ((MMHandleType)player); @@ -380,15 +345,9 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ break; /* get state info from msg */ -#ifdef GST_API_VERSION_1 - voldstate = gst_structure_get_value (structure, "old-state"); - vnewstate = gst_structure_get_value (structure, "new-state"); - vpending = gst_structure_get_value (structure, "pending-state"); -#else - voldstate = gst_structure_get_value (msg->structure, "old-state"); - vnewstate = gst_structure_get_value (msg->structure, "new-state"); - vpending = gst_structure_get_value (msg->structure, "pending-state"); -#endif + voldstate = gst_structure_get_value (gst_message_get_structure(msg), "old-state"); + vnewstate = gst_structure_get_value (gst_message_get_structure(msg), "new-state"); + vpending = gst_structure_get_value (gst_message_get_structure(msg), "pending-state"); oldstate = (GstState)voldstate->data[0].v_int; newstate = (GstState)vnewstate->data[0].v_int; @@ -527,6 +486,10 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) // @ { debug_log("GST_MESSAGE_ASYNC_DONE : %s\n", gst_element_get_name(GST_MESSAGE_SRC(msg))); + /* we only handle message from pipeline */ + if (msg->src != (GstObject *)player->pipeline->mainbin[MMPLAYER_M_PIPE].gst) + break; + if (player->doing_seek) { if (MMPLAYER_TARGET_STATE(player) == MM_PLAYER_STATE_PAUSED) @@ -612,7 +575,6 @@ if (gst_tag_list_get_string(tag_list, gsttag, &string)) \ }\ } -#ifdef GST_API_VERSION_1 #define MMPLAYER_UPDATE_TAG_IMAGE(gsttag, attribute, playertag) \ value = gst_tag_list_get_value_index(tag_list, gsttag, index); \ if (value) \ @@ -620,37 +582,22 @@ if (value) \ GstMapInfo info; \ gst_buffer_map (buffer, &info, GST_MAP_WRITE); \ buffer = gst_value_get_buffer (value); \ - debug_log ( "update album cover data : %p, size : %d\n", info.data, gst_buffer_get_size(buffer)); \ - player->album_art = (gchar *)g_malloc(gst_buffer_get_size(buffer)); \ + debug_log ( "update album cover data : %p, size : %d\n", info.data, info.size); \ + player->album_art = (gchar *)g_malloc(info.size); \ if (player->album_art); \ { \ - memcpy(player->album_art, info.data, gst_buffer_get_size(buffer)); \ - mm_attrs_set_data_by_name(attribute, playertag, (void *)player->album_art, gst_buffer_get_size(buffer)); \ + memcpy(player->album_art, info.data, info.size); \ + mm_attrs_set_data_by_name(attribute, playertag, (void *)player->album_art, info.size); \ } \ gst_buffer_unmap (buffer, &info); \ } -#else -#define MMPLAYER_UPDATE_TAG_IMAGE(gsttag, attribute, playertag) \ -value = gst_tag_list_get_value_index(tag_list, gsttag, index); \ -if (value) \ -{\ - buffer = gst_value_get_buffer (value); \ - debug_log ( "update album cover data : %p, size : %d\n", GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer)); \ - player->album_art = (gchar *)g_malloc(GST_BUFFER_SIZE(buffer)); \ - if (player->album_art); \ - { \ - memcpy(player->album_art, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer)); \ - mm_attrs_set_data_by_name(attribute, playertag, (void *)player->album_art, GST_BUFFER_SIZE(buffer)); \ - } \ -} -#endif #define MMPLAYER_UPDATE_TAG_UINT(gsttag, attribute, playertag) \ if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint))\ {\ if(v_uint)\ {\ - if(gsttag==GST_TAG_BITRATE)\ + if(strcmp(gsttag, GST_TAG_BITRATE) == 0)\ {\ if (player->updated_bitrate_count == 0) \ mm_attrs_set_int_by_name(attribute, "content_audio_bitrate", v_uint); \ @@ -663,7 +610,7 @@ if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint))\ debug_log ( "update bitrate %d[bps] of stream #%d.\n", v_uint, player->updated_bitrate_count);\ }\ }\ - else if (gsttag==GST_TAG_MAXIMUM_BITRATE)\ + else if (strcmp(gsttag, GST_TAG_MAXIMUM_BITRATE))\ {\ if (player->updated_maximum_bitrate_countis_sound_extraction ) { GstCaps* caps = NULL; @@ -1480,11 +1423,10 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) /*capsfilter */ MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CAPS_DEFAULT, "capsfilter", "audiocapsfilter", TRUE); - caps = gst_caps_from_string( "audio/x-raw-int, " - "endianness = (int) LITTLE_ENDIAN, " - "signed = (boolean) true, " - "width = (int) 16, " - "depth = (int) 16" ); + caps = gst_caps_from_string( "audio/x-raw," + "format = (string)S16LE," + "layout = (string)interleaved" ); + g_object_set (GST_ELEMENT(audiobin[MMPLAYER_A_CAPS_DEFAULT].gst), "caps", caps, NULL ); gst_caps_unref( caps ); @@ -1497,17 +1439,7 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) if ((srcpad = gst_element_get_static_pad(player->pipeline->mainbin[MMPLAYER_M_DEMUX].gst, "src"))) { -#ifdef GST_API_VERSION_1 - if ((caps = gst_pad_get_current_caps(srcpad))) - { - MMPLAYER_LOG_GST_CAPS_TYPE(caps); - GstStructure *str = gst_caps_get_structure(caps, 0); - if (str) - gst_structure_get_int (str, "channels", &channels); - gst_caps_unref(caps); - } -#else - if ((caps = gst_pad_get_caps(srcpad))) + if ((caps = gst_pad_query_caps(srcpad,NULL))) { MMPLAYER_LOG_GST_CAPS_TYPE(caps); GstStructure *str = gst_caps_get_structure(caps, 0); @@ -1515,7 +1447,6 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) gst_structure_get_int (str, "channels", &channels); gst_caps_unref(caps); } -#endif gst_object_unref(srcpad); } } @@ -1601,9 +1532,6 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) char *caps_type = NULL; GstCaps* caps = NULL; - /* resampler */ - MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_RESAMPLER, "audioresample", "resampler", TRUE); - /* get conf. values */ mm_attrs_multiple_get(player->attrs, NULL, @@ -1614,10 +1542,11 @@ __mmplayer_gst_create_audio_pipeline(mm_player_t* player) /* capsfilter */ MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_CAPS_DEFAULT, "capsfilter", "audiocapsfilter", TRUE); - caps = gst_caps_new_simple ("audio/x-raw-int", + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S16LE", "rate", G_TYPE_INT, dst_samplerate, "channels", G_TYPE_INT, dst_channels, - "depth", G_TYPE_INT, dst_depth, + "layout", G_TYPE_STRING, "interleaved", NULL); caps_type = gst_caps_to_string(caps); @@ -1877,7 +1806,7 @@ __mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDispl } } - video_caps = gst_caps_new_simple( "video/x-raw-rgb", + video_caps = gst_caps_new_simple( "video/x-raw", "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL); @@ -2071,7 +2000,6 @@ ERROR: int __mmplayer_gst_create_text_pipeline(mm_player_t* player) { - MMPlayerGstElement* first_element = NULL; MMPlayerGstElement* textbin = NULL; GList* element_bucket = NULL; GstPad *pad = NULL; @@ -2307,7 +2235,6 @@ __mmplayer_gst_create_subtitle_src(mm_player_t* player) GstElement * pipeline = NULL; GstElement *subsrc = NULL; GstElement *subparse = NULL; - GstPad *sinkpad = NULL; gchar *subtitle_uri =NULL; gchar *charset = NULL; @@ -2819,11 +2746,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ debug_error ("fakesink element could not be created\n"); goto INIT_ERROR; } -#ifdef GST_API_VERSION_1 GST_OBJECT_FLAG_UNSET (mainbin[MMPLAYER_M_SRC_FAKESINK].gst, GST_ELEMENT_FLAG_SINK); -#else - GST_OBJECT_FLAG_UNSET (mainbin[MMPLAYER_M_SRC_FAKESINK].gst, GST_ELEMENT_IS_SINK); -#endif /* take ownership of fakesink. we are reusing it */ gst_object_ref( mainbin[MMPLAYER_M_SRC_FAKESINK].gst ); @@ -2857,11 +2780,8 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @ } /* set sync handler to get tag synchronously */ -#ifdef GST_API_VERSION_1 gst_bus_set_sync_handler(bus, __mmplayer_bus_sync_callback, player, NULL); -#else - gst_bus_set_sync_handler(bus, __mmplayer_bus_sync_callback, player); -#endif + /* finished */ gst_object_unref(GST_OBJECT(bus)); g_list_free(element_bucket); @@ -2934,11 +2854,7 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player) // @ GstPad *pad = NULL; pad = gst_element_get_static_pad(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "src" ); -#ifdef GST_API_VERSION_1 gst_pad_remove_probe (pad, ahs_appsrc_cb_probe_id); -#else - gst_pad_remove_buffer_probe (pad, ahs_appsrc_cb_probe_id); -#endif gst_object_unref(pad); pad = NULL; ahs_appsrc_cb_probe_id = 0; @@ -2967,7 +2883,7 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player) // @ /* disconnecting bus watch */ if ( player->bus_watcher ) - g_source_remove( player->bus_watcher ); + __mmplayer_remove_g_source_from_context(player->bus_watcher); player->bus_watcher = 0; if ( mainbin ) @@ -2976,12 +2892,7 @@ __mmplayer_gst_destroy_pipeline(mm_player_t* player) // @ MMPlayerGstElement* videobin = player->pipeline->videobin; MMPlayerGstElement* textbin = player->pipeline->textbin; GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (mainbin[MMPLAYER_M_PIPE].gst)); - -#ifdef GST_API_VERSION_1 gst_bus_set_sync_handler (bus, NULL, NULL, NULL); -#else - gst_bus_set_sync_handler (bus, NULL, NULL); -#endif gst_object_unref(bus); debug_log("pipeline status before set state to NULL\n"); diff --git a/src/mm_player_priv_internal.c b/src/mm_player_priv_internal.c index 1d86491..b663f18 100755 --- a/src/mm_player_priv_internal.c +++ b/src/mm_player_priv_internal.c @@ -102,6 +102,7 @@ __mmplayer_release_signal_connection(mm_player_t* player) debug_fenter(); return_if_fail( player ); + return_if_fail( player->signals ); for ( ; sig_list; sig_list = sig_list->next ) { @@ -135,7 +136,9 @@ __mmplayer_dump_pipeline_state( mm_player_t* player ) GstIterator*iter = NULL; gboolean done = FALSE; - GstElement *item = NULL; + GValue item = { 0, }; + GstElement *element; + GstElementFactory *factory = NULL; GstState state = GST_STATE_VOID_PENDING; @@ -154,48 +157,52 @@ __mmplayer_dump_pipeline_state( mm_player_t* player ) if ( iter != NULL ) { while (!done) { - switch ( gst_iterator_next (iter, (gpointer)&item) ) - { - case GST_ITERATOR_OK: - gst_element_get_state(GST_ELEMENT (item),&state, &pending,time); + switch ( gst_iterator_next (iter, &item) ) + { + case GST_ITERATOR_OK: + element = g_value_get_object (&item); + gst_element_get_state(element,&state, &pending,time); - factory = gst_element_get_factory (item) ; - if (!factory) + factory = gst_element_get_factory (element) ; + + if (factory) { - debug_error("%s:%s : From:%s To:%s refcount : %d\n", GST_OBJECT_NAME(factory) , GST_ELEMENT_NAME(item) , - gst_element_state_get_name(state), gst_element_state_get_name(pending) , GST_OBJECT_REFCOUNT_VALUE(item)); + debug_error("%s:%s : From:%s To:%s refcount : %d\n", GST_OBJECT_NAME(factory) , GST_ELEMENT_NAME(element) , + gst_element_state_get_name(state), gst_element_state_get_name(pending) , GST_OBJECT_REFCOUNT_VALUE(element)); } - gst_object_unref (item); - break; - case GST_ITERATOR_RESYNC: - gst_iterator_resync (iter); - break; - case GST_ITERATOR_ERROR: - done = TRUE; - break; - case GST_ITERATOR_DONE: - done = TRUE; - break; - } + g_value_reset(&item); + break; + case GST_ITERATOR_RESYNC: + gst_iterator_resync (iter); + break; + case GST_ITERATOR_ERROR: + done = TRUE; + break; + case GST_ITERATOR_DONE: + done = TRUE; + break; + } } } - item = GST_ELEMENT(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst); + element = GST_ELEMENT(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst); - gst_element_get_state(GST_ELEMENT (item),&state, &pending,time); + gst_element_get_state(element,&state, &pending,time); - factory = gst_element_get_factory (item) ; + factory = gst_element_get_factory (element) ; if (!factory) { debug_error("%s:%s : From:%s To:%s refcount : %d\n", GST_OBJECT_NAME(factory), - GST_ELEMENT_NAME(item), + GST_ELEMENT_NAME(element), gst_element_state_get_name(state), gst_element_state_get_name(pending), - GST_OBJECT_REFCOUNT_VALUE(item) ); + GST_OBJECT_REFCOUNT_VALUE(element) ); } + g_value_unset (&item); + if ( iter ) gst_iterator_free (iter); @@ -243,6 +250,9 @@ __mmplayer_gst_set_state (mm_player_t* player, GstElement * element, GstState s if ( ret == GST_STATE_CHANGE_FAILURE || ( state != element_state ) ) { + if (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_READY) + __mmplayer_release_signal_connection( player ); + debug_error("failed to change [%s] element state to [%s] within %d sec\n", GST_ELEMENT_NAME(element), gst_element_state_get_name(state), timeout ); @@ -276,7 +286,7 @@ __mmplayer_cancel_delayed_eos( mm_player_t* player ) if ( player->eos_timer ) { - g_source_remove( player->eos_timer ); + __mmplayer_remove_g_source_from_context( player->eos_timer ); } player->eos_timer = 0; @@ -420,11 +430,7 @@ __mmplayer_link_decoder( mm_player_t* player, GstPad *srcpad) return_val_if_fail ( srcpad, FALSE ); /* to check any of the decoder (video/audio) need to be linked to parser*/ -#ifdef GST_API_VERSION_1 - srccaps = gst_pad_get_current_caps( srcpad ); -#else - srccaps = gst_pad_get_caps( srcpad ); -#endif + srccaps = gst_pad_query_caps( srcpad, NULL ); if ( !srccaps ) goto ERROR; @@ -479,11 +485,7 @@ __mmplayer_link_sink( mm_player_t* player , GstPad *srcpad) return_val_if_fail ( srcpad, FALSE ); /* to check any of the decoder (video/audio) need to be linked to parser*/ -#ifdef GST_API_VERSION_1 - srccaps = gst_pad_get_current_caps( srcpad ); -#else - srccaps = gst_pad_get_caps( srcpad ); -#endif + srccaps = gst_pad_query_caps( srcpad, NULL ); if ( !srccaps ) goto ERROR; @@ -1100,7 +1102,6 @@ __mmplayer_handle_streaming_error ( mm_player_t* player, GstMessage * message ) return TRUE; } - void __mmplayer_add_sink( mm_player_t* player, GstElement* sink ) { @@ -1114,7 +1115,6 @@ __mmplayer_add_sink( mm_player_t* player, GstElement* sink ) debug_fleave(); } - void __mmplayer_del_sink( mm_player_t* player, GstElement* sink ) { diff --git a/src/mm_player_utils.c b/src/mm_player_utils.c index eae640d..787b234 100755 --- a/src/mm_player_utils.c +++ b/src/mm_player_utils.c @@ -34,7 +34,7 @@ bool util_exist_file_path(const char *file_path) { - int fd = NULL; + int fd = -1; struct stat stat_results = {0, }; if (!file_path || !strlen(file_path)) @@ -200,6 +200,7 @@ __util_gst_pad_probe(GstPad *pad, GstBuffer *buffer, gpointer u_data) { gint flag = (gint) u_data; GstElement* parent = NULL; + GstMapInfo mapinfo = {0, }; gboolean ret = TRUE; /* show name as default */ @@ -213,14 +214,12 @@ __util_gst_pad_probe(GstPad *pad, GstBuffer *buffer, gpointer u_data) } /* show buffer size */ + gst_buffer_map(buffer, &mapinfo, GST_MAP_READ); if ( flag & MM_PROBE_BUFFERSIZE ) { -#ifdef GST_API_VERSION_1 - debug_warning("buffer size : %ud\n", gst_buffer_get_size(buffer)); -#else - debug_warning("buffer size : %ud\n", GST_BUFFER_SIZE(buffer)); -#endif + debug_warning("buffer size : %ud\n", mapinfo.size); } + gst_buffer_unmap(buffer, &mapinfo); /* show buffer duration */ if ( flag & MM_PROBE_BUFFER_DURATION ) @@ -231,9 +230,7 @@ __util_gst_pad_probe(GstPad *pad, GstBuffer *buffer, gpointer u_data) /* show buffer caps */ if ( flag & MM_PROBE_CAPS ) { -#ifndef GST_API_VERSION_1 - debug_warning("caps : %s\n", gst_caps_to_string(GST_BUFFER_CAPS(buffer))); -#endif + debug_warning("caps : %s\n", gst_caps_to_string(gst_pad_get_current_caps(pad))); } /* drop buffer if flag is on */ @@ -405,7 +402,7 @@ util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2) // @ return (gst_plugin_feature_get_rank(f2)+f2_rank_inc) - (gst_plugin_feature_get_rank(f1)+f1_rank_inc ); } -char* +const char* util_get_charset(const char *file_path) { UCharsetDetector* ucsd;