|
a/src/cdplugins/cdplugin.hxx |
|
b/src/cdplugins/cdplugin.hxx |
|
... |
|
... |
17 |
#ifndef _CDPLUGIN_H_INCLUDED_
|
17 |
#ifndef _CDPLUGIN_H_INCLUDED_
|
18 |
#define _CDPLUGIN_H_INCLUDED_
|
18 |
#define _CDPLUGIN_H_INCLUDED_
|
19 |
|
19 |
|
20 |
#include <string>
|
20 |
#include <string>
|
21 |
#include "upmpdutils.hxx"
|
21 |
#include "upmpdutils.hxx"
|
|
|
22 |
#include "libupnpp/device/vdir.hxx"
|
22 |
|
23 |
|
|
|
24 |
class CDPlugin;
|
|
|
25 |
class ConfSimple;
|
|
|
26 |
|
|
|
27 |
/// Service/Environment interface for media server modules
|
|
|
28 |
class CDPluginServices {
|
|
|
29 |
public:
|
|
|
30 |
/// Returns something like "/tidal" (no end slash)
|
|
|
31 |
virtual std::string getpathprefix(CDPlugin *) = 0;
|
|
|
32 |
|
|
|
33 |
/// Retrieve the IP address and port for the libupnp server. URLs
|
|
|
34 |
/// intended to be served this way (by adding a vdir) should use
|
|
|
35 |
/// these as host/port
|
|
|
36 |
virtual std::string getupnpaddr(CDPlugin *) = 0;
|
|
|
37 |
virtual int getupnpport(CDPlugin *) = 0;
|
|
|
38 |
|
|
|
39 |
/// Add a virtual directory and set file operation interface. path
|
|
|
40 |
/// must be equal or begin with the pathprefix.
|
|
|
41 |
virtual bool setfileops(CDPlugin *, const std::string& path,
|
|
|
42 |
UPnPProvider::VirtualDir::FileOps ops)= 0;
|
|
|
43 |
|
|
|
44 |
/// Access the main configuration file.
|
|
|
45 |
virtual ConfSimple *getconfig(CDPlugin *)= 0;
|
|
|
46 |
virtual const std::vector<std::string> getexecpath(CDPlugin *)= 0;
|
|
|
47 |
};
|
|
|
48 |
|
23 |
// Interface for media server modules
|
49 |
/// Interface to media server modules
|
|
|
50 |
///
|
|
|
51 |
/// The main operations, Browse and Search, return content as UpSong
|
|
|
52 |
/// structures. At the very minimum, id, parentid, iscontainer and
|
|
|
53 |
/// title should be properly set for each entry. Id is very important for
|
|
|
54 |
/// directories (containers), because this is the main parameter to
|
|
|
55 |
/// the browse call. title is what gets displayed in lists by the
|
|
|
56 |
/// control point.
|
|
|
57 |
///
|
|
|
58 |
/// The rest of the UpSong fields are only meaningful for items
|
|
|
59 |
/// (tracks), and only one is mandatory: uri.
|
|
|
60 |
///
|
|
|
61 |
/// The item uri will be used by the renderer for fetching the data to
|
|
|
62 |
/// be played. Three types can be used:
|
|
|
63 |
/// - A direct URL, usable by the renderer for fetching the data from
|
|
|
64 |
/// wherever it is (for example a radio stream HTTP URL).
|
|
|
65 |
/// - A vdir URL: this should have a host/port part matching the media
|
|
|
66 |
/// server host/port (which can be obtained through the environment
|
|
|
67 |
/// interface). Data will be fetched by libupnp using the vdir
|
|
|
68 |
/// interface. This is simple but limited: the libupnp HTTP server
|
|
|
69 |
/// does not emit "accept-range" headers, meaning that most CPs will
|
|
|
70 |
/// not try range requests, and that seeking will not work. No
|
|
|
71 |
/// redirects are possible. The URL path part should begin with the
|
|
|
72 |
/// pathprefix, which is how the request will be routed to the
|
|
|
73 |
/// appropriate plugin.
|
|
|
74 |
/// - A libmicrohttpd URL. A plugin may start a microhttpd instance,
|
|
|
75 |
/// and receive the connections directly. The host/port will be
|
|
|
76 |
/// obtained from the configuration. The advantage is that redirects
|
|
|
77 |
/// and range requests are possible, but it is a bit more
|
|
|
78 |
/// complicated as some libmicrohttpd knowledge is required.
|
|
|
79 |
///
|
24 |
class CDPlugin {
|
80 |
class CDPlugin {
|
25 |
public:
|
81 |
public:
|
26 |
CDPlugin() {
|
82 |
CDPlugin(const std::string& name, CDPluginServices *services)
|
|
|
83 |
: m_name(name), m_services(services) {
|
27 |
}
|
84 |
}
|
28 |
virtual ~CDPlugin() {
|
85 |
virtual ~CDPlugin() {
|
29 |
}
|
86 |
}
|
30 |
|
87 |
|
31 |
/// List children or return metadata for target object. You can
|
88 |
/// List children or return metadata for target object. You can
|
|
... |
|
... |
33 |
enum BrowseFlag {BFChildren, BFMeta};
|
90 |
enum BrowseFlag {BFChildren, BFMeta};
|
34 |
|
91 |
|
35 |
/// Browse object at objid, which should be a container, and
|
92 |
/// Browse object at objid, which should be a container, and
|
36 |
/// return its content.
|
93 |
/// return its content.
|
37 |
///
|
94 |
///
|
38 |
/// This reflects an UPnP Browse action, refer to UPnP documentation.
|
95 |
/// This reflects an UPnP Browse action. Refer to UPnP documentation.
|
39 |
///
|
96 |
///
|
40 |
/// @param objid the object to browse.
|
97 |
/// @param objid the object to browse.
|
41 |
/// @param stidx first entry to return.
|
98 |
/// @param stidx first entry to return.
|
42 |
/// @param cnt number of entries.
|
99 |
/// @param cnt number of entries.
|
43 |
/// @param[output] entries output content.
|
100 |
/// @param[output] entries output content.
|
|
... |
|
... |
67 |
const std::string& ctid, int stidx, int cnt,
|
124 |
const std::string& ctid, int stidx, int cnt,
|
68 |
const std::string& searchstr,
|
125 |
const std::string& searchstr,
|
69 |
std::vector<UpSong>& entries,
|
126 |
std::vector<UpSong>& entries,
|
70 |
const std::vector<std::string>& sortcrits = std::vector<std::string>())
|
127 |
const std::vector<std::string>& sortcrits = std::vector<std::string>())
|
71 |
= 0;
|
128 |
= 0;
|
|
|
129 |
|
|
|
130 |
const std::string& getname() {
|
|
|
131 |
return m_name;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
std::string m_name;
|
|
|
135 |
CDPluginServices *m_services;
|
72 |
};
|
136 |
};
|
73 |
|
137 |
|
74 |
#endif /* _CDPLUGIN_H_INCLUDED_ */
|
138 |
#endif /* _CDPLUGIN_H_INCLUDED_ */
|