@@ -55,6 +55,13 @@ struct mpd_song {
5555
5656 struct mpd_tag_value tags [MPD_TAG_COUNT ];
5757
58+ /**
59+ * The "real" URI, the one to be used for opening the
60+ * resource. If this attribute is nullptr, then #uri
61+ * shall be used.
62+ */
63+ char * real_uri ;
64+
5865 /**
5966 * Duration of the song in seconds, or 0 for unknown.
6067 */
@@ -136,6 +143,7 @@ mpd_song_new(const char *uri)
136143 for (unsigned i = 0 ; i < MPD_TAG_COUNT ; ++ i )
137144 song -> tags [i ].value = NULL ;
138145
146+ song -> real_uri = NULL ;
139147 song -> duration = 0 ;
140148 song -> duration_ms = 0 ;
141149 song -> start = 0 ;
@@ -179,6 +187,8 @@ void mpd_song_free(struct mpd_song *song) {
179187 }
180188 }
181189
190+ free (song -> real_uri );
191+
182192 free (song );
183193}
184194
@@ -216,6 +226,7 @@ mpd_song_dup(const struct mpd_song *song)
216226 } while (src_tag != NULL );
217227 }
218228
229+ ret -> real_uri = strdup (song -> real_uri );
219230 ret -> duration = song -> duration ;
220231 ret -> duration_ms = song -> duration_ms ;
221232 ret -> start = song -> start ;
@@ -331,6 +342,20 @@ mpd_song_get_tag(const struct mpd_song *song,
331342 return tag -> value ;
332343}
333344
345+ static void
346+ mpd_song_set_real_uri (struct mpd_song * song , char * real_uri )
347+ {
348+ song -> real_uri = real_uri ;
349+ }
350+
351+ const char *
352+ mpd_song_get_real_uri (const struct mpd_song * song )
353+ {
354+ assert (song != NULL );
355+
356+ return song -> real_uri ;
357+ }
358+
334359static void
335360mpd_song_set_duration (struct mpd_song * song , unsigned duration )
336361{
@@ -546,6 +571,8 @@ mpd_song_feed(struct mpd_song *song, const struct mpd_pair *pair)
546571 mpd_song_set_prio (song , strtoul (pair -> value , NULL , 10 ));
547572 else if (strcmp (pair -> name , "Format" ) == 0 )
548573 mpd_song_parse_audio_format (song , pair -> value );
574+ else if (strcmp (pair -> name , "RealUri" ) == 0 )
575+ mpd_song_set_real_uri (song , strdup (pair -> value ));
549576
550577 return true;
551578}
0 commit comments