* \#include <media_controller_server.h>
*
* @section CAPI_MEDIA_CONTROLLER_SERVER_MODULE_OVERVIEW Overview
-* The @ref CAPI_MEDIA_CONTROLLER_SERVER_MODULE API allows you to send the playback info (#mc_server_set_playback_state(), #mc_server_set_playback_position(), #mc_server_set_playlist_item_index()), the metadata (#mc_server_set_metadata() and playlist (#mc_server_set_playlist_item_index(), #mc_server_create_playlist()). and to receive the custom command (#mc_server_set_custom_cmd_received_cb()), to update the status information on the latest server (#mc_server_update_playback_info(), #mc_server_update_metadata(). \n
+* The @ref CAPI_MEDIA_CONTROLLER_SERVER_MODULE API allows you to send the playback info (#mc_server_set_playback_state(), #mc_server_set_playback_position(), #mc_server_set_playlist_item_info()), the metadata (#mc_server_set_metadata() and playlist (#mc_server_set_playlist_item_index(), #mc_server_create_playlist()). and to receive the custom command (#mc_server_set_custom_cmd_received_cb()), to update the status information on the latest server (#mc_server_update_playback_info(), #mc_server_update_metadata(). \n
* Before doing those things you should create handle(#mc_server_create()). And if you don't use handle anymore, you have to destroy it(#mc_server_destroy()).
*
*/
int mc_client_get_playback_position(mc_playback_h playback, unsigned long long *position);
/**
+ * @deprecated Deprecated since 5.0. Use mc_client_get_playlist_item_info() instead.
* @brief Gets the index of the media in playlist.
* @details Gets the index of the current playing media in a playlist. If the media controller server didn't set the index, the value is NULL.
- * @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif
+ * @since_tizen @if MOBILE 4.0 @endif
*
* @privlevel public
* @privilege %http://tizen.org/privilege/mediacontroller.client
* @see mc_client_set_playback_updated_cb()
* @see mc_client_foreach_server_playlist()
*/
-int mc_client_get_playlist_item_index(mc_playback_h playback, char **index);
+int mc_client_get_playlist_item_index(mc_playback_h playback, char **index) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Gets the playlist name and index of the media in playlist.
+ * @details Gets the playlist name and index of the current playing media in a playlist. If the media controller server didn't set the info, @a playlist_name and @a index will be set to NULL.
+ * @since_tizen 5.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.client
+ *
+ * @remarks The @a playlist_name and @a index should be released using free().
+ *
+ * @param[in] playback The handle to playback
+ * @param[out] playlist_name The playlist name media included
+ * @param[out] index The index of the media
+ * @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
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre The playback update callback should be set with mc_client_set_playback_updated_cb().
+ * @see mc_client_set_playback_updated_cb()
+ * @see mc_client_foreach_server_playlist()
+ */
+int mc_client_get_playlist_item_info(mc_playback_h playback, char **playlist_name, char **index);
+
/**
* @brief Gets the playback content type.
typedef struct {
mc_playback_states_e state;
unsigned long long position;
+ char *playlist_name;
char *index;
mc_content_type_e content_type;
} media_controller_playback_s;
int mc_server_set_playback_position(mc_server_h server, unsigned long long position);
/**
- * @brief Sets the index of the current playing media in the playlist to update the latest playback info. \n
+ * @deprecated Deprecated since 5.0. Use mc_server_set_playlist_item_info() instead.
+ * @brief Sets the index of the current playing media in the playlist to update the latest playback info.
* @details If a media controller server has a playlist, the server can register and share it with media controller client. A playlist is a set of "index" and "media metadata".\n
* The media controller server can let media controller clients know the index of current playing media by using this function.
* @since_tizen @if MOBILE 4.0 @elseif WEARABLE 5.0 @endif
* @see mc_server_update_playback_info()
* @see mc_server_create_playlist()
*/
-int mc_server_set_playlist_item_index(mc_server_h server, const char *index);
+int mc_server_set_playlist_item_index(mc_server_h server, const char *index) TIZEN_DEPRECATED_API;
+
+/**
+ * @brief Sets the playlist name and index of the current playing media in the playlist to update the latest playback info.
+ * @details If a media controller server has a playlist, the server can register and share it with media controller client. A playlist is a set of "index" and "media metadata".\n
+ * The media controller server can let media controller clients know the playlist name and index of current playing media by using this function.
+ * @since_tizen 5.0
+ *
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/mediacontroller.server
+ *
+ * @param[in] server The handle to media controller server
+ * @param[in] playlist_name The playlist name media included. The length of the playlist name should be less than 4096byte
+ * @param[in] index The index of the current playing media in the playlist
+ * @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
+ * @retval #MEDIA_CONTROLLER_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre Create a media controller server handle by calling mc_server_create().
+ * @post Apply the updated playback information by calling mc_server_update_playback_info().
+ * @see mc_server_create()
+ * @see mc_server_destroy()
+ * @see mc_server_update_playback_info()
+ * @see mc_server_create_playlist()
+ */
+int mc_server_set_playlist_item_info(mc_server_h server, const char *playlist_name, const char *index);
/**
* @brief Sets the playback content type to update the latest playback info.
Name: capi-media-controller
Summary: A media controller library in Tizen Native API
-Version: 0.1.68
+Version: 0.1.69
Release: 1
Group: Multimedia/API
License: Apache-2.0
{
media_controller_playback_s *mc_playback = (media_controller_playback_s *)playback;
+ mc_warning("DEPRECATION WARNING: mc_client_get_playlist_item_index() is deprecated and will be removed from next release. Use mc_client_get_playlist_item_info() instead.");
+
+ mc_retvm_if(mc_playback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ mc_retvm_if(index == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "index is NULL");
+
+ *index = g_strdup(mc_playback->index);
+
+ return MEDIA_CONTROLLER_ERROR_NONE;
+}
+
+int mc_client_get_playlist_item_info(mc_playback_h playback, char **playlist_name, char **index)
+{
+ media_controller_playback_s *mc_playback = (media_controller_playback_s *)playback;
+
mc_retvm_if(mc_playback == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ mc_retvm_if(playlist_name == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "playlist_name is NULL");
mc_retvm_if(index == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "index is NULL");
+ *playlist_name = g_strdup(mc_playback->playlist_name);
*index = g_strdup(mc_playback->index);
return MEDIA_CONTROLLER_ERROR_NONE;
MC_SERVER_FIELD_SERVER_STATE,
MC_SERVER_FIELD_PLAYBACK_STATE,
MC_SERVER_FIELD_PLAYBACK_POSITION,
+ MC_SERVER_FIELD_PLAYLIST_NAME,
MC_SERVER_FIELD_PLAYLIST_INDEX,
MC_SERVER_FIELD_PLAYBACK_CONTENT_TYPE,
MC_SERVER_FIELD_TITLE,
mc_retvm_if(handle == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is 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%d%s%llu%s%s%s%d", MC_DB_CMD_UPDATE_PLAYBACK, MC_STRING_DELIMITER,
+ sql_str = g_strdup_printf("%s%s%s%s%d%s%llu%s%s%s%s%s%d", MC_DB_CMD_UPDATE_PLAYBACK, MC_STRING_DELIMITER,
server_name, MC_STRING_DELIMITER,
playback.state, MC_STRING_DELIMITER,
playback.position, MC_STRING_DELIMITER,
+ playback.playlist_name, MC_STRING_DELIMITER,
playback.index, MC_STRING_DELIMITER,
playback.content_type);
mc_retvm_if(sql_str == NULL, MEDIA_CONTROLLER_ERROR_INVALID_OPERATION, "fail making sql_str");
}
index = g_strdup((char *)sqlite3_column_text(stmt, 2)); //0 : server_name, 1 : playlist_name
- _metadata->title = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TITLE -3));
- _metadata->artist = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ARTIST -3));
- _metadata->album = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ALBUM -3));
- _metadata->author = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_AUTHOR -3));
- _metadata->genre = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_GENRE -3));
- _metadata->duration = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DURATION -3));
- _metadata->date = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DATE -3));
- _metadata->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_COPYRIGHT -3));
- _metadata->description = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DESCRIPTION -3));
- _metadata->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TRACK_NUM -3));
- _metadata->picture = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_PICTURE -3));
+ _metadata->title = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TITLE -4));
+ _metadata->artist = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ARTIST -4));
+ _metadata->album = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_ALBUM -4));
+ _metadata->author = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_AUTHOR -4));
+ _metadata->genre = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_GENRE -4));
+ _metadata->duration = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DURATION -4));
+ _metadata->date = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DATE -4));
+ _metadata->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_COPYRIGHT -4));
+ _metadata->description = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_DESCRIPTION -4));
+ _metadata->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_TRACK_NUM -4));
+ _metadata->picture = g_strdup((const char *)sqlite3_column_text(stmt, MC_SERVER_FIELD_PICTURE -4));
if (callback(index, (mc_metadata_h)_metadata, user_data) == false) {
MC_SAFE_FREE(index);
#include <bundle_internal.h>
#define MAX_PLAYLIST_LEN 100
+#define MAX_INPUT_STR_LEN 4096
static void __server_playback_state_command_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data);
static void __server_playback_action_cb(const char *interface_name, const char *signal_name, const char *message, const char *request_id, void *user_data);
{
media_controller_server_s *mc_server = (media_controller_server_s *)server;
+ mc_warning("DEPRECATION WARNING: mc_server_set_playlist_item_index() is deprecated and will be removed from next release. Use mc_server_set_playlist_item_info() instead.");
+
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
mc_retvm_if(!MC_STRING_VALID(index), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid index");
return MEDIA_CONTROLLER_ERROR_NONE;
}
+int mc_server_set_playlist_item_info(mc_server_h server, const char *playlist_name, const char *index)
+{
+ media_controller_server_s *mc_server = (media_controller_server_s *)server;
+
+ mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
+ mc_retvm_if(!MC_STRING_VALID(playlist_name), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid playlist_name");
+ mc_retvm_if(strlen(playlist_name) > MAX_INPUT_STR_LEN, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Playlist_name is too long. The length of the playlist name should be less than %d byte", MAX_INPUT_STR_LEN);
+ mc_retvm_if(!MC_STRING_VALID(index), MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Invalid index");
+
+ MC_SAFE_FREE(mc_server->playback.playlist_name);
+ MC_SAFE_FREE(mc_server->playback.index);
+
+ mc_server->playback.playlist_name = g_strdup(playlist_name);
+ mc_server->playback.index = g_strdup(index);
+
+ if ((mc_server->playback.playlist_name == NULL) || (mc_server->playback.index == NULL)) {
+ mc_error("Fail to set playlist item info");
+ MC_SAFE_FREE(mc_server->playback.playlist_name);
+ MC_SAFE_FREE(mc_server->playback.index);
+ return MEDIA_CONTROLLER_ERROR_OUT_OF_MEMORY;
+ }
+
+ return MEDIA_CONTROLLER_ERROR_NONE;
+}
+
int mc_server_set_playback_content_type(mc_server_h server, mc_content_type_e content_type)
{
int ret = MEDIA_CONTROLLER_ERROR_NONE;
mc_retvm_if(mc_server == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "Handle is NULL");
- mc_debug("playback info update: state [%d], position [%llu], index [%s], content_type [%d]", mc_server->playback.state, mc_server->playback.position, mc_server->playback.index, mc_server->playback.content_type);
+ mc_debug("playback info update: state [%d], position [%llu], playlist_name[%s], index [%s], content_type [%d]",
+ mc_server->playback.state, mc_server->playback.position, mc_server->playback.playlist_name, mc_server->playback.index, mc_server->playback.content_type);
ret = mc_db_update_playback_info(mc_server->db_handle, mc_server->server_name, mc_server->playback);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
server_state INTEGER DEFAULT 1, \
playback_state INTEGER DEFAULT 0, \
playback_position INTEGER DEFAULT 0, \
+ playlist_name TEXT, \
playlist_index TEXT, \
playback_content_type INTEGER DEFAULT 4, \
title TEXT, \
sql_str = sqlite3_mprintf("UPDATE '%q' SET server_state=%d, playback_state=%d;", params[1], i_value, i_value_1);
} else if (strncmp(MC_DB_CMD_UPDATE_PLAYBACK, params[0], strlen(MC_DB_CMD_UPDATE_PLAYBACK)) == 0) {
- if (params[2] == NULL || params[3] == NULL || params[4] == NULL || params[5] == NULL) {
+ if (params[2] == NULL || params[3] == NULL || params[4] == NULL || params[5] == NULL || params[6] == NULL) {
mc_error("wrong query");
ret = MEDIA_CONTROLLER_ERROR_INVALID_OPERATION;
goto ERROR;
mc_safe_strtoi(params[2], &i_value);
mc_safe_strtoull(params[3], &llu_value);
- mc_safe_strtoi(params[5], &i_value_1);
- sql_str = sqlite3_mprintf("UPDATE '%q' SET playback_state=%d, playback_position=%llu, playlist_index=%Q, playback_content_type=%d;", params[1], i_value, llu_value, params[4], i_value_1);
+ mc_safe_strtoi(params[6], &i_value_1);
+ sql_str = sqlite3_mprintf("UPDATE '%q' SET playback_state=%d, playback_position=%llu, playlist_name=%Q, playlist_index=%Q, playback_content_type=%d;", params[1], i_value, llu_value, params[4], params[5], i_value_1);
} 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",
media_controller_client_s *_client = (media_controller_client_s *)g_mc_client;
unsigned long long position = 0;
mc_playback_states_e playback_state = MC_PLAYBACK_STATE_NONE;
+ char *playlist_name = NULL;
char *index = NULL;
mc_content_type_e content_type = MC_CONTENT_TYPE_UNDECIDED;
mc_client_get_playback_position(playback, &position);
mc_client_get_playback_state(playback, &playback_state);
mc_client_get_playlist_item_index(playback, &index);
+ MC_SAFE_FREE(index);
+
+ mc_client_get_playlist_item_info(playback, &playlist_name, &index);
mc_client_get_playback_content_type(playback, &content_type);
- mc_debug("[Client:%s] Playback updated from server[%s] playback_state[%d] position[%lld] index[%s] content_type[%d]", _client->client_name, server_name, playback_state, position, index, content_type);
+ mc_debug("[Client:%s] Playback updated from server[%s] playback_state[%d] position[%lld] playlist_name [%s] index[%s] content_type[%d]",
+ _client->client_name, server_name, playback_state, position, playlist_name, index, content_type);
+ MC_SAFE_FREE(playlist_name);
MC_SAFE_FREE(index);
}
char *metadata_value;
mc_shuffle_mode_e shuffle_mode;
mc_repeat_mode_e repeate_mode;
+ char *playlist_name = NULL;
char *index = NULL;
mc_content_type_e content_type = MC_CONTENT_TYPE_UNDECIDED;
char *icon_url = NULL;
g_print("Fail to get playback position");
ret = mc_client_get_playlist_item_index(playback, &index);
+ MC_SAFE_FREE(index);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
- g_print("Fail to get playback position");
+ g_print("Fail to get playlist item index");
+
+ ret = mc_client_get_playlist_item_info(playback, &playlist_name, &index);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE)
+ g_print("Fail to get playlist item info");
ret = mc_client_get_playback_content_type(playback, &content_type);
if (ret != MEDIA_CONTROLLER_ERROR_NONE)
g_print("Fail to get playback content type");
- g_print("playback state [%d], position [%lld], index [%s], content_type[%d]", playback_state, playback_position, index, content_type);
+ g_print("playback state [%d], position [%lld], playlist_name [%s], index [%s], content_type[%d]", playback_state, playback_position, playlist_name, index, content_type);
+ MC_SAFE_FREE(playlist_name);
MC_SAFE_FREE(index);
ret = mc_client_destroy_playback(playback);
break;
case CURRENT_STATE_SET_ITEM_ID:
+ ret = mc_server_set_playlist_item_info(g_mc_server, "test_playlist_id", cmd);
+ if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
+ g_print("Fail to set playlist info");
+ return FALSE;
+ }
+
ret = mc_server_set_playlist_item_index(g_mc_server, cmd);
if (ret != MEDIA_CONTROLLER_ERROR_NONE) {
- g_print("Fail to set media id");
+ g_print("Fail to set playlist info");
return FALSE;
}
g_print("set media id: %s", cmd);