21 #ifndef GV_HTTPSERVER__H
22 #define GV_HTTPSERVER__H
37 class HttpServerSource ;
38 class HttpServerSources ;
39 class HttpServerConfig ;
40 class HttpServerResources ;
41 class HttpServerInput ;
65 virtual void onException( std::exception & )
override ;
66 virtual void readEvent()
override ;
71 unsigned int m_reopen_timeout ;
88 std::string
name()
const ;
92 std::string
info()
const ;
126 unsigned int channel_reopen_timeout ) ;
138 bool valid(
const std::string & url_path ) ;
151 typedef std::pair<ImageInputSource*,HttpServerInput*> Pair ;
154 Pair findByName(
const std::string & ) ;
155 Pair findByNumber(
size_t ) ;
156 bool addChannel(
const std::string & ,
bool do_throw ) ;
161 std::vector<Pair> m_list ;
162 unsigned int m_reopen_timeout ;
189 void addChannel(
const std::string & channel_name ) ;
195 std::string
setDefault(
const std::string & ) ;
202 std::vector<std::string>
channels()
const ;
253 ResourceType resourceType(
const G::Path & url_path )
const ;
254 static bool readable(
const G::Path & ) ;
255 void log( std::ostream & )
const ;
256 static G::Path normalise(
const G::Path & path_in ,
const std::string & default_ ) ;
260 typedef std::map<std::string,std::string> Map ;
264 bool m_with_specials ;
265 std::string m_default_resource ;
266 std::vector<std::string> m_channels ;
281 void init(
unsigned int idle_timeout ,
unsigned int first_image_timeout ,
G::EpochTime repeat_timeout ,
282 unsigned int refresh_header ,
286 void init(
unsigned int idle_timeout ,
unsigned int first_image_timeout ,
G::EpochTime repeat_timeout ,
287 unsigned int refresh_header ,
288 const std::string &
type ) ;
312 std::string
type()
const ;
338 static bool integral(
const G::Url & url ,
const std::string & key ) ;
342 unsigned int m_refresh ;
346 unsigned int m_idle_timeout ;
347 unsigned int m_first_image_timeout ;
350 bool m_more_verbose ;
unsigned int refresh() const
Returns the value for the http refresh header.
A configuration structure for Gv::HttpServerPeer holding default settings from the command-line which...
A subsecond-resolution timestamp based on a time_t.
void setDirectory(const G::Path &)
Sets a directory for file resources.
std::string channelName(const G::Path &url_path) const
Returns the channel name for the given channel-like url path.
bool specialResource(const G::Path &url_path) const
Returns true if the url path is for a special resource (eg. "/__").
bool set(ImageInputSource *, const std::string &info)
Sets the source pointer. Used by Gv::HttpServerSources.
~HttpServerSource()
Destructor.
bool withStatus() const
Returns true if the status url is enabled.
bool streaming() const
Returns true if streaming using multipart/x-mixed-replace.
The GNet::Address class encapsulates a TCP/UDP transport address.
GNet::Address gateway() const
Returns the gateway network address, or the default address if none.
std::string type() const
Returns the required content-type.
void resend()
Calls resend() on the source.
bool valid(const std::string &url_path)
Returns true if the given url path looks like it is for an input-source rather than a file...
A simple parser for URLs.
void addChannelAny()
Adds the wildcard channel.
Gr::ImageConverter & converter()
Returns the image-converter reference, as passed in to the constructor.
std::string info() const
Returns information on the channel publisher, or the empty string for non-channel sources...
bool fileResource(const G::Path &url_path) const
Returns true if the url path is for a file (eg. "/index.html").
void init(unsigned int idle_timeout, unsigned int first_image_timeout, G::EpochTime repeat_timeout, unsigned int refresh_header, const GNet::Address &gateway, bool more_verbose)
Initialises the configuration from command-line parameters.
bool quick() const
Returns true if requesting the most-recent data from the channel rather than waiting for the next upd...
unsigned int idleTimeout() const
Returns the connection idle timeout.
std::vector< std::string > channels() const
Returns a list of added channel names.
HttpServerConfig()
Default constructor for reasonable default values.
std::string fileResourcePath(const G::Path &url_path) const
Returns the file-system path for the given url path, or the empty string if there is no matching reso...
bool empty() const
Returns true if just default-constructed with no "add" or "set" methods called.
std::string fileResourceType(const G::Path &url_path) const
Returns the content-type path for the given url path, or the empty string if there is no matching res...
bool moreVerbose() const
Returns true for more verbosity.
void addFileAny()
Allow any file in the directory.
A base class for classes that handle asynchronous events from the event loop.
void addFileType(const G::Path &, const std::string &type)
Adds a filename-to-type mapping that overrides the extension mapping.
Used by a ImageInputHandler-derived object to hold a ImageInputSource pointer.
G::EpochTime imageRepeatTimeout() const
Returns the repeat timeout.
std::string setDefault(const std::string &)
Sets the default resource. Returns a warning string.
bool anyChannel() const
Returns true if addChannelAny() called.
HttpServerResources()
Default constructor.
static std::string guessType(const G::Path &path)
Returns a probable content-type based on the filename, or the empty string.
std::pair< std::string, std::string > fileResourcePair(const G::Path &url_path) const
Returns fileResourcePath() and fileResourceType() as a pair.
std::string name() const
Returns the source name.
~HttpServerSources()
Destructor.
A container for ImageInputSource pointers, used by Gv::HttpServerPeer.
A configuration structure for resources that Gv::HttpServerPeer makes available.
unsigned int firstImageTimeout() const
Returns the first-image timeout.
An image format converter that can convert to and from the raw and jpeg formats (only), with scaling and monochrome options.
bool select(const std::string &url_path, HttpServerSource &)
Looks up the required input source and deposits its pointer into the supplied holder.
A timer class template in which the timeout is delivered to the specified method. ...
std::string addFile(const G::Path &)
Adds a file resource.
int scale() const
Returns the required scale factor.
HttpServerSource(ImageInputHandler &)
Constructor.
void addChannel(const std::string &channel_name)
Adds a channel resource.
A Path object represents a file system path.
bool monochrome() const
Returns the monochrome flag.
bool channelResource(const G::Path &url_path) const
Returns true if the url path is for a channel (eg. "/_foo").
void log() const
Emits diagnostic logging for the configured resources.
HttpServerSources(Gr::ImageConverter &, const HttpServerResources &, unsigned int channel_reopen_timeout)
Constructor.