* limitations under the License.
*/
-#include <media_filter.h>
-#include <media_info.h>
+
#include <media_info_private.h>
-#include <media_group.h>
int media_album_get_album_count_from_db(filter_h filter, int *album_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if(album_count != NULL)
- {
+ if (album_count != NULL)
ret = _media_db_get_group_count(filter, MEDIA_GROUP_ALBUM, album_count);
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if(callback == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ if (callback == NULL) {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if((album_id > 0) && (media_count != NULL))
- {
+ if ((album_id > 0) && (media_count != NULL))
ret = _media_db_get_group_item_count_by_id(album_id, filter, MEDIA_GROUP_ALBUM, media_count);
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if((album_id > 0) && (callback != NULL))
- {
+ if ((album_id > 0) && (callback != NULL))
ret = _media_db_get_group_item_by_id(album_id, filter, callback, user_data, MEDIA_GROUP_ALBUM);
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
sqlite3_stmt *stmt = NULL;
- char select_query[DEFAULT_QUERY_SIZE];
-
- media_content_debug_func();
+ char select_query[DEFAULT_QUERY_SIZE] = {0, };
- if(album_id < 0)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retvm_if(album_id <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid album_id [%d]", album_id);
+ content_retvm_if(album == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid album");
memset(select_query, 0x00, sizeof(select_query));
snprintf(select_query, sizeof(select_query), SELECT_ALBUM_FROM_ALBUM, album_id);
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ ret = _content_get_result(select_query, &stmt);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
- while(sqlite3_step(stmt) == SQLITE_ROW)
- {
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
media_album_s *_album = (media_album_s*)calloc(1, sizeof(media_album_s));
+ if (_album == NULL) {
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ SQLITE3_FINALIZE(stmt);
+ return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ }
- _album->album_id = (int)sqlite3_column_int(stmt, 0);
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
- _album->name = strdup((const char *)sqlite3_column_text(stmt, 1));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
- _album->artist = strdup((const char *)sqlite3_column_text(stmt, 2));
+ _album->album_id = album_id;
+ _album->name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+ _album->artist = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+ _album->album_art_path = g_strdup((const char *)sqlite3_column_text(stmt, 2));
*album = (media_album_h)_album;
}
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
+ SQLITE3_FINALIZE(stmt);
return ret;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_album_s *_album = (media_album_s*)album;
- media_content_debug_func();
-
- if(_album)
- {
+ if (_album) {
SAFE_FREE(_album->name);
SAFE_FREE(_album->artist);
SAFE_FREE(_album->album_art_path);
SAFE_FREE(_album);
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_album_s *_src = (media_album_s*)src;
- if(_src != NULL)
- {
+ if (_src != NULL) {
media_album_s *_dst = (media_album_s*)calloc(1, sizeof(media_album_s));
-
- if(_dst == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
+ content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
_dst->album_id = _src->album_id;
- if(STRING_VALID(_src->name))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ if (_src->name != NULL) {
+ _dst->name = g_strdup(_src->name);
+ if (_dst->name == NULL) {
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
media_album_destroy((media_album_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
}
- if(STRING_VALID(_src->artist))
- {
- _dst->artist = strdup(_src->artist);
- if(_dst->artist == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ if (_src->artist != NULL) {
+ _dst->artist = g_strdup(_src->artist);
+ if (_dst->artist == NULL) {
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
media_album_destroy((media_album_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
}
- if(STRING_VALID(_src->album_art_path))
- {
- _dst->album_art_path = strdup(_src->album_art_path);
- if(_dst->album_art_path == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ if (_src->album_art_path != NULL) {
+ _dst->album_art_path = g_strdup(_src->album_art_path);
+ if (_dst->album_art_path == NULL) {
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
media_album_destroy((media_album_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
*dst = (media_album_h)_dst;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_album_s *_album = (media_album_s*)album;
- if(_album && album_id)
- {
+ if (_album && album_id) {
*album_id = _album->album_id;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_album_s *_album = (media_album_s*)album;
- if(_album)
- {
- if(STRING_VALID(_album->name))
- {
- *name = strdup(_album->name);
- if(*name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ if (_album) {
+ if (_album->name != NULL) {
+ *name = g_strdup(_album->name);
+ content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*name = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_album_s *_album = (media_album_s*)album;
- if(_album)
- {
- if(STRING_VALID(_album->artist))
- {
- *artist = strdup(_album->artist);
- if(*artist == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ if (_album) {
+ if (_album->artist != NULL) {
+ *artist = g_strdup(_album->artist);
+ content_retvm_if(*artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*artist = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_album_s *_album = (media_album_s*)album;
- if(_album)
- {
- if(STRING_VALID(_album->album_art_path))
- {
- *album_art = strdup(_album->album_art_path);
- if(*album_art == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ if (_album) {
+ if (_album->album_art_path != NULL) {
+ *album_art = g_strdup(_album->album_art_path);
+ content_retvm_if(*album_art == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
*album_art = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int media_group_get_group_count_from_db(filter_h filter, media_group_e group, int *group_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+#ifdef _USE_TVPD_MODE
+ if ((group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_GROUP_MAX) || (group_count == NULL)) {
+#else
+ if ((group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_CONTENT_GROUP_MAX) || (group_count == NULL)) {
+#endif
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ } else {
+ ret = _media_db_get_media_group_count(group, filter, group_count);
+ }
- media_content_debug_func();
+ return ret;
+}
+#ifdef _USE_TVPD_MODE
+int media_group_foreach_group_and_count_from_db(filter_h filter, media_group_e group, media_group_and_count_cb callback, void *user_data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
- if((group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD) || (group_count == NULL))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ if ((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_GROUP_MAX)) {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- else
- {
- ret = _media_db_get_media_group_count(group, filter, group_count);
+ } else {
+ ret = _media_db_get_media_group_and_count(group, filter, callback, user_data);
}
return ret;
}
+#endif
int media_group_foreach_group_from_db(filter_h filter, media_group_e group, media_group_cb callback, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_content_debug_func();
-
- if((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+#ifdef _USE_TVPD_MODE
+ if ((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_GROUP_MAX)) {
+#else
+ if ((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_CONTENT_GROUP_MAX)) {
+#endif
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- else
- {
+ } else {
ret = _media_db_get_media_group(group, filter, callback, user_data);
}
int media_group_get_media_count_from_db(const char *group_name, media_group_e group, filter_h filter, int *media_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_content_debug_func();
-
- if((media_count == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+#ifdef _USE_TVPD_MODE
+ if ((media_count == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_GROUP_MAX)) {
+#else
+ if ((media_count == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_CONTENT_GROUP_MAX)) {
+#endif
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- else
- {
- ret = _media_db_get_media_group_item_count(group_name, group, filter, media_count);
+ } else {
+ ret = _media_db_get_media_group_item_count(group_name, filter, group, media_count);
}
return ret;
int media_group_foreach_media_from_db(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_content_debug_func();
-
- if((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+#ifdef _USE_TVPD_MODE
+ if ((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_GROUP_MAX)) {
+#else
+ if ((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group >= MEDIA_CONTENT_GROUP_MAX)) {
+#endif
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- else
- {
- ret = _media_db_get_media_group_item(group_name, group, filter, callback, user_data);
+ } else {
+ ret = _media_db_get_media_group_item(group_name, filter, group, callback, user_data);
}
return ret;