libupnpp 0.16.0
A C++ wrapper for the Portable UPnP reference library
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
UPnPClient::UPnPDirObject Class Reference

UPnP Media Server directory entry, converted from XML data. More...

#include <cdircontent.hxx>

Public Types

enum  ObjType { objtnone = -1 , item , container }
 
enum  ItemClass {
  ITC_audioItem = 0 , ITC_playlist = 1 , ITC_unknown = 2 , ITC_videoItem = 3 ,
  ITC_audioItem_musicTrack = ITC_audioItem , ITC_audioItem_playlist = ITC_playlist
}
 

Public Member Functions

bool getprop (const std::string &name, std::string &value) const
 Get named property.
 
const std::string getprop (const std::string &name) const
 Get named property.
 
const std::string & getupropref (const std::string &name) const
 Get reference to first (supposed unique) instance of property.
 
bool getRoledArtists (std::vector< std::pair< std::string, std::string > > &out) const
 Specialized methods for artists, dealing with the role attribute and the special AlbumArtist role value.
 
std::string getAlbumArtist () const
 
std::string getArtists () const
 
std::string getAlbumArtistElseArtists () const
 
bool getrprop (unsigned int ridx, const std::string &nm, std::string &val) const
 Get named resource attribute.
 
std::string f2s (const std::string &nm, bool isresfield)
 Simplified interface to retrieving values: we don't distinguish between non-existing and empty, and we only use the first ressource.
 
int getDurationSeconds (unsigned ridx=0) const
 Return resource duration in seconds.
 
std::string getdidl () const
 Get a DIDL document suitable for sending to a mediaserver.
 
void clear ()
 
std::string dump () const
 

Public Attributes

std::string m_id
 Object Id.
 
std::string m_pid
 Parent Object Id.
 
std::string m_title
 Value of dc:title.
 
ObjType m_type
 Item or container.
 
ItemClass m_iclass
 Item type details.
 
std::multimap< std::string, std::string > m_props
 Storage for the properties.
 
std::vector< UPnPResourcem_resources
 Resources: there may be several, for example for different audio formats of the same track, each with an URI and descriptor fields.
 

Friends

class UPnPDirParser
 

Detailed Description

UPnP Media Server directory entry, converted from XML data.

This is a dumb data holder class, a struct with helpers.

Member Function Documentation

◆ getAlbumArtist()

std::string UPnPClient::UPnPDirObject::getAlbumArtist ( ) const
Returns
the value of upnp:artist role="AlbumArtist"

◆ getAlbumArtistElseArtists()

std::string UPnPClient::UPnPDirObject::getAlbumArtistElseArtists ( ) const
Returns
albumartist if set, else artists

◆ getArtists()

std::string UPnPClient::UPnPDirObject::getArtists ( ) const
Returns
concatenate all upnp:artist values, appending a role in parentheses if set, excluding AlbumArtist.

◆ getdidl()

std::string UPnPClient::UPnPDirObject::getdidl ( ) const

Get a DIDL document suitable for sending to a mediaserver.

We may have missed useful stuff while parsing the data from the content directory, so we send the original if we can.

◆ getDurationSeconds()

int UPnPClient::UPnPDirObject::getDurationSeconds ( unsigned  ridx = 0) const
inline

Return resource duration in seconds.

Parameters
ridxresource index.
Returns
duration or 1 if the attribute is not found.

◆ getprop() [1/2]

const std::string UPnPClient::UPnPDirObject::getprop ( const std::string &  name) const

Get named property.

Return empty value if it does not exist.

Parameters
name(e.g. dc:description, upnp:album...). Use m_title instead for dc:title, and the specialized artist methods for upnp:artist.
Returns
value if found, empty string if not found.

◆ getprop() [2/2]

bool UPnPClient::UPnPDirObject::getprop ( const std::string &  name,
std::string &  value 
) const

Get named property.

Discriminate non-existing from empty values

Parameters
name(dc:description, upnp:album...). Use m_title instead for dc:title, and the specialized artist methods for upnp:artist.
[out]valuethe parameter value if found
Returns
true if found.

◆ getRoledArtists()

bool UPnPClient::UPnPDirObject::getRoledArtists ( std::vector< std::pair< std::string, std::string > > &  out) const

Specialized methods for artists, dealing with the role attribute and the special AlbumArtist role value.

return vector of {role, artist} pairs (role can be empty).

◆ getrprop()

bool UPnPClient::UPnPDirObject::getrprop ( unsigned int  ridx,
const std::string &  nm,
std::string &  val 
) const
inline

Get named resource attribute.

Field names: "bitrate", "duration" (H:mm:ss.ms), "nrAudioChannels", "protocolInfo", "sampleFrequency" (Hz), "size" (bytes).

Parameters
ridxindex in resources array.
nmattribute name.
[output]value if found.
Returns
true if found, else false.

◆ getupropref()

const std::string & UPnPClient::UPnPDirObject::getupropref ( const std::string &  name) const

Get reference to first (supposed unique) instance of property.

Used for e.g. upnp:class

Member Data Documentation

◆ m_props

std::multimap<std::string, std::string> UPnPClient::UPnPDirObject::m_props

Storage for the properties.

Properties as gathered from the XML document (album, artist, etc.). In general, the multimap keys are the XML tag names, with exceptions:

  • dc:title is stored in a proper field, m_title.
  • upnp:artist fields with an an additional role are stored with the following key: upnp:artist role="rolename" There are utility functions to deal with this. upnp:artist is the only property in UPnP 1 with a significant attribute (role).

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