* 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)
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);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
if (callback == NULL) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
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);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
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);
+ 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];
+ 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) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ 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);
- _album->name = g_strdup((const char *)sqlite3_column_text(stmt, 1));
- _album->artist = g_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;
}
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_src != NULL) {
media_album_s *_dst = (media_album_s*)calloc(1, sizeof(media_album_s));
- media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
_dst->album_id = _src->album_id;
if (_src->name != NULL) {
_dst->name = g_strdup(_src->name);
if (_dst->name == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ 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 (_src->artist != NULL) {
_dst->artist = g_strdup(_src->artist);
if (_dst->artist == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ 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 (_src->album_art_path != NULL) {
_dst->album_art_path = g_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);
+ 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;
}
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
*album_id = _album->album_id;
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_album) {
if (_album->name != NULL) {
*name = g_strdup(_album->name);
- media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ 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);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_album) {
if (_album->artist != NULL) {
*artist = g_strdup(_album->artist);
- media_content_retvm_if(*artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ 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);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_album) {
if (_album->album_art_path != NULL) {
*album_art = g_strdup(_album->album_art_path);
- media_content_retvm_if(*album_art == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ 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);
+ 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)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+#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);
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 ((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_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;
-
+#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)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+#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(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;
-
+#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)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+#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, filter, group, media_count);
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;
-
+#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)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+#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, filter, group, callback, user_data);