|
pianod2
multisource multiuser scriptable networked music player
|
Base class that wraps any audio source, such as Pandora, Spotify, or local music. More...
#include <mediaunit.h>


Public Types | |
| 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... | |
Public Member Functions | |
| Source (SourceParameters *params) | |
| Initialize the source. More... | |
| virtual | ~Source (void) |
| Destroy a source. More... | |
| void | persist (void) const |
| Persist source parameters, attaching them to the owner's user data. More... | |
| virtual bool | flush (void) |
| Persist data for a source. 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 Statistics & | getStatistics () 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 |
| virtual const char * | kind (void) const =0 |
| A unique string identifying the type of source. More... | |
| 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... | |
| virtual bool | requireNameForCreatePlaylist (void) const |
| Indicate if a name is required when creating a playlist. More... | |
| PianodPlaylist * | getPlaylistByName (const char *name) |
| Retrieve a playlist by name. More... | |
| virtual PlaylistList | getPlaylists (const Filter &filter=Filter::All)=0 |
| Retrieve the source's playlists. More... | |
| virtual PianodPlaylist * | getMixPlaylist (void)=0 |
| virtual PianodPlaylist * | getEverythingPlaylist (void)=0 |
| virtual PianodPlaylist * | getTransientPlaylist (const Filter &criteria) |
| Create a temporary playlist based on a filter. More... | |
| virtual PianodPlaylist * | createPlaylist (const char *name, MusicThingie::Type type, MusicThingie *from) |
| Create a playlist using a thingie as an initial seed. More... | |
| virtual PianodPlaylist * | createPlaylist (const char *name, const Filter &filter) |
| Create a playlist using a filter. More... | |
| virtual MusicThingie * | getAnythingById (const SplitId &id)=0 |
| virtual Player * | getPlayer (const AudioSettings &audio, PianodSong *song)=0 |
| virtual SongList | getRandomSongs (PianodPlaylist *playlist, const UserList &users, SelectionMethod selectionMethod)=0 |
| virtual ThingieList | getSuggestions (const Filter &filter, SearchRange what=SearchRange::EXHAUSTIVE)=0 |
| virtual float | periodic (void) |
| Do intermittent or background tasks. More... | |
| void | playbackComplete (bool played, bool successfully) |
| Update playback statistics. More... | |
| virtual void | playbackProblem (void) |
| virtual MusicThingie * | getSuggestion (MusicThingie *thing, MusicThingie::Type type, SearchRange where=SearchRange::SHALLOW)=0 |
| Retrieve an equivalent or related album, artist, or song from a source. More... | |
| MusicThingie * | getSuggestion (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... | |
| User * | getOwner (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 |
Protected Types | |
| enum class | State { INITIALIZING , VALID , READY , DEAD } |
Protected Member Functions | |
| MusicThingie * | getSuggestion (MusicThingie *thing, MusicThingie::Type type, SearchRange where, bool fully_confirm) |
| Get a thing as a suggestion of a specific type. More... | |
Protected Attributes | |
| State | state = State::INITIALIZING |
| const SourceParameters * | parameters = nullptr |
| Configuration details for this source, provided on source creation. More... | |
Static Private Member Functions | |
| static void | defaultStatusHandler (RESPONSE_CODE status, const char *detail) |
| Log status and alert messages by sending them to stdout. More... | |
Private Attributes | |
| SerialNumber | serialNum = 0 |
| Assigned by media manager when registered. More... | |
| State | announced_state = State::INITIALIZING |
| Used by media manager for managing callbacks. More... | |
| Statistics | statistics |
| Source playback statistics. More... | |
| time_t | lockout_until = 0 |
| std::function< void(RESPONSE_CODE status, const char *detail)> | statusHandler = defaultStatusHandler |
| Hook for the status handler, allowing status messages to be rerouted. More... | |
Friends | |
| class | Manager |
Base class that wraps any audio source, such as Pandora, Spotify, or local music.
Provides a standard interface that pianod can work with. Players can extend their interface with custom commands by deriving from both this and PianodInterpreter, and providing their specialized commands. Care should be used to avoid polluting command space with potentially generic commands.
| typedef unsigned long Media::Source::SerialNumber |
|
strongprotected |
| Media::Source::Source | ( | SourceParameters * | params | ) |
Initialize the source.
| params | Source parameters. |
|
virtual |
Destroy a source.
Reimplemented in ToneGenerator::Source, Filesystem::Source, and Pandora::Source.
| void Media::Source::alert | ( | RESPONSE_CODE | message | ) | const |
Send an alert notification regarding this source.
The source's identity is appended and the message routed through the status handler, which is usually routed to the media manager.
| message | The numeric status code for the alert. |


| void Media::Source::alert | ( | RESPONSE_CODE | message, |
| const char * | detail, | ||
| const char * | reason = nullptr |
||
| ) | const |
Send an alert notification regarding this source.
The source's identity is appended and the message routed through the status handler, which is usually routed to the media manager.
| message | The numeric status code for the alert. |
| detail | Additional text pertaining to the alert. |
| reason | Optional text describing the reason for the alert. |

|
virtual |
Indicate if arbitrary tracks can be requested from this source.
Reimplemented in ToneGenerator::Source, Media::Manager, and Filesystem::Source.

|
virtual |
Create a playlist using a filter.
| name | The name of the playlist |
| filter | The selection criteria. |
| CommandError | if a request is invalid. |
Reimplemented in ToneGenerator::Source, Media::Manager, and Filesystem::Source.

|
virtual |
Create a playlist using a thingie as an initial seed.
Seed type allows, for example, to use a song's artist.
| name | The name of the playlist. |
| type | The type of seed to create. |
| from | The initial seed. |
| CommandError | if a request is invalid. |
Reimplemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.


|
staticprivate |
Log status and alert messages by sending them to stdout.
This function is invoked indirectly so that it may be replaced by the media manager, which then posts the status notifications to its subscribers. .
|
inline |
Provide a filename for persisting the source's data.


|
virtual |
Persist data for a source.
Reimplemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.
|
pure virtual |
Implemented in Media::Manager, ToneGenerator::Source, Pandora::Source, and Filesystem::Source.

|
pure virtual |
Implemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.

|
pure virtual |
Implemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.

|
pure virtual |
Implemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.
| PianodPlaylist * Media::Source::getPlaylistByName | ( | const char * | name | ) |
Retrieve a playlist by name.
| name | The name of the playlist to retrieve. |


|
pure virtual |
Retrieve the source's playlists.
| filter | Criteria specifying the subset of the playlists to retrieve. |
Implemented in Pandora::Source, Media::Manager, Filesystem::Source, and ToneGenerator::Source.


|
pure virtual |
Implemented in Media::Manager, ToneGenerator::Source, Filesystem::Source, and Pandora::Source.

|
inline |
Retrieve playback statistics about the source.

|
protected |
Get a thing as a suggestion of a specific type.
| thing | The thing to transform. |
| type | The type of suggestion to retrieve. |
| where | Where to search:
|
| fully_confirm | If false, album and title are enough for a song match. If true, either album name or duration must also match. |
| CommandError | if not found or ambiguous results. |

|
pure virtual |
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.
| thing | The item to match. |
| type | The desired type to find. |
| where | Selects the depth/exhaustiveness of search. |
| CommandError | with:
|
Implemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.


|
inline |
Retrieve an equivalent album, artist, or song from a source.
getSuggestion, 3-parameter version. 
|
pure virtual |
Implemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.

|
virtual |
Create a temporary playlist based on a filter.
| criteria | A filter specifying the song selection algorithm. |
| E_MEDIA_ACTION | if a non-request source. |
Reimplemented in ToneGenerator::Source, Media::Manager, and Filesystem::Source.

| std::string Media::Source::identify | ( | ) | const |
Identify the unique source.


|
inline |
Check if source is temporarily locked out due to repeated failures.

|
inline |
Check if the source is online.

|
inline |
|
pure virtual |
A unique string identifying the type of source.
Implemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.

| const std::string & Media::Source::name | ( | void | ) | const |
Get the name of this source.
The kind/name combination is used by the media manager to identify individual sources.

|
virtual |
Do intermittent or background tasks.
Reimplemented in ToneGenerator::Source, Pandora::Source, Media::Manager, and Filesystem::Source.
| void Media::Source::persist | ( | void | ) | const |
Persist source parameters, attaching them to the owner's user data.


| void Media::Source::playbackComplete | ( | bool | played, |
| bool | successfully | ||
| ) |
Update playback statistics.


|
inlinevirtual |
Reimplemented in Filesystem::Source.
| void Media::Source::reportStatus | ( | const char * | detail | ) | const |
Send a status notification regarding this source.
The status is routed through alert.
| detail | The status message. |


|
inline |

|
virtual |
Indicate if a name is required when creating a playlist.
Reimplemented in Pandora::Source.

| Parsnip::Data Media::Source::serializeIdentity | ( | ) | const |


|
inline |
Get the source's unique number assigned by the media manager.

|
friend |
|
private |
Used by media manager for managing callbacks.
|
private |
|
protected |
Configuration details for this source, provided on source creation.
|
private |
Assigned by media manager when registered.
|
protected |
|
private |
Source playback statistics.
|
private |
Hook for the status handler, allowing status messages to be rerouted.