int mc_db_update_playback_info(const char *table_name, const media_controller_playback_s playback);
int mc_db_update_whole_metadata(const char *server_name,
const char *title, const char *artist, const char *album, const char *author, const char *genre, const char *duration, const char *date,
- const char *copyright, const char *description, const char *track_num, const char *picture);
+ const char *copyright, const char *description, const char *track_num, const char *picture, const char *season, const char *episode, const char *resolution);
int mc_db_update_shuffle_mode(const char *table_name, int shuffle_mode);
int mc_db_update_repeat_mode(const char *table_name, int repeat_mode);
int mc_db_update_icon_uri(const char *server_name, const char *uri);
int mc_metadata_get(mc_metadata_h metadata, mc_meta_e attribute, char **value);
/**
+ * @brief Encodes the season data for use in metadata.
+ * @details You can set various metadata information by using functions such as mc_server_set_metadata() and mc_server_add_item_to_playlist().
+ * However, if you want to set metadata information regarding the season,\n
+ * you should encode the season information with this function and then set the encoded data.\n
+ * Otherwise, you will receive an error. \n
+ * @a season_title can be NULL. If it is NULL, the decoded season_title will also be NULL.\n
+ * @since_tizen 5.5
+ *
+ * @remarks The @a season should be released using free(). \n
+ *
+ * @param[in] season_num The season number
+ * @param[in] season_title The season title
+ * @param[out] encoded_season The encoded season information
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see mc_server_set_metadata()
+ * @see mc_server_add_item_to_playlist()
+ * @see mc_metadata_decode_season()
+ */
+int mc_metadata_encode_season(int season_num, const char *season_title, char **encoded_season);
+
+/**
+ * @brief Encodes the episode data for use in metadata.
+ * @details You can set various metadata information by using functions such as mc_server_set_metadata() and mc_server_add_item_to_playlist().
+ * However, if you want to set metadata information regarding the episode,\n
+ * you should encode the episode information with this function and then set the encoded data.\n
+ * Otherwise, you will receive an error. \n
+ * @a episode_title can be NULL. If it is NULL, the decoded episode_title will also be NULL.\n
+ * @since_tizen 5.5
+ *
+ * @remarks The @a episode should be released using free(). \n
+ *
+ * @param[in] episode_num The episode number
+ * @param[in] episode_title The episode title
+ * @param[out] encoded_episode The encoded episode information
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see mc_server_set_metadata()
+ * @see mc_server_add_item_to_playlist()
+ * @see mc_metadata_decode_episode()
+ */
+int mc_metadata_encode_episode(int episode_num, const char *episode_title, char **encoded_episode);
+
+/**
+ * @brief Encodes the resolution data for use in metadata.
+ * @details You can set various metadata information by using functions such as mc_server_set_metadata() and mc_server_add_item_to_playlist().
+ * However, if you want to set metadata information regarding the resolution,\n
+ * you should encode the resolution information with this function and then set the encoded data.\n
+ * Otherwise, you will receive an error. \n
+ * @since_tizen 5.5
+ *
+ * @remarks The @a resolution should be released using free(). \n
+ *
+ * @param[in] width Content width
+ * @param[in] height Content height
+ * @param[out] encoded_resolution The encoded resolution information
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see mc_server_set_metadata()
+ * @see mc_server_add_item_to_playlist()
+ * @see mc_metadata_decode_resolution()
+ */
+int mc_metadata_encode_resolution(unsigned int width, unsigned int height, char **encoded_resolution);
+
+/**
+ * @brief Decodes the season data.
+ * @details You can get various metadata information by using mc_metadata_get().
+ * However, if you want to get proper season number and season title,\n
+ * you should use this function on results of calling mc_metadata_get().\n
+ * Otherwise, you will operate on an unreadable value. \n
+ * @since_tizen 5.5
+ *
+ * @remarks The @a season_title should be released using free(). \n
+ *
+ * @param[in] encoded_season The encoded season information
+ * @param[out] season_num The season number
+ * @param[out] season_title The season title
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @pre Get the encoded season information by calling mc_metadata_get()
+ *
+ * @see mc_metadata_get()
+ * @see mc_metadata_encode_season()
+ */
+int mc_metadata_decode_season(const char *encoded_season, int *season_num, char **season_title);
+
+/**
+ * @brief Decodes the episode data.
+ * @details You can get various metadata information by using mc_metadata_get().
+ * However, if you want to get proper episode number and episode title,\n
+ * you should use this function on results of calling mc_metadata_get().\n
+ * Otherwise, you will operate on an unreadable value. \n
+ * @since_tizen 5.5
+ *
+ * @remarks The @a episode_title should be released using free(). \n
+ *
+ * @param[in] encoded_episode The encoded episode information
+ * @param[out] episode_num The episode number
+ * @param[out] episode_title The episode title
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @pre Get the encoded episode information by calling mc_metadata_get()
+ *
+ * @see mc_metadata_get()
+ * @see mc_metadata_encode_episode()
+ */
+int mc_metadata_decode_episode(const char *encoded_episode, int *episode_num, char **episode_title);
+
+/**
+ * @brief Decodes the resolution data.
+ * @details You can get various metadata information by using mc_metadata_get().
+ * However, if you want to get proper resolution, \n
+ * you should use this function on results of calling mc_metadata_get().\n
+ * Otherwise, you will operate on an unreadable value. \n
+ * @since_tizen 5.5
+ *
+ * @param[in] encoded_resolution The encoded resolution information
+ * @param[out] width Content width
+ * @param[out] height Content height
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTROLLER_ERROR_NONE Successful
+ * @retval #MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @pre Get the encoded resolution information by calling mc_metadata_get()
+ *
+ * @see mc_metadata_get()
+ * @see mc_metadata_encode_resolution()
+ */
+int mc_metadata_decode_resolution(const char *encoded_resolution, unsigned int *width, unsigned int *height);
+
+/**
* @}
*/
char *description;
char *track_num;
char *picture;
+ char *season;
+ char *episode;
+ char *resolution;
} media_controller_metadata_s;
typedef struct {
int _mc_playlist_update(mc_priv_type_e type, const char *controller_name, mc_playlist_h playlist);
int _mc_metadata_set(mc_metadata_h metadata, mc_meta_e attribute, const char *value);
+int _parse_encoded_meta(mc_meta_e attribute, const char *encoded_meta, int *int_val_1, char **str_val, int *int_val_2);
#ifdef __cplusplus
}
* @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
*/
typedef enum {
- MC_META_MEDIA_TITLE = 0, /**< Title */
- MC_META_MEDIA_ARTIST, /**< Artist */
- MC_META_MEDIA_ALBUM, /**< Album */
- MC_META_MEDIA_AUTHOR, /**< Author */
- MC_META_MEDIA_GENRE, /**< Genre */
- MC_META_MEDIA_DURATION, /**< Duration */
- MC_META_MEDIA_DATE, /**< Date */
- MC_META_MEDIA_COPYRIGHT, /**< Copyright */
- MC_META_MEDIA_DESCRIPTION, /**< Description */
- MC_META_MEDIA_TRACK_NUM, /**< Track Number */
- MC_META_MEDIA_PICTURE, /**< Picture. Album Art */
+ MC_META_MEDIA_TITLE = 0, /**< Title */
+ MC_META_MEDIA_ARTIST, /**< Artist */
+ MC_META_MEDIA_ALBUM, /**< Album */
+ MC_META_MEDIA_AUTHOR, /**< Author */
+ MC_META_MEDIA_GENRE, /**< Genre */
+ MC_META_MEDIA_DURATION, /**< Duration */
+ MC_META_MEDIA_DATE, /**< Date */
+ MC_META_MEDIA_COPYRIGHT, /**< Copyright */
+ MC_META_MEDIA_DESCRIPTION, /**< Description */
+ MC_META_MEDIA_TRACK_NUM, /**< Track Number */
+ MC_META_MEDIA_PICTURE, /**< Picture. Album Art */
+ MC_META_MEDIA_SEASON, /**< Season (Since 5.5) */
+ MC_META_MEDIA_EPISODE, /**< Episode (Since 5.5) */
+ MC_META_MEDIA_RESOLUTION, /**< Content resolution (Since 5.5) */
} mc_meta_e;
/**
MC_SERVER_FIELD_DESCRIPTION,
MC_SERVER_FIELD_TRACK_NUM,
MC_SERVER_FIELD_PICTURE,
+ MC_SERVER_FIELD_SEASON,
+ MC_SERVER_FIELD_EPISODE,
+ MC_SERVER_FIELD_RESOLUTION,
MC_SERVER_FIELD_SHUFFLE_MODE,
MC_SERVER_FIELD_REPEAT_MODE,
} server_table_field_e;
int mc_db_update_whole_metadata(const char *server_name,
const char *title, const char *artist, const char *album, const char *author, const char *genre, const char *duration, const char *date,
- const char *copyright, const char *description, const char *track_num, const char *picture)
+ const char *copyright, const char *description, const char *track_num, const char *picture, const char *season, const char *episode, const char *resolution)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
char *sql_str = NULL;
mc_retvm_if(server_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "server_name is NULL");
- sql_str = g_strdup_printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", MC_DB_CMD_UPDATE_META, MC_STRING_DELIMITER, server_name, MC_STRING_DELIMITER,
+ sql_str = g_strdup_printf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", MC_DB_CMD_UPDATE_META, MC_STRING_DELIMITER, server_name, MC_STRING_DELIMITER,
title, MC_STRING_DELIMITER,
artist, MC_STRING_DELIMITER,
album, MC_STRING_DELIMITER,
copyright, MC_STRING_DELIMITER,
description, MC_STRING_DELIMITER,
track_num, MC_STRING_DELIMITER,
- picture);
+ picture, MC_STRING_DELIMITER,
+ season, MC_STRING_DELIMITER,
+ episode, MC_STRING_DELIMITER,
+ resolution);
ret = __mc_db_update_db(MC_PRIV_TYPE_SERVER, sql_str);
_metadata->description = g_strdup((const char *)sqlite3_column_text(stmt, col++));
_metadata->track_num = g_strdup((const char *)sqlite3_column_text(stmt, col++));
_metadata->picture = g_strdup((const char *)sqlite3_column_text(stmt, col++));
+ _metadata->season = g_strdup((const char *)sqlite3_column_text(stmt, col++));
+ _metadata->episode = g_strdup((const char *)sqlite3_column_text(stmt, col++));
+ _metadata->resolution = g_strdup((const char *)sqlite3_column_text(stmt, col++));
*metadata = (mc_metadata_h)_metadata;
#include "media_controller_private.h"
#include "media_controller_db.h"
+#include "mc_util.h"
+
+#define KEY_SEASON "SEASON"
+#define KEY_EPISODE "EPISODE"
+#define KEY_RESOLUTION "RESOLUTION"
int _mc_metadata_set(mc_metadata_h metadata, mc_meta_e attribute, const char *value)
{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
media_controller_metadata_s *_metadata = (media_controller_metadata_s *)metadata;
+ int int_val_1 = 0;
+ int int_val_2 = 0;
+ char *str_val = NULL;
mc_retvm_if(_metadata == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
MC_SAFE_FREE(_metadata->picture);
_metadata->picture = g_strdup(value);
break;
+ case MC_META_MEDIA_SEASON:
+ ret = _parse_encoded_meta(MC_META_MEDIA_SEASON, value, &int_val_1, &str_val, NULL);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "Invalid meta");
+
+ MC_SAFE_FREE(str_val);
+
+ MC_SAFE_FREE(_metadata->season);
+ _metadata->season = g_strdup(value);
+ break;
+ case MC_META_MEDIA_EPISODE:
+ ret = _parse_encoded_meta(MC_META_MEDIA_EPISODE, value, &int_val_1, &str_val, NULL);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "Invalid meta");
+
+ MC_SAFE_FREE(str_val);
+
+ MC_SAFE_FREE(_metadata->episode);
+ _metadata->episode = g_strdup(value);
+ break;
+ case MC_META_MEDIA_RESOLUTION:
+ ret = _parse_encoded_meta(MC_META_MEDIA_RESOLUTION, value, &int_val_1, NULL, &int_val_2);
+ mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "Invalid meta");
+
+ MC_SAFE_FREE(str_val);
+
+ MC_SAFE_FREE(_metadata->resolution);
+ _metadata->resolution = g_strdup(value);
+ break;
default:
mc_error("Invalid Parameter [%d]", attribute);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
_dst->description = g_strdup(_src->description);
_dst->track_num = g_strdup(_src->track_num);
_dst->picture = g_strdup(_src->picture);
+ _dst->season = g_strdup(_src->season);
+ _dst->episode = g_strdup(_src->episode);
+ _dst->resolution = g_strdup(_src->resolution);
*dst = (mc_metadata_h)_dst;
mc_retvm_if(mc_metadata == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- MC_SAFE_FREE(mc_metadata->title);
- MC_SAFE_FREE(mc_metadata->artist);
- MC_SAFE_FREE(mc_metadata->album);
- MC_SAFE_FREE(mc_metadata->author);
- MC_SAFE_FREE(mc_metadata->genre);
- MC_SAFE_FREE(mc_metadata->duration);
- MC_SAFE_FREE(mc_metadata->date);
- MC_SAFE_FREE(mc_metadata->copyright);
- MC_SAFE_FREE(mc_metadata->description);
- MC_SAFE_FREE(mc_metadata->track_num);
- MC_SAFE_FREE(mc_metadata->picture);
+ MC_SAFE_G_FREE(mc_metadata->title);
+ MC_SAFE_G_FREE(mc_metadata->artist);
+ MC_SAFE_G_FREE(mc_metadata->album);
+ MC_SAFE_G_FREE(mc_metadata->author);
+ MC_SAFE_G_FREE(mc_metadata->genre);
+ MC_SAFE_G_FREE(mc_metadata->duration);
+ MC_SAFE_G_FREE(mc_metadata->date);
+ MC_SAFE_G_FREE(mc_metadata->copyright);
+ MC_SAFE_G_FREE(mc_metadata->description);
+ MC_SAFE_G_FREE(mc_metadata->track_num);
+ MC_SAFE_G_FREE(mc_metadata->picture);
+ MC_SAFE_G_FREE(mc_metadata->season);
+ MC_SAFE_G_FREE(mc_metadata->episode);
+ MC_SAFE_G_FREE(mc_metadata->resolution);
MC_SAFE_FREE(mc_metadata);
if (mc_metadata->picture != NULL)
meta_val = strdup(mc_metadata->picture);
break;
+ case MC_META_MEDIA_SEASON:
+ if (mc_metadata->season != NULL)
+ meta_val = strdup(mc_metadata->season);
+ break;
+ case MC_META_MEDIA_EPISODE:
+ if (mc_metadata->episode != NULL)
+ meta_val = strdup(mc_metadata->episode);
+ break;
+ case MC_META_MEDIA_RESOLUTION:
+ if (mc_metadata->resolution != NULL)
+ meta_val = strdup(mc_metadata->resolution);
+ break;
default:
mc_error("Invalid Parameter [%d]", attribute);
return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
return ret;
}
+int mc_metadata_encode_season(int season_num, const char *season_title, char **encoded_season)
+{
+ gchar *_meta = NULL;
+ gchar *_encoded_meta = NULL;
+
+ mc_retvm_if(encoded_season == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid season");
+
+ _meta = g_strdup_printf("%s%s%d%s%s", KEY_SEASON, MC_STRING_DELIMITER, season_num, MC_STRING_DELIMITER, season_title);
+ mc_retvm_if(_meta == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "Out of memory");
+
+ _encoded_meta = g_base64_encode((const guchar *)_meta, strlen(_meta));
+
+ *encoded_season = _encoded_meta;
+
+ MC_SAFE_G_FREE(_meta);
+
+ return MEDIA_CONTROLLER_ERROR_NONE;
+}
+
+int mc_metadata_encode_episode(int episode_num, const char *episode_title, char **encoded_episode)
+{
+ gchar *_meta = NULL;
+ gchar *_encoded_meta = NULL;
+
+ mc_retvm_if(encoded_episode == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid episode");
+
+ _meta = g_strdup_printf("%s%s%d%s%s", KEY_EPISODE, MC_STRING_DELIMITER, episode_num, MC_STRING_DELIMITER, episode_title);
+ mc_retvm_if(_meta == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "Out of memory");
+
+ _encoded_meta = g_base64_encode((const guchar *)_meta, strlen(_meta));
+
+ *encoded_episode = _encoded_meta;
+
+ MC_SAFE_G_FREE(_meta);
+
+ return MEDIA_CONTROLLER_ERROR_NONE;
+}
+
+int mc_metadata_encode_resolution(unsigned int width, unsigned int height, char **encoded_resolution)
+{
+ gchar *_meta = NULL;
+ gchar *_encoded_meta = NULL;
+
+ mc_retvm_if(encoded_resolution == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid resolution");
+
+ _meta = g_strdup_printf("%s%s%d%s%d", KEY_RESOLUTION, MC_STRING_DELIMITER, width, MC_STRING_DELIMITER, height);
+ mc_retvm_if(_meta == NULL, MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY, "Out of memory");
+
+ _encoded_meta = g_base64_encode((const guchar *)_meta, strlen(_meta));
+
+ *encoded_resolution = _encoded_meta;
+
+ MC_SAFE_G_FREE(_meta);
+
+ return MEDIA_CONTROLLER_ERROR_NONE;
+}
+
+int _parse_encoded_meta(mc_meta_e attribute, const char *encoded_meta, int *int_val_1, char **str_val, int *int_val_2)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ gsize out_len = 0;
+ guchar *_decoded_meta = NULL;
+ gchar **params = NULL;
+ int _int_val_1 = 0;
+ int _int_val_2 = 0;
+
+ mc_retvm_if(encoded_meta == NULL, MEDIA_CONTROLLER_ERROR_NONE, "[No-Error]meta value is NULL");
+ mc_retvm_if(int_val_1 == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid int_val_1");
+
+ if ((attribute == MC_META_MEDIA_SEASON) || (attribute == MC_META_MEDIA_EPISODE))
+ mc_retvm_if(str_val == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid str_val");
+
+ if (attribute == MC_META_MEDIA_RESOLUTION)
+ mc_retvm_if(int_val_2 == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "invalid int_val_2");
+
+ _decoded_meta = g_base64_decode(encoded_meta, &out_len);
+ mc_retvm_if(_decoded_meta == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "decoding fail");
+
+ params = g_strsplit((const gchar *)_decoded_meta, MC_STRING_DELIMITER, 0);
+ MC_SAFE_G_FREE(_decoded_meta);
+ mc_retvm_if(params == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "parsing fail");
+
+ if ((params[0] == NULL) || (params[1] == NULL) || (params[2] == NULL)) {
+ g_strfreev(params);
+ mc_error("wrong parameter");
+ return MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
+ }
+
+ mc_secure_debug("[%d] [%s] [%s] [%s]", attribute, params[0], params[1], params[2]);
+
+ if (((attribute == MC_META_MEDIA_SEASON) && (strncmp(params[0], KEY_SEASON, strlen(KEY_SEASON)) == 0))
+ || ((attribute == MC_META_MEDIA_EPISODE) && (strncmp(params[0], KEY_EPISODE, strlen(KEY_EPISODE)) == 0))) {
+
+ ret = mc_safe_strtoi(params[1], &_int_val_1);
+ if (ret == MEDIA_CONTROLLER_ERROR_NONE) {
+ *int_val_1 = _int_val_1;
+ *str_val = g_strdup(params[2]);
+ }
+ } else if (attribute == MC_META_MEDIA_RESOLUTION) {
+ ret = mc_safe_strtoi(params[1], &_int_val_1);
+ if (ret == MEDIA_CONTROLLER_ERROR_NONE)
+ ret = mc_safe_strtoi(params[2], &_int_val_2);
+
+ if (ret == MEDIA_CONTROLLER_ERROR_NONE) {
+ *int_val_1 = _int_val_1;
+ *int_val_2 = _int_val_2;
+ }
+ } else {
+ mc_error("Invalid attribute [%d]", attribute);
+ ret = MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER;
+ }
+
+ g_strfreev(params);
+
+ return ret;
+}
+
+int mc_metadata_decode_season(const char *encoded_season, int *season_num, char **season_title)
+{
+ return _parse_encoded_meta(MC_META_MEDIA_SEASON, encoded_season, season_num, season_title, NULL);
+}
+
+int mc_metadata_decode_episode(const char *encoded_episode, int *episode_num, char **episode_title)
+{
+ return _parse_encoded_meta(MC_META_MEDIA_EPISODE, encoded_episode, episode_num, episode_title, NULL);
+}
+
+int mc_metadata_decode_resolution(const char *encoded_resolution, unsigned int *width, unsigned int *height)
+{
+ return _parse_encoded_meta(MC_META_MEDIA_RESOLUTION, encoded_resolution, (int *)width, NULL, (int *)height);
+}
#include "media_controller_db.h"
#define MAX_PLAYLIST_LEN 100
+#define MC_META_LIST "title, artist, album, author, genre, duration, date, copyright, description, track_num, picture, season, episode, resolution"
+
typedef struct {
char *index;
mc_retm_if(playlist_item == NULL, "invalid playlist_item");
MC_SAFE_FREE(playlist_item->index);
- mc_metadata_destroy(playlist_item->metadata);
+ mc_metadata_destroy((mc_metadata_h)playlist_item->metadata);
MC_SAFE_FREE(playlist_item);
}
_item = (mc_playlist_item_s*)g_list_nth_data(_playlist->item_list, idx);
if (_item != NULL && _item->index != NULL && _item->metadata != NULL) {
- sql_str = sqlite3_mprintf("INSERT INTO '%q' (server_name, playlist_name, item_index, title, artist, album, author, genre, duration, date, copyright, description, track_num, picture) VALUES (%Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
- MC_DB_TABLE_PLAYLIST, _playlist->server_name, _playlist->playlist_name, _item->index,
- _item->metadata->title, _item->metadata->artist, _item->metadata->album, _item->metadata->author, _item->metadata->genre, _item->metadata->duration, _item->metadata->date, _item->metadata->copyright, _item->metadata->description, _item->metadata->track_num, _item->metadata->picture);
+ sql_str = sqlite3_mprintf("INSERT INTO '%q' (server_name, playlist_name, item_index, %s) VALUES (%Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
+ MC_DB_TABLE_PLAYLIST, MC_META_LIST, _playlist->server_name, _playlist->playlist_name, _item->index,
+ _item->metadata->title, _item->metadata->artist, _item->metadata->album, _item->metadata->author, _item->metadata->genre, _item->metadata->duration, _item->metadata->date,
+ _item->metadata->copyright, _item->metadata->description, _item->metadata->track_num, _item->metadata->picture, _item->metadata->season, _item->metadata->episode, _item->metadata->resolution);
if (sql_str != NULL)
query_list = g_list_append(query_list, sql_str);
}
}
} else {
- sql_str = sqlite3_mprintf("INSERT INTO '%q' (server_name, playlist_name, item_index, title, artist, album, author, genre, duration, date, copyright, description, track_num, picture) VALUES (%Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
- MC_DB_TABLE_PLAYLIST, _playlist->server_name, _playlist->playlist_name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ sql_str = sqlite3_mprintf("INSERT INTO '%q' (server_name, playlist_name, item_index, %s) VALUES (%Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);",
+ MC_DB_TABLE_PLAYLIST, MC_META_LIST, _playlist->server_name, _playlist->playlist_name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
if (sql_str != NULL)
query_list = g_list_append(query_list, sql_str);
ret = mc_db_update_whole_metadata(mc_server->server_name,
mc_server->metadata->title, mc_server->metadata->artist, mc_server->metadata->album, mc_server->metadata->author,
mc_server->metadata->genre, mc_server->metadata->duration, mc_server->metadata->date, mc_server->metadata->copyright,
- mc_server->metadata->description, mc_server->metadata->track_num, mc_server->metadata->picture);
+ mc_server->metadata->description, mc_server->metadata->track_num, mc_server->metadata->picture,
+ mc_server->metadata->season, mc_server->metadata->episode, mc_server->metadata->resolution);
mc_retvm_if(ret != MEDIA_CONTROLLER_ERROR_NONE, ret, "fail to mc_db_update_whole_metadata");
ret = __mc_server_send_message(mc_server, MC_DBUS_UPDATE_INTERFACE, MC_DBUS_SIGNAL_NAME_METADATA, 0, 0, NULL);
#define DB_DELETE_FROM_CLIENT_LIST "DELETE FROM "MC_DB_TABLE_CLIENT_LIST" WHERE (client_name = '%q');"
#define DB_UPDATE_STATE_PLAYBACK "UPDATE '%q' SET server_state=%d, playback_state=%d;"
#define DB_DROP_TABLE "DROP TABLE IF EXISTS '%q';"
+#define DB_META_FIELD "title TEXT, artist TEXT, album TEXT, author TEXT, genre TEXT, duration INTEGER DEFAULT 0, date TEXT, copyright TEXT, description TEXT, track_num TEXT, picture TEXT, season TEXT, episode TEXT, resolution TEXT, "
#define MC_DB_NAME ".media_controller.db"
#define REGULAR_USER 5000
server_name TEXT NOT NULL, \
playlist_name TEXT NOT NULL, \
item_index TEXT, \
- title TEXT, \
- artist TEXT, \
- album TEXT, \
- author TEXT, \
- genre TEXT, \
- duration TEXT, \
- date TEXT, \
- copyright TEXT, \
- description TEXT, \
- track_num TEXT, \
- picture TEXT, unique(server_name, playlist_name, item_index));",
- MC_DB_TABLE_PLAYLIST);
+ %s \
+ unique(server_name, playlist_name, item_index));",
+ MC_DB_TABLE_PLAYLIST, DB_META_FIELD);
ret = mc_db_util_update_db(handle, sql_str);
SQLITE3_SAFE_FREE(sql_str);
playlist_index TEXT, \
playback_content_type INTEGER DEFAULT 4, \
age_rating INTEGER DEFAULT 0, \
- title TEXT, \
- artist TEXT, \
- album TEXT, \
- author TEXT, \
- genre TEXT, \
- duration INTEGER DEFAULT 0, \
- date TEXT, \
- copyright TEXT, \
- description TEXT, \
- track_num TEXT, \
- picture TEXT, \
+ %s \
shuffle_mode INTEGER DEFAULT 1, \
repeat_mode INTEGER DEFAULT 1, \
icon_uri TEXT, \
ability_decided INTEGER DEFAULT 0, \
ability_supported INTEGER DEFAULT 0 \
);INSERT INTO '%q' (server_name) VALUES ('%q');",
- params[1], params[1], params[1]);
+ params[1], DB_META_FIELD, params[1], params[1]);
} else if (strncmp(MC_DB_CMD_UPDATE_SERVER_LIST, params[0], strlen(MC_DB_CMD_UPDATE_SERVER_LIST)) == 0) {
sql_str = sqlite3_mprintf("INSERT INTO '%q' (server_name) VALUES ('%q');", MC_DB_TABLE_SERVER_LIST, params[1]);
params[1], i_value, llu_value, params[4], params[5], i_value_1, i_value_2);
} else if (strncmp(MC_DB_CMD_UPDATE_META, params[0], strlen(MC_DB_CMD_UPDATE_META)) == 0) {
- sql_str = sqlite3_mprintf("UPDATE '%q' SET title=%Q, artist=%Q, album=%Q, author=%Q, genre=%Q, duration=%Q, date=%Q, copyright=%Q, description=%Q, track_num=%Q, picture=%Q",
- params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
+ sql_str = sqlite3_mprintf("UPDATE '%q' SET title=%Q, artist=%Q, album=%Q, author=%Q, genre=%Q, duration=%Q, date=%Q, copyright=%Q, description=%Q, track_num=%Q, picture=%Q, season=%Q, episode=%Q, resolution=%Q",
+ params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12], params[13], params[14], params[15]);
} else if (strncmp(MC_DB_CMD_UPDATE_SHUFFLE, params[0], strlen(MC_DB_CMD_UPDATE_SHUFFLE)) == 0) {
if (params[2] == NULL) {
| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------*/
-static void __get_and_check_metadata(mc_metadata_h metadata)
+void __get_and_check_metadata(mc_metadata_h metadata)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
int idx = 0;
+ int int_val_1 = 0;
+ int int_val_2 = 0;
+ char *str_val = NULL;
char *value = NULL;
- for (idx = 0; idx <= MC_META_MEDIA_PICTURE; idx++) {
+ for (idx = 0; idx <= MC_META_MEDIA_RESOLUTION; idx++) {
ret = mc_metadata_get(metadata, idx, &value);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("Fail to mc_metadata_get");
- mc_debug("metadata [%d] value [%s]\n", idx, value);
+ if (idx == MC_META_MEDIA_SEASON) {
+ ret = mc_metadata_decode_season(value, &int_val_1, &str_val);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_metadata_decode_season");
+ else
+ mc_debug("metadata [season] season_num [%d] season_title [%s]\n", int_val_1, str_val);
+
+ } else if (idx == MC_META_MEDIA_EPISODE) {
+ ret = mc_metadata_decode_episode(value, &int_val_1, &str_val);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_metadata_decode_episode");
+ else
+ mc_debug("metadata [episode] episode_num [%d] episode_title [%s]\n", int_val_1, str_val);
+
+ } else if (idx == MC_META_MEDIA_RESOLUTION) {
+ ret = mc_metadata_decode_resolution(value, (unsigned int *)&int_val_1, (unsigned int *)&int_val_2);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_metadata_decode_resolution");
+ else
+ mc_debug("metadata [resolution] width [%d] height [%d]\n", int_val_1, int_val_2);
+
+ } else {
+ mc_debug("metadata [%d] value [%s]\n", idx, value);
+ }
+
+ MC_SAFE_FREE(str_val);
MC_SAFE_FREE(value);
}
}
---------------------------------------------------------------------------*/
static mc_server_h g_mc_server;
-static int g_metadata_type;
+static mc_meta_e g_metadata_type;
static mc_shuffle_mode_e g_shuffle_mode;
static mc_repeat_mode_e g_repeat_mode;
static mc_playlist_update_mode_e g_playlist_mode;
| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------*/
+void __get_and_check_metadata(mc_metadata_h metadata)
+{
+ int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ int idx = 0;
+ int int_val_1 = 0;
+ int int_val_2 = 0;
+ char *str_val = NULL;
+ char *value = NULL;
+
+ for (idx = 0; idx <= MC_META_MEDIA_RESOLUTION; idx++) {
+ ret = mc_metadata_get(metadata, idx, &value);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_metadata_get");
+
+ if (idx == MC_META_MEDIA_SEASON) {
+ ret = mc_metadata_decode_season(value, &int_val_1, &str_val);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_metadata_decode_season");
+ else
+ mc_debug("metadata [season] season_num [%d] season_title [%s]\n", int_val_1, str_val);
+
+ } else if (idx == MC_META_MEDIA_EPISODE) {
+ ret = mc_metadata_decode_episode(value, &int_val_1, &str_val);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_metadata_decode_episode");
+ else
+ mc_debug("metadata [episode] episode_num [%d] episode_title [%s]\n", int_val_1, str_val);
+
+ } else if (idx == MC_META_MEDIA_RESOLUTION) {
+ ret = mc_metadata_decode_resolution(value, (unsigned int *)&int_val_1, (unsigned int *)&int_val_2);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_metadata_decode_resolution");
+ else
+ mc_debug("metadata [resolution] width [%d] height [%d]\n", int_val_1, int_val_2);
+
+ } else {
+ mc_debug("metadata [%d] value [%s]\n", idx, value);
+ }
+
+ MC_SAFE_FREE(str_val);
+ MC_SAFE_FREE(value);
+ }
+}
+
void __playback_action_received_cb(const char *client_name, const char *request_id, mc_playback_action_e action, void *user_data)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
bool server_playlist_item_cb(const char *index, mc_metadata_h meta, void *user_data)
{
- int ret = MEDIA_CONTROLLER_ERROR_NONE;
- int idx = 0;
- char *value = NULL;
+ mc_debug("playlist index [%s]", index);
+ __get_and_check_metadata(meta);
- for (idx = 0; idx <= MC_META_MEDIA_PICTURE; idx++) {
- ret = mc_metadata_get(meta, idx, &value);
- if (ret != MEDIA_CONTROLLER_ERROR_NONE)
- mc_error("Fail to mc_metadata_get [%d]", ret);
-
- mc_debug("index [%s] value [%s]", index, value);
- MC_SAFE_FREE(value);
- }
-
- return true;
+return true;
}
bool server_playlist_list_cb(mc_playlist_h playlist, void *user_data)
const char *playlist_name_2 = "test_2";
unsigned int idx = 0;
GList *playlist_list = NULL;
+ char *season = NULL;
+ char *episode = NULL;
+ char *resolution = NULL;
if (mode == MC_PLAYLIST_UPDATED) {
ret = mc_server_create_playlist(server, playlist_name_1, &playlist_1);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("Fail to mc_server_create_playlist [%d]", ret);
+ ret = mc_metadata_encode_season(1, "season_1", &season);
+ ret = mc_metadata_encode_episode(1, "episode_1", &episode);
+ ret = mc_metadata_encode_resolution(320, 240, &resolution);
+
mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_TITLE, "title_1");
mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_ARTIST, "artist_1");
mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_ALBUM, "album_1");
mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_DESCRIPTION, "destription_1");
mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_TRACK_NUM, "track_num_1");
mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_PICTURE, "picture_1");
+ mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_SEASON, season);
+ mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_EPISODE, episode);
+ mc_server_add_item_to_playlist(server, playlist_1, "1", MC_META_MEDIA_RESOLUTION, resolution);
+
+ MC_SAFE_FREE(season);
+ MC_SAFE_FREE(episode);
+ MC_SAFE_FREE(resolution);
+
+ ret = mc_metadata_encode_season(2, "season_2", &season);
+ ret = mc_metadata_encode_episode(2, "episode_2", &episode);
+ ret = mc_metadata_encode_resolution(640, 480, &resolution);
mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_TITLE, "title_2");
mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_ARTIST, "artist_2");
mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_DESCRIPTION, "destription_2");
mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_TRACK_NUM, "track_num_2");
mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_PICTURE, "picture_2");
+ mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_SEASON, season);
+ mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_EPISODE, episode);
+ mc_server_add_item_to_playlist(server, playlist_1, "2", MC_META_MEDIA_RESOLUTION, resolution);
+
+ MC_SAFE_FREE(season);
+ MC_SAFE_FREE(episode);
+ MC_SAFE_FREE(resolution);
for (idx = 3; idx < 100; idx++) {
char idx_str[255] = {0,};
ret = mc_playlist_destroy(playlist_1);
ret = mc_playlist_destroy(playlist_2);
- ret = mc_server_get_playlist(server, playlist_name_1, &playlist_2);
+ ret = mc_server_get_playlist(server, playlist_name_1, &playlist_1);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("Fail to mc_server_get_playlist [%d]", ret);
- if (playlist_2 != NULL) {
+ if (playlist_1 != NULL) {
char *playlist_name = NULL;
- ret = mc_playlist_get_name(playlist_2, &playlist_name);
+ ret = mc_playlist_get_name(playlist_1, &playlist_name);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("Fail to mc_playlist_get_name [%d]", ret);
- mc_debug("Get playlist [%s]", playlist_name);
+ mc_debug("playlist_name [%s]", playlist_name);
MC_SAFE_FREE(playlist_name);
- mc_server_add_item_to_playlist(server, playlist_2, "100", MC_META_MEDIA_PICTURE, "picture_100");
- ret = mc_server_update_playlist_done(server, playlist_2);
+ mc_server_add_item_to_playlist(server, playlist_1, "100", MC_META_MEDIA_PICTURE, "picture_100");
+ ret = mc_server_update_playlist_done(server, playlist_1);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
mc_error("Fail to mc_server_update_playlist_done [%d]", ret);
- ret = mc_playlist_destroy(playlist_2);
+ ret = mc_playlist_destroy(playlist_1);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ mc_error("Fail to mc_playlist_destroy [%d]", ret);
+
}
} else {
return TRUE;
}
+static char *__make_meta(const char *meta)
+{
+ char *encoded_meta = NULL;
+
+ if (g_metadata_type == MC_META_MEDIA_SEASON) {
+ mc_metadata_encode_season(9, meta, &encoded_meta);
+ } else if (g_metadata_type == MC_META_MEDIA_EPISODE) {
+ mc_metadata_encode_episode(10, meta, &encoded_meta);
+ } else if (g_metadata_type == MC_META_MEDIA_RESOLUTION) {
+ mc_metadata_encode_resolution(320, 240, &encoded_meta);
+ } else {
+ g_print("invalid meta type [%d] \n", g_metadata_type);
+ return NULL;
+ }
+
+ return encoded_meta;
+}
+
static gboolean _set_info(int type, char *cmd)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
g_print("set metadata name: %d", g_metadata_type);
break;
case CURRENT_STATE_SET_METADATA_VALUE:
- metadata = strdup(cmd);
+ if ((g_metadata_type == MC_META_MEDIA_SEASON) || (g_metadata_type == MC_META_MEDIA_EPISODE) || (g_metadata_type == MC_META_MEDIA_RESOLUTION))
+ metadata = __make_meta(cmd);
+ else
+ metadata = strdup(cmd);
ret = mc_server_set_metadata(g_mc_server, g_metadata_type, metadata);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
g_print("Fail to set metadata");
int server_sequential_test(void)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
+ char *season = NULL;
+ char *episode = NULL;
+ char *resolution = NULL;
ret = mc_server_create(&g_mc_server);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
/*return ret; */
}
+ ret = mc_metadata_encode_season(10, "season_10", &season);
+ ret = mc_metadata_encode_episode(20, "episode_20", &episode);
+ ret = mc_metadata_encode_resolution(320, 240, &resolution);
+
ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_TITLE, "media_title");
ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_ARTIST, "media_artist");
ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_ALBUM, "media_album");
ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_DESCRIPTION, "media_description");
ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_TRACK_NUM, "media_track_num 3/10");
ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_PICTURE, "media_picture_path");
+ ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_SEASON, season);
+ ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_EPISODE, episode);
+ ret = mc_server_set_metadata(g_mc_server, MC_META_MEDIA_RESOLUTION, resolution);
+
+ MC_SAFE_FREE(season);
+ MC_SAFE_FREE(episode);
+ MC_SAFE_FREE(resolution);
+
ret = mc_server_update_metadata(g_mc_server);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
g_print("Fail to mc_server_update_metadata\n");