HTTP

HTTP is the protocol underlying the Web. The protocol is agnostic to the content it carries - while it was originally designed to carry HTML documents it is now used to transport image files, Postscript documents, PowerPoint files and almost anything. This includes media files, the subject of this book.

HTTP servers

Content is delivered from a Web site by means of HTTP servers. The most well-known of these is Apache, but in the Linux world Nginx and Lighttpd are also common. There are a number of proprietary servers as well.

An HTTP server can deliver static files stored on the server, or construct content dynamically from e.g. a database connection.

HTTP clients

HTTP Browsers

Point the browser to the URL of an audio file and it will pass the content to a helper which will attempt to play the file. The browser will choose the helper based on the file extension of the URL, or based on the Content-Type of the file as delivered in the HTTP header from the HTTP server.

mplayer

MPlayer is HTTP-aware: just give the URL of the file

	
mplayer http://localhost/audio/enigma/audio_01.ogg
	
      

VLC

VLC is also HTTP-aware: just give the URL of the file

	
vlc http://localhost/audio/enigma/audio_01.ogg
	
      

Streaming vs downloading

If you download a file from the Web, then you can play it once it has finished downloading. This means that play is delayed until the entire file has been saved into the local file file system. On the other hand, since it is now local it can play without worrying about network delays. A simple shell script to illustrate this is

	
wget -O tmp  http://localhost/audio/enigma/audio_01.ogg
mplayer tmp
rm tmp
	
      

The alternative is to read the resource from the Web and hand it as it is received to a player, using some sort of pipeline. This is fine as long as the pipeline is large enough to buffer enough of the resource that it can cope with network delays. It is illustrated by

	
wget -O -  http://localhost/audio/enigma/audio_01.ogg | mplayer -
	
      

(Yes, I know, mplayer can stream URLs directly - I'm using this way it for the point I'm making.).



Copyright © Jan Newmarch, jan@newmarch.name
Creative Commons License
"Programming and Using Linux Sound - in depth" by Jan Newmarch is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License .
Based on a work at https://jan.newmarch.name/LinuxSound/ .

If you like this book, please contribute using PayPal

Or Flattr me:
Flattr this book