static int set_avtransport_uri(struct action_event *event) { if (obtain_instanceid(event, NULL) < 0) { return -1; } char *uri = upnp_get_string(event, "CurrentURI"); if (uri == NULL) { return -1; } service_lock(); char *meta = upnp_get_string(event, "CurrentURIMetaData"); // Transport URI/Meta set now, current URI/Meta when it starts playing. int requires_meta_update = replace_transport_uri_and_meta(uri, meta); if (transport_state_ == TRANSPORT_PLAYING) { // Uh, wrong state. // Usually, this should not be called while we are PLAYING, only // STOPPED or PAUSED. But if actually some controller sets this // while playing, probably the best is to update the current // current URI/Meta as well to reflect the state best. replace_current_uri_and_meta(uri, meta); } output_set_uri(uri, (requires_meta_update ? update_meta_from_stream : NULL)); service_unlock(); free(uri); free(meta); return 0; }
static int set_avtransport_uri(struct action_event *event) { int rc = 0; ENTER(); if (obtain_instanceid(event, NULL)) { LEAVE(); return -1; } char *uri = upnp_get_string(event, "CurrentURI"); if (uri == NULL) { LEAVE(); return -1; } service_lock(); char *meta = upnp_get_string(event, "CurrentURIMetaData"); int requires_meta_update = replace_transport_uri_and_meta(uri, meta); output_set_uri(uri, (requires_meta_update ? update_meta_from_stream : NULL)); notify_changed_uris(); service_unlock(); free(uri); free(meta); LEAVE(); return rc; }
DBG_STATIC int set_avtransport_uri(struct action_event *event) { char *value; int rc = 0; if (upnp_obtain_instanceid(event, NULL)) { upnp_set_error(event, UPNP_TRANSPORT_E_INVALID_IID, "ID non-zero invalid"); return -1; } value = upnp_get_string(event, "CurrentURI"); if (value == NULL) return -1; ithread_mutex_lock(&transport_mutex); DBG_PRINT(DBG_LVL4, "%s: Set URI to '%s'\n", __FUNCTION__, value); // do the work output_set_uri(value); transport_set_var(TRANSPORT_VAR_AV_URI, value); free(value); value = upnp_get_string(event, "CurrentURIMetaData"); if (value != NULL) { DBG_PRINT(DBG_LVL4, "%s: Set URI MetaData to '%s'\n", __FUNCTION__, value); // First set new value so we may extract some information about // the stream (Ex: track_duration) transport_set_var(TRANSPORT_VAR_AV_URI_META, value); free(value); // Locate duration attribute in 'res' element under 'item' value = (char *)transport_get_attr_metadata("duration"); if (value) { transport_set_var(TRANSPORT_VAR_CUR_TRACK_DUR, value); free(value); } } else { rc = -1; } transport_state = TRANSPORT_STOPPED; transport_set_var(TRANSPORT_VAR_TRANSPORT_STATE, "STOPPED"); transport_notify_lastchange(event, transport_get_state_lastchange()); ithread_mutex_unlock(&transport_mutex); return rc; }
void timerPlay(char *uri) { service_lock(); output_stop(); change_transport_state(TRANSPORT_STOPPED); output_set_uri(uri, NULL); replace_var(TRANSPORT_VAR_REL_TIME_POS, kZeroTime); if (output_play(&inform_play_transition_from_output)) { } else { change_transport_state(TRANSPORT_PLAYING); const char *av_uri = get_var(TRANSPORT_VAR_AV_URI); const char *av_meta = get_var(TRANSPORT_VAR_AV_URI_META); replace_current_uri_and_meta(av_uri, av_meta); } service_unlock(); }