DACPShare * dacp_share_new (const gchar * library_name, DACPPlayer * player, DMAPDb * db, DMAPContainerDb * container_db) { DACPShare *share; g_object_ref (db); g_object_ref (container_db); share = DACP_SHARE (g_object_new (DACP_TYPE_SHARE, "name", get_dbid (), "library-name", library_name, "password", NULL, "db", db, "container-db", container_db, "player", G_OBJECT (player), "transcode-mimetype", NULL, NULL)); g_debug ("Starting DACP server"); _dmap_share_server_start (DMAP_SHARE (share)); _dmap_share_publish_start (DMAP_SHARE (share)); return share; }
/* FIXME: trancode_mimetype currently not used for DPAP, only DAAP. * Threrfore, it is not passed to g_object_new. */ DPAPShare * dpap_share_new (const char *name, const char *password, gpointer db, gpointer container_db, gchar * transcode_mimetype) { DPAPShare *share; share = DPAP_SHARE (g_object_new (DPAP_TYPE_SHARE, "name", name, "password", password, "db", db, "container-db", container_db, NULL)); _dmap_share_server_start (DMAP_SHARE (share)); _dmap_share_publish_start (DMAP_SHARE (share)); return share; }
DAAPShare * daap_share_new (const char *name, const char *password, DMAPDb * db, DMAPContainerDb * container_db, gchar * transcode_mimetype) { DAAPShare *share; g_object_ref (db); g_object_ref (container_db); share = DAAP_SHARE (g_object_new (DAAP_TYPE_SHARE, "name", name, "password", password, "db", db, "container-db", container_db, "transcode-mimetype", transcode_mimetype, NULL)); _dmap_share_server_start (DMAP_SHARE (share)); _dmap_share_publish_start (DMAP_SHARE (share)); return share; }
static void dacp_share_fill_playstatusupdate (DACPShare * share, SoupMessage * message) { GNode *cmst; DAAPRecord *record; DACPPlayState play_state; DACPRepeatState repeat_state; gboolean shuffle_state; guint playing_time; g_object_get (share->priv->player, "play-state", &play_state, "repeat-state", &repeat_state, "shuffle-state", &shuffle_state, "playing-time", &playing_time, NULL); record = dacp_player_now_playing_record (share->priv->player); cmst = dmap_structure_add (NULL, DMAP_CC_CMST); dmap_structure_add (cmst, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK); dmap_structure_add (cmst, DMAP_CC_CMSR, share->priv->current_revision); dmap_structure_add (cmst, DMAP_CC_CAPS, (gint32) play_state); dmap_structure_add (cmst, DMAP_CC_CASH, shuffle_state ? 1 : 0); dmap_structure_add (cmst, DMAP_CC_CARP, (gint32) repeat_state); if (record) { gchar *title; gchar *artist; gchar *album; gint duration; guint track_time; g_object_get (record, "title", &title, "songartist", &artist, "songalbum", &album, "duration", &duration, NULL); track_time = duration * 1000; //dmap_structure_add (cmst, DMAP_CC_CAVC, 1); dmap_structure_add (cmst, DMAP_CC_CAAS, 2); dmap_structure_add (cmst, DMAP_CC_CAAR, 6); dmap_structure_add (cmst, DMAP_CC_CANP, (gint64) 0); if (title) dmap_structure_add (cmst, DMAP_CC_CANN, title); if (artist) dmap_structure_add (cmst, DMAP_CC_CANA, artist); if (album) dmap_structure_add (cmst, DMAP_CC_CANL, album); dmap_structure_add (cmst, DMAP_CC_CANG, ""); dmap_structure_add (cmst, DMAP_CC_ASAI, 0); //dmap_structure_add (cmst, DMAP_CC_AEMK, 1); g_debug ("Playing time: %u, Track time: %u", playing_time, track_time); dmap_structure_add (cmst, DMAP_CC_CANT, track_time - playing_time); dmap_structure_add (cmst, DMAP_CC_CAST, track_time); g_free (title); g_free (artist); g_free (album); g_object_unref (record); } _dmap_share_message_set_from_dmap_structure (DMAP_SHARE (share), message, cmst); dmap_structure_destroy (cmst); }