diff options
author | Eunhae Choi <eunhae1.choi@samsung.com> | 2017-09-05 16:42:12 +0900 |
---|---|---|
committer | Eunhae Choi <eunhae1.choi@samsung.com> | 2017-09-05 17:35:48 +0900 |
commit | da5cd5491fd0e714a5c12efbc2132d8bcecad95d (patch) | |
tree | aefd4ac3ee7437582fedb68a57f507176e99ebe6 | |
parent | 1db41fc04d47e33c3ee3f1b49e0897e9269ae85e (diff) | |
download | libmm-player-da5cd5491fd0e714a5c12efbc2132d8bcecad95d.tar.gz libmm-player-da5cd5491fd0e714a5c12efbc2132d8bcecad95d.tar.bz2 libmm-player-da5cd5491fd0e714a5c12efbc2132d8bcecad95d.zip |
[0.6.66] remove deadcodesubmit/tizen/20170906.061717accepted/tizen/unified/20170907.185646
Change-Id: I7e85b852d7d977982e04d25074f25afeafa2689e
-rw-r--r-- | packaging/libmm-player.spec | 2 | ||||
-rw-r--r-- | src/include/mm_player_utils.h | 24 | ||||
-rw-r--r-- | src/mm_player_priv.c | 110 | ||||
-rw-r--r-- | src/mm_player_utils.c | 156 |
4 files changed, 55 insertions, 237 deletions
diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index d5aeffd..7d4ac2d 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.6.65 +Version: 0.6.66 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_player_utils.h b/src/include/mm_player_utils.h index f6bbf3f..6890e58 100644 --- a/src/include/mm_player_utils.h +++ b/src/include/mm_player_utils.h @@ -112,24 +112,6 @@ do { \ #define MMPLAYER_FLEAVE(); #endif -#define MAX_SOUND_DEVICE_LEN 18 - -/* element linking */ -#ifdef GST_EXT_PAD_LINK_UNCHECKED -#define GST_ELEMENT_LINK_FILTERED gst_element_link_filtered_unchecked -#define GST_ELEMENT_LINK_MANY gst_element_link_many_unchecked -#define GST_ELEMENT_LINK gst_element_link_unchecked -#define GST_ELEMENT_LINK_PADS gst_element_link_pads_unchecked -#define GST_PAD_LINK gst_pad_link_unchecked -#else -#define GST_ELEMENT_LINK_FILTERED gst_element_link_filtered -#define GST_ELEMENT_LINK_MANY gst_element_link_many -#define GST_ELEMENT_LINK gst_element_link -#define GST_ELEMENT_UNLINK gst_element_unlink -#define GST_ELEMENT_LINK_PADS gst_element_link_pads -#define GST_PAD_LINK gst_pad_link -#endif - #define MMPLAYER_RETURN_IF_FAIL(expr) \ if (!(expr)) { \ LOGW("faild [%s]", #expr); \ @@ -266,13 +248,7 @@ LOGD("-- prev %s, current %s, pending %s, target %s --\n", \ #define MMPLAYER_URL_HAS_HLS_SUFFIX(x_player) __has_suffix(x_player, "m3u8") bool util_is_sdp_file(const char *path); -int util_get_rank_increase(const char *factory_class); -int util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2); // @ int util_exist_file_path(const char *file_path); -bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_size); -bool util_remove_file_backup(const char *backup_path); /* For Midi Player */ -int util_is_midi_type_by_mem(void *mem, int size); -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); const char* util_get_charset(const char *file_path); diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index a60de08..69a168d 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -343,7 +343,7 @@ _mmplayer_update_content_attrs(mm_player_t* player, enum content_attr_flag flag) } if (player->duration < 0) { - LOGW("duration : %lld is Non-Initialized !!! \n",player->duration); + LOGW("duration : %lld is Non-Initialized !!! \n", player->duration); player->duration = 0; } @@ -605,7 +605,7 @@ __mmplayer_set_state(mm_player_t* player, int state) /* rtsp case, get content attrs by GstMessage */ if (!MMPLAYER_IS_RTSP_STREAMING(player)) { /* it's first time to update all content attrs. */ - _mmplayer_update_content_attrs( player, ATTR_ALL ); + _mmplayer_update_content_attrs(player, ATTR_ALL); } /* set max sound priority to keep own sound and not to mute other's one */ @@ -997,7 +997,7 @@ __mmplayer_handle_buffering_message(mm_player_t* player) /* rtsp streaming pause makes rtsp server stop sending data. */ if (!MMPLAYER_IS_RTSP_STREAMING(player)) { LOGD("set pause state during buffering\n"); - __gst_pause( player, TRUE ); + __gst_pause(player, TRUE); } } } @@ -1006,7 +1006,7 @@ __mmplayer_handle_buffering_message(mm_player_t* player) case MM_PLAYER_STATE_PLAYING: /* rtsp streaming pause makes rtsp server stop sending data. */ if (!MMPLAYER_IS_RTSP_STREAMING(player)) { - __gst_pause ( player, TRUE ); + __gst_pause(player, TRUE); } break; @@ -1064,7 +1064,7 @@ static VariantData * __mmplayer_adaptive_var_info(const VariantData *self, gpointer user_data) { VariantData *var_info = NULL; - g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail(self != NULL, NULL); var_info = g_new0(VariantData, 1); if (!var_info) return NULL; @@ -1329,13 +1329,13 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) if ((GST_TIME_AS_SECONDS(player->last_position) <= 0) && (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED)) { msg_param.connection.buffering = player->streamer->buffering_percent; - MMPLAYER_POST_MSG( player, MM_MESSAGE_BUFFERING, &msg_param ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_BUFFERING, &msg_param); } else { LOGD("Not updating Buffering Message for Live RTSP case !!!\n"); } } else { msg_param.connection.buffering = player->streamer->buffering_percent; - MMPLAYER_POST_MSG( player, MM_MESSAGE_BUFFERING, &msg_param ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_BUFFERING, &msg_param); } } MMPLAYER_CMD_UNLOCK(player); @@ -1388,7 +1388,7 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) int retVal = MM_ERROR_NONE; LOGD("trying to play from (%lu) pending position\n", player->pending_seek.pos); - retVal = __gst_set_position( player, player->pending_seek.format, player->pending_seek.pos, TRUE ); + retVal = __gst_set_position(player, player->pending_seek.format, player->pending_seek.pos, TRUE); if (MM_ERROR_NONE != retVal) LOGE("failed to seek pending postion. just keep staying current position.\n"); @@ -1446,14 +1446,14 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) if (MMPLAYER_IS_RTSP_STREAMING(player) && (MMPLAYER_IS_LIVE_STREAMING(player))) { - LOGD("Current Buffering Percent = %d",player->streamer->buffering_percent); + LOGD("Current Buffering Percent = %d", player->streamer->buffering_percent); if (player->streamer->buffering_percent < 100) { MMMessageParamType msg_param = {0, }; LOGW("Posting Buffering Completed Message to Application !!!"); msg_param.connection.buffering = 100; - MMPLAYER_POST_MSG ( player, MM_MESSAGE_BUFFERING, &msg_param ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_BUFFERING, &msg_param); } } } @@ -1618,9 +1618,9 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) extract duration ,codec info , resolution from sdp and get it by GstMessage */ if (!strcmp(structure_name, "rtspsrc_properties")) { - gchar *audio_codec = NULL; - gchar *video_codec = NULL; - gchar *video_frame_size = NULL; + gchar *audio_codec = NULL; + gchar *video_codec = NULL; + gchar *video_frame_size = NULL; gst_structure_get(gst_message_get_structure(msg), "rtsp_duration", G_TYPE_UINT64, &player->duration, NULL); LOGD("rtsp duration : %lld msec", GST_TIME_AS_MSECONDS(player->duration)); @@ -1644,11 +1644,11 @@ __mmplayer_gst_callback(GstBus *bus, GstMessage *msg, gpointer data) char *seperator = strchr(video_frame_size, '-'); if (seperator) { - char video_width[10]={0,}; + char video_width[10] = {0,}; int frame_size_len = strlen(video_frame_size); int separtor_len = strlen(seperator); - strncpy(video_width,video_frame_size,(frame_size_len-separtor_len)); + strncpy(video_width, video_frame_size, (frame_size_len - separtor_len)); mm_attrs_set_int_by_name(attrs, "content_video_width", atoi(video_width)); seperator++; @@ -2175,7 +2175,7 @@ NEW_ELEMENT: } /* link it */ - if (GST_PAD_LINK_OK != GST_PAD_LINK(pad, sinkpad)) { + if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad)) { LOGE("failed to link autoplug element\n"); goto ERROR; } @@ -3460,7 +3460,7 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data) } /* link */ - if (GST_PAD_LINK_OK != GST_PAD_LINK(pad, sinkpad)) { + if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad)) { LOGE("failed to get pad from sinkbin\n"); goto ERROR; } @@ -3988,7 +3988,7 @@ __mmplayer_gst_element_link_bucket(GList* element_bucket) } if (prv_element && prv_element->gst) { - if (GST_ELEMENT_LINK(GST_ELEMENT(prv_element->gst), GST_ELEMENT(element->gst))) { + if (gst_element_link(GST_ELEMENT(prv_element->gst), GST_ELEMENT(element->gst))) { LOGD("linking [%s] to [%s] success\n", GST_ELEMENT_NAME(GST_ELEMENT(prv_element->gst)), GST_ELEMENT_NAME(GST_ELEMENT(element->gst))); @@ -5691,8 +5691,7 @@ __mmplayer_update_subtitle(GstElement* object, GstBuffer *buffer, GstPad *pad, g MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE); MMPLAYER_RETURN_VAL_IF_FAIL(buffer, FALSE); - if (player->is_subtitle_force_drop) - { + if (player->is_subtitle_force_drop) { LOGW("subtitle is dropped forcedly."); return ret; } @@ -6191,7 +6190,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) /* parsing cookies */ if ((cookie_list = util_get_cookie_list((const char*)cookies))) { g_object_set(G_OBJECT(element), "cookies", cookie_list, NULL); - g_strfreev (cookie_list); + g_strfreev(cookie_list); } if (user_agent) g_object_set(G_OBJECT(element), "user-agent", user_agent, NULL); @@ -6235,7 +6234,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) g_object_set(G_OBJECT(element), "location", player->profile.uri, NULL); g_object_get(element, "location", &location, NULL); LOGD("PD_LOCATION [%s].\n", location); - if(location) + if (location) g_free(location); } } @@ -7310,16 +7309,15 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo * Since some element could have some timing problemn with quering duration, try again. */ if (!player->duration) { - 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, GST_FORMAT_TIME, &dur_nsec)) { /* For RTSP Streaming , duration is not returned in READY state. So seek to the previous position does not work properly. * Added a patch to postpone the actual seek when state changes to PLAY. Sending a fake SEEK_COMPLETED event to finish the current request. */ - if ((MMPLAYER_IS_RTSP_STREAMING( player )) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { + if ((MMPLAYER_IS_RTSP_STREAMING(player)) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { player->pending_seek.is_pending = TRUE; player->pending_seek.format = format; player->pending_seek.pos = position; player->doing_seek = FALSE; - MMPLAYER_POST_MSG ( player, MM_MESSAGE_SEEK_COMPLETED, NULL ); + MMPLAYER_POST_MSG(player, MM_MESSAGE_SEEK_COMPLETED, NULL); return MM_ERROR_NONE; } else { goto SEEK_ERROR; @@ -7355,10 +7353,10 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo if (position > dur_msec) goto INVALID_ARGS; - query = gst_query_new_seeking (GST_FORMAT_TIME); - if (gst_element_query (player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, query)) { - gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL); - gst_query_unref (query); + query = gst_query_new_seeking(GST_FORMAT_TIME); + if (gst_element_query(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, query)) { + gst_query_parse_seeking(query, NULL, &seekable, NULL, NULL); + gst_query_unref(query); if (!seekable) { LOGW("non-seekable content"); @@ -7367,7 +7365,7 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo } } else { LOGW("failed to get seeking query"); - gst_query_unref (query); /* keep seeking operation */ + gst_query_unref(query); /* keep seeking operation */ } LOGD("seeking to(%lu) msec, duration is %d msec\n", position, dur_msec); @@ -7376,13 +7374,13 @@ __gst_set_position(mm_player_t* player, int format, unsigned long position, gboo But when a rtsp clip (especially from Youtube Desktop View) is paused and kept for sometime,npt-start is still increasing. This causes problem is position calculation during normal pause resume scenarios also. Currently during seek , we are sending the current position to rtspsrc module for position saving for later use. */ - if ((MMPLAYER_IS_RTSP_STREAMING( player )) && + if ((MMPLAYER_IS_RTSP_STREAMING(player)) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_nsec)) LOGW("getting current position failed in seek\n"); player->last_position = pos_nsec; - g_object_set( player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL ); + g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL); } if (player->doing_seek) { @@ -8100,7 +8098,7 @@ void __mmplayer_sound_focus_watch_callback(int id, mm_sound_focus_type_e focus_t if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL || player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM || - player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA ) { + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA) { if (!MMPLAYER_IS_RTSP_STREAMING(player)) { // hold 0.7 second to excute "fadedown mute" effect LOGW("do fade down->pause->undo fade down"); @@ -8190,7 +8188,7 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou if (player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_CALL || player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_ALARM || - player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA ) { + player->sound_focus.focus_changed_msg == MM_PLAYER_FOCUS_CHANGED_BY_MEDIA) { if (!MMPLAYER_IS_RTSP_STREAMING(player)) { //hold 0.7 second to excute "fadedown mute" effect LOGW("do fade down->pause->undo fade down"); @@ -9492,9 +9490,9 @@ _mmplayer_pause(MMHandleType hplayer) But when a rtsp clip (especially from Youtube Desktop View) is paused and kept for sometime,npt-start is still increasing. This causes problem is position calculation during normal pause resume scenarios also. Currently during pause , we are sending the current position to rtspsrc module for position saving. */ - if ((MMPLAYER_IS_RTSP_STREAMING( player )) && + if ((MMPLAYER_IS_RTSP_STREAMING(player)) && (__mmplayer_get_stream_service_type(player) != STREAMING_SERVICE_LIVE)) { - g_object_set( player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL ); + g_object_set(player->pipeline->mainbin[MMPLAYER_M_SRC].gst, "resume-position", player->last_position, NULL); } } break; @@ -10371,12 +10369,12 @@ __mmplayer_verify_next_play_path(mm_player_t *player) char *profileName; system_info_get_platform_string("http://tizen.org/feature/profile", &profileName); switch (*profileName) { - case 't': - case 'T': - profile_tv = 1; - break; - default: - profile_tv = 0; + case 't': + case 'T': + profile_tv = 1; + break; + default: + profile_tv = 0; } free(profileName); } @@ -12103,8 +12101,8 @@ __gst_send_event_to_sink(mm_player_t* player, GstEvent* event) /* While adding subtitles in live feeds seek is getting called. Adding defensive check in framework layer.*/ if (GST_EVENT_TYPE(event) == GST_EVENT_SEEK) { - if (MMPLAYER_IS_LIVE_STREAMING (player)) { - LOGE ("Should not send seek event during live playback"); + if (MMPLAYER_IS_LIVE_STREAMING(player)) { + LOGE("Should not send seek event during live playback"); return TRUE; } } @@ -12479,7 +12477,7 @@ __mmplayer_do_change_videosink(mm_player_t* player, const int dec_index, const c } /* unlink between decoder and videobin and remove previous videosink from videobin */ - GST_ELEMENT_UNLINK(GST_ELEMENT(player->pipeline->mainbin[dec_index].gst), GST_ELEMENT(player->pipeline->videobin[MMPLAYER_V_BIN].gst)); + gst_element_unlink(GST_ELEMENT(player->pipeline->mainbin[dec_index].gst), GST_ELEMENT(player->pipeline->videobin[MMPLAYER_V_BIN].gst)); if (!gst_bin_remove(GST_BIN(player->pipeline->videobin[MMPLAYER_V_BIN].gst), GST_ELEMENT(player->pipeline->videobin[MMPLAYER_V_SINK].gst))) { LOGE("failed to remove former videosink from videobin"); return MM_ERROR_PLAYER_INTERNAL; @@ -12561,7 +12559,7 @@ __mmplayer_do_change_videosink(mm_player_t* player, const int dec_index, const c LOGE("failed to get sink pad from videobin"); return MM_ERROR_PLAYER_INTERNAL; } - if (GST_PAD_LINK_OK != GST_PAD_LINK(src_pad_dec, sink_pad_videobin)) { + if (GST_PAD_LINK_OK != gst_pad_link(src_pad_dec, sink_pad_videobin)) { LOGE("failed to link"); return MM_ERROR_PLAYER_INTERNAL; } @@ -13735,7 +13733,7 @@ __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_ty MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(player); - for (i=0; i<MMPLAYER_PATH_MAX; i++) { + for (i = 0; i < MMPLAYER_PATH_MAX; i++) { if (path_type == MMPLAYER_PATH_MAX || path_type == i) { player->storage_info[i].type = STORAGE_TYPE_INTERNAL; @@ -13753,7 +13751,7 @@ __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_ty int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int state) { int ret = MM_ERROR_NONE; - mm_player_t* player = (mm_player_t*) hplayer; + mm_player_t* player = (mm_player_t*)hplayer; MMMessageParamType msg_param = {0, }; MMPLAYER_FENTER(); @@ -13802,17 +13800,17 @@ int _mmplayer_get_adaptive_variant_info(MMHandleType hplayer, int *num, char **v return ret; } - result = g_strdup (""); + result = g_strdup(""); for (idx = 0 ; idx < total ; idx++) { VariantData *v_data = NULL; v_data = g_list_nth_data(player->adaptive_info.var_list, idx); if (v_data) { - gchar data[64]={0}; + gchar data[64] = {0}; snprintf(data, sizeof(data), "%d,%d,%d,", v_data->bandwidth, v_data->width, v_data->height); - tmp = g_strconcat (result, data, NULL); - g_free (result); + tmp = g_strconcat(result, data, NULL); + g_free(result); result = tmp; } else { LOGW("There is no variant data in %d", idx); @@ -13837,9 +13835,9 @@ int _mmplayer_set_max_adaptive_variant_limit(MMHandleType hplayer, int bandwidth LOGD("set limit to [b]%d, [w]%d, [h]%d", bandwidth, width, height); - player->adaptive_info.limit.bandwidth = (bandwidth >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(bandwidth):(ADAPTIVE_VARIANT_DEFAULT_VALUE); - player->adaptive_info.limit.width = (width >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(width):(ADAPTIVE_VARIANT_DEFAULT_VALUE); - player->adaptive_info.limit.height = (height >= ADAPTIVE_VARIANT_DEFAULT_VALUE)?(height):(ADAPTIVE_VARIANT_DEFAULT_VALUE); + player->adaptive_info.limit.bandwidth = (bandwidth >= ADAPTIVE_VARIANT_DEFAULT_VALUE) ? (bandwidth) : (ADAPTIVE_VARIANT_DEFAULT_VALUE); + player->adaptive_info.limit.width = (width >= ADAPTIVE_VARIANT_DEFAULT_VALUE) ? (width) : (ADAPTIVE_VARIANT_DEFAULT_VALUE); + player->adaptive_info.limit.height = (height >= ADAPTIVE_VARIANT_DEFAULT_VALUE) ? (height) : (ADAPTIVE_VARIANT_DEFAULT_VALUE); if (player->pipeline && player->pipeline->mainbin && player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst) { LOGD("update max limit of %s", GST_ELEMENT_NAME(player->pipeline->mainbin[MMPLAYER_M_ADAPTIVE_DEMUX].gst)); diff --git a/src/mm_player_utils.c b/src/mm_player_utils.c index 8bc83b4..98c999e 100644 --- a/src/mm_player_utils.c +++ b/src/mm_player_utils.c @@ -71,122 +71,6 @@ int util_exist_file_path(const char *file_path) return MM_ERROR_NONE; } -bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_size) -{ - FILE *fp = NULL; - int wsize = 0; - - fp = fopen(backup_path, "wb"); - if (!fp) - return FALSE; - - wsize = fwrite(data_ptr, sizeof(char), data_size, fp); - - fclose(fp); - - if (wsize != data_size) { - if (!access(backup_path, R_OK)) - remove(backup_path); - - LOGE("No space to write!\n"); - - return FALSE; - } - - return TRUE; -} - -bool util_remove_file_backup(const char *backup_path) -{ - if (!backup_path || !strlen(backup_path)) - return FALSE; - - int res = access(backup_path, R_OK); - if (!res) { - if (remove(backup_path) == -1) - return FALSE; - } - - return TRUE; -} - -#define DETECTION_PREFIX_SIZE 20 -int util_is_midi_type_by_mem(void *mem, int size) -{ - const char *p = (const char *)mem; - - if (size < DETECTION_PREFIX_SIZE) - return MM_AUDIO_CODEC_INVALID; - - /* mmf file detection */ - if (p[0] == 'M' && p[1] == 'M' && p[2] == 'M' && p[3] == 'D') { - LOGD("MM_AUDIO_CODEC_MMF\n"); - return MM_AUDIO_CODEC_MMF; - } - - /* midi file detection */ - if (p[0] == 'M' && p[1] == 'T' && p[2] == 'h' && p[3] == 'd') { - LOGD("MM_AUDIO_CODEC_MIDI, %d\n", MM_AUDIO_CODEC_MIDI); - return MM_AUDIO_CODEC_MIDI; - } - /* mxmf file detection */ - if (p[0] == 'X' && p[1] == 'M' && p[2] == 'F' && p[3] == '_') { - LOGD("MM_AUDIO_CODEC_MXMF\n"); - return MM_AUDIO_CODEC_MXMF; - } - - /* wave file detection */ - if (p[0] == 'R' && p[1] == 'I' && p[2] == 'F' && p[3] == 'F' && - p[8] == 'W' && p[9] == 'A' && p[10] == 'V' && p[11] == 'E' && - p[12] == 'f' && p[13] == 'm' && p[14] == 't') { - LOGD("MM_AUDIO_CODEC_WAVE\n"); - return MM_AUDIO_CODEC_WAVE; - } - /* i-melody file detection */ - if (memcmp(p, "BEGIN:IMELODY", 13) == 0) { - LOGD("MM_AUDIO_CODEC_IMELODY\n"); - return MM_AUDIO_CODEC_IMELODY; - } - - return MM_AUDIO_CODEC_INVALID; -} - -int util_is_midi_type_by_file(const char *file_path) -{ - struct stat file_attrib; - FILE *fp = NULL; - char prefix[DETECTION_PREFIX_SIZE] = {0,}; - int size; - - if (!file_path) - return FALSE; - - fp = fopen(file_path, "r"); - - if (!fp) - return FALSE; - - memset(&file_attrib, 0, sizeof(file_attrib)); - - if (stat(file_path, &file_attrib) != 0) { - fclose(fp); - return FALSE; - } - - size = (int) file_attrib.st_size; - - if (size < DETECTION_PREFIX_SIZE) { - fclose(fp); - return FALSE; - } - - size = fread(prefix, sizeof(char), DETECTION_PREFIX_SIZE, fp); - - fclose(fp); - - return util_is_midi_type_by_mem(prefix, size); -} - char** util_get_cookie_list(const char *cookies) { @@ -280,46 +164,6 @@ util_is_sdp_file(const char *path) return ret; } -int64_t -util_get_time(void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; -} - -int -util_get_rank_increase(const char *factory_class) -{ - gint rank_pri_inc = 20; - gint rank_sec_inc = 10; - gint ret = 0; - - if (g_strrstr(factory_class, "Dsp")) - ret = rank_pri_inc; - else if (g_strrstr(factory_class, "HW")) - ret = rank_pri_inc; - else if (g_strrstr(factory_class, "Arm")) - ret = rank_sec_inc; - - return ret; -} - -int -util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2) -{ - const gchar *klass; - int f1_rank_inc = 0, f2_rank_inc = 0; - - klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f1)); - f1_rank_inc = util_get_rank_increase(klass); - - klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f2)); - f2_rank_inc = util_get_rank_increase(klass); - - return (gst_plugin_feature_get_rank(f2)+f2_rank_inc) - (gst_plugin_feature_get_rank(f1)+f1_rank_inc); -} - const char* util_get_charset(const char *file_path) { |