pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
Pandora::Source Class Reference

#include <pandora.h>

Inheritance diagram for Pandora::Source:
Inheritance graph
[legend]
Collaboration diagram for Pandora::Source:
Collaboration graph
[legend]

Public Member Functions

const ConnectionParametersconnectionParams () const
 
 Source (const ConnectionParameters &params)
 
 ~Source ()
 Destroy a source. More...
 
virtual const char * kind (void) const override
 A unique string identifying the type of source. More...
 
virtual bool requireNameForCreatePlaylist (void) const override
 Indicate if a name is required when creating a playlist. More...
 
virtual bool flush (void) override
 Persist data for a source. More...
 
virtual float periodic (void) override
 Do intermittent or background tasks. More...
 
virtual PlaylistList getPlaylists (const Filter &filter=Filter::All) override
 Retrieve the source's playlists. More...
 
virtual PianodPlaylistgetMixPlaylist (void) override
 Retrieve the mix playlist. More...
 
virtual PianodPlaylistgetEverythingPlaylist (void) override
 Retrieve the everything playlist. More...
 
virtual Media::PlayergetPlayer (const AudioSettings &audio, PianodSong *song) override
 
virtual MusicThingiegetAnythingById (const Media::SplitId &id) override
 
virtual ThingieList getSuggestions (const Filter &filter, SearchRange where) override
 
virtual PianodPlaylistcreatePlaylist (const char *name, MusicThingie::Type type, MusicThingie *from) override
 Create a playlist using a thingie as an initial seed. More...
 
virtual SongList getRandomSongs (PianodPlaylist *playlist, const UserList &, Media::SelectionMethod) override
 
virtual MusicThingiegetSuggestion (MusicThingie *thing, MusicThingie::Type type, SearchRange where) override
 Retrieve an equivalent or related album, artist, or song from a source. More...
 
StationgetStationByStationId (const std::string &station_id)
 
void removeStationByStationId (const std::string &station_id)
 
Status executeRequest (Request &request)
 
const UserFeaturesuserFeatures () const
 
- Public Member Functions inherited from Media::Source
 Source (SourceParameters *params)
 Initialize the source. More...
 
void persist (void) const
 Persist source parameters, attaching them to the owner's user data. More...
 
bool isReady (void) const
 Check if the source is online. More...
 
SerialNumber serialNumber (void) const
 Get the source's unique number assigned by the media manager. More...
 
const StatisticsgetStatistics () const
 Retrieve playback statistics about the source. More...
 
const bool isLockedOut () const
 Check if source is temporarily locked out due to repeated failures. More...
 
Parsnip::Data serializeIdentity () const
 
std::string identify () const
 Identify the unique source. More...
 
void alert (RESPONSE_CODE message) const
 Send an alert notification regarding this source. More...
 
void alert (RESPONSE_CODE message, const char *detail, const char *reason=nullptr) const
 Send an alert notification regarding this source. More...
 
void reportStatus (const char *detail) const
 Send a status notification regarding this source. More...
 
void reportStatus (const std::string &detail) const
 
const std::string & name (void) const
 Get the name of this source. More...
 
std::string key (void) const
 Key is a combination of kind and name. More...
 
std::string filename (void) const
 Provide a filename for persisting the source's data. More...
 
virtual bool canExpandToAllSongs (void) const
 Indicate if arbitrary tracks can be requested from this source. More...
 
PianodPlaylistgetPlaylistByName (const char *name)
 Retrieve a playlist by name. More...
 
virtual PianodPlaylistgetTransientPlaylist (const Filter &criteria)
 Create a temporary playlist based on a filter. More...
 
virtual PianodPlaylistcreatePlaylist (const char *name, const Filter &filter)
 Create a playlist using a filter. More...
 
void playbackComplete (bool played, bool successfully)
 Update playback statistics. More...
 
virtual void playbackProblem (void)
 
MusicThingiegetSuggestion (MusicThingie *thing, SearchRange where=SearchRange::SHALLOW)
 Retrieve an equivalent album, artist, or song from a source. More...
 
- Public Member Functions inherited from PrimaryOwnership
 PrimaryOwnership (void)
 Default construct ownership: No owner, private access. More...
 
 PrimaryOwnership (Type rule, User *owner=nullptr)
 Construct ownership. More...
 
 ~PrimaryOwnership (void)
 
void abandon (void)
 Disassociate ownership from any owner, and mark as disowned. More...
 
void abandon (const User *user)
 Conditionally dissociate ownership. More...
 
UsergetOwner (void) const
 
bool isOwned (void) const
 
const std::string & ownerName (void) const
 Retrieve the name of the owner. More...
 
virtual bool isOwnedBy (const User *user) const override
 Check if we are owned by a user. More...
 
virtual bool hasPermission (const User *user, Action action) const override
 Determine if a user has permission to use this item in some manner. More...
 
- Public Member Functions inherited from Ownership
bool isVisibleBy (const User *user) const
 
bool isUsableBy (const User *user) const
 
bool isDecendableBy (const User *user) const
 
bool isReadableBy (const User *user) const
 
bool isEditableBy (const User *user) const
 

Public Attributes

Library library
 Lookup table of things we gave out. More...
 
SearchResults prior_searches
 Search results saved for reuse;. More...
 
SkipTracker skips {60, 86400}
 Skip counts for limiting. More...
 

Private Types

using SearchResults = std::unordered_map< std::string, ThingieList >
 

Private Member Functions

bool updateStationList (PianodPlaylist::PlaylistType mixSetting=PianodPlaylist::SINGLE)
 Get initial or refresh station list. More...
 
void updateGenreStations ()
 Get initial or refresh genre station list. More...
 
bool initializeMix ()
 
void pushMixToServers (bool mix_all=false)
 Update the quickmix/station shuffle by sending a list of desired stations to Pandora. More...
 
void setMixAllOnServers ()
 
bool restore ()
 
bool persist () const
 

Private Attributes

StationLookup stations
 A collection of stations, indexed by station ID. More...
 
time_t station_list_expiration = 0
 When cached station list expires. More...
 
std::string station_list_checksum
 Checksum from last station list received. More...
 
time_t genre_stations_expiration = 0
 When genre stations list expires. More...
 
std::string genre_stations_checksum
 Checksum from last genre station list received. More...
 
PlaylistList genre_stations
 The genre stations. More...
 
Retainer< Station * > mix_playlist
 The mix/shuffle meta-playlist. More...
 
Retainer< Station * > everything_playlist
 The everything meta-playlist. More...
 
Communication comm
 Pandora server communicator. More...
 
std::unique_ptr< Parsnip::Datarecovery
 Data from persistence file. More...
 

Additional Inherited Members

- Public Types inherited from Media::Source
typedef unsigned long SerialNumber
 
- Public Types inherited from Ownership
enum class  Type {
  DISOWNED , PRIVATE , SHARED , PUBLISHED ,
  PUBLIC
}
 Access levels for an object. More...
 
enum class  Action { SEE , USE , READ , ALTER }
 Access actions for an object. More...
 
- Protected Types inherited from Media::Source
enum class  State { INITIALIZING , VALID , READY , DEAD }
 
- Protected Member Functions inherited from Media::Source
MusicThingiegetSuggestion (MusicThingie *thing, MusicThingie::Type type, SearchRange where, bool fully_confirm)
 Get a thing as a suggestion of a specific type. More...
 
- Protected Attributes inherited from Media::Source
State state = State::INITIALIZING
 
const SourceParametersparameters = nullptr
 Configuration details for this source, provided on source creation. More...
 

Member Typedef Documentation

◆ SearchResults

using Pandora::Source::SearchResults = std::unordered_map<std::string, ThingieList>
private

Constructor & Destructor Documentation

◆ Source()

Pandora::Source::Source ( const ConnectionParameters params)
Here is the call graph for this function:

◆ ~Source()

Pandora::Source::~Source ( void  )
virtual

Destroy a source.

Reimplemented from Media::Source.

Member Function Documentation

◆ connectionParams()

const ConnectionParameters* Pandora::Source::connectionParams ( ) const
inline
Here is the caller graph for this function:

◆ createPlaylist()

PianodPlaylist * Pandora::Source::createPlaylist ( const char *  name,
MusicThingie::Type  type,
MusicThingie from 
)
overridevirtual

Create a playlist using a thingie as an initial seed.

Seed type allows, for example, to use a song's artist.

Parameters
nameThe name of the playlist.
typeThe type of seed to create.
fromThe initial seed.
Returns
The playlist created.
Exceptions
CommandErrorif a request is invalid.

Reimplemented from Media::Source.

Here is the call graph for this function:

◆ executeRequest()

Status Pandora::Source::executeRequest ( Request request)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush()

bool Pandora::Source::flush ( void  )
overridevirtual

Persist data for a source.

Returns
True on success, false on error.

Reimplemented from Media::Source.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAnythingById()

MusicThingie * Pandora::Source::getAnythingById ( const Media::SplitId id)
overridevirtual

Implements Media::Source.

Here is the call graph for this function:

◆ getEverythingPlaylist()

PianodPlaylist * Pandora::Source::getEverythingPlaylist ( void  )
overridevirtual

Retrieve the everything playlist.

Implements Media::Source.

◆ getMixPlaylist()

PianodPlaylist * Pandora::Source::getMixPlaylist ( void  )
overridevirtual

Retrieve the mix playlist.

Implements Media::Source.

◆ getPlayer()

Media::Player * Pandora::Source::getPlayer ( const AudioSettings audio,
PianodSong song 
)
overridevirtual

Implements Media::Source.

Here is the call graph for this function:

◆ getPlaylists()

PlaylistList Pandora::Source::getPlaylists ( const Filter filter = Filter::All)
overridevirtual

Retrieve the source's playlists.

Parameters
filterCriteria specifying the subset of the playlists to retrieve.
Returns
Playlists matching the filter, or all playlists if omitted.

Implements Media::Source.

Here is the call graph for this function:

◆ getRandomSongs()

SongList Pandora::Source::getRandomSongs ( PianodPlaylist playlist,
const UserList ,
Media::SelectionMethod   
)
overridevirtual

Implements Media::Source.

Here is the call graph for this function:

◆ getStationByStationId()

Station * Pandora::Source::getStationByStationId ( const std::string &  station_id)

Retrieve station from station list by station ID.

Parameters
station_idThe station ID of the station.
Returns
The station.
Here is the caller graph for this function:

◆ getSuggestion()

MusicThingie * Pandora::Source::getSuggestion ( MusicThingie thing,
MusicThingie::Type  type,
SearchRange  where 
)
overridevirtual

Retrieve an equivalent or related album, artist, or song from a source.

To support pianod's engine, this converts items between sources. The engine should not be asking for type conversions within a source.

Parameters
thingThe item to match.
typeThe desired type to find.
whereSelects the depth/exhaustiveness of search.
Returns
The single, best-matching item.
Exceptions
CommandErrorwith:
  • E_INVALID (inadequate criteria)
  • E_AMBIGUOUS (multiple matches)
  • E_NOTFOUND.

Implements Media::Source.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSuggestions()

ThingieList Pandora::Source::getSuggestions ( const Filter filter,
SearchRange  where 
)
overridevirtual

Implements Media::Source.

Here is the call graph for this function:

◆ initializeMix()

bool Pandora::Source::initializeMix ( )
private

◆ kind()

const char * Pandora::Source::kind ( void  ) const
overridevirtual

A unique string identifying the type of source.

Implements Media::Source.

◆ periodic()

float Pandora::Source::periodic ( void  )
overridevirtual

Do intermittent or background tasks.

Returns
Suggested time before periodic() be invoked again. No guarantees are offered about actual behavior.

Reimplemented from Media::Source.

Here is the call graph for this function:

◆ persist()

bool Pandora::Source::persist ( void  ) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushMixToServers()

void Pandora::Source::pushMixToServers ( bool  mix_all = false)
private

Update the quickmix/station shuffle by sending a list of desired stations to Pandora.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeStationByStationId()

void Pandora::Source::removeStationByStationId ( const std::string &  station_id)

Delete station from station list by station ID.

Parameters
station_idThe station ID of the station.
Here is the caller graph for this function:

◆ requireNameForCreatePlaylist()

bool Pandora::Source::requireNameForCreatePlaylist ( void  ) const
overridevirtual

Indicate if a name is required when creating a playlist.

Returns
True if a name is required, false otherwise.

Reimplemented from Media::Source.

◆ restore()

bool Pandora::Source::restore ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMixAllOnServers()

void Pandora::Source::setMixAllOnServers ( )
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateGenreStations()

void Pandora::Source::updateGenreStations ( )
private

Get initial or refresh genre station list.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateStationList()

bool Pandora::Source::updateStationList ( PianodPlaylist::PlaylistType  mixSetting = PianodPlaylist::SINGLE)
private

Get initial or refresh station list.

Parameters
mixSettingThe playing mix setting (single playlist, mix, or everything).
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ userFeatures()

const UserFeatures& Pandora::Source::userFeatures ( ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ comm

Communication Pandora::Source::comm
private

Pandora server communicator.

◆ everything_playlist

Retainer<Station *> Pandora::Source::everything_playlist
private

The everything meta-playlist.

◆ genre_stations

PlaylistList Pandora::Source::genre_stations
private

The genre stations.

◆ genre_stations_checksum

std::string Pandora::Source::genre_stations_checksum
private

Checksum from last genre station list received.

◆ genre_stations_expiration

time_t Pandora::Source::genre_stations_expiration = 0
private

When genre stations list expires.

◆ library

Library Pandora::Source::library

Lookup table of things we gave out.

◆ mix_playlist

Retainer<Station *> Pandora::Source::mix_playlist
private

The mix/shuffle meta-playlist.

◆ prior_searches

SearchResults Pandora::Source::prior_searches

Search results saved for reuse;.

◆ recovery

std::unique_ptr<Parsnip::Data> Pandora::Source::recovery
private

Data from persistence file.

◆ skips

SkipTracker Pandora::Source::skips {60, 86400}

Skip counts for limiting.

◆ station_list_checksum

std::string Pandora::Source::station_list_checksum
private

Checksum from last station list received.

◆ station_list_expiration

time_t Pandora::Source::station_list_expiration = 0
private

When cached station list expires.

◆ stations

StationLookup Pandora::Source::stations
private

A collection of stations, indexed by station ID.


The documentation for this class was generated from the following files: