Switch to unified view

a/src/mediaserver/cdplugins/cdplugin.hxx b/src/mediaserver/cdplugins/cdplugin.hxx
...
...
19
19
20
#include <string>
20
#include <string>
21
#include "upmpdutils.hxx"
21
#include "upmpdutils.hxx"
22
#include "libupnpp/device/vdir.hxx"
22
#include "libupnpp/device/vdir.hxx"
23
23
24
class CDPlugin;
25
class ConfSimple;
26
27
/// Service/Environment interface for media server modules
28
class CDPluginServices {
24
class CDPluginServices;
29
public:
30
    /// For modules which use the common microhttpd server
31
    /// (tidal/qobuz/gmusic). Returns something like "/tidal" (no end
32
    /// slash), which must be inserted at the top of the track URLs
33
    /// paths so that an HTTP request can be processed-for /
34
    /// dispatched-to the right plugin.
35
    virtual std::string getpathprefix(CDPlugin *) = 0;
36
    /// Returns the plugin to which belongs the parameter path, based
37
    /// on the path prefix above.
38
    virtual CDPlugin *getpluginforpath(const std::string& path) = 0;
39
40
    /// Retrieve the "friendly name" for the media server, for display purposes
41
    virtual std::string getfname() = 0;
42
    
43
    /// IP address for the server.
44
    ///
45
    /// This is the host address / network interface used by libupnp,
46
    /// which can only support one. All generated URLs should be for
47
    /// this address as this is the only one guaranteed to be
48
    /// accessible from clients (in case this server has several
49
    /// interfaces). 
50
    virtual std::string getupnpaddr(CDPlugin *) = 0;
51
    
52
    /// IP port used by the libupnp HTTP server.
53
    ///
54
    /// URLs intended to be served this way (by adding a vdir) should
55
    /// use this for the port value. No module does this at present so
56
    /// that this call is not used. The microhttpd instance (serves
57
    /// for the tidal/qobuz/gmusic plugins) uses port 49149 by
58
    /// default. The value can be changed with the "plgmicrohttpport"
59
    /// configuration variable. The local mediaserver (uprcl) uses
60
    /// neither the libupnp HTTP server nor microhttpd, but an internal
61
    /// Python server instance, on port 9090 by default (can be
62
    /// changed with the "uprclhostport" configuration variable).
63
    virtual int getupnpport(CDPlugin *) = 0;
64
65
    /// Add a virtual directory and set file operation interface. path
66
    /// must be equal or begin with the pathprefix. Not used at all at present.
67
    virtual bool setfileops(CDPlugin *, const std::string& path,
68
                            UPnPProvider::VirtualDir::FileOps ops)= 0;
69
70
    /// Get a pointer to the the main configuration file contents.
71
    virtual bool config_get(const std::string& nm, std::string& val) = 0;
72
};
73
25
74
/// Interface to media server modules
26
/// Interface to media server modules
75
///
27
///
76
/// The main operations, Browse and Search, return content as UpSong
28
/// The main operations, Browse and Search, return content as UpSong
77
/// structures. At the very minimum, id, parentid, iscontainer and
29
/// structures. At the very minimum, id, parentid, iscontainer and
...
...
160
112
161
    std::string m_name;
113
    std::string m_name;
162
    CDPluginServices *m_services;
114
    CDPluginServices *m_services;
163
};
115
};
164
116
117
/// Service/Environment interface for media server modules
118
class CDPluginServices {
119
public:
120
    /// Returns the plugin to which belongs the parameter path, based
121
    /// on the path prefix above.
122
    virtual CDPlugin *getpluginforpath(const std::string& path) = 0;
123
124
    /// Retrieve the "friendly name" for the media server, for display purposes
125
    virtual std::string getfname() = 0;
126
    
127
    /// IP address and port used by the libupnp HTTP server.
128
    ///
129
    /// This is the host address / network interface and port used by
130
    /// libupnp, which can only support one. URLs intended to be
131
    /// served this way (by adding a vdir) should should use this
132
    /// address as this is the only one guaranteed to be accessible
133
    /// from clients (in case this server has several interfaces).
134
    /// The getupnpport() call is unused at present because no module
135
    /// uses the internal server (all use the microhttpd started by
136
    /// plgwithslave).
137
    /// The getupnpaddr() call is used to determine the host for the
138
    /// microhttp server (so it works on the same i/f as the upnp one,
139
    /// always).
140
    ///
141
    /// The microhttpd instance uses port 49149 by default. The value
142
    /// can be changed with the "plgmicrohttpport" configuration
143
    /// variable. The local mediaserver (uprcl) uses neither the
144
    /// libupnp HTTP server nor microhttpd, but an internal Python
145
    /// server instance, on port 9090 by default (can be changed with
146
    /// the "uprclhostport" configuration variable).
147
    virtual std::string getupnpaddr(CDPlugin *) = 0;
148
    virtual int getupnpport(CDPlugin *) = 0;
149
    /// Add a virtual directory and set file operation interface. path
150
    /// must be equal or begin with the pathprefix. Not used at all at present.
151
    virtual bool setfileops(CDPlugin *, const std::string& path,
152
                            UPnPProvider::VirtualDir::FileOps ops)= 0;
153
154
    /// Main configuration file access.
155
    virtual bool config_get(const std::string& nm, std::string& val) = 0;
156
157
158
    /// Default port to start the server on
159
    static int default_microhttpport() { return 49149;}
160
161
    /// For modules which use the common microhttpd server
162
    /// (tidal/qobuz/gmusic). Returns something like "/tidal" (no end
163
    /// slash), which must be inserted at the top of the track URLs
164
    /// paths so that an HTTP request can be processed-for /
165
    /// dispatched-to the right plugin.
166
    static std::string getpathprefix(CDPlugin *plg) {
167
        return getpathprefix(plg->getname());
168
    }
169
    static std::string getpathprefix(const std::string& name) {
170
        return std::string("/") + name;
171
    }
172
};
173
165
#endif /* _CDPLUGIN_H_INCLUDED_ */
174
#endif /* _CDPLUGIN_H_INCLUDED_ */