Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Register name used to load filter: httpout
The HTTP output filter can act as:
- a simple HTTP server
- an HTTP server sink
- an HTTP server file sink
- an HTTP client sink
- an HTTP server source
The server currently handles GET, HEAD, PUT, POST, DELETE methods.
Single or multiple byte ranges are supported for both GET and PUT/POST methods.
- for GET, the resulting body is a single-part body formed by the concatenated byte ranges as requested (no overlap checking).
- for PUT/POST, the received data is pushed to the target file according to the byte ranges specified in the client request.
When a single read directory is specified, the server root
/ is the content of this directory.
When multiple read directories are specified, the server root
/ contains the list of the mount points with their directory names.
When a write directory is specified, the upload resource name identifies a file in this directory (the write directory name is not present in the URL).
Listing can be enabled on server using dlist.
When disabled, a GET on a directory will fail.
When enabled, a GET on a directory will return a simple HTML listing of the content inspired from Apache.
Simple HTTP server
In this mode, the filter doesn't need any input connection and exposes all files in the directories given by rdirs.
PUT and POST methods are only supported if a write directory is specified by wdir option.
This sets up a read-only server.
This sets up a write-only server.
This sets up a read-write server running on port 8080.
HTTP server sink
In this mode, the filter will forward input PIDs to connected clients, trashing the data if no client is connected unless hold is specified.
The filter doesn't use any read directory in this mode.
This mode is mostly usefull to setup live HTTP streaming of media sessions such as MP3, MPEG-2 TS or other muxed representations:
gpac -i MP3_SOURCE -o http://localhost/live.mp3 --hold
In this example, the server waits for client requests on
/live.mp3 and will then push each input packet to all connected clients.
If the source is not real-time, you can inject a reframer filter performing realtime regulation.
gpac -i MP3_SOURCE reframer:rt=on @ -o http://localhost/live.mp3
In this example, the server will push each input packet to all connected clients, or trash the packet if no connected clients.
HTTP server file sink
In this mode, the filter will write input PIDs to files in the first read directory specified, acting as a file output sink.
The filter uses a read directory in this mode, which must be writable.
Upon client GET request, the server will check if the requested file matches the name of a file currently being written by the server.
If so, the server will keep refreshing the source size until the associated input file is closed.
This mode is typically used for origin server in HAS sessions where clients may request files while they are being produced (low latency DASH).
gpac -i SOURCE -o http://localhost/live.mpd --rdirs=temp
HTTP client sink
In this mode, the filter will upload input PIDs data to remote server using PUT (or POST if post is set).
This mode must be explicitly activated using hmode.
The filter uses no read or write directories in this mode.
gpac -i SOURCE -o http://targethost:8080/live.mpd:gpac:hmode=push
In this example, the filter will send PUT methods to the server running on port 8080 at
targethost location (IP address or name).
HTTP server source
In this mode, the server acts as a source rather than a sink. It declares incoming PUT or POST methods as output PIDs
This mode must be explicitly activated using hmode.
The filter uses no read or write directories in this mode, and updloaded data is NOT stored by the server.
gpac httpout:hmode=source vout aout
In this example, the filter will try to play uploaded files through video and audio output.
dst (string): location of destination file - see filter help
port (unsigned int, default: 80): server port
ifce (string): default network inteface to use
rdirs (string list): list of directories to expose for read - see filter help
wdir (string): directory to expose for write - see filter help
block_size (unsigned int, default: 10000): block size used to read and write TCP socket
user_agent (string, default: $GUA): user agent string, by default solved from GPAC preferences
close (boolean, default: false): close HTTP connection after each request
maxc (unsigned int, default: 100): maximum number of connections, 0 is unlimited
maxp (unsigned int, default: 6): maximum number of connections for one peer, 0 is unlimited
cache_control (string): specify the
Cache-Control string to add;
none disable ETag
hold (boolean, default: false): hold packets until one client connects
hmode (enum, default: default): filter operation mode, ignored if wdir is set. See filter help for more details. Mode can be
- default: run in server mode (see filter help)
- push: run in client mode using PUT or POST (see filter help)
- source: use server as source filter on incoming PUT/POST
timeout (unsigned int, default: 30): timeout in seconds for persistent connections; 0 disable timeout
ext (string): set extension for graph resolution, regardless of file extension
mime (string): set mime type for graph resolution
quit (boolean, default: false): exit server once all input PIDs are done and client disconnects (for test purposes)
post (boolean, default: false): use POST instead of PUT for uploading files
dlist (boolean, default: false): enable HTML listing for GET requests on directories