From 4ef24696245dfbd1e9f64ac0dd5f058fb5c077a5 Mon Sep 17 00:00:00 2001 From: Ravi Kiran K N Date: Tue, 19 Sep 2017 16:35:21 +0530 Subject: [PATCH] Add comments Remove unused functions Change-Id: I4e4f6349c829c1c6e1a23a364a51f3195132e5a0 Signed-off-by: Ravi Kiran K N --- include/common/mp-util-media-service.h | 19 - src/common/mp-util-media-service.c | 918 +++------------------------------ 2 files changed, 73 insertions(+), 864 deletions(-) diff --git a/include/common/mp-util-media-service.h b/include/common/mp-util-media-service.h index fdf02a4..0819555 100644 --- a/include/common/mp-util-media-service.h +++ b/include/common/mp-util-media-service.h @@ -68,32 +68,19 @@ void mp_util_svc_finish_session(void); // For gallery list bool mp_util_svc_extract_video_list_from_folder(char *szFolderPath, int nSortType, int nItemType); // For myfiles. bool mp_util_svc_extract_video_list_by_item_type(int nSortType, int nItemType); // For video list by item type. (All/Phone/Cloud) -bool mp_util_svc_extract_video_list_from_favorite(int nSortType); // For favorite naming of gallery. -bool mp_util_svc_extract_video_list_for_search_view(const char *keyword, int nItemType); // For only video type files of video search view bool mp_util_svc_index_list_for_search_view(const char *keyword, void **index_list); // For only video type files of video search view -bool mp_util_svc_index_list_for_cloud_view(void **index_list, int *nListSize); // get cloud data from media list void mp_util_svc_destory_video_list(void); bool mp_util_svc_destory_video_item_list(void); -bool mp_util_svc_remove_item_by_url_with_list(char *szFilePath); bool mp_util_svc_remove_item_by_list_index(int nVideoItemIndex); bool mp_util_svc_get_video_id_by_video_url(const char *szPath, char **szVideoID); char *mp_util_svc_get_video_Thumbnail_by_video_url(const char *szMediaUri); -int mp_util_svc_get_video_width_by_video_url(const char *szMediaUri); -int mp_util_svc_get_video_height_by_video_url(const char *szMediaUri); unsigned int mp_util_svc_get_video_last_play_time_by_video_url(const char *szPath); -unsigned int mp_util_svc_get_video_duration_by_video_url(const char - *szPath); -int mp_util_svc_get_video_file_size_by_video_url(const char *szPath); void mp_util_svc_set_video_last_played_time_by_url(char *szMediaUri, unsigned int nPosition); -bool mp_util_svc_get_video_current_url_pre_next_item(char *szCurrMediaUri, - char *szPreMediaUri, - char *szNextMediaUri, - bool bLoop); // For video list char *mp_util_svc_get_video_url(const int nVideoItemIndex); @@ -106,15 +93,10 @@ unsigned long long mp_util_svc_get_video_item_size(const int int mp_util_svc_get_video_item_width(const int nVideoItemIndex); int mp_util_svc_get_video_item_height(const int nVideoItemIndex); -time_t mp_util_svc_get_video_item_data_time(const int nVideoItemIndex); -char *mp_util_svc_get_video_item_extension(const int nVideoItemIndex); -double mp_util_svc_get_video_item_longitude(const int nVideoItemIndex); -double mp_util_svc_get_video_item_latitude(const int nVideoItemIndex); char *mp_util_svc_get_video_item_modified_time(const int nVideoItemIndex); int mp_util_svc_get_video_list_size_for_checking_index(void); int mp_util_svc_get_number_of_video_item_by_type(void); -int mp_util_svc_get_total_video_type_files(void); void mp_util_svc_print_list_info(void); int mp_util_svc_find_video_item_index_by_url(const char *szPath); char *mp_util_svc_get_video_id_by_index(const int nVideoItemIndex); @@ -185,7 +167,6 @@ bool mp_util_svc_extract_video_list_from_folder_by_personal(char int nItemType, int nViewType); bool mp_util_svc_check_valid_personal(int nViewType); -void *mp_util_svc_get_video_item(const int nVideoItemIndex); int mp_util_svc_move_from_db(const char *path); void mp_util_svc_move_to_db(const int nVideoItemIndex, const char *szVideoPath); diff --git a/src/common/mp-util-media-service.c b/src/common/mp-util-media-service.c index e889d4b..2c35a38 100644 --- a/src/common/mp-util-media-service.c +++ b/src/common/mp-util-media-service.c @@ -39,7 +39,11 @@ static int nTotalVideoTypeFiles = 0; static int nNumberOfVideoItemByType = 0; static media_content_noti_h noti_handle = NULL; - +/** +* Check if the give file is of 3gp format +* @param szFileUri : file string +* @return true/false +*/ bool mp_util_svc_is_3gp_file(char *szFileUri) { @@ -269,55 +273,6 @@ static bool mp_util_svc_iterate_for_personal_folder_list_cb(media_folder_h // // Internal function // -bool mp_util_svc_get_file_directory_name(char *szFilePath, - char *szFileName, - char *szDirectoryName, - char *szDirectoryPath) -{ - if (!szFilePath) { - VideoLogError("[ERR]"); - return FALSE; - } - - int nCount = 0; - int nLoopCount = 0; - - for (nLoopCount = strlen(szFilePath); nLoopCount >= 0; nLoopCount--) { - if (szFilePath[nLoopCount] != '\0') { - nCount++; - } - - if (szFilePath[nLoopCount] == '/') { - if (szFileName) { - memcpy(szFileName, &szFilePath[nLoopCount + 1], --nCount); - *(szFileName + nCount) = '\0'; - } - - if (szDirectoryPath) { - memcpy(szDirectoryPath, &szFilePath[0], nLoopCount); - *(szDirectoryPath + nLoopCount + 1) = '\0'; - } - - if (szDirectoryName) { - nCount = 0; - for (--nLoopCount; nLoopCount >= 0; nLoopCount--) { - nCount++; - if (szFilePath[nLoopCount] == '/') { - memcpy(szDirectoryName, - &szFilePath[nLoopCount + 1], --nCount); - *(szDirectoryName + nCount) = '\0'; - - return TRUE; - } - } - } - - return TRUE; - } - } - - return FALSE; -} // // External function @@ -797,102 +752,6 @@ bool mp_util_svc_extract_video_list_by_item_type(int nSortType, return TRUE; } -bool mp_util_svc_extract_video_list_from_favorite(int nSortType) -{ - if (VideoItemList) { - VideoLogInfo("Already exist video list."); - return FALSE; - } - - filter_h m_FilterHandle = NULL; - media_content_order_e nOrderType = MEDIA_CONTENT_ORDER_ASC; - char szOrderObj[STR_LEN_MAX] = { 0, }; - char szTmpStr[STR_LEN_MAX] = { 0, }; - - nWhatFileType = MP_MEDIA_ALL_FILE_TYPE; - - nTotalVideoTypeFiles = 0; - nNumberOfVideoItemByType = 0; - - switch (nSortType) { - case MP_MEDIA_SORT_BY_NONE: - case MP_MEDIA_SORT_BY_RECENTLY_VIEWED: - nOrderType = MEDIA_CONTENT_ORDER_DESC; - strncpy(szOrderObj, MEDIA_LAST_PLAYED_TIME, STR_LEN_MAX - 1); - break; - - case MP_MEDIA_SORT_BY_RECENTLY_ADDED: - nOrderType = MEDIA_CONTENT_ORDER_DESC; - strncpy(szOrderObj, MEDIA_ADDED_TIME, STR_LEN_MAX - 1); - break; - - case MP_MEDIA_SORT_BY_NAME: - nOrderType = MEDIA_CONTENT_ORDER_ASC; - strncpy(szOrderObj, MEDIA_DISPLAY_NAME, STR_LEN_MAX - 1); - break; - - case MP_MEDIA_SORT_BY_SIZE: - nOrderType = MEDIA_CONTENT_ORDER_DESC; - strncpy(szOrderObj, MEDIA_SIZE, STR_LEN_MAX - 1); - break; - - case MP_MEDIA_SORT_BY_TYPE: - nOrderType = MEDIA_CONTENT_ORDER_ASC; - strncpy(szOrderObj, MEDIA_MIME_TYPE, STR_LEN_MAX - 1); - break; - - default: - nOrderType = MEDIA_CONTENT_ORDER_ASC; - strncpy(szOrderObj, MEDIA_LAST_PLAYED_TIME, STR_LEN_MAX - 1); - } - - if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to create media filter handle."); - return FALSE; - } - - if (!mp_util_get_personal_status()) { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and MEDIA_FAVOURITE = 1 and MEDIA_PATH NOT LIKE \"%s%%\"", - VIDEO_UTIL_PERSONAL_HEAD_STR); - } else { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and MEDIA_FAVOURITE = 1"); - } - - if (media_filter_set_condition - (m_FilterHandle, szTmpStr, - MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_filter_set_order - (m_FilterHandle, nOrderType, szOrderObj, - MEDIA_CONTENT_COLLATE_NOCASE) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set order."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_info_foreach_media_from_db - (m_FilterHandle, mp_util_svc_iterate_for_video_item_list_view_cb, - &VideoItemList) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError - ("Fail to get video item list with filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_filter_destroy(m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to destroy media filter handle."); - return FALSE; - } - - return TRUE; -} - bool mp_util_svc_index_list_for_search_view(const char *keyword, void **index_list) @@ -934,122 +793,6 @@ bool mp_util_svc_index_list_for_search_view(const char *keyword, return TRUE; } -bool mp_util_svc_index_list_for_cloud_view(void **index_list, - int *nListSize) -{ - return FALSE; -} - - -bool mp_util_svc_extract_video_list_for_search_view(const char *keyword, - int nItemType) -{ - if (VideoItemList) { - VideoLogError("Already exist video list."); - return FALSE; - } - - filter_h m_FilterHandle = NULL; - media_content_order_e nOrderType = MEDIA_CONTENT_ORDER_ASC; - char szOrderObj[STR_LEN_MAX] = { 0, }; - char szTmpStr[STR_LEN_MAX] = { 0, }; - - nWhatFileType = MP_MEDIA_ALL_FILE_TYPE; - nTotalVideoTypeFiles = 0; - nNumberOfVideoItemByType = 0; - - nOrderType = MEDIA_CONTENT_ORDER_ASC; - strncpy(szOrderObj, MEDIA_DISPLAY_NAME, STR_LEN_MAX - 1); - - if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to create media filter handle."); - return FALSE; - } - - switch (nItemType) { - case MP_LIST_VIEW_ALL: - if (!mp_util_get_personal_status()) { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_DISPLAY_NAME like \"%%%s%%\" and MEDIA_PATH NOT LIKE \"%s%%\"", - keyword, VIDEO_UTIL_PERSONAL_HEAD_STR); - } else { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_DISPLAY_NAME like \"%%%s%%\"", - keyword); - } - break; - - case MP_LIST_VIEW_PHONE: - if (!mp_util_get_personal_status()) { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1) and MEDIA_DISPLAY_NAME like \"%%%s%%\" and MEDIA_PATH NOT LIKE \"%s%%\"", - keyword, VIDEO_UTIL_PERSONAL_HEAD_STR); - } else { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 and (MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE=1) and MEDIA_DISPLAY_NAME like \"%%%s%%\"", - keyword); - } - break; - - case MP_LIST_VIEW_CLOUD: - if (!mp_util_get_personal_status()) { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101) and MEDIA_STORAGE_TYPE = 101 and MEDIA_DISPLAY_NAME like \"%%%s%%\" and MEDIA_PATH NOT LIKE \"%s%%\"", - keyword, VIDEO_UTIL_PERSONAL_HEAD_STR); - } else { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101) and MEDIA_STORAGE_TYPE = 101 and MEDIA_DISPLAY_NAME like \"%%%s%%\"", - keyword); - } - break; - - default: - if (!mp_util_get_personal_status()) { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_DISPLAY_NAME like \"%%%s%%\" and MEDIA_PATH NOT LIKE \"%s%%\"", - keyword, VIDEO_UTIL_PERSONAL_HEAD_STR); - } else { - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) and MEDIA_DISPLAY_NAME like \"%%%s%%\"", - keyword); - } - break; - } - - if (media_filter_set_condition - (m_FilterHandle, szTmpStr, - MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_filter_set_order - (m_FilterHandle, nOrderType, szOrderObj, - MEDIA_CONTENT_COLLATE_NOCASE) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set order."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_info_foreach_media_from_db - (m_FilterHandle, mp_util_svc_iterate_for_video_item_list_view_cb, - &VideoItemList) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError - ("Fail to get video item list with filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_filter_destroy(m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to destroy media filter handle."); - return FALSE; - } - - return TRUE; -} - - void mp_util_svc_destory_video_list(void) { @@ -1072,65 +815,6 @@ void mp_util_svc_destory_video_list(void) nNumberOfVideoItemByType = 0; } -bool mp_util_svc_remove_item_by_url_with_list(char *szFilePath) -{ - if (!szFilePath) { - VideoLogError("[ERR]"); - return FALSE; - } - - if (!VideoItemList) { - VideoLogError("pList is empty already."); - return FALSE; - } - - VideoSecureLogInfo("szFilePath : %s", szFilePath); - - char *szGetFilePath = NULL; - media_info_h pItem = NULL; - Eina_List *pIterateList = NULL; - EINA_LIST_FOREACH(VideoItemList, pIterateList, pItem) { - if (pItem) { - if (media_info_get_file_path(pItem, &szGetFilePath) == - MEDIA_CONTENT_ERROR_NONE) { - if (szGetFilePath) { - if (!strcmp(szGetFilePath, szFilePath)) { - char *szMediaID = NULL; - media_info_get_media_id(pItem, &szMediaID); - media_info_delete_from_db(szMediaID); - mp_util_delete_wall_file(szMediaID); - VideoItemList = - eina_list_remove(VideoItemList, pItem); - media_info_destroy(pItem); - - nNumberOfVideoItemByType--; - - if (szMediaID) { - free(szMediaID); - } - - if (szGetFilePath) { - free(szGetFilePath); - } - - return TRUE; - } - } else { - VideoLogError - ("No exist %s in media info Database module.", - szFilePath); - return FALSE; - } - } - } - } - - if (szGetFilePath) { - free(szGetFilePath); - } - return FALSE; -} - bool mp_util_svc_remove_item_by_list_index(int nVideoItemIndex) { @@ -1179,327 +863,104 @@ bool mp_util_svc_remove_item_from_db_by_list_index(int nVideoItemIndex) media_info_get_media_id(pItem, &szMediaID); if (szMediaID) { mp_util_delete_wall_file(szMediaID); - media_info_delete_from_db(szMediaID); - free(szMediaID); - } else { - VideoLogError("No exist media ID in index %d of list.", - nVideoItemIndex); - return FALSE; - } - } else { - VideoLogError("Fail to remove item in media svc and list."); - return FALSE; - } - - return TRUE; -} - -bool mp_util_svc_get_video_id_by_video_url(const char *szPath, - char **szVideoID) -{ - media_info_h pVideoItem = NULL; - filter_h m_FilterHandle = NULL; - char szTmpStr[STR_LEN_MAX] = { 0, }; - bool bRet = FALSE; - int ret = -1; - - if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogInfo("Fail to create media filter handle."); - bRet = FALSE; - } - - snprintf(szTmpStr, STR_LEN_MAX, "MEDIA_PATH = \"%s\"", szPath); - if (media_filter_set_condition(m_FilterHandle, - szTmpStr, - MEDIA_CONTENT_COLLATE_DEFAULT) != - MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set filter condition."); - media_filter_destroy(m_FilterHandle); - m_FilterHandle = NULL; - bRet = FALSE; - } - - if (media_info_foreach_media_from_db(m_FilterHandle, - mp_util_svc_iterate_for_get_video_item_cb, - &pVideoItem) != - MEDIA_CONTENT_ERROR_NONE) { - VideoLogError - ("Fail to get video item list with filter condition."); - if (m_FilterHandle) { - media_filter_destroy(m_FilterHandle); - m_FilterHandle = NULL; - } - bRet = FALSE; - } - - if (m_FilterHandle) { - ret = media_filter_destroy(m_FilterHandle); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to destroy media filter handle."); - m_FilterHandle = NULL; - } - bRet = FALSE; - } - - if (pVideoItem) { - char *szMediaID = NULL; - media_info_get_media_id(pVideoItem, &szMediaID); - *szVideoID = szMediaID; - media_info_destroy(pVideoItem); - bRet = TRUE; - } else { - bRet = FALSE; - } - - return bRet; -} - -unsigned int mp_util_svc_get_video_last_play_time_by_video_url(const char - *szPath) -{ - if (!szPath) { - VideoLogError("No exist video path."); - return 0; - } - - VideoLogInfo("szPath : %s", szPath); - - int nLastPlayedTime = 0; - media_info_h pVideoItem = NULL; - filter_h m_FilterHandle = NULL; - char szTmpStr[STR_LEN_MAX] = { 0, }; - - if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to create media filter handle."); - return FALSE; - } - - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", - szPath); - if (media_filter_set_condition - (m_FilterHandle, szTmpStr, - MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_info_foreach_media_from_db - (m_FilterHandle, mp_util_svc_iterate_for_get_video_item_cb, - &pVideoItem) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError - ("Fail to get video item list with filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_filter_destroy(m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to destroy media filter handle."); - return FALSE; - } - - if (pVideoItem) { - video_meta_h pVideoMetaHandle = NULL; - if (media_info_get_video(pVideoItem, &pVideoMetaHandle) == - MEDIA_CONTENT_ERROR_NONE) { - video_meta_get_played_position(pVideoMetaHandle, - &nLastPlayedTime); - VideoLogInfo("Last Played Time : %d", nLastPlayedTime); - video_meta_destroy(pVideoMetaHandle); - } - media_info_destroy(pVideoItem); - } - - return (unsigned int) nLastPlayedTime; -} - -unsigned int mp_util_svc_get_video_duration_by_video_url(const char - *szPath) -{ - if (!szPath) { - VideoLogError("No exist video path."); - return 0; - } - - VideoSecureLogInfo("szPath : %s", szPath); - - int nDurationTime = 0; - media_info_h pVideoItem = NULL; - filter_h m_FilterHandle = NULL; - char szTmpStr[STR_LEN_MAX] = { 0, }; - - if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to create media filter handle."); - return FALSE; - } - - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", - szPath); - if (media_filter_set_condition - (m_FilterHandle, szTmpStr, - MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_info_foreach_media_from_db - (m_FilterHandle, mp_util_svc_iterate_for_get_video_item_cb, - &pVideoItem) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError - ("Fail to get video item list with filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_filter_destroy(m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to destroy media filter handle."); - return FALSE; - } - - if (pVideoItem) { - video_meta_h pVideoMetaHandle = NULL; - if (media_info_get_video(pVideoItem, &pVideoMetaHandle) == - MEDIA_CONTENT_ERROR_NONE) { - video_meta_get_duration(pVideoMetaHandle, &nDurationTime); - video_meta_destroy(pVideoMetaHandle); - } - media_info_destroy(pVideoItem); - } - - return (unsigned int) nDurationTime; -} - -int mp_util_svc_get_video_file_size_by_video_url(const char *szPath) -{ - if (!szPath) { - VideoLogError("No exist video path."); - return 0; - } - - VideoSecureLogInfo("szPath : %s", szPath); - - unsigned long long nSize = 0; - media_info_h pVideoItem = NULL; - filter_h m_FilterHandle = NULL; - char szTmpStr[STR_LEN_MAX] = { 0, }; - - if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to create media filter handle."); - return FALSE; - } - - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", - szPath); - if (media_filter_set_condition - (m_FilterHandle, szTmpStr, - MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to set filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_info_foreach_media_from_db - (m_FilterHandle, mp_util_svc_iterate_for_get_video_item_cb, - &pVideoItem) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError - ("Fail to get video item list with filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; - } - - if (media_filter_destroy(m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to destroy media filter handle."); + media_info_delete_from_db(szMediaID); + free(szMediaID); + } else { + VideoLogError("No exist media ID in index %d of list.", + nVideoItemIndex); + return FALSE; + } + } else { + VideoLogError("Fail to remove item in media svc and list."); return FALSE; } - if (pVideoItem) { - media_info_get_size(pVideoItem, &nSize); - media_info_destroy(pVideoItem); - } - - return nSize; + return TRUE; } -char *mp_util_svc_get_video_Thumbnail_by_video_url(const char *szMediaUri) +bool mp_util_svc_get_video_id_by_video_url(const char *szPath, + char **szVideoID) { - if (!szMediaUri) { - VideoLogError("No exist video path."); - return NULL; - } - media_info_h pVideoItem = NULL; filter_h m_FilterHandle = NULL; - char *szThumbnailPath = NULL; char szTmpStr[STR_LEN_MAX] = { 0, }; + bool bRet = FALSE; + int ret = -1; if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to create media filter handle."); - return FALSE; + VideoLogInfo("Fail to create media filter handle."); + bRet = FALSE; } - memset(szTmpStr, 0, STR_LEN_MAX); - snprintf(szTmpStr, STR_LEN_MAX, - "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", - szMediaUri); - if (media_filter_set_condition - (m_FilterHandle, szTmpStr, - MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { + snprintf(szTmpStr, STR_LEN_MAX, "MEDIA_PATH = \"%s\"", szPath); + if (media_filter_set_condition(m_FilterHandle, + szTmpStr, + MEDIA_CONTENT_COLLATE_DEFAULT) != + MEDIA_CONTENT_ERROR_NONE) { VideoLogError("Fail to set filter condition."); media_filter_destroy(m_FilterHandle); - return FALSE; + m_FilterHandle = NULL; + bRet = FALSE; } - if (media_info_foreach_media_from_db - (m_FilterHandle, mp_util_svc_iterate_for_get_video_item_cb, - &pVideoItem) != MEDIA_CONTENT_ERROR_NONE) { + if (media_info_foreach_media_from_db(m_FilterHandle, + mp_util_svc_iterate_for_get_video_item_cb, + &pVideoItem) != + MEDIA_CONTENT_ERROR_NONE) { VideoLogError ("Fail to get video item list with filter condition."); - media_filter_destroy(m_FilterHandle); - return FALSE; + if (m_FilterHandle) { + media_filter_destroy(m_FilterHandle); + m_FilterHandle = NULL; + } + bRet = FALSE; } - if (media_filter_destroy(m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to destroy media filter handle."); - return FALSE; + if (m_FilterHandle) { + ret = media_filter_destroy(m_FilterHandle); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + VideoLogError("Fail to destroy media filter handle."); + m_FilterHandle = NULL; + } + bRet = FALSE; } if (pVideoItem) { - media_info_get_thumbnail_path(pVideoItem, &szThumbnailPath); - VideoSecureLogInfo("Video thumbnail file path : %s", - szThumbnailPath); + char *szMediaID = NULL; + media_info_get_media_id(pVideoItem, &szMediaID); + *szVideoID = szMediaID; media_info_destroy(pVideoItem); + bRet = TRUE; + } else { + bRet = FALSE; } - return szThumbnailPath; + return bRet; } -int mp_util_svc_get_video_width_by_video_url(const char *szMediaUri) +unsigned int mp_util_svc_get_video_last_play_time_by_video_url(const char + *szPath) { - if (!szMediaUri) { + if (!szPath) { VideoLogError("No exist video path."); return 0; } - VideoSecureLogInfo("szPath : %s", szMediaUri); + VideoLogInfo("szPath : %s", szPath); + int nLastPlayedTime = 0; media_info_h pVideoItem = NULL; filter_h m_FilterHandle = NULL; char szTmpStr[STR_LEN_MAX] = { 0, }; - int nWidth = 0; if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { VideoLogError("Fail to create media filter handle."); return FALSE; } - memset(szTmpStr, 0, STR_LEN_MAX); snprintf(szTmpStr, STR_LEN_MAX, "MEDIA_TYPE = 1 AND (MEDIA_STORAGE_TYPE=0 OR MEDIA_STORAGE_TYPE=1 OR MEDIA_STORAGE_TYPE=101 OR MEDIA_STORAGE_TYPE=121) AND MEDIA_PATH = \"%s\"", - szMediaUri); + szPath); if (media_filter_set_condition (m_FilterHandle, szTmpStr, MEDIA_CONTENT_COLLATE_DEFAULT) != MEDIA_CONTENT_ERROR_NONE) { @@ -1524,34 +985,30 @@ int mp_util_svc_get_video_width_by_video_url(const char *szMediaUri) if (pVideoItem) { video_meta_h pVideoMetaHandle = NULL; - - if (media_info_get_video(pVideoItem, &pVideoMetaHandle) != + if (media_info_get_video(pVideoItem, &pVideoMetaHandle) == MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to get pVideoMetaHandle."); - } else { - if (pVideoMetaHandle) { - video_meta_get_width(pVideoMetaHandle, &nWidth); - video_meta_destroy(pVideoMetaHandle); - } else { - VideoLogError("No exist pVideoMetaHandle"); - } + video_meta_get_played_position(pVideoMetaHandle, + &nLastPlayedTime); + VideoLogInfo("Last Played Time : %d", nLastPlayedTime); + video_meta_destroy(pVideoMetaHandle); } + media_info_destroy(pVideoItem); } - return nWidth; + return (unsigned int) nLastPlayedTime; } -int mp_util_svc_get_video_height_by_video_url(const char *szMediaUri) +char *mp_util_svc_get_video_Thumbnail_by_video_url(const char *szMediaUri) { if (!szMediaUri) { VideoLogError("No exist video path."); - return 0; + return NULL; } media_info_h pVideoItem = NULL; filter_h m_FilterHandle = NULL; + char *szThumbnailPath = NULL; char szTmpStr[STR_LEN_MAX] = { 0, }; - int nHeight = 0; if (media_filter_create(&m_FilterHandle) != MEDIA_CONTENT_ERROR_NONE) { VideoLogError("Fail to create media filter handle."); @@ -1585,22 +1042,13 @@ int mp_util_svc_get_video_height_by_video_url(const char *szMediaUri) } if (pVideoItem) { - video_meta_h pVideoMetaHandle = NULL; - - if (media_info_get_video(pVideoItem, &pVideoMetaHandle) != - MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("Fail to get pVideoMetaHandle."); - } else { - if (pVideoMetaHandle) { - video_meta_get_height(pVideoMetaHandle, &nHeight); - video_meta_destroy(pVideoMetaHandle); - } else { - VideoLogError("No exist pVideoMetaHandle"); - } - } + media_info_get_thumbnail_path(pVideoItem, &szThumbnailPath); + VideoSecureLogInfo("Video thumbnail file path : %s", + szThumbnailPath); + media_info_destroy(pVideoItem); } - return nHeight; + return szThumbnailPath; } void mp_util_svc_set_video_last_played_time_by_url(char *szMediaUri, @@ -1669,125 +1117,6 @@ void mp_util_svc_set_video_last_played_time_by_url(char *szMediaUri, } } -bool mp_util_svc_get_video_current_url_pre_next_item(char *szCurrMediaUri, - char *szPreMediaUri, - char *szNextMediaUri, - bool bLoop) -{ - - if (!szCurrMediaUri) { - VideoLogError("[ERR] No exist current file path."); - return FALSE; - } - - if (!VideoItemList) { - VideoLogError("No exist VideoItemList."); - if (bLoop) { - strncpy(szNextMediaUri, szCurrMediaUri, - (sizeof(char) * STR_LEN_MAX) - 1); - } - return FALSE; - } - - int nCount = 0; - int nListSize = 0; - media_info_h pVideoItem = NULL; - Eina_List *pIterateList = NULL; - - memset(szPreMediaUri, 0, sizeof(char) * STR_LEN_MAX); - memset(szNextMediaUri, 0, sizeof(char) * STR_LEN_MAX); - - nListSize = eina_list_count(VideoItemList); - - if (nListSize <= 1) { - VideoLogError("Video list size == 1."); - return FALSE; - } - - EINA_LIST_FOREACH(VideoItemList, pIterateList, pVideoItem) { - if (pVideoItem == NULL) { - continue; - } - - char *szVideoItemFilePath = NULL; - media_info_get_file_path(pVideoItem, &szVideoItemFilePath); - if (szVideoItemFilePath) { - VideoSecureLogInfo("URL of the File item - %s (%d / %d)", - szVideoItemFilePath, nCount, nListSize); - if (!strcmp(szVideoItemFilePath, szCurrMediaUri)) { - free(szVideoItemFilePath); - szVideoItemFilePath = NULL; - - pVideoItem = NULL; - pVideoItem = - (media_info_h) eina_list_nth(VideoItemList, - nCount - 1); - if (pVideoItem) { - media_info_get_file_path(pVideoItem, - &szVideoItemFilePath); - strncpy(szPreMediaUri, szVideoItemFilePath, - (sizeof(char) * STR_LEN_MAX) - 1); - - free(szVideoItemFilePath); - szVideoItemFilePath = NULL; - } else if (bLoop) { - media_info_h m_LastItem = - (media_info_h) eina_list_nth(VideoItemList, - nListSize - 1); - VideoLogError("%p", m_LastItem); - if (m_LastItem) { - media_info_get_file_path(m_LastItem, - &szVideoItemFilePath); - strncpy(szPreMediaUri, szVideoItemFilePath, - (sizeof(char) * STR_LEN_MAX) - 1); - - free(szVideoItemFilePath); - szVideoItemFilePath = NULL; - } - m_LastItem = NULL; - } - - pVideoItem = NULL; - pVideoItem = - (media_info_h) eina_list_nth(VideoItemList, - nCount + 1); - if (pVideoItem) { - media_info_get_file_path(pVideoItem, - &szVideoItemFilePath); - strncpy(szNextMediaUri, szVideoItemFilePath, - (sizeof(char) * STR_LEN_MAX) - 1); - - free(szVideoItemFilePath); - szVideoItemFilePath = NULL; - } else if (bLoop) { - media_info_h m_FirstItem = - (media_info_h) eina_list_nth(VideoItemList, 0); - if (m_FirstItem) { - media_info_get_file_path(m_FirstItem, - &szVideoItemFilePath); - strncpy(szNextMediaUri, szVideoItemFilePath, - (sizeof(char) * STR_LEN_MAX) - 1); - - free(szVideoItemFilePath); - szVideoItemFilePath = NULL; - } - m_FirstItem = NULL; - } - - VideoSecureLogInfo("PreMediaUri-NextMediaUri:%s-%s", - szPreMediaUri, szNextMediaUri); - - return TRUE; - } - free(szVideoItemFilePath); - szVideoItemFilePath = NULL; - } - - ++nCount; - } - - return FALSE; -} char *mp_util_svc_get_video_url(const int nVideoItemIndex) { @@ -2012,84 +1341,6 @@ int mp_util_svc_get_video_item_height(const int nVideoItemIndex) return nHeight; } -time_t mp_util_svc_get_video_item_data_time(const int nVideoItemIndex) -{ - if (!VideoItemList) { - VideoLogError("Not exist video item list handle."); - return 0; - } - - time_t nDateTime = 0; - media_info_h pVideoItem = - (media_info_h) eina_list_nth(VideoItemList, nVideoItemIndex); - if (pVideoItem) { - if (media_info_get_modified_time(pVideoItem, &nDateTime) != - MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("media_info_get_modified_time fail"); - return 0; - } - VideoLogError("Video date time : %d", nDateTime); - } - - return nDateTime; -} - -char *mp_util_svc_get_video_item_extension(const int nVideoItemIndex) -{ - if (!VideoItemList) { - VideoLogError("Not exist video item list handle."); - return 0; - } - - return NULL; -} - -double mp_util_svc_get_video_item_longitude(const int nVideoItemIndex) -{ - if (!VideoItemList) { - VideoLogError("Not exist video item list handle."); - return 0; - } - - double nLongitude = 0; - media_info_h pVideoItem = - (media_info_h) eina_list_nth(VideoItemList, nVideoItemIndex); - if (pVideoItem) { - int nRet = MEDIA_CONTENT_ERROR_NONE; - nRet = media_info_get_longitude(pVideoItem, &nLongitude); - if (nRet != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("media_info_get_longitude failed : [%d]!!!", - nRet); - return 0; - } - } - - return nLongitude; -} - -double mp_util_svc_get_video_item_latitude(const int nVideoItemIndex) -{ - if (!VideoItemList) { - VideoLogError("Not exist video item list handle."); - return 0; - } - - double dLatitude = 0; - media_info_h pVideoItem = - (media_info_h) eina_list_nth(VideoItemList, nVideoItemIndex); - if (pVideoItem) { - int nRet = MEDIA_CONTENT_ERROR_NONE; - nRet = media_info_get_latitude(pVideoItem, &dLatitude); - if (nRet != MEDIA_CONTENT_ERROR_NONE) { - VideoLogError("media_info_get_latitude failed : [%d]!!!", - nRet); - return 0; - } - } - - return dLatitude; -} - char *mp_util_svc_get_video_item_modified_time(const int nVideoItemIndex) { if (!VideoItemList) { @@ -2137,29 +1388,6 @@ int mp_util_svc_get_number_of_video_item_by_type(void) return nNumberOfVideoItemByType; } -int mp_util_svc_get_total_video_type_files(void) -{ - - return (int) nTotalVideoTypeFiles; -} - -void *mp_util_svc_get_video_item(const int nVideoItemIndex) -{ - if (!VideoItemList) { - VideoLogError("Not exist video item list handle."); - return NULL; - } - - if (nVideoItemIndex < 0 - || nVideoItemIndex >= - mp_util_svc_get_video_list_size_for_checking_index()) { - VideoLogError("Error number of list item."); - return NULL; - } - - return (void *) eina_list_nth(VideoItemList, nVideoItemIndex); -} - void mp_util_svc_print_list_info(void) { if (!VideoItemList) { @@ -3735,7 +2963,7 @@ static int __mp_util_svc_sort_by_size(const void *d1, const void *d2) } else if (nFileSize1 > nFileSize2) { result = -1; } else { - result = -1; + result = 0; } return result; -- 2.7.4