connected the pieces of the RDS thing; next: testing (part of #722)
This commit is contained in:
parent
8818ae3537
commit
087253a71c
6 changed files with 157 additions and 17 deletions
|
@ -1795,7 +1795,7 @@ GLiveSupport :: createScratchpadWindow(void)
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
LiveSupport :: GLiveSupport ::
|
LiveSupport :: GLiveSupport ::
|
||||||
GLiveSupport :: writeToSerial(Ptr<const std::string>::Ref message)
|
GLiveSupport :: writeToSerial(Ptr<const Glib::ustring>::Ref message)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -1809,3 +1809,64 @@ GLiveSupport :: writeToSerial(Ptr<const std::string>::Ref message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Replace the placeholders in the RDS settings with the current values.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: substituteRdsData(Ptr<Glib::ustring>::Ref rdsString)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
Ptr<Playable>::Ref playable = masterPanel->getCurrentInnerPlayable();
|
||||||
|
|
||||||
|
// these substitutions are documented in the doxygen docs of the
|
||||||
|
// public updateRds() function
|
||||||
|
substituteRdsItem(rdsString, "%c", playable, "dc:creator");
|
||||||
|
substituteRdsItem(rdsString, "%t", playable, "dc:title");
|
||||||
|
substituteRdsItem(rdsString, "%d", playable, "dc:format:extent");
|
||||||
|
substituteRdsItem(rdsString, "%s", playable, "dc:source");
|
||||||
|
substituteRdsItem(rdsString, "%y", playable, "ls:year");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Replace a single placeholders in the RDS settings.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: substituteRdsItem(Ptr<Glib::ustring>::Ref rdsString,
|
||||||
|
const std::string & placeholder,
|
||||||
|
Ptr<Playable>::Ref playable,
|
||||||
|
const std::string & metadataKey)
|
||||||
|
throw ()
|
||||||
|
{
|
||||||
|
unsigned int pos;
|
||||||
|
while ((pos = rdsString->find(placeholder)) != std::string::npos) {
|
||||||
|
Ptr<const Glib::ustring>::Ref value;
|
||||||
|
if (playable) {
|
||||||
|
value = playable->getMetadata(metadataKey);
|
||||||
|
}
|
||||||
|
if (!value) {
|
||||||
|
value.reset(new Glib::ustring("?"));
|
||||||
|
}
|
||||||
|
rdsString->replace(pos, placeholder.length(), *value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Read the RDS settings, and send them to the serial port.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: updateRds(void) throw ()
|
||||||
|
{
|
||||||
|
Ptr<Glib::ustring>::Ref
|
||||||
|
rdsString = optionsContainer->getCompleteRdsString();
|
||||||
|
if (rdsString) {
|
||||||
|
substituteRdsData(rdsString);
|
||||||
|
writeToSerial(rdsString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -368,6 +368,41 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
refreshPlaylistInLiveMode(Ptr<Playlist>::Ref playlist)
|
refreshPlaylistInLiveMode(Ptr<Playlist>::Ref playlist)
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace the placeholders in the RDS settings with the
|
||||||
|
* current values.
|
||||||
|
*
|
||||||
|
* @param rdsString the string with the placeholders;
|
||||||
|
* they will be replaced in place.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
substituteRdsData(Ptr<Glib::ustring>::Ref rdsString)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace a single placeholders in the RDS settings.
|
||||||
|
* If the corresponding metadata is not found, a "?" character
|
||||||
|
* is substituted instead.
|
||||||
|
*
|
||||||
|
* @param rdsString the string with the placeholders;
|
||||||
|
* they will be replaced in place.
|
||||||
|
* @param placeholder the string to be substituted, e.g. "%t".
|
||||||
|
* @param playable the Playable object whose data is to be used.
|
||||||
|
* @param metadataKay the kind of metadata to be substituted.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
substituteRdsItem(Ptr<Glib::ustring>::Ref rdsString,
|
||||||
|
const std::string & placeholder,
|
||||||
|
Ptr<Playable>::Ref playable,
|
||||||
|
const std::string & metadataKey)
|
||||||
|
throw ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a string to the serial device.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
writeToSerial(Ptr<const Glib::ustring>::Ref message) throw ();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -1291,10 +1326,20 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
createScratchpadWindow(void) throw ();
|
createScratchpadWindow(void) throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a string to the serial device.
|
* Read the RDS settings, and send them to the serial port.
|
||||||
|
*
|
||||||
|
* The following RDS placeholders will be substituted:
|
||||||
|
*
|
||||||
|
* "%c" ---> "dc:creator" (Creator)
|
||||||
|
* "%t" ---> "dc:title" (Title)
|
||||||
|
* "%d" ---> "dc:format:extent" (Duration)
|
||||||
|
* "%s" ---> "dc:source" (Album)
|
||||||
|
* "%y" ---> "ls:year" (Year)
|
||||||
|
*
|
||||||
|
* @see substituteRdsData()
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
writeToSerial(Ptr<const std::string>::Ref message) throw ();
|
updateRds(void) throw ();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ================================================= external data structures */
|
/* ================================================= external data structures */
|
||||||
|
|
|
@ -441,6 +441,9 @@ MasterPanelWindow :: onUpdateTime(int dummy) throw ()
|
||||||
// refresh all windows
|
// refresh all windows
|
||||||
gLiveSupport->runMainLoop();
|
gLiveSupport->runMainLoop();
|
||||||
|
|
||||||
|
// refresh the RDS display
|
||||||
|
gLiveSupport->updateRds();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,17 +783,6 @@ MasterPanelWindow :: getNextItemToPlay() throw ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* Set the "now playing" display.
|
|
||||||
*----------------------------------------------------------------------------*/
|
|
||||||
void
|
|
||||||
MasterPanelWindow :: setNowPlaying(Ptr<Playable>::Ref playable)
|
|
||||||
throw ()
|
|
||||||
{
|
|
||||||
nowPlayingWidget->setPlayable(playable);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Resize an image to fit in a box, preserving its aspect ratio.
|
* Resize an image to fit in a box, preserving its aspect ratio.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -876,7 +868,7 @@ MasterPanelWindow :: uploadToHub(Ptr<Playable>::Ref playable)
|
||||||
searchButton));
|
searchButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = searchWindow->uploadToHub(playable);
|
searchWindow->uploadToHub(playable);
|
||||||
|
|
||||||
searchWindow->present();
|
searchWindow->present();
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,9 +549,25 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the "now playing" display.
|
* Set the "now playing" display.
|
||||||
|
*
|
||||||
|
* @param playable the Playable whose data is to be displayed.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
setNowPlaying(Ptr<Playable>::Ref playable) throw ();
|
setNowPlaying(Ptr<Playable>::Ref playable) throw ()
|
||||||
|
{
|
||||||
|
nowPlayingWidget->setPlayable(playable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Playable currently shown in the "now playing" display.
|
||||||
|
*
|
||||||
|
* @return the currently playing item; 0 if nothing is playing.
|
||||||
|
*/
|
||||||
|
Ptr<Playable>::Ref
|
||||||
|
getCurrentInnerPlayable(void) throw ()
|
||||||
|
{
|
||||||
|
return nowPlayingWidget->getCurrentInnerPlayable();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload a Playable object to the network hub.
|
* Upload a Playable object to the network hub.
|
||||||
|
|
|
@ -203,7 +203,10 @@ NowPlaying :: setPlayable(Ptr<Playable>::Ref playable) throw ()
|
||||||
playlistLabel->set_text("");
|
playlistLabel->set_text("");
|
||||||
resetRemainsTimeState();
|
resetRemainsTimeState();
|
||||||
this->playable.reset();
|
this->playable.reset();
|
||||||
|
this->currentInnerPlayable.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gLiveSupport->updateRds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -380,6 +383,8 @@ NowPlaying :: onUpdateTime(void) throw ()
|
||||||
innerElapsed ));
|
innerElapsed ));
|
||||||
remainsTime->set_text(*TimeConversion::timeDurationToHhMmSsString(
|
remainsTime->set_text(*TimeConversion::timeDurationToHhMmSsString(
|
||||||
innerRemains ));
|
innerRemains ));
|
||||||
|
|
||||||
|
currentInnerPlayable = innerPlayable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,10 +84,16 @@ class NowPlaying : public Gtk::HBox,
|
||||||
bool isPaused;
|
bool isPaused;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The item which is currently playing.
|
* The item which is currently playing (audio clip or playlist).
|
||||||
*/
|
*/
|
||||||
Ptr<Playable>::Ref playable;
|
Ptr<Playable>::Ref playable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audio clip which is currently playing (could be nested
|
||||||
|
* several levels inside the "playable" object).
|
||||||
|
*/
|
||||||
|
Ptr<Playable>::Ref currentInnerPlayable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The label holding the title of the now playing item.
|
* The label holding the title of the now playing item.
|
||||||
*/
|
*/
|
||||||
|
@ -279,6 +285,21 @@ class NowPlaying : public Gtk::HBox,
|
||||||
{
|
{
|
||||||
onStopButtonClicked();
|
onStopButtonClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Playable object which is playing now.
|
||||||
|
* If a playlist is playing, does not return the playlist, but
|
||||||
|
* the audio clip inside the playlist (possibly several levels deep).
|
||||||
|
*
|
||||||
|
* This is used by GLiveSupport::substituteRdsData().
|
||||||
|
*
|
||||||
|
* @return the currently playing item; 0 if nothing is playing.
|
||||||
|
*/
|
||||||
|
Ptr<Playable>::Ref
|
||||||
|
getCurrentInnerPlayable(void) throw ()
|
||||||
|
{
|
||||||
|
return currentInnerPlayable;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue