stream(mpeg audio) v1.25 by megacz(megacz@usa.com), Wednesday 20-Jan-2007
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ =====================
__ ___ ___ ______
_____/ /_________ ____ _____ ___ _ _< / |__ \ / ____/
/ ___/ __/ ___/ _ \/ __ `/ __ `__ \ | | / / / __/ //___ \
(__ ) /_/ / / __/ /_/ / / / / / / | |/ / /_ / __/____/ /
/____/\__/_/ \___/\__,_/_/ /_/ /_/ |___/_/(_)____/_____/
]i[ intro
===== =======
'stream' is a very powerful ARexx script that makes possible to STREAM,
RECORD and/or PLAY Shoutcast(MPEG-1,2,2.5/I,II,III) radio.
The main feature is unlimited number of streamers running at the same time,
so basically u r able to record as many Shoutcasts as ur machine resources
r adequate to launch new process, not worying too much about the CPU time
(coz of resetable process priorities that could be below 0 when recording).
Other features in brief:
- fully CLI driven ( i see now faces of those who dont like the CONSOLE:,
hehheh)
- streamers following-tracing ( up to 10 streamers could be traced)
- very informational progress indicator for each streamer:
[...](194/14/3153820/7300/0/0/4/5/0/0)[...]
1. time elapsed------------/^^ /^ /^^^^^^ /^^^ / / / / / /
2. network speed (Kb/s)-------/ / / / / / / / /
3. tot. number of bytes received/ / / / / / / /
4. network buffer fill level(bytes)----/ / / / / / /
5. disk buffer fill level(bytes)-----------/ / / / / /
6. if player not running network !delay-----/ / / / /
7. number of loops to pass until !delay------/ / / /
8. refresh rate of ind. in VERBOSE/S----------/ / /
9. is recording paused(0=no/1=yes)?------------/ /
10. number of reconnects-------------------------/
- custom, reusable ports ( useful with web browsers for instance)
- streamers switching ( the ability to drop the audio at one streamer and
link it again to the other without terminating the previous one)
- auto sense of the buffering ( when audio decoder is linked and then
dropped streamer will behave like it would be still online, in the
other words there will be no full-speed effect after audio dropping)
- possibility to PAUSE and/or RESUME any recording streamer at any time
- AHI support ( now also from command line)
- popular pls://,m3u:// playlists support as well as list:// books
( to create fresh books use 'tools/screparse')
- synchronous disk buffer ( no more filesystem performance loss when
recording)
- silent reconnection on Shoutcast drops ( streamer will try to reconnect
unlimited number of times, but if there will be critial/init error it will
give up - critical/init means usually timeout at some operation, like
dns querying failure or connection timeout at startup)
- eventized streamer priorities ( when player linked and when player
dropped priorities)
- http proxy support ( just in case)
- ... and many other minor ones u will discover by using frequently =D
]r[ requirements
===== ==============
Any Amiga with 68020+/os2.04+/512+Kb and TCP/IP stack will handle streaming
very good, but for listening its recommended at least 68030+. 'stream' likes
every TCP/IP stack with 'bsdsocket.library' API.
Dependencies:
- system/RexxMast (system)
+libs/rexxsupport.library
+libs/rexxsyslib.library
+c/rx
- c/status (system)
- c/break (system)
- FIFO: (http://aminet.net/dev/gg/fifolib-bin.lha)
+libs/fifo.library
+l/fifo-handler
- c/mpega (http://aminet.net/mus/play/MPEGA35.lha)
(http://aminet.net/util/libs/mpega_library.lha)
(http://aminet.net/util/libs/mpega-WarpUP.lha)
(http://aminet.net/util/libs/mpega_libmad.lha)
+libs/mpega.library
- TCP/IP[AmiTCP] (http://ftp.back2roots.org/geekgadgets/amiga/m68k/alpha/amitcp/AmiTCP-bin-30b2.lha)
- RxSocket (http://aminet.net/comm/tcp/rxsocket.lha)
+libs/rxsocket.library
+libs/rxlibnet.library
]c[ config/installation
===== =====================
Now, start ur favourite text editor and check out the variables, there
r things u want to customize, all the variables have comments so no fear.
However, there r vars. that have very little explanation so i will extend
comments of these vars. here:
'stream_text_buffer' - with this var. u adjust how much to read in one go
for text showing and 'stream_pipe_dchsfx' &
'stream_pipe_qchsfx' channels, recommended range
is 4096-65535, usually u dont want to change this.
'stream_reqf_limit' - this one determines how much to load from the start
of the x-fer, this avoids situations where connection
has been established with not a shoutcast/http server.
dont set below 2048!
'stream_mask_trace' - this will put 'mask' before each refresh of the trace/
verbose status, "0:" no, "1:" yes
masks r simply previous entries with almost all chars
translated to spaces, except "0a" = LF's.
its a good idea to turn this on!
'stream_pipe_retry' - this var. will set all the information resolvers into
retry mode if they will receive malformed data, FIFO:
is not perfect when in 'async' mode and this will fix
malformed data by resolving them again if they r
incomplete or unreadable. this applies to the info
channels('stream_pipe_dchsfx' & 'stream_pipe_qchsfx')
only. turn this on!!!
template: 'sw:tries:looprate(ticks)'
ex.: "1:10:3"
- turned on:10 times and fail:resolve every 3 ticks
'stream_tick_idle' - this is the one that sets params for player simulation,
template: 'sw:min(ticks):max(ticks):minl:maxl'
-on/off:minimum delay:maximum delay:min.loops:max.loops
ex.1: "1:50:150:3:11"
- turned on:1 sec.:3 sec.:3 loops:11 loops,
it will pass 3-11 loops and wait 1-3 seconds
ex.2: "0:25:0:1:0"
- this will not try to measure the real treshold and
will use static of 0.5 sec. every 1 loop
ex.3" "0:0:0:0"
- streamer will start downloading at full speed
as soon as the player will drop
NOTE: simulation is only active when there is no
player linked otherwise everything depends
on the bitrate and the internal params of
the player.
generally u want to use this.
Installation is simple, just copy it somewhere - SYS:C/ seemd to be
the best place for often use.
]u[ usage
===== =======
Help below can be seen by typing "stream" with no args in CLI.
"
stream(mpeg audio) v1.24 by megacz(megacz@usa.com)
template: stream <URL/K|COMMAND/K> [RECORD/S] [AS=/K] [VOL=/N] [PORT=/K[,1]]
[AHI=/K] [PROXY=/K] [APPEND/S] [OVERWRITE/S] [DETACH/S]
[NOAUDIO/S] [VERBOSE/S]
commands:
SHOW - show all active streamer(s)
SERVERS - show streamer(s) request feedback(s)
DROP - drop the audio only
STOP<,portsuffix>[,1] - stop streamer(s), #?=all
LINK[,portsuffix][,1] - link decoder to the streamer
PAUSE<,portsuffix><,#> - pause rec. in req. streamer, #=(0/1)
TRACE[,ps,ps,..,.][,%] - t. str., max of 10 [,ps] or [,%] - dyn.
URL:
file://<file> - play mpeg file locally
http://<site>[:port][/path] - stream data from remote host
pls://<file>[,word|#|$|?] - parse .pls
m3u://<file>[,word|#|$|?] - parse .m3u
list://<file>[,word|#|$|?] - parse list/book
+[,word] - search for a #?word#? beside/in the url
+[,#] - pick number of the entry to stream
+[,$] - shuffle the playlist($=0)
+[,?] - show file content
(if nothing specified the very first
entry will be choosed and streamed.)
"
additional explanation:
[PORT=/K[,1]] - allows to specify static port suffix (not
nescesarily a number), it could be almost
anything but not the "%" char -see TRACE.
[,1] after that suffix will result in
reuse that port if it is occupied, also
the audio will be dropped!
IMPORTANT: "=" is a part of the option,
sorry for that, its a must coz it gives
the parser extact location of the args.
[VERBOSE/S] - with this specified u will see how the
streamer(which is usually started
in the background) works.
DROP - it will cause player = 'mpega' to terminate,
but this will not bring the streamer down
as long as it records, only streamers that
do not record will terminate too.
STOP<,portsuffix>[,1] - will stop streamer with a given <,portsuffix>
plus additionally can drop the audio by
specyfying [,1] after the <,portsuffix>.
if u want to stop all the streamers just
type '#?' as a <,portsuffix> and the audio
will drop too.
LINK[,portsuffix][,1] - will link the player to the requested streamer,
[,portsuffix] can be ommited so it will link
to the very first on the port list.
[,1] after [,portsuffix] will drop the audio
if it is up otherwise if audio is up it will
print server information and will report that
the player is already running.
TRACE[,ps,ps,..,.][,%] - allows to fetch and present up to 10 streamers
progress indicators every user defined amount
of seconds. trace can work in 3 modes:
1. "TRACE" with no args will grab 10 very first
running streamers and will be checking them
every some amount of seconds, if some of them
will drop it will mark them as dead.
2. "TRACE,%" will be completly dynamic, there
will be checks for new streamers every 10
already presented, thus if some streamer
will drop trace will wipe it out from the
list.
3. "TRACE<,ps,...>" will pick up to 10 port
suffixes and will be checking them like in
mode 1.
ur console should be able to display at least 80x25
so the output will be looking good all the time.
example output of trace:
"
STREAM.@: querying running streamers...
STREAM.@: tracing(refresh every ~10 seconds)...
---
[+]. STREAM.1 - 21:03:13/29-11-06/(2/0/19243/7168/12075/50/3/5/0/0)
>(stream.591096.mp3) : file init ok! next info = status.
[+]. STREAM.2 - 21:04:17/29-11-06/(23/130/149803/6144/18432/50/3/5/0/0)
>(hd1:pcu_liveshow.mp3) : 2 audio packet(s) written.
[+]. STREAM.3 - 21:06:21/29-11-06/(45/0/287531/7168/38912/50/3/5/0/0)
>(hd2:testing.mp3) : oops! disk full?!! 2 packet(s) lost!
[+]. STREAM.4 - 21:08:23/29-11-06/(1/0/10027/7168/0/50/3/5/0/0)
>(NIL:) : http://69.42.69.99:8000
[-]. STREAM.5 - 21:09:17/29-11-06/(1/0/11592/1024/0/50/3/5/0/0)
>(NIL:) : http://213.251.163.207:8242
[-]. STREAM.6 - 21:08:59/29-11-06/(33/0/634880/5880/0/50/3/5/0/0)
>(NIL:) : http://localhost/hdx/pub/jerkyboys_song.mp3
---
STREAM.@: trace is in (auto/static) mode. press CTRL+C to stop.
STREAM.@: interrupted!
"
As u can see TRACE is a fantastic thing =D it will be telling u if
everything is fine or not... plus u can enable logfile for the
streamers to collect even more informations.
example usage(my favourite):
"
38.[local]RamDisk:> stream list://comedy,?
stream(mpeg audio) v1.24 by megacz(megacz@usa.com)
STREAM.@: showing contents of 'sys:shoutlists/comedy'...
---
> http://209.190.20.82:8004 | THE DEFCON COMEDY NETWORK - 300+ Hours of th
> http://64.62.194.5:11216 | Khaha.com ((STEREO)): -- The Original **Unce
> http://64.236.34.97:80/strea | KPIG - Live Free-Range DJs 24/7 - Freedom, C
> http://66.254.105.246:8000 | Random Loveline
> http://205.188.215.232:8022 | KPIG AACp 24k
> http://70.87.59.154:8000 | No Holds Barred Radio Network, #1 for Live o
> http://213.189.22.206:8016 | Humorzender
> http://213.251.163.207:8242 | RadioPrank.Com - We play phone pranks all th
> http://69.42.69.99:8000 | (PCU) Prank Call Underground Radio (PCU)
> http://207.200.96.229:8024 | KPIG AACp 64k
> http://213.189.2.194:8930 | Patrick Kicken's Pret Zender! check www.pa
> http://204.11.33.120:8000 | George Carlin Radio
> http://213.251.169.28:8010 | 80s Box & Today's http://boxradio.co.uk aac+
> http://62.75.144.187:8110 | Deutsche Satire Deutsche Comedy
> http://69.5.81.71:7170 | Cringe Humor Radio - Comedy That Questions Y
> http://207.210.74.187:8000 | GoonShowRadio
> http://68.12.220.148:8000 | Phil Hendrie - 24 Hours a day
> http://146.82.140.43:8000 | SuperTraks - THE GREATEST MUSIC EVER RECORDE
> http://69.60.124.148:8000 | -=RantRadio Talk=- Speak Your Mind
> http://67.19.78.90:8010 | No Holds Barred Radio Network, #1 for Live o
---
STREAM.@: The file is 21 line(s) and 1580 bytes(s) long.
38.[local]RamDisk:> stream list://comedy,RadioPrank.Com
stream(mpeg audio) v1.24 by megacz(megacz@usa.com)
STREAM.@: connecting to 'http://213.251.163.207:8242'...
STREAM.@: streamer 'STREAM.1' has been started in the background.
STREAM.@: linking to the streamer(STREAM.1)...
STREAM.@: fetching request feedback...
---
ICY 200 OK
icy-notice2:SHOUTcast Distributed Network Audio Server/Linux v1.9.5
icy-name:RadioPrank.Com - We Play Phone Pranks All The Time....
icy-genre:Comedy Alternative Talk
icy-url:http://www.radioprank.com
content-type:audio/mpeg
icy-pub:1
icy-br:56
---
STREAM.@: 'mpega' args. '-m -u -D -r -T -N -w -b0 -q0 -f1 -t2000 -F11050 -v20 -p0'
MPEGA 3.5 (21.12.98) [Generic] (C)1995-1998 Stephane TAVENARD
Email: Stephane.Tavenard@wanadoo.fr
Giftware MPEG Audio decoder for Layers I,II and III
File playing: FIFO:STREAM.1/rt
Output: no file, low quality, mono 11025Hz
File Type: MPEG1-III mono 56kbps 44100Hz
File length: 10226:06
Elapsed time: 00:02
"
using 'stream' together with web browser:
! AWeb
--------
Click RMB and go to 'Settings>Browser Settings...' after the prefs window
popup click the last tab '5 Viewers' and add new MIME type entry like this:
Type: audio / x-scpls
Extensions: pls
Action: Extl. program (E)
Name: rx
Arguments: c:stream pls//%f port=www,1
Press Return key now and click on Save.
Additionally go to 'Settings>Program Settings...' and after the window popup
click on the last tab '4 Programs' u will find there 'Console' and the string
gadget, now enter this in there:
Console: CON:0/5000/422/216/%t/AUTO/CLOSE/INACTIVE/SCREEN%n
this will cause 'stream' to be opened in a window allowing u to stop it
any time by pressing CTRL+C, but if u dont want any windows type at the
end of the 'Arguments' '>NIL:'.
! IBrowse
-----------
Click RMB and go to 'Preferences>Settings...', double click 'General' and pick
'MIME Types', press 'Add' and enter things below in the appropriate str. gadgets:
MIME Type: audio / x-scpls
Extension: pls
Action: External viewer
Viewer: rx
Arguments: c:stream pls://%f port=www,1
Additionally pick 'General' and in the 'Output window:' string gadget type this:
Output window: CON:0/5000/422/216/IBrowse Output/AUTO/CLOSE/INACTIVE/SCREEN%p
this will cause 'stream' to be opened in a window allowing u to stop it
any time by pressing CTRL+C, but if u dont want any windows type at the
end of the 'Arguments' '>NIL:'.
! Other
---------
If ur temporary storage 'T:' is assigned to a device which volume name
or some directories in the path have white spaces in their names may need to
enclose '%f' with '"' like:
Arguments: c:stream pls://"%f" port=www,1
but i have seen that AWeb performs this already even if there is no spaces
in the path, so if something doest work try both methods.
Note that requesting new '.pls' from the server will stop the streamer
'STREAM.WWW' if it is running as well as 'mpega' causing also the
window to close.
U can of course use some other more advanced console handler like KingCON
and configure it to iconify/menufy instead of popping up the window, this might
be very comfy. The line for this would be:
Ex. console: KCON:0/5000/422/216/Example/CLOSE/INACTIVE/MENUFY/NOICON/KEEPCLOSED/AUTOICONIFY
Just remove '/MENUFY/NOICON' if u want icon on ur Workbench.
This solution however has one jerky limitation which is 'mpega' doesnt react
to CTRL+C and i have no idea why is that... but external signalling works ok.
]t[ technical
===== ===========
spaces - u r allowed to use spaces at the command line in the paths and
filenames, if u want to do so just enclose such a string with '"' like:
'stream pls://"ram disk:my list has so many spaces in the name.pls",?'
however if u got some url that contain spaces u r not allowed to
enter them like in the example above, use '%20' instead, like:
'stream http://server.domain.x/~spaces%20r%20so%20unsexy/stream%20bla'
network
buffer - in case of network buffer i recommend 7168 as a resonable value beetwen
low bitrate and high bitrate mpegs, u may of coz want ot set it higher
if u got ultra fast internet connection, but generally filling too large
buffers may cause pauses in playing - this also depends on the settings
u have specified in the 'mpega', one of the very important is '-t' it
decides how much to prebuffer in miliseconds for audio reply.
if u got very slow connection to the net or using modem try lower values
like 512-2048 so the process will be downloading data more often.
priority - priorities r not very critical here if u got fast CPU, but if u got
68020/68030 u may want to set 'stream_pri__idle' to a minus value, this
will be especially helpful when u decide to launch 5+ recording streamers,
but be aware of listening to some shoutcast when 'stream_pri__mpega'
is higher than 'stream_pri__idle' coz ur recording streamers will not
get any cpu time at that time, thus they might timeout!
fifo - FIFO: device doesnt require any mountlist! just run it from CLI,
i mention about this here coz some of u may not had read fifo doc...
just add such a line to the 'startup-sequence' for permanent use:
'RUN >NIL: l:fifo-handler'
passwords - i have also added a way of connecting to password protected servers
but i dont know if this work for all the servers out there, template for
such a resource would look like this:
'stream http://server.domain.x/~johnnybravo/file.mp3\\user\\password'
it works well with 'REALM' protection, plus note that the library
'rxlibnet.library' is not being loaded at startup, but only when ur
request contain '\\user\\password'.
The method of encoding 'user' and 'password' fields is base64 in so
called 'Basic Authorisation' mode.
numeric
values - another thing r the numeric values, note that there is no checks
wether the value assigned to the variable is a numeric or not, so
for correct operation do not specify any letters in place of
digits and everything will be okay.
]h[ history
===== =========
older versions
--------------
1.0 , ??-???-2004 - initial version
1.1 , 26-Jun-2005 - first improved version
1.21, 28-Jan-2006 - rewritten with new features
1.22, 14-May-2006 - fixed problems with KingCON,
fixed problem where .mp3's could not be played
1.23, 14-Jun-2006 - updated 'tools/'
1.24, 24-Nov-2006 - rewritten from scratch with new features
and new methods of controlling pipe dev.
current version
---------------
1.25, 20-Jan-2007 - fixed problems with KingCON where;
CTRL+C keypress in detached mode caused
streamers and player to stop...
31-Jan-2007 - added socket timeouts, so that 'stream' will not
block anymore for unlimited amount of time, but
will fail after user defined interval and optionally
try to reconnect(its related to unexpected connection
drops when reading)
]E[ ENDIF
===== =======
good luck!
|