CoB1Rreflect_help.htmlcSstl_status.html fixed_payload_type.htmlLreflect_help_location.html=funcs.jss"stl_config.htmlreflect_location.html 6stl_loc.htmlreflect_cfg.html !status_r.htmlN%֠reflect.bcl.first ($appstatus  appconfig.binstl.bcl=stl.tok areflect.html Kvisual.js 4jreflect.bcl 5reflect.tokZGreflect_status.htmloHreflect_config.htmlI_status_data.html =K_status.html Kstl_cfg.htmlstatus_data_r.htmlŞstl_location.htmlGMstl_main_help.htmlUREADME_reflect stl_lmenu.htmlreflect_lmenu.html=stl.htmlreflect_loc.htmlreflect_main_help.htmlRstl_help_location.html )stl_help.htmlHTTP/1.0 200 Content-type: text/html
Help

Network Settings
This section allows the configuration of the following device settings:
  • IP address
  • Netmask
  • Gateway
  • DNS
  • Syslog message destination server: if unset (default, set to 0.0.0.0) syslog messages are broadcasted
  • DHCP hostname
  • WEB server listening port
Configurator Server 1,2,3

At boot time the application will try to contact the first available server.
The first of them that will answer with a valid reply will be used for further communications.

NOTE: for a valid reply from the server, the device must be already registered into the server database.
Security Settings
This section allows to configure the device password and other security settings.

Reset Function
Enable or disable the "Reset" function on the Reset button and on the WEB UI. In order to restart the device press the Reset button once.
Default: "enabled"

Factory Defaults
Enable or disable the "Factory Defaults" function on the Reset button. In order to revert all settings to factory defaults keep the Reset button pressed until the red LED starts blinking (approx. 10 seconds).
Default: "enabled"

Update Function
Enable or disable the WEB Update function of the device. If the Update function is disabled, the only way to update the firmware is to use the serial rescue.
Default: "enabled"

Set Password
This is visible as long as no password is set.
Enter a password (up to 25 characters) and hit the "Apply" button. After the restart you should close the browser window and open a new browser window. You will be asked to supply user name and password. The user name can be omitted but the password has to be supplied in order to see the web configuration.

Old Password / New Password
These fields are visible as long as a password is set.

To allow free access (clearing the password) enter the old password and leave the field "New Password" empty. Enter the old password in the password field above the "Apply" button as well and then hit the "Apply" button.
After the restart you will not be asked for user name and password anymore.

To change the password enter the old password and enter the new password in the field "New Password". Enter the old password in the password field above the "Apply" button as well and then hit the "Apply" button.
After the restart you will be asked for user name and password. The user name can be omitted but the new password has to be supplied in order to see the web configuration.


HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: text/html Help

Fixed RTP Payload Types:

0 u-Law, 8bit, mono, 8kHz
8 A-Law, 8bit, mono, 8kHz
10 PCM, 16bit, MSB first, signed, 44.1kHz stereo, left channel first
11 PCM, 16bit, MSB first, signed, 44.1kHz mono
14 any MPEG audio
96 PCM, 16bit, MSB first, signed, 8kHz mono
97 u-Law, 8bit, mono, 24kHz
98 A-Law, 8bit, mono, 24kHz
99 PCM, 16bit, MSB first, signed, 24kHz mono
100 u-Law, 8bit, mono, 32kHz
101 A-Law, 8bit, mono, 32kHz
102 PCM, 16bit, MSB first, signed, 32kHz mono
103 PCM, 16bit, MSB first, signed, 48kHz stereo, left channel first
104 PCM, 16bit, LSB first, signed, 8kHz mono
105 PCM, 16bit, LSB first, signed, 24kHz mono
106 PCM, 16bit, LSB first, signed, 32kHz mono
107 PCM, 16bit, LSB first, signed, 44.1kHz stereo, left channel first
108 PCM, 16bit, LSB first, signed, 48kHz stereo, left channel first
109 u-Law, 8bit, mono, 12kHz
110 A-Law, 8bit, mono, 12kHz
111 PCM, 16bit, MSB first, signed, 12kHz mono
112 PCM, 16bit, LSB first, signed, 12kHz mono
HTTP/1.0 200 Content-type: text/html
Help

The Barix Reflector service takes the difficulties out of streaming STL audio over the internet.

See more at www.barix.com
HTTP/1.0 200 Content-type: application/x-javascript function turnBackBold(speclink){ var anchors=document.links for (i=0;i
&LSetup(3,"%s",130,D,0,"");

BASIC SETTINGS

NETWORK SETTINGS
Use SonicIP Yes No
IP Address . . .
Netmask . . .
Gateway IP Address . . .
Primary DNS . . .
Alternative DNS . . .
Syslog Address . . .
DHCP Host Name
Web Server Port

OUTGOING STREAM
Stream Method URL Port
Streaming Mode
Input Trigger Level
Input Inactivity Timeout msec
Output Trigger Level
Output Inactivity
Timeout
msec
Keep-alive Period msec

INCOMING STREAM
Stream Method URL Port
RTP delay

AUDIO
Format
Sample Rate
Quality
Input Source
Input Gain dB
Output Audio Level dB
Fading Effect Enabled Disabled

I/O AND CONTROL
Front Panel LEDs
Relay 1 Mode
Relay 2 Mode
Relay 3 Mode
Relay 4 Mode
SNMP Destination IP(s)
SMTP Server IP/DNS
Local e-mail (FROM:)
Destination e-mail(s) (TO:)

SERIAL 1
Baud rate
Data bits
Parity
Stop bits
Handshake
UDP/TCP Control Port for COM1
 
SERIAL 2
Baud rate
Data bits
Parity
Stop bits
Handshake
UDP/TCP Control Port for COM2
 
&LSetup(3,"%s",130,D,0," "); &LSetup(3,"%s",130,D,!0," ");

SECURITY SETTINGS
Reset Function Enabled Disabled
Factory Defaults Enabled Disabled
Update Function Enabled Disabled
Set Password Old Password
New Password
HTTP/1.0 200 Content-type: text/html
   Using Reflector service.
HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: text/html

Site Type:Using Reflector Service
Device Status:
#define CFG_PORT 12345 #define CFG_SERVER "bravo648.server4you.de" '#define CFG_SERVER "192.168.2.100" #define AUDIO_PORT 40000 ' local port for sending/receiving audio #define RTP_SEND_TIME 4000 ' send RTP every 4s #define CFG_SEND_TIME 10000 ' send CFG request every minute #define REPL_SERVER "brtp.barix.com" ' replicator's IP address '#define REPL_SERVER "192.168.2.100" #define REPL_PORT 40000 ' replicator's IP address ' variables ' --------- dim cfgip ' address of the configuration server dim cfgid ' ID of the configuration request dim _Mudp$(1500) ' configuration answer - UDP packet dim udpl ' length of the last UDP packet received (lastlen) - see the UDP receiver dim cfgts ' timestamp of the last configuration; 0 = no config yet dim dst(1,1) ' streaming table for the LINK command dim gncfg ' get new configuration; if set to 1 there is a newer configuration on the server ' and it should be requested dim rstrt ' restart audio; if set to 1 the audio engine should restart with a new configuration in the ' cfg parameters dim cfg$ ' for the configuration parser: contains a new configuration #define BRTP_REQ_LEN 12 dim brtp$(BRTP_REQ_LEN) ' BRTP request dim mac$(13) ' contains the MAC address without separators ' configuration parameters from the server dim mode ' direction of the audio communication: 0=encoder, 1=decoder #define MODE_DECODER 1 #define MODE_ENCODER 0 dim stereo ' stereo/mono dim input ' input source #define INPUT_LINE 1 #define INPUT_MIC 2 #define INPUT_OPTICAL 4 #define INPUT_COAX 5 dim vol ' volume in dB dim gain ' input gain in dB dim buffer ' how much to buffer on the decoder - in milliseconds dim qual ' MPEG encoder quality ' functions ' --------- ' dim gethx ' this doesn't work because BCL is broken ' workarounding with a gosub dim ghxp1$ dim gethx ' handles ' ------- ' 1 - configuration UDP socket ' 2 - audio UDP socket ' 7 - audio #define CFG_HANDLE 1 #define STREAM_HANDLE 2 #define AUDIO_HANDLE 7 ' timers ' ------ ' 1 - setup configuration UDP request sent every minute ' 2 - BRTP request sent every 5s syslog "Reflector client v1.0 20100326" ' set up BRTP request mac$=sprintf$("%H",0) brtp$="BRX " ' emulation of gethx(mid$(mac$,1,4)) call with gosub ghxp1$=mid$(mac$,1,4) : gosub 50000 midset brtp$,5,-2,gethx ghxp1$=mid$(mac$,5,4) : gosub 50000 midset brtp$,7,-2,gethx ghxp1$=mid$(mac$,9,4) : gosub 50000 midset brtp$,9,-2,gethx syslog "Using server "+CFG_SERVER 10 ' resolve configuration server's address cfgip=resolve(CFG_SERVER) if cfgip=0 then syslog "Cannot resolve address of the configuration server, retrying in 1 minute" delay 60000 goto 10 endif ' open configuration handle open "UDP:0.0.0.0:"+str$(CFG_PORT) as CFG_HANDLE on UDP gosub 20000 ' setup configuration request every minute on timer1 gosub 11000 gosub 11000 timer 1,CFG_SEND_TIME syslog "Waiting for initial configuration" gncfg=1 ' force configuration reload at startup gosub 11000 dst(0,1)=REPL_PORT dst(0,0)=resolve(REPL_SERVER) 20 if rstrt=0 then goto 20 syslog "Initial configuration received" rstrt=0 ' main loop if mode=MODE_DECODER then syslog "Initialising audio: MP3 decoder, buffering "+str$(buffer)+" milliseconds" open "AUD:1,1,0,"+str$(buffer) as AUDIO_HANDLE else ' disable CRC, disable MS stereo, disable bit reservoir, emphasis none, copy, no copyright syslog "Initialising audio: MP3 encoder" open "AUD:2,1,"+str$(qual+&H8700+(1-stereo)*2048)+","+str$(buffer) as AUDIO_HANDLE endif ' set audio parameters syslog "Configuring audio" write 7,str$(gain),-2 ' AD gain ' FIXME - convert dB into steps 0-15 write 7,str$(input),-3 ' input source write 7,str$(stereo),-4 ' input mode stereo/mono write 7,str$(1-stereo),-5 ' output mode stereo/mono write 7,"1",-11 ' dB volume write 7,str$(vol),-12 open "UDP:0.0.0.0:"+str$(AUDIO_PORT) as STREAM_HANDLE if mode=MODE_DECODER then on timer2 gosub 30000 timer 2,RTP_SEND_TIME ' send the BRTP request 3x gosub 30000 gosub 30000 gosub 30000 endif syslog "Starting audio transfer" link STREAM_HANDLE,AUDIO_HANDLE,dst 30 if rstrt=0 then goto 30 syslog "New configuration received, closing audio" ' Shutdown '--------- ' FIXME what's the proper sequence ? close STREAM_HANDLE ' stop streaming close AUDIO_HANDLE timer 2,0 ' disable BRTP requests goto 20 ' configuration request handling '------------------------------- 11000 ' send config request local cfgrq$ if gncfg=1 then syslog "Sending configuration request" cfgrq$="id="+str$(cfgid)+"&mac="+mac$+"&get_config=fw_type=91,cfg_ver=30,set_ver=30" write CFG_HANDLE,cfgrq$,len(cfgrq$),sprintf$("%lA",cfgip),CFG_PORT else syslog "Sending ping to the configuration server" cfgrq$="id="+str$(cfgid)+"&mac="+mac$+"&ping" write CFG_HANDLE,cfgrq$,len(cfgrq$),sprintf$("%lA",cfgip),CFG_PORT endif cfgid=cfgid+1 return 12000 ' parse UDP answer ' request in _Mudp$; length in udpl (negative) local cmd$,keyw$,pos,newts ' cmd$ - command (they are spearated with "&") ' keyw$ - keyword within the command (before "=") ' pos - position within the string, for string search ' newts - new timestamp syslog "Received server response, parsing" midset _Mudp$,-udpl+1,1,0 ' terminate the UDP string syslog "DEBUG: "+_Mudp$ 12001 ' split the udp answer into commands separated with "&" pos=instr(1,_Mudp$,"&") if pos=0 then cmd$=_Mudp$ ' extract command _Mudp$="" ' empty _Mudp$ else cmd$=mid$(_Mudp$,1,pos-1) ' extract command _Mudp$=mid$(_Mudp$,pos+1) ' cut off the first command endif ' extract keyword from the command "cmd$" pos=instr(1,cmd$,"=") if pos=0 then keyw$=cmd$ ' extract keyword else keyw$=mid$(cmd$,1,pos-1) ' extract keyword endif if keyw$="ping" then newts=val(mid$(cmd$,pos+1+len("time_stamp="))) if newts<>cfgts then ' new configuration available; get it syslog "New configuration available" gncfg=1 cfgts=newts gosub 11000 endif goto 12002 endif if keyw$="status" then cfg$=mid$(cmd$,pos+1) if cfg$="no_config" then syslog "Device not configured" goto 12002 endif if keyw$="config" then cfg$=mid$(cmd$,pos+1) gosub 12100 ' parse configuration gncfg=0 rstrt=1 goto 12002 endif 12002 if len(_Mudp$)>0 then goto 12001 return 12100 ' parse configuration ' request in cfg$ local pos2,field$,keyw2$,val$,x ' position within the parsed string; configuration field; configuration keyword; value; temporary parameter syslog "Received a new configuration: "+cfg$ 12101 ' split the config string into fields separated with "," pos2=instr(1,cfg$,",") if pos2=0 then field$=cfg$ ' extract one cfg field cfg$="" ' empty cfg$ else field$=mid$(cfg$,1,pos2-1) ' extract one cfg field cfg$=mid$(cfg$,pos2+1) ' cut off the first field endif ' extract keyword from the config field pos2=instr(1,field$,"=") if pos2=0 then keyw2$=field$ ' extract keyword val$="" else keyw2$=mid$(field$,1,pos2-1) ' extract keyword val$=mid$(field$,pos2+1) endif if keyw2$="input" then if val$="line" then input=INPUT_LINE if val$="mic" then input=INPUT_MIC if val$="optical" then input=INPUT_OPTICAL if val$="coax" then input=INPUT_COAX goto 12102 endif if keyw2$="mode" then if val$="encoder" then mode=MODE_ENCODER else mode=MODE_DECODER goto 12102 endif if keyw2$="out_gain" then vol=val(val$) goto 12102 endif if keyw2$="in_gain" then gain=val(val$) goto 12102 endif if keyw2$="buffer" then buffer=val(val$) goto 12102 endif if keyw2$="quality" then x=val(val$) if x=40 then stereo=0 : qual=&H20 ' 22.0hkHz, quality 2 if x=64 then stereo=0 : qual=&H01 ' 44.1kHz, quality 0 if x=80 then stereo=1 : qual=&H31 ' 44.1kHz, quality 3 if x=140 then stereo=1 : qual=&H71 ' 44.1kHz, highest quality (7) if x=192 then stereo=1 : qual=&H73 ' 48kHz, highest quality (7) buffer=val(val$) goto 12102 endif 12102 if len(cfg$)>0 then goto 12101 return ' UDP receive handler '-------------------- 20000 ' check config handle if mediatype(CFG_HANDLE)=0 then goto 20001 udpl=lastlen(CFG_HANDLE) if udpl>=0 then goto 20001 read CFG_HANDLE,_Mudp$ gosub 12000 ' parse the configuration answer goto 20000 ' something received in the last loop, try again until the UDP FIFO is empty 20001 ' discard all blocks on stream handle if mediatype(STREAM_HANDLE)=0 then goto 20002 udpl=lastlen(STREAM_HANDLE) if udpl<0 then read STREAM_HANDLE,_Mudp$ : goto 20001 20002 return ' BRTP send request - timer handler '---------------------------------- 30000 ' send BRTP request write STREAM_HANDLE,brtp$,BRTP_REQ_LEN,REPL_SERVER,REPL_PORT '''syslog "Sending BRTP request" return 50000 ' gethx: converts ascii hex into a 16-bit integer 'local ghxp1$,tmp1,tmp2 local tmp1,tmp2 gethx=0 ghxp1$=lcase$(ghxp1$) for tmp1=1 to 4 gethx=gethx*16 tmp2=midget(ghxp1$,tmp1,1) if and(tmp2>=asc("0"),tmp2<=asc("9")) then gethx=gethx+tmp2-asc("0") if and(tmp2>=asc("a"),tmp2<=asc("f")) then gethx=gethx+tmp2-asc("a")+10 next tmp1 return
STL Application Status Page
Site Type&LSetup(3,"%s",536,B,0,"Studio Encoder");&LSetup(3,"%s",536,B,1,"Transmitter Decoder");&LSetup(3,"%s",536,B,2,"Studio Encoder / Decoder");&LSetup(3,"%s",536,B,3,"Transmitter Encoder / Decoder");
StreamMethodURL/IPPort
Outgoing Stream 1&LSetup(4,"%s",600,S);&LSetup(1,"%u",864,W);
Outgoing Stream 2&LSetup(4,"%s",632,S);&LSetup(1,"%u",866,W);
Outgoing Stream 3&LSetup(4,"%s",664,S);&LSetup(1,"%u",868,W);
Outgoing Stream 4&LSetup(4,"%s",696,S);&LSetup(1,"%u",870,W);
Outgoing Stream 5&LSetup(4,"%s",728,S);&LSetup(1,"%u",872,W);
Outgoing Stream 6&LSetup(4,"%s",760,S);&LSetup(1,"%u",874,W);
Outgoing Stream 7&LSetup(4,"%s",792,S);&LSetup(1,"%u",876,W);
Outgoing Stream 8&LSetup(4,"%s",824,S);&LSetup(1,"%u",878,W);
Incoming Stream&LSetup(4,"%s",890,S);&LSetup(1,"%u",534,W);
Streaming Mode&LSetup(3,"%s",520,B,0,"send always");&LSetup(3,"%s",520,B,1,"send on input1");&LSetup(3,"%s",520,B,2,"send on input2");&LSetup(3,"%s",520,B,3,"send on level");&LSetup(3,"%s",520,B,4,"respond");&LSetup(3,"%s",520,B,5,"never");
Input Trigger Level&LSetup(1,"%u",521,W);
Inactivity Timeout&LSetup(1,"%u",523,W); msecs.
Keep-alive Period&LSetup(3,"%s",529,B,255,"Disabled");&LSetup(3,"%s",529,B, 0,"0 (Passive)");&LSetup(3,"%s",529,B, 5,"50");&LSetup(3,"%s",529,B, 10,"100");&LSetup(3,"%s",529,B, 25,"250");&LSetup(3,"%s",529,B, 50,"500");&LSetup(3,"%s",529,B,100,"1000");&LSetup(3,"%s",529,B,250,"2500");
Buffer level&LSetup(1,"%u",525,W); bytes
Audio 
Encoding Audio Format&LSetup(3,"%s",511,B,0,"G.711 uLaw mono");&LSetup(3,"%s",511,B,1,"G.711 aLaw mono");&LSetup(3,"%s",511,B,2,"PCM 16bit mono big endian");&LSetup(3,"%s",511,B,3,"PCM 16bit mono little endian");&LSetup(3,"%s",511,B,4,"PCM 16bit stereo big endian");&LSetup(3,"%s",511,B,5,"PCM 16bit stereo little endian");&LSetup(3,"%s",511,B,6,"MPEG mono");&LSetup(3,"%s",511,B,7,"MPEG stereo");
Encoding Sample Rate&LSetup(3,"%s",512,B,0,"8 kHz";&LSetup(3,"%s",512,B,1,"12 kHz");&LSetup(3,"%s",512,B,2,"16 kHz");&LSetup(3,"%s",512,B,3,"22.05 kHz");&LSetup(3,"%s",512,B,4,"24 kHz");&LSetup(3,"%s",512,B,5,"32 kHz");&LSetup(3,"%s",512,B,6,"44.1 kHz");&LSetup(3,"%s",512,B,7,"48 kHz");
Encoding Quality (MPEG only)&LSetup(1,"%u",513,B);
Input Source&LSetup(3,"%s",510,B,1, "Analog Line");&LSetup(3,"%s",510,B,9,"AES/EBU");
Input Gain
Output Audio Level
Fading Effect&LSetup(3,"%s",507,B,1,"On");&LSetup(3,"%s",507,B,0,"Off");
I/O and Control 
Front Panel LEDs
Relay 1 Mode
Relay 2 Mode
Relay 3 Mode
Relay 4 Mode
SNMP Destination IP(s)&LSetup(4,"%s",540,S);
SMTP Server IP/DNS&LSetup(4,"%s",1000,S);
Local e-mail (FROM:)&LSetup(4,"%s",1050,S);
Destination e-mail(s) (TO:)&LSetup(4,"%s",1100,S);
Serial 
Serial Port 1, baud rate
Serial Port 1, data bits&LSetup(3,"%s",80,b2-3,2,"7");&LSetup(3,"%s",80,b2-3,3,"8");
Serial Port 1, parity&LSetup(3,"%s",80,b4-5,0,"no");&LSetup(3,"%s",80,b4-5,3,"even");&LSetup(3,"%s",80,b4-5,1,"odd");
Serial Port 1, stop&LSetup(3,"%s",80,b6-7,1,"1");&LSetup(3,"%s",80,b6-7,3,"2");
Serial Port 1, handshake
TCP Port for COM1&LSetup(1,"%d",503,W);
Serial Port 2, baud rate
Serial Port 2, data bits&LSetup(3,"%s",83,b2-3,2,"7");&LSetup(3,"%s",83,b2-3,3,"8");
Serial Port 2, parity&LSetup(3,"%s",83,b4-5,0,"no");&LSetup(3,"%s",83,b4-5,3,"even");&LSetup(3,"%s",83,b4-5,1,"odd");
Serial Port 2, stop&LSetup(3,"%s",83,b6-7,1,"1");&LSetup(3,"%s",83,b6-7,3,"2");
Serial Port 2, handshake
TCP Port for COM2&LSetup(1,"%d",505,W);
RTP Statistics 
Lost Frames&LBAS(1,"%u",rtplo);
Duplicated Frames&LBAS(1,"%u",rtpdu);
Dropped Frames&LBAS(1,"%u",rtpdr);
Latency&LBAS(1,"%u",rtpla); msec
Save this data before contacting Barix support service.
X 0.0.0.0brtp.barix.comus-reflector.barix.comeu-reflector.barix.com'0208 '--------------------------------------------------------------------------------------------- ' STL, general gateway for audio ' ' 02.00 Apr 08 2010 AD started from Andrew RTP_STL V1.24 ' + added new web UI ' + added standard BRTP ' + added appstatus page ' c chged usb failover fixed, just ON/OFF available ' + added keep alive "disabled", no send, no reply ' ! fixed no pld update without USB pen on decoder side ' ! fixed USB audio holes sometime ' 02.01 Jun 12 2010 AD c chged buffer to msecs, song module C8.05 introduced ' c added external ADC option ' 02.02 Jul 23 2010 AD c chged loopback as default mixer (0x4000) always ' + added RTP statistics ' + added Exstreamer 500 support ' + added Reflector-based reboot ' 02.03 Jul 27 2010 PK ! fixed #61.14: long string expressions causing audio dropouts ' Jul 30 2010 PK ! fixed input selection on Ex500 (WEB UI) ' 02.04 Aug 10 2010 AD + added SNMP alarm system ' + added SNMP Walk parameters as per BNA request spec. ' + added relay ON while OUT On/Off options ' ! fixed input states must not be displayed for device with no inputs ' ! fixed activation of relays in "send on level" and "send on inputX" ' done immediate (no timeout) ' + added minor alarm for no incoming stream ' 02.05 Aug 13 2010 AD ! fixed ON while OUT audio ON/OFF behaviour ' ! fixed bug #061.15 ' 02.06 Sep 07 2010 AD ! fixed bug #061.18, relay 1 set to On while OUT audio OFF, ' _MSG_1.mp3 was locking app. in a loop. ' 02.07 Sep 28 2010 AD ! fixed bug #061.20, stream 2 (com2) reused in init ' 02.08 Oct 28 2010 AD ! fixed bug #061.01, UDP/TCP port - no check for value range ' c chged stream numbers changed to 8 and 9 for usb playlist / mesgs ' ! fixed bug #061.22, _MSG_x.MP3 feature works not properly ' c chged status page update method '--------------------------------------------------------------------------------------------- dim ver$(24) ver$="V2.08 (Oct 28 2010)" #define WMODE_SE 0 #define WMODE_TD 1 #define WMODE_SED 2 #define WMODE_TED 3 syslog "STL, general tunnel for audio "+ver$ dim l,j,i,j1,x dim dst(7,1),sdst(7,1),tdst(7),mdst(1,1),idst(7),rdst dim _Ms$(1500) dim set$,vol,scks$,lport,rport,port,rhost$(16) dim msg$(500),sts$,audio$(30),dir$(15),snd$(15),rcv$(15),nd$(25) dim RL$(15),RL_o$(15),file$(128),brtps,brtpc dim ad_gn,mc_gn,inp,af,bit5 dim sr,srt,ql,qlty,msdel,confl,ocnfl,smode,kaprd,kadis,rmode(8),levth,stout,bcip$(16) dim dmode,talk,buffl,tm0,relay,rf(8),tm,buf,atime,btime dim levl,levr,levlo,levro,ldbl,ldbr,ldblo,ldbro dim IR$(9),IR_o$(9),IL$(9),IL_o$(9),mp3fl,mp3mn,plo,pln,volfd,fact,atimI,btimI,ramp,msgfl,mf(8) dim com$(50),_Mb$(1024),lb,com1p,com2p,ofs,comb,rh1$(16),rh2$(16),rp1,rp2 'for SG'S dim snmp$,snmpd(3) 'for SNMP dim tmout,mserv$,mfrom$,mto$,msubj$,mbody$,tmp$ 'for SMTP (e-mail) dim wmode ' working mode dim rtpdr,rtpdu,rtplo,rtpla ' statistics dim outth,otout dim atomI, btomI dim pllst, mdlay dim badpf, bufhi ' new 2.04, SNMP parameters dim _S01$(16) ' "RST " ' Relay state dim _S02$(64) ' "CST " ' Connection state dim _S03$(16) ' "IAL " ' Input audio level left dim _S04$(16) ' "IAR " ' Input audio level right dim _S05$(16) ' "OAL " ' Output audio level left dim _S06$(16) ' "OAR " ' Output audio level right dim _S07$(16) ' "LOF " ' RTP lost frames dim _S08$(16) ' "DUF " ' RTP duplicated frames dim _S09$(16) ' "DRF " ' RTP dropped frames dim _S10$(16) ' "LAT " ' RTP latency dim _S40$ ' last alarm text _S02$="CST No keep-alive info" ' startup status ' AD 05-08-2010 ' new 2.04, alarm service introduced. ' ' how it works: ' ' There is a 32-bit bitmask (amask) keeping alarm states for a maximumn of 32 alarms. ' Alarms are set(/unset) through the function as below: ' ' alarm(ALARM_CONN_LOST,1) ' ' Every time a new alarm change is dectected checking amask with old mask (omask) ' the correspondent alarm/s trap is/are sent. dim amask,omask ' 32 alarms to be used, (on/off) dim atmp dim algen$ ' general text for alarm event ' stream map ' ' 0 SMTP / setup init readings ' 1 com 1 ' 2 com 2 ' 3 ' 4 UDP audio tunnel ' 5 TCP/UDP SG ' 6 TCP/UDP SG ' 7 audio ' alarms #define ALARM_CONN_LOST 0 #define ALARM_NO_IN_STREAM 1 ' alarms severities, max 16, and correspondent human readable strings #define SEV_NONE 0 #define SEV_INFO 1 #define SEV_MINOR 2 #define SEV_MAJOR 3 #define SEV_CRITICAL 4 dim sev$(16) sev$="NONINFMINMAJCRI" ' alarm specific parameters, as bitmask per every alarm (severities, etc) ' XXXXXXXXXXXXXXXXXXXXXXXXSSSSUUUU ' X = reservered for future uses ' S = alarm set(on) severity ' U = alarm unset(off) severity dim apara(32) apara(ALARM_CONN_LOST)=or(shl(SEV_CRITICAL,4),SEV_INFO) apara(ALARM_NO_IN_STREAM)=or(shl(SEV_MINOR,4),SEV_INFO) dim sread dim ssave dim alarm ' set / unset (1/0) alarm state dim alsnd ' send alarm, parames are alarm n. and state (on/off) dim calcd ' calculate low buffer limit bcip$ = sprintf$("%1A",5) 'broadcast IP for auto start-up config for i = 1 to 8 ioctl i,0 'all possible relays off next i ' *** READING SETUP VARIABLES *** ' detecting hw type i = iostate(60000) if and(i,i<26) then j=-1 ' decoder only ? if or(i=1,i=9,i=14,i=20) then j=WMODE_TD ' or encoder only ? if i=8 then j=WMODE_SE if j<>-1 then lock 1 sread(500) midset set$,37,1,j ssave(500) lock 0 endif endif sread(500) ' WMODE wmode=midget(set$,37,1) outth=midget(set$,28,2) otout=midget(set$,39,2) ' AUDIO vol=midget(set$,1,1) ' AD, volume in dB if vol>127 then vol=vol-256 ' convert to signed if vol>12 then vol=12 ' safe limit ad_gn = midget(set$,2,1) : if ad_gn>15 then ad_gn=15 mc_gn = midget(set$,3,1) : if mc_gn>15 then mc_gn=15 ramp = midget(set$,8,1) ' fading option ' SG'S com1p = midget(set$,4,2) 'UDP/TCP port for COM1 gateway (0 - disable, >0 - UDP, <0 - TCP) if com1p > 32768 then com1p = com1p-65536 com2p = midget(set$,6,2) 'UDP/TCP port for COM2 gateway (0 - disable, >0 - UDP, <0 - TCP) if com2p > 32768 then com2p = com2p-65536 inp = midget(set$,11,1) 'input (1=line,2=mic,4/5=SPDIF opt/coax,9=AES/EBU) if inp = 9 then inp = 5 'really use 5 for AES/EBU in BCL ' AUDIO FORMAT af = midget(set$,12,1) 'audio format if or(af=3, af=5) then bit5 = 1 'correction for PCM LSB mono / stereo if af>5 then if af=6 then mp3mn = 1 'it is mono MPEG 1/2 format mp3fl = 1 'it is MPEG 1/2 format (to BCL table) endif ' AUDIO BCL Quality SETUP ' transforming sample rate from a common drop down value sr = midget(set$,13,1) 'sampling rate, common if or(sr<0,sr>7) then af=1:sr=0 'protection against bad eeprom if mp3fl=0 then i=0 ' stereo bit if or(af=4,af=5) then i=4096 if af>=2 then af=2 if sr=0 then srt=8 if sr=1 then srt=12 if sr=4 then srt=24 if sr=5 then srt=32 if sr=6 then srt=44 if sr=7 then srt=48 qlty=i+256*af+srt 'analog quality w/o coder bits else ql = midget(set$,14,1) 'mpeg qlty, AD, DOM asked to add a separate drop down if sr=2 then srt=4 ' 16 if sr=3 then srt=0 if sr=4 then srt=2 if sr=5 then srt=5 if sr=6 then srt=1 if sr=7 then srt=3 qlty=1024+16*ql+srt ' 1024 bit reservoir endif msdel = midget(set$,26,2) 'max playback buffer level if and(mp3fl=0,msdel>1000) then msdel = 1000 ' auto limitation from the FW, to 32K smode = midget(set$,21,1) 'sending mode if wmode=WMODE_TD then smode=5 'set to never if transmitter only kaprd = midget(set$,30,1) 'keep-alive sending period (0 - disable) if kaprd=255 then kaprd=0 : kadis=1 'disable send and receive else kaprd=kaprd*10 endif rmode(1) = midget(set$,31,1) 'Relay1 mode rmode(2) = midget(set$,32,1) 'Relay2 mode rmode(3) = midget(set$,33,1) 'Relay3 mode rmode(4) = midget(set$,34,1) 'Relay4 mode levth = midget(set$,22,2) 'trigger level for "send on level" stout = midget(set$,24,2) 'stop "send on level" after this number of ms lport = midget(set$,35,2) 'local port (0 for encoder) snmp$ = mid$(set$,41,60) 'destination SNMP IPs (string) if snmp$ then syslog "SNMP destination : "+snmp$ sread(1000) mserv$ = mid$(set$, 1, 50) 'IP/DNS of open SMTP server mfrom$ = mid$(set$, 51, 50) 'e-mail address of this device mto$ = mid$(set$,101,100) 'comma delimited destination e-mail addresses syslog "SMTP: "+mserv$+", from: "+mfrom$+", to: "+mto$ if mserv$ then syslog "SMTP destination : "+mserv$ on timer1 gosub 2500 'waiting for SMTP timer 1,0 : _TMR_(1) = 0 'initial state 'check message files on USB (trick: mf(0) is quasi file to block output mixer) for i = 0 to 8 open "C_R:usb:///_MSG_"+str$(i)+".MP3" as 6 'try to open message file on USB if mediatype(6) then mf(i) = 1 : close 6 'set flags for existing messafe files next i 3 'possible restart after autoplay syslog "Start/restart for streaming..." ' playing from playlist reset, playing message reset msgfl=0 : pllst=0 for i = 0 to 7 if mediatype(i) then close i rf(i+1) = 0 'drop remote inputs next i plo = 127 : file$ = "" ' serial gateway sread(0) if com1p then i = 1 : gosub 30050 if com1p > 0 then open "UDP:0.0.0.0:"+str$( com1p) as 5 'open COM1-UDP5 if com1p < 0 then open "TCP:0.0.0.0:"+str$(-com1p) as 5 'open COM1-TCP5 endif if com2p then i = 2 : gosub 30050 if com2p > 0 then open "UDP:0.0.0.0:"+str$( com2p) as 6 'open COM2-UDP6 if com2p < 0 then open "TCP:0.0.0.0:"+str$(-com2p) as 6 'open COM2-TCP6 endif ' start of init j = 1 'parse SNMP IPs string for i = 0 to 3 if j > len(snmp$) then goto 15 'rest of string is empty j1 = instr(j,snmp$,",") : if j1=0 then j1 = len(snmp$)+1 'limit of IP/DNS snmpd(i) = RESOLVE(mid$(snmp$,j,j1-j)) : j = j1+1 'value of IP next i 15 'continue... ' OUTGOING STREAM (DESTINATIONS) sread(600) ' parse URL strings for i = 0 to 7 scks$ = mid$(set$,1+32*i,32) dst(i,0)=resolve(scks$) : sdst(i,0) = dst(i,0) next i open "STP:856" as 0 : read 0,set$ : close 0 for i = 0 to 7 ' parse Destination Type idst(i) = midget(set$,1+i,1) ' parse Remote Port values dst(i,1) = midget(set$,9+i*2,2) : sdst(i,1) = dst(i,1) ' trace out sockets syslog "d "+str$(i+1)+" : type "+str$(idst(i))+" : "+& sprintf$("%lA",dst(i,0))+" : "+str$(dst(i,1)) next i if idst(0)=2 then if wmode=WMODE_SE then ' BRTP must listen in the 1 Destination port syslog "Studio Encoder, BRTP selected, listening on Outgoing Stream BRTP port." open "UDP:0.0.0.0:"+str$(dst(0,1)) as 4 'usual passive UDP socket goto 14 else syslog "BRTP service will listen on the same incoming stream port." endif endif 10 ' continue... ' INCOMING STREAM if lport then port = lport else port = dst(0,1) 'conventional local port for encoder if port=0 then msg$ = "'red'> wrong settings: all ports are zero" ': goto 999 'end ' receiving mode scks$=mid$(set$,35,32) rdst=midget(set$,67,1) ' listening type j=resolve(scks$) ' listening resolved ip syslog "in : type "+str$(rdst)+" : "+sprintf$("%lA",j)+" : "+str$(port) if rdst=1 then 'type=1, then multicast open "UDP:"+sprintf$("%lA",j)+":"+str$(port) as 4 'multicast UDP socket mdst(0,0) = j : mdst(0,1) = port 'socket for possible keep-alive dst(0,0) = 0 : sdst(0,0) = 0 'to set passive half-duplex decoder in future if mdst(0,0) = resolve(bcip$) then close 4 : goto 13 'if BRTP with broadcast IP endif if or(rdst=0,rdst=2) then if rdst=2 then mdst(0,0)=j : mdst(0,1)=port 13 open "UDP:0.0.0.0:"+str$(port) as 4 'usual passive UDP socket endif 14 ' Std BRTP, check enabled ? if and(wmode <> WMODE_TD, idst(0)=2) then brtpc=1 ' Std BRTP, send enabled if and(wmode <> WMODE_SE, rdst=2) then brtps=_TMR_(0) : gosub 500 ' first BRTP request ' active half-duplex encoder if and(wmode = WMODE_SE, idst(0)<2) then dmode=2 : goto 11 'passive (learned) half-duplex encoder if and(wmode = WMODE_SE, idst(0)=2) then dmode = -2 : dst(0,1) = 0 : sdst(0,1) = 0 : goto 11 endif 'active full-duplex encoder/decoder if and(or(wmode = WMODE_SED, wmode = WMODE_TED), idst(0)<2) then dmode=1 : goto 11 'passive (learned) full-duplex encoder/decoder if and(or(wmode = WMODE_SED, wmode = WMODE_TED), idst(0)=2) then dmode=-1 : dst(0,1) = 0 : sdst(0,1) = 0 : goto 11 endif 'passive half-duplex decoder if and(wmode = WMODE_TD, rdst=2) then dmode = 0 : goto 11 'passive multicast half-duplex decoder if and(wmode = WMODE_TD, rdst=0) then dmode = 0 : goto 11 11 ' audio if or(dmode=2,dmode=-2) then if mp3fl = 0 then 'encoder analog audio$ = "AUD:11,"+str$(or(1,shl(bit5,5)))+","+str$(or(qlty,shl(1,10)))+","+str$(msdel) goto 12 endif if mp3fl = 1 then 'encoder mpeg audio$ = "AUD:2,7,"+str$(or(qlty,shl(mp3mn,11)))+","+str$(msdel) : goto 12 endif endif if dmode = 0 then if mp3fl = 0 then 'decoder analog ' here only msdel is used, frame_duration left as automatic calculated from the FW audio$ = "AUD:11,"+str$(or(1,shl(bit5,5)))+","+str$(or(qlty,shl(1,11)))+","+str$(msdel) goto 12 endif 'decoder mpeg and all other formats (auto from RTP) if mp3fl=1 then audio$ = "AUD:1,7,0,"+str$(msdel) : goto 12 endif 'encoder/decoder (dmode -1 or +1) if mp3fl then ' a site type change, with still an MPEG format can result in bad audio open ' let's default to uLaw mono 8Khz syslog "Unsupported full-duplex audio format, default to uLaw 8Khz mono" bit5=0 : qlty=256*0+8 lock 1 sread(500) : midset set$,12,1,0 : midset set$,13,1,0 : ssave(500) lock 0 endif audio$ = "AUD:11,"+str$(or(1,shl(bit5,5)))+","+str$(or(qlty,shl(3,10)))+","+str$(msdel) 12 ' bufhi limit calculation from bitrate bufhi=calcd() ' give the chance to cactch the first keep alive tm=_TMR_(0) if smode then gosub 370 'initially to block sending for all modes excepting "send always" gosub 350 'open audio tunnel IR_o$ = "????????" : IL_o$ = "????????" : RL_o$ = "????????" 'init for status 'start of main loop 100 ' connection state changed ? if confl<>ocnfl then gosub 600 : ocnfl=confl ' alarm for stream missing if confl then if buffl then alarm(ALARM_NO_IN_STREAM,0) else alarm(ALARM_NO_IN_STREAM,1) endif ' some alarm to process ? if amask<>omask then gosub 700 ' process alarms if any ' message programmed for a relay ? Playlist can't be interrupted ! if and(msgfl,pllst=0) then if file$ then gosub 400 'try to play message file from USB if msgfl=0 then mdlay=_TMR_(0) : goto 3 else if ramp then gosub 10200 ' ramp down actual music if any else write 7,str$(-127),-12 : gosub 460 endif endif goto 100 ' AD continue until the message is played endif ' serial gateway, bgn if com1p then if and(com1p < 0, kaprd, _TMR_(0)-tm0 > kaprd) then if mediatype(5) then if connected(5)=0 then close 5 : syslog "close COM1-TCP/handle 5" if mediatype(5)=0 then open "TCN:"+rhost$+":"+str$(-com1p) as 5 : syslog "open COM1-TCP" 'open active COM1-TCP5 endif if filesize(1) then gosub 30001 'send COM1 -> UDP/TCP5 if com1p > 0 then lb = lastlen(5) : if lb<0 then gosub 30005 ' receive UDP5 -> COM1 if com1p < 0 then if mediatype(5) then if and(connected(5),filesize(5)) then gosub 30007 ' receive TCP5 -> COM1 endif if com2p then if and(com2p < 0, kaprd, _TMR_(0)-tm0 > kaprd) then if mediatype(6) then if connected(6)=0 then close 6 : syslog "close COM2-TCP/handle 6" if mediatype(6)=0 then open "TCN:"+rhost$+":"+str$(-com2p) as 6 : syslog "open COM2-TCP" 'open active COM2-TCP6 endif if filesize(2) then gosub 30002 'send COM2 -> UDP/TCP6 if com2p > 0 then lb = lastlen(6) : if lb<0 then gosub 30006 ' receive UDP6 -> COM2 if com2p < 0 then if mediatype(6) then if and(connected(6),filesize(6)) then gosub 30008 ' receive TCP6 -> COM2 endif ' serial gateway, end IL$ = "" 'drop input values for i = 1 to 8 if or(iostate(200+i)=0,iostate(200+i)=2) then IL$=IL$+"1" else IL$=IL$+"0" next i read 7,_Ms$,-1 : levl=lastlen(7) : _S03$="IAL "+str$(levl) 'left audio in level read 7,_Ms$,-2 : levr=lastlen(7) : _S04$="IAR "+str$(levr) 'right audio in level read 7,_Ms$,-3 : levlo=lastlen(7) : _S05$="OAL "+str$(levlo) 'left audio out level read 7,_Ms$,-4 : levro=lastlen(7) : _S06$="OAR "+str$(levro) 'right audio out level read 7,_Ms$,-13 : ldbl=lastlen(7) 'left audio in level read 7,_Ms$,-14 : ldbr=lastlen(7) 'right audio in level read 7,_Ms$,-15 : ldblo=lastlen(7) 'left audio out level read 7,_Ms$,-16 : ldbro=lastlen(7) 'right audio out level read 7,_Ms$,-10 : rtplo=lastlen(7) : _S07$ = "LOF "+str$(rtplo) read 7,_Ms$,-11 : rtpdu=lastlen(7) : _S08$ = "DUF "+str$(rtpdu) read 7,_Ms$,-12 : rtpdr=lastlen(7) : _S09$ = "DRF "+str$(rtpdr) read 7,_Ms$,-20 : rtpla=lastlen(7) : _S10$ = "LAT "+str$(rtpla) if talk then snd$ = "OUT stream ON" else snd$ = "OUT stream OFF" if buffl then rcv$ = "IN stream ON" else rcv$ = "IN stream OFF" if IL_o$ <> IL$ then if kaprd then write 4,tmp$,10,rhost$,rport 'to send urgent changes inputs if dmode then 'if active side if smode = 1 then gosub 320 '"send on input1" mode if smode = 2 then gosub 320 '"send on input2" mode if smode = 3 then gosub 330 '"send on level" mode if and(kaprd, _TMR_(0)-tm0 > kaprd) then 'send keepalive/heart-beat messages tm0 = _TMR_(0) : write 4,"?"+IL$,10,sdst 'send request each keepalive period endif else if and(kaprd, _TMR_(0)-tm0 > kaprd) then 'send keepalive/heart-beat messages tm0 = _TMR_(0) : write 4,"?"+IL$,10,mdst 'send request each keepalive period endif endif if dmode = -2 then gosub 390 'check timers to free BRTP table on streaming end if and(brtps, _TMR_(0)>brtps+4000) then brtps=_TMR_(0) gosub 500 endif ' See LINK cmd, l<0 ONLY for non correct PAYLOAD TYPES or Outbands l=lastlen(4) if l<0 then if plo=-1 then goto 3 'possible restart after autoplay rhost$ = rmthost$(4) 'IP of active remote side rport = rmtport(4) 'port of active remote side if and(dmode=0,kaprd,mdst(0,0)=0) then mdst(0,0)=RESOLVE(rhost$) : mdst(0,1)=rport 'socket for possible keep-alive read 4,_Ms$ tm = _TMR_(0) ' keep alive reset ' check for a payload if and(dmode=0,midget(_Ms$,1,1)=&H80) then 'if new RTP stream pln = and(midget(_Ms$,2,1),127) 'get RTP payload if plo <> pln then gosub 200 : goto 11 'start new passive RTP endif if mid$(_Ms$,1,1) = "!" then 'gotten reply from passive side (keep-alive) dir$ = "OUT Con to" : nd$ = "Net Delay: "+str$((tm-tm0)/2)+" ms" 'drop relay message IR$ = mid$(_Ms$,2) : confl=1 for i=1 to 8 rf(i)=val(mid$(IR$,i,1)) 'gotten remote input i value next i if dmode=2 then write 7,str$(vol),-12 'set volume to vol for sender endif if mid$(_Ms$,1,1) = "?" then 'if heart-beat request (keep-alive) dir$ = "IN Con ON from" : nd$ = "RTP Payload: "+str$(plo) 'drop relay message IR$ = mid$(_Ms$,2) : confl = 2 for i = 1 to 8 rf(i) = val(mid$(IR$,i,1)) 'gotten remote input i value next i 'if dmode < 0 then gosub 380 'get new destination IP:port for passive (learned) if and(talk = 0, buffl = 1, smode = 4) then gosub 360 'start sending for "respond" mode if kadis=0 then write 4,"!"+IL$,10,rhost$,rport 'send heart-beat reply message if dmode = -2 then write 7,str$(vol),-12 'set volume to vol for sender endif ' STANDARD RTP, AD if brtpc then 'get new destination IP:port for passive (learned) if mid$(_Ms$,1,3)="BRX" then gosub 380 endif ' long expression split into several subexpressions to allow task switch (see bug #61.14) msg$ = "'lime'>
" + dir$ + "" + rhost$ + ": "+ str$(rport) msg$ = msg$ + "INput AUD L:" + str$(levl) + "
" + nd$ msg$ = msg$ + "   Remote DIs:" + IR$ + "INput AUD R:" + str$(levr) msg$ = msg$ + "
" + rcv$ + "Local DIs:" + IL$ + "   OUTput AUD L:" msg$ = msg$ + str$(levlo) + "
" + snd$ + "Local Relays:" + RL$ msg$ = msg$ + "OUTput AUD R:" + str$(levro) + "
" endif 101 read 7,_Ms$,-6 : buf = lastlen(7) 'check rest of audio buffer 'syslog "plo="+str$(plo) ' why plo = -1 ? if plo=-1 then gosub 400 : goto 100 'try to autoplay from USB if buf>bufhi/10 then if _TMR_(0)-tm > 3000 then msg$ = "'lime'> IN Con ON, "+rcv$ : tm = _TMR_(0) 'to avoid interrupt by timer 'to correct rhost$ and rport if confl <> 3 then confl = 3 : syslog "Restart for no Keep-alive" : goto 3 endif buffl=1 'set buffer flag if ramp then if msgfl=0 then gosub 10300 ' fading, rumping up after a message else if msgfl=0 then write 7,str$(vol),-12 'set volume to vol endif else buffl = 0 : if and(talk=1,smode=4) then gosub 370 'block sending for "respond" mode if _TMR_(0)-tm>3500 then confl = 0 : msg$ = "'red'> NB! Connection is broken or closed!" 'drop buffer flag and set volume to 0 (except keepalive OFF mode) volfd = 0 : if kaprd then write 7,str$(0),-12 if dmode = 0 then syslog "prepare possible autoplay" plo = -1 'prepare possible autoplay ' SG can stay open actually, stream 8,9 are used for playlist and msg files 'if mediatype(5) then close 5 'finish gateway for using by autoplay playlist 'if mediatype(6) then close 6 'finish gateway for using by current autoplay file endif endif endif 102 RL$ = "" 'drop output values for i = 1 to 8 'actions for Relay i for gotten request/reply gosub 300 : ioctl i,relay : RL$=RL$+str$(relay) if and(relay, mf(i)) then ' studio encoder only ? no message must be played if or(dmode=2,dmode=-2) then next i ' message must have priority on playlists since message is linked to relay action ' and can happen also with stream on. if or(rmode(i)=1,rmode(i)=5,rmode(i)=6,rmode(i)=8,rmode(i)=9,rmode(i)=10) then ' a certain delay is required to detect some level is back if _TMR_(0)-mdlay>5000 then msgfl=i else msgfl=i ' start process for playing message file, later 460 set file$ endif endif next i if IR_o$ <> IR$ then IR_o$ = IR$ if IL_o$ <> IL$ then IL_o$ = IL$ if RL_o$ <> RL$ then RL_o$ = RL$ _S01$ = "RST "+RL$ for i = 0 to 3 if snmpd(i) then trap sprintf$("%lA",snmpd(i)),6,1,"P1.3.0","E1.5.1.1.1.2.1" next i if mserv$ then msubj$ = RL$ : gosub 2300 'send by e-mail endif ' long expression split into several subexpressions to allow task switch (see bug #61.14) sts$ = str$(smode)+":"+str$(PLO)+":" sts$ = sts$+str$(TALK)+":"+str$(BUFFL)+":"+str$(CONFL)+":" sts$ = sts$+str$(LEVL)+":"+str$(LEVR)+":"+str$(LEVLO)+":" sts$ = sts$+str$(LEVRO)+":"+str$(LDBL)+":"+str$(LDBR)+":" sts$ = sts$+str$(LDBLO)+":"+str$(LDBRO)+":"+IR_O$+":" sts$ = sts$+IL_O$+":"+RL_O$+":"+RHOST$+":"+str$(RPORT)+":" goto 100 'end of main loop 999 delay 10000 end ' get new values for audio (see BCL manual, 3.10.3.5 RTP payload types) 200 plo=pln : mp3fl=0 : syslog "new RTP payload type "+str$(plo)'set a new payload as old value if plo = 0 then qlty = &H0008 : bit5 = 0 : return 'u-Law, 8bit, mono, 8kHz if plo = 8 then qlty = &H0108 : bit5 = 0 : return 'A-Law, 8bit, mono, 8kHz if plo = 10 then qlty = &H122C : bit5 = 0 : return 'PCM, 16bit, MSB first, signed, 44.1kHz stereo, left channel first if plo = 11 then qlty = &H022C : bit5 = 0 : return 'PCM, 16bit, MSB first, signed, 44.1kHz mono if plo = 14 then mp3fl = 1 : return 'MPEG audio if plo = 96 then qlty = &H0208 : bit5 = 0 : return 'PCM, 16bit, MSB first, signed, 8kHz mono if plo = 97 then qlty = &H0018 : bit5 = 0 : return 'u-Law, 8bit, mono, 24kHz if plo = 98 then qlty = &H0118 : bit5 = 0 : return 'A-Law, 8bit, mono, 24kHz if plo = 99 then qlty = &H0218 : bit5 = 0 : return 'PCM, 16bit, MSB first, signed, 24kHz mono if plo = 100 then qlty = &H0020 : bit5 = 0 : return 'u-Law, 8bit, mono, 32kHz if plo = 101 then qlty = &H0120 : bit5 = 0 : return 'A-Law, 8bit, mono, 32kHz if plo = 102 then qlty = &H0220 : bit5 = 0 : return 'PCM, 16bit, MSB first, signed, 32kHz mono if plo = 103 then qlty = &H1230 : bit5 = 0 : return 'PCM, 16bit, MSB first, signed, 48kHz stereo, left channel first if plo = 104 then qlty = &H0208 : bit5 = 1 : return 'PCM, 16bit, LSB first, signed, 8kHz mono if plo = 105 then qlty = &H0218 : bit5 = 1 : return 'PCM, 16bit, LSB first, signed, 24kHz mono if plo = 106 then qlty = &H0220 : bit5 = 1 : return 'PCM, 16bit, LSB first, signed, 32kHz mono if plo = 107 then qlty = &H122C : bit5 = 1 : return 'PCM, 16bit, LSB first, signed, 44.1kHz stereo, left channel first if plo = 108 then qlty = &H1230 : bit5 = 1 : return 'PCM, 16bit, LSB first, signed, 48kHz stereo, left channel first if plo = 109 then qlty = &H000C : bit5 = 0 : return 'u-Law, 8bit, mono, 12kHz if plo = 110 then qlty = &H010C : bit5 = 0 : return 'A-Law, 8bit, mono, 12kHz if plo = 111 then qlty = &H020C : bit5 = 0 : return 'PCM, 16bit, MSB first, signed, 12kHz mono if plo = 112 then qlty = &H020C : bit5 = 1 : return 'PCM, 16bit, LSB first, signed, 12kHz mono syslog "wrong or generic RTP payload type "+str$(plo) : plo = 127 return '------------------------------------------------------------------------------ 300 'actions for gotten request/reply '------------------------------------------------------------------------------ relay = 0 'syslog "rmode(i):"+str$(rmode(i)) on 1+rmode(i) goto 301,302,303,304,305,306,307,308,309,310,311 301 if rf(i) then relay = 1 : return else return 'set relay by remote input 302 if confl then relay = 1 : return else return 'set relay by connection ON 303 return 'set relay by always OFF 304 if buffl then relay = 1 : return else return 'set relay by incomming stream ON 305 if buffl=0 then relay = 1 : return else return 'set relay by incomming stream OFF 306 if confl=0 then relay = 1 : return else return 'set relay by connection OFF 307 gosub 340 : return 'set relay by IN audio OFF 308 gosub 340 : return 'set relay by IN audio change (pulsed) 309 gosub 340 : return 'set relay by IN audio ON 310 gosub 345 : return 'set relay by OUT audio ON 311 gosub 345 : return 'set relay by OUT audio OFF syslog "wrong mode setting for Relay "+str$(i) return '------------------------------------------------------------------------------ 320 'actions for smode = 1 or 2 '------------------------------------------------------------------------------ if val(mid$(IL$,smode,1)) then 'check input1/2 if talk=0 then ',_TMR_(0)-btime>stout) then gosub 360 'set destination sockets and start sending syslog "start talk with active input1/2 "+str$(smode)+" immediate send" endif atime = _TMR_(0) 'remember latest time "send on input1/2" else if and(talk=1,_TMR_(0)-atime>stout) then gosub 370 'block sending syslog "stop talk with passive input "+str$(smode)+" after "+str$(stout)+" ms" endif btime = _TMR_(0) 'remember latest block time "send on input1/2" endif return '------------------------------------------------------------------------------ 330 'actions for smode = 3 (ON while incoming stream ON) '------------------------------------------------------------------------------ if or(levl>levth,levr>levth) then 'check levels if talk=0 then ',_TMR_(0)-btime>stout) then gosub 360 'set destination sockets and start sending syslog "start talk with levels "+str$(levl)+"/"+str$(levr)+" >= "+str$(levth)+" immediate" endif atime=_TMR_(0) 'remember latest activate time "send on level" else if and(talk=1,_TMR_(0)-atime>stout) then gosub 370 'block sending syslog "stop talk with levels "+str$(levl)+"/"+str$(levr)+" after "+str$(stout)+" ms" endif btime=_TMR_(0) 'remember latest block time "send on level" endif return '------------------------------------------------------------------------------ 340 'actions for rmode = 6,7,8 (ON while IN audio ON/OFF + pulse on change) '------------------------------------------------------------------------------ if or(levl > levth, levr > levth) then 'check levels if and(btimI-atimI > 0, btimI-atimI < stout) then btimI = _TMR_(0)-stout-5000 'block short switching if _TMR_(0)-btimI > stout then if rmode(i) = 8 then relay = 1 'ON for audio ON if rmode(i) = 7 then if _TMR_(0)-btimI < stout+3000 then relay = 1 'ON for 3 sec else if rmode(i) = 6 then relay = 1 'ON for audio still ON endif atimI = _TMR_(0) 'remember latest activate time "send on level" else if and(atimI-btimI > 0, atimI-btimI < stout) then atimI = _TMR_(0)-stout-5000 'block short switching if _TMR_(0)-atimI > stout then if rmode(i) = 6 then relay = 1 'ON for audio OFF if rmode(i) = 7 then if _TMR_(0)-atimI < stout+3000 then relay = 1 'ON for 3 sec else if rmode(i) = 8 then relay = 1 'ON for audio still OFF endif btimI = _TMR_(0) 'remember latest block time "send on level" endif return ' actions for rmode = 9 10 (ON while OUT audio ON/OFF ) 345 if or(levlo>outth,levro>outth) then ' se sopra soglia if and(btomI-atomI>0,btomI-atomIotout then if rmode(i)=9 then relay = 1 ' ON for audio ON else if rmode(i)=10 then relay = 1 ' ON for audio still ON endif atomI=_TMR_(0) ' remember latest activate time "send on level" else if and(atomI-btomI>0,atomI-btomIotout then if rmode(i)=10 then relay = 1 ' ON for audio OFF else if rmode(i)=9 then relay = 1 ' ON for audio still OFF endif btomI=_TMR_(0) 'remember latest block time "send on level" endif return '------------------------------------------------------------------------------ 350 'open audio tunnel '------------------------------------------------------------------------------ if mediatype(7) then close 7 syslog "Opening audio : "+audio$ syslog "Actual dmode : "+str$(dmode) open audio$ as 7 'open audio if dmode then write 7,str$(ad_gn), -2 'set A/D Gain write 7,str$(mc_gn), -1 'set Mic Gain write 7,str$(inp), -3 'set input source to mic/line endif 'set mixer for 100% input and 100% output 'if mf(0)=0 then if or(dmode=2,dmode=-2) then write 7,"16448",-13 ' default, 0x4000, new loopback feature write 7,str$(1),-11 'volume in dB write 7,str$(-127),-12 'set volume to 0 firstly ' reset fixed ramp rate, volume id db volfd =- 127 : fact = 96 link 4,7,dst 'new Petr audio tunnel if wmode<>WMODE_TD then gosub 360 'try start anyway if some sockets exist, 2009/12/01 write 4,"*",1,sdst 'wake up remote Connection Status endif return 360 'set source destination sockets in order to start sending talk=0 LOCK 1 for i=0 to 7 dst(i,0)=sdst(i,0) : dst(i,1)=sdst(i,1) : if dst(i,0) then talk=1 next i LOCK 0 return 370 'reset source destination sockets to 0 in order to block sending LOCK 1 for i=0 to 7 dst(i,0)=0 : dst(i,1)=0 next i LOCK 0 talk=0 return 380 'get new destination IP:port for passive (learned) for i=0 to 7 ' up to maximum of 8 channels if and(sprintf$("%lA",sdst(i,0))=rhost$, sdst(i,1)=rport) then ' already exists ? 'syslog "channel already exist, updating timer" tdst(i) = _TMR_(0) : return 'update timer for this channel endif next i for i=0 to 7 ' get the first free slot if and(sdst(i,0)=0,sdst(i,1)=0) then syslog "Added BRTP channel: ["+str$(i)+"] -> "+rhost$+":"+str$(rport) sdst(i,0)=resolve(rhost$) : sdst(i,1)=rport : tdst(i)=_TMR_(0) gosub 360 ' wake up the "Connection Status" after usb playing if ka=passive write 4,"!"+IL$,10,rhost$,rport return endif next i syslog "BRTP table is full, no possibility to add: "+rhost$+":"+str$(rport) return 390 'check timers for BRTP table for i = 0 to 7 if and(tdst(i), _TMR_(0)-tdst(i) > 30000) then 'channel timer is exhausted syslog "Deleted by timer BRTP channel: ["+str$(i)+"] -> "+& sprintf$("%lA",dst(i,0))+":"+str$(dst(i,1)) sdst(i,0) = 0 : sdst(i,1) = 0 : tdst(i) = 0 gosub 360 : return endif next i return '------------------------------------------------------------------------------ '--- serial gateway, bgn ------------------------------------------------------ '------------------------------------------------------------------------------ 30001 '------------------------------------------------------------------------------ read 1,_Mb$ : lb = lastlen(1) if lb > 0 then if com1p > 0 then if rh1$ then write 5,_Mb$,lb,rh1$,rp1 else write 5,_Mb$,lb,rhost$,com1p if com1p < 0 then if mediatype(5) then if connected(5) then write 5,_Mb$,lb endif return '------------------------------------------------------------------------------ 30002 '------------------------------------------------------------------------------ read 2,_Mb$ : lb = lastlen(2) if lb > 0 then if com2p > 0 then if rh2$ then write 6,_Mb$,lb,rh2$,rp2 else write 6,_Mb$,lb,rhost$,com2p if com2p < 0 then if mediatype(6) then if connected(6) then write 6,_Mb$,lb endif return '------------------------------------------------------------------------------ 30005 rh1$=rmthost$(5) : rp1=rmtport(5) : read 5,_Mb$ : write 1,_Mb$,-lb : return '------------------------------------------------------------------------------ 30006 rh2$=rmthost$(6) : rp2=rmtport(6) : read 6,_Mb$ : write 2,_Mb$,-lb : return '------------------------------------------------------------------------------ 30007 read 5,_Mb$ : lb = lastlen(5) : write 1,_Mb$,lb : return '------------------------------------------------------------------------------ 30008 read 6,_Mb$ : lb = lastlen(6) : write 2,_Mb$,lb : return '------------------------------------------------------------------------------ 30050 'open com port '------------------------------------------------------------------------------ if i = 1 then ofs = 81 'setup offset for COM1 if i = 2 then ofs = 84 'setup offset for COM2 com$="COM:" comb=midget(set$,ofs+1,1) if comb=0 then com$=com$+"38400," if comb=1 then com$=com$+"19200," if comb=2 then com$=com$+"9600," if comb=3 then com$=com$+"4800," if comb=4 then com$=com$+"2400," if comb=5 then com$=com$+"1200," if comb=6 then com$=com$+"600," if comb=7 then com$=com$+"300," if comb=8 then com$=com$+"115200," if comb=9 then com$=com$+"57600," if comb=10 then com$=com$+"230400," if comb=11 then com$=com$+"76800," comb=midget(set$,ofs,1) if and(comb,&H30)=0 then com$=com$+"N," if and(comb,&H30)=&H30 then com$=com$+"E," if and(comb,&H30)=&H10 then com$=com$+"O," if and(comb,4) then com$=com$+"8," else com$=com$+"7," if and(comb,128) then com$=com$+"2," else com$=com$+"1," comb=midget(set$,ofs+2,1) if comb=0 then com$=com$+"NON:" if comb=1 then com$=com$+"SFW:" if comb=2 then com$=com$+"HDW:" if comb=8 then com$=com$+"485:" com$=com$+str$(i) 'number of serial port syslog "serial> "+com$ open com$ as i 'open serial port for the gateway return '------------------------------------------------------------------------------ '--- serial gateway, end ------------------------------------------------------ '------------------------------------------------------------------------------ ' SMTP Subroutine - Used to send an email message ' ' The following variables must be defined before calling: ' ' mserv$ : The address of the SMTP server ' mfrom$ : The from email address (from@host.com) ' mto$ : The to email addresses (to1@host1.com,to2@host2.com,...) ' msubj$ : The email message subject ' mbody$ : The body text of the email ' ' Uses File Handle 0 for TCP I/O '------------------------------------------------------------------------------ 2300 if mfrom$ = "" then syslog "Empty e-mail address FROM. SUBJ: "+ msubj$ goto 2302 if mto$ = "" then syslog "Empty e-mail address TO. SUBJ: " + msubj$ goto 2302 open "TCP:"+sprintf$("%lA",RESOLVE(mserv$))+":25" as 0 if mediatype(0) = 0 then syslog "SMTP server ("+mserv$+") is wrong!" goto 2301 tmout = 3000 'max time for e-mail sending in order not to break audio connection timer 1,tmout 'set waiting timer 2010 if connected(0) = 0 then if _TMR_(1) then goto 2010 else goto 2301 syslog mserv$ write 0,"HELO STL\r\n",0 2011 read 0,tmp$,0 : if len(tmp$) = 0 then if _TMR_(1) then goto 2011 else goto 2301 syslog mfrom$ write 0,"MAIL FROM: <" + mfrom$ + ">\r\n",0 2012 read 0,tmp$,0 : if len(tmp$) = 0 then if _TMR_(1) then goto 2012 else goto 2301 j = 0 2303 i = j + 1 : j = instr(i,mto$,",") if j then tmp$ = mid$(mto$,i,j-i) else tmp$ = mid$(mto$,i) syslog tmp$ 'part of mto$ write 0,"RCPT TO: <" + tmp$ + ">\r\n",0 2013 read 0,tmp$,0 : if len(tmp$) = 0 then if _TMR_(1) then goto 2013 else goto 2301 if j then goto 2303 'repeat for some addresses write 0,"DATA\r\n",0 2014 read 0,tmp$,0 : if len(tmp$) = 0 then if _TMR_(1) then goto 2014 else goto 2301 syslog msubj$ write 0,"From: " + mfrom$ + "\r\n",0 write 0,"Subject: " + msubj$ + "\r\n",0 write 0,"To: " + mto$ + "\r\n",0 write 0,"Content-Type: text/html\r\n",0 write 0, "\r\n",0 'write 0, mbody$ + "\r\n",0 write 0, "",0 write 0, "",0 write 0, "\r\n.\r\n",0 'EOM 2015 read 0,tmp$,0 : if len(tmp$) = 0 then if _TMR_(1) then goto 2015 else goto 2301 syslog mbody$ write 0,"QUIT\r\n",0 2016 read 0,tmp$,0 : if len(tmp$) = 0 then if _TMR_(1) then goto 2016 else goto 2301 2301 if mediatype(0) then close 0 if _TMR_(1) = 0 then syslog "ERROR : incomplete SMTP sending." gosub 2501 2302 '''mto$ = "" 'to prevent sending to nobody return '------------------------------------------------------------------------------ 2500 syslog "end of waiting SMTP sending for "+str$(tmout) '------------------------------------------------------------------------------ 2501 timer 1,0 _TMR_(1) = 0 'drop flag _TMR_(1) return 399 ' open mp3 open "AUD:1,0,0,0" as 7 write 7,str$(vol),-12 delay 450 ' workaround to avoid first part lost on MICRONAS volume rump-up devices return ' try to autoplay from USB (open if not, and play a chunk) 400 if file$="" then ' opening/getting next file from "playlist.m3u" badpf=0 : gosub 450 if file$="" then return ' new file has been found, close and re-opening audio here if mediatype(7) then close 7 gosub 399 endif if mediatype(9)=0 then open "C_R:usb:///"+file$ as 9 if mediatype(9)=0 then ' bad file if badpf=0 then syslog "ERROR : can't find playlist file "+file$ badpf=1 return endif msg$ = "'yellow'> Autoplay: "+file$ 'playback... 401 if filesize(7)<4096 then return 'is there free buffer enough ? l=0 : if mediatype(9) then read 9,_Ms$ : l=lastlen(9) if l>0 then write 7,_Ms$,l : goto 401 ' add to play buffer until it's near to be full ' l<=0 = EOF if mediatype(9) then close 9 ' end of the current file if msgfl then msgfl=0 ' end of message, re-check the application status close 7, 1 : file$="" if pllst then gosub 400 ' restart needed imediately to avoid stream error readin 7 return ' play by USB playlist file "playlist.m3u" 450 syslog "getting next playlist file" if mediatype(8)=0 then open "C_R:usb:///playlist.m3u" as 8 'check playlist if mediatype(8)=0 then syslog "ERROR : playlist not found." : return pllst=1 451 read 8,tmp$,0 if len(tmp$)>0 then if instr(1,UCASE$(tmp$),".MP3") = 0 then goto 451 'miss all other files (except MP3) file$ = tmp$ : syslog "Start autoplay: "+file$ return endif close 8 : goto 450 'start playlist again return ' get message file 460 if mediatype(7) then close 7 ' finish audio tunnel for using by message play if mediatype(9) then close 9 ' if playlist is playing, just reset file$="_MSG_"+str$(msgfl)+".MP3" gosub 399 return '------------------------------------------------------------------------------ 500 ' initiate a standard BRTP stream request if rdst=2 then 'syslog "sending BRTP announcment" 'syslog "dest : " + sprintf$("%lA",mdst(0,0)) + ":" + str$(mdst(0,1)) write 4,"BRX ",4,sprintf$("%lA",mdst(0,0)),mdst(0,1) endif return 550 ' alarm, set/unset the alarm LOCAL alrm,state if state then amask=or(amask,shl(1,alrm)) else amask=and(amask,not(shl(1,alrm))) endif return 600 ' get status string 'syslog "connection state changed: confl="+str$(confl)+" ocnfl="+str$(ocnfl) _S02$="CST " on confl+1 goto 601,602,603,604 601 _S02$=_S02$+"No keep-alive info" : goto 610 602 _S02$=_S02$+"Established TO "+rhost$+":"+str$(rport) : goto 610 603 _S02$=_S02$+"Established FROM "+rhost$+":"+str$(rport) : goto 610 604 _S02$=_S02$+"Only Stream FROM "+rhost$+":"+str$(rport) : goto 610 610 if and(ocnfl>0,confl=0) then alarm(ALARM_CONN_LOST,1) if and(confl>0,ocnfl=0) then alarm(ALARM_CONN_LOST,0) return 650 ' alsnd alarm, preparing texts LOCAL als,set if set<>0 then set=1 x=1000+(shl(als,1))+set _S40$="ALARM " if set then ' apply string for severity _S40$=_S40$+mid$(sev$,1+(shr(apara(als),4)*3),3) else _S40$=_S40$+mid$(sev$,1+(and(apara(als),&H0f)*3),3) endif on als+1 goto 651,652,653,654 ' .. etc, apply alarm descriptions 651 _S40$=_S40$+" CONNECTION_LOST" algen$="Connection lost for keep alive missing" : goto 690 652 _S40$=_S40$+" NO_INCOMING_STREAM" algen$="Incoming stream missing" : goto 690 653 654 690 if set=0 then _S40$=_S40$+"_CLEARED " else _S40$=_S40$+" " _S40$=_S40$+algen$ ' append general text syslog "SENDING ALARM: "+_S40$ for i=0 to 3 ' ready, fire if snmpd(i) then trap sprintf$("%lA",snmpd(i)),6,x,"P1.3.0","E3.1.1.0","E1.5.1.1.1.2.40" next i alsnd=0 return 700 ' alarm, sending, once for all for atmp=0 to 31 if and(amask,shl(1,atmp)) then ' alarm is set if and(omask,shl(1,atmp))=0 then alsnd(atmp,1) ' sending SET if it was not set only else if and(omask,shl(1,atmp)) then alsnd(atmp,0) ' sending CLEAR if it was set only endif next atmp omask=amask alarm=0 return 10000 'sread LOCAL val1 open "STP:"+str$(val1) as 0 : read 0,set$ : close 0 sread=1 return 10100 'ssave LOCAL val2 open "STP:"+str$(val2) as 0 : write 0,set$,256 : close 0 ssave=1 return 10200 'fade volume to 0 before message if volfd>-32 then ' syslog "ramping down, volfd="+str$(volfd) volfd=volfd-1 : write 7,str$(volfd),-12 if volfd<=-32 then volfd=-127 else ' undefined volfd=-127 endif 'close gateway/tunnel and get message file if volfd=-127 then syslog "Playing message" : gosub 460 return 10300 'restore ramp volume to vol if volfd1 then fact=shr(fact,1) volfd=volfd+fact : write 7,str$(volfd),-12 endif return ' calcd ' AD 22.10.2010 ' initial implementation of this application was detecting the stream using ' the buf=bufhi/10 algorithm. ' This detection was tested and well working. So with the introduction of ' the msec delay, bufhi in bytes is reconstructed starting from msec delay. 10400 LOCAL Bps if mp3fl then ' bitrate depend on quality ' using minimal bitrate Bps=4625 else x=and(shr(qlty,8),2) ' format j=and(qlty,&Hff) ' Khz i=and(shr(qlty,12),1) ' stereo if or(x=0,x=1) then ' uLaw, aLaw Bps=j*1000 ' 8 bit samples else ' PCM Bps=j*1000*2 ' 16 bit samples endif if i then Bps=shl(Bps,1) endif ' Bps : 1 = x : mdelay calcd=msdel*Bps/1000 return end TBg,=<5B5,D50F54H58K5<M5@Q5V5[5`5e5j5n5t5z55 5 5 5 5 5 5 5" 5& 5* 5. 52 56 5: 5> 5B 5F 5J 5n 5r 5 5 5 5 5 6 6 6 6 6 6 6 #6 )6 /6 46 96 ?6 E6K6Q6U6Y6"_6&d6*j6.p62u66{6:~666666666666666666666 6667 7 7b7=7!7'7i-72787<7@7E7J7N7S7X7]7c7 j7 o7 t7 {7" 71 7@ 7O 7h 7w 7 7v 7 7 7 7 72^777777777777@$8d 8t888"8(8.848:8A8 V2.08 (Oct 28 2010)?STL, general tunnel for audio  CST No keep-alive info+ NONINFMINMAJCRI`Z  I 6    `Z  I 6     \ %1A  ` <` `` ; ` H ` ` k` I `  `  `  `  ` ` ` `&B`[  D %  ``\  BFF`[  `J %  %  `O %    `P %  '  ` %    `  ` ` `  `  ` %    `` ` %    `` `> %    `B %    `B`B `B`C %    `C`C `C` %    `  ` ` %    I `  `  ` `` `7 `6 F` %    I ` `  ` ` `6 ` I `  `   ` ` ` ` ` ` `  ` ` ` `  ` ` ,` ` 0` ```Ez` %    ` ` ` ` ` ` ` ` ` ` ` ` ` ``F` %    H `6  `  ` ` %    `J ` ` %    ` ` ` E ` ` F`!  %    `!  %    `!  %  !  `!  %  "  `" %    `# %    ` %  #   Z  ) < ?SNMP destination : `[   Z   2  Z  3 2  Z  e d ?SMTP: , from: , to: ?SMTP destination : = [-> `  ` -C_R:usb:///_MSG_X ` .MP3.4  `@ ` /`?Start/restart for streaming...`? `S ` 4 ` /``) ` ``8  `[  `BP`  '`B-UDP:0.0.0.0:X `B .`B-TCP:0.0.0.0:X `B .F`CQ`  '`C-UDP:0.0.0.0:X `C .`C-TCP:0.0.0.0:X `C .F` ` `#  ` $ `  , `  ` #  `H ` M Z  ` `` ` ```[ X `  Z   `  ` `  M  ` `  ` `  `-STP:856.0 /` ` ` %  `  ` `  %   `  ` `  ` `  ?d X `  : type X ` `  : \ %lA ` `   : X ` `  ``  `J t?Studio Encoder, BRTP selected, listening on Outgoing Stream BRTP port.-UDP:0.0.0.0:X `   . EB?BRTP service will listen on the same incoming stream port.FF`  ` ` E ` `   ` 1 'red'> wrong settings: all ports are zero Z  #  ` %  C  ` M  ?in : type X `  : \ %lA `  : X ` ` f-UDP:\ %lA ` :X ` .`   ``   ``   `   `   M   / FI `  `  ;` `   ``   `-UDP:0.0.0.0:X ` .FH `J `   ` H `J `  ` `  0H `J  `    `$ L H `J  `   !`$ `   `   L FH I `J  `J  `    `$ L H I `J  `J  `    `$ `   `   L FH `J  `   `$ L H `J  `   `$ L I `$  `$  `6 G AUD:11,X I  6 `  ,X I ` 6   ,X ` 0F`6 3 AUD:2,7,X I ` 6 `7  ,X ` 0FF`$ v`6 H AUD:11,X I  6 `  ,X I ` 6   ,X ` 0F`6  AUD:1,7,0,X ` 0F`6?Unsupported full-duplex audio format, default to uLaw 8Khz mono` ` B`[  D   D   `\  BF AUD:11,X I  6 `  ,X I ` 6   ,X ` `V `_ `* `  ` # " ???????? ???????? ????????`` w0` ```& `]   E `]   F`W`X 43H `? `S  U  -`? `T `  sE)`>  3E1 X   /FFF`BH `B ` `  `'` j4  +3   /?close COM1-TCP/handle 54  +-TCN::X `B .?open COM1-TCPF9   %`B`A 2  `A &`B"4  H 3  9   &F`CH `C ` `  `'` j4  +3   /?close COM2-TCP/handle 64  +-TCN::X `C .?open COM2-TCPF9   ,&`C`A 2  `A &`C"4  H 3  9   &F ` I ; `  ; `   1E  0`0  `. 2  ! IAL X `. 0  `/ 2  " IAR X `/ 0  `0 2  # OAL X `0 0  `1 2  $ OAR X `1 0   `2 2  0  `3 2  0  `4 2  0  `5 2  0   `M 2  % LOF X `M 0   `L 2  & DUF X `L 0   `K 2  ' DRF X `K 0  `N 2  ( LAT X `N `% OUT stream ONE OUT stream OFF`& IN stream ONE IN stream OFF`1    ``$``  `  `  H ` `  `'` `' `  1 ?  `FE5H ` `  `'` `' `  1 ?  ` FF`$  %H ` `  ` ` `   0F` 2  ` `8 s ]  ` 5  H `$  ` `    `   M  `   `0 `* `  H `$  %     +`9 H %     `8`9 L FZ    ! OUT Con to Net Delay: X `*`'   ms Z   ` ` `) ` ) Z  `  ``$ 1 X `  FZ    ? IN Con ON from RTP Payload: X `8  Z   ` ` `) ` ) Z  `  `H `%  `&  `   h#` 1 !   ``$ 1 X `  F`Z    BRX #F 'lime'>
: X `  INput AUD L:X `. 
     Remote DIs:INput AUD R:X `/  
 Local DIs:   OUTput AUD L: X `0 
 Local Relays:  OUTput AUD R:X `1 
F0  `+ 2  `8  -`+`V `  `* Y 'lime'> IN Con ON,  `* `  `(` ?Restart for no Keep-alivesF`& `>`?  T4E`? 1 X `  FE`& H `%  `   #`  `* `  'red'> NB! Connection is broken or closed!`: `1 X   `$ *?prepare possible autoplay`8 FFF `  <` `( X `( H `( `@ ` I `$  `$  `I `! `  `! `  `! `  `! `  `! `  `! `  `  `T`? `E `? `FF`    n  RST  ` `H ` 2*\ %lA `H `   P1.3.0 E1.5.1.1.1.2.1`  )F X ` :X `8 : X `% :X `& :X ` : X `. :X `/ :X `0 : X `1 :X `2 :X `3 : X `4 :X `5 :: : ::X ` :+'"`8 `9`6 ?new RTP payload type X `8 `8  ` ` !`8 ` ` !`8  ` ,` !`8  ` ,` !`8 `6 !`8 `` ` !`8 a ` ` !`8 b` ` !`8 c` ` !`8 d `  ` !`8 e`  ` !`8 f`  ` !`8 g` 0` !`8 h` ` !`8 i` ` !`8 j`  ` !`8 k` ,` !`8 l` 0` !`8 m `  ` !`8 n`  ` !`8 o`  ` !`8 p`  ` !?wrong or generic RTP payload type X `8 `8 !`( =`! `   , . > P b h n t z`) `  `( !E!` `( !E!!`& `( !E!`&  `( !E!`  `( !E! e ! e ! e ! !! !!?wrong mode setting for Relay X ` !) Z  `  [`% E h#?start talk with active input1/2 X `  immediate sendF`, `  EiH `%  `  `,`# F #?stop talk with passive input X `  after X `#  msF`- `  F!I `.`" `/`" d`% N h#?start talk with levels X `. /X `/  >= X `"  immediateF`, `  ElH `%  `  `,`# I #?stop talk with levels X `. /X `/  after X `#  msF`- `  F!I `.`" `/`" H `=`< `=`<`# `= `  `#`  `=`#=`! ` `( `! ` `  `=`# `( E`! ` `( F`< `  EH `<`= `<`=`# `< `  `#`  `<`#=`! ` `( `! ` `  `<`# `( E`! ` `( F`= `  F!I `0`O `1`O pH `R`Q `R`Q`P `R `  `P`  `R`P`! `  `( E`! `  `( F`Q `  EnH `Q`R `Q`R`P `Q `  `P`  `Q`P`! `  `( E`! `  `( F`R `  F!4  /?Opening audio : ?Actual dmode : X `$ -.`$-1 X ` 1 X ` 1 X ` F1 X   1 X   `: `; `O  ``J h#1 *  `F!`% B` ` `  ` `  ` `  ` `  ` `  `% `B!B` ` `  ` `  `B`% !` H \ %lA ` `   ` `  ` ` ` `  !F`` H ` `   ` `   z?Added BRTP channel: [X ` ] -> :X ` ` `  M  ` `  `` ` `   h#1 !   `!F`?BRTP table is full, no possibility to add: :X ` !` H ` ` `  ` ` 0u {?Deleted by timer BRTP channel: [X ` ] -> \ %lA ` `  :X ` `  ` `  ` `  ` `  h#!F`!0 `A 2  `AX`B*1  `A  `FE1  `A  `B`B4  3   1  `AF!0 `A 2  `AX`C*1  `A  `GE1  `A  `C`C4  3   1  `AF! ]  `F 5  0 1  `A! ]  `G 5  0 1  `A!0 `A 2  1  `A!0 `A 2  1  `A!` `D Q` `D T COM:`E %  `D  `E  38400,`E  19200,`E  9600,`E  4800,`E  2400,`E  1200,`E  600,`E  300,`E  115200,`E   57600,`E   230400,`E   76800,`E %  `D  H `E 0   N,H `E 0 0  E,H `E 0   O,H `E   8,E  7,H `E   2,E  1,`E %  `D  `E  NON:`E  SFW:`E  HDW:`E  485: X ` ?serial> -.`! .?Empty e-mail address FROM. SUBJ: W- ,?Empty e-mail address TO. SUBJ: W--TCP:\ %lA M  :25.4  (?SMTP server () is wrong!-`I  > `I3  `   u*E-?1 HELO STL 0  #  `   *E-?1 MAIL FROM: <> 0  #  `   *E-` ` `` $ `  , ` Z  ` `` E Z  ` ?1 RCPT TO: <> 0  #  `   ~+E-`"+1 DATA 0  #  `   +E-?1 From:  1 Subject:  1 To:  1 Content-Type: text/html 1  1  1  1  . 0  #  `   ,E-?1 QUIT 0  #  `   ,E-4  /`  &?ERROR : incomplete SMTP sending. -!?end of waiting SMTP sending for X `I > `  !-AUD:1,0,0,0.1 X `  +! ,`U  . !4  / -F4  -C_R:usb:///. 4  <`U *?ERROR : can't find playlist file `U !F 'yellow'> Autoplay: 9  !` 4  0 ` 2  `1  `y.4  / `?`? /  `S -!?getting next playlist file4   -C_R:usb:///playlist.m3u.4  "?ERROR : playlist not found.!`S 0  #  >$  _  .MP3 g/ ?Start autoplay: !F/.!4  /4  /  _MSG_X `? .MP3 -!` -1 BRX  \ %lA `   `   F!: `a`W I `W 6  `` E`W H `W G 6  `` F! CST =`0 0 0  1 No keep-alive info81 Established TO :X ` 81 Established FROM :X ` 81 Only Stream FROM :X ` 81H ` `   `]   H ` `   `]   !: `c`c `  6 `b  `c) ALARM `c)) )Z +  7 `Z `b    E') )Z +  H `Z `b    F=`b 2 T2 2 2) ) CONNECTION_LOST* Connection lost for keep alive missing2) ) NO_INCOMING_STREAM* Incoming stream missing2`c ) )_CLEARED E ) ) ) )*?SENDING ALARM: )` `H ` ?*\ %lA `H `  ` P1.3.0 E3.1.1.0 E1.5.1.1.1.2.40``^ !`Y H `W 6  `Y "H `X 6  `Y  `^ `Y  EH `X 6  `Y  `^ `Y  F`Y`X `W`] !:-STP:X `d .0 /`[ !:-STP:X `e .1  /`\ !`: .`: `:1 X `:  `:   `: E `: F`: ?Playing message /!`:` -`; `; 7 `;  `: `:`;1 X `:  F!:`6`f Et` H 7 `   ` H `  ` H 7 `   I `  `  `f `E`f `F` `f 6 `f  F`_ ``f!"_TMR_LJIJ1XDSTSDSTTDSTMDSTIDSTRDSTVOLLPORTRPORTPORTBRTPSBRTPCAD_GNMC_GNINPAFBIT5SRSRTQLQLTYMSDELCONFLOCNFLSMODEKAPRDKADISRMODELEVTHSTOUTDMODETALKBUFFLTM0RELAYRFTMBUFATIMEBTIMELEVLLEVRLEVLOLEVROLDBLLDBRLDBLOLDBROMP3FLMP3MNPLOPLNVOLFDFACTATIMIBTIMIRAMPMSGFLMFLBCOM1PCOM2POFSCOMBRP1RP2SNMPDTMOUTWMODERTPDRRTPDURTPLORTPLAOUTTHOTOUTATOMIBTOMIPLLSTMDLAYBADPFBUFHIAMASKOMASKATMPAPARASREADSSAVEALARMALSNDCALCDALRMSTATEALSSETVAL1VAL2BPSVER$_MS$SET$SCKS$RHOST$MSG$STS$AUDIO$DIR$SND$RCV$ND$RL$RL_O$FILE$BCIP$IR$IR_O$IL$IL_O$COM$_MB$RH1$RH2$SNMP$MSERV$MFROM$MTO$MSUBJ$MBODY$TMP$_S01$_S02$_S03$_S04$_S05$_S06$_S07$_S08$_S09$_S10$_S40$ALGEN$SEV$HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: application/x-javascript //&L(0,"*",1); /* STL standard visual functions * Angelo Dureghello, Barix AG */ function clear(o) { o.getElementById('table1').style.display = "none"; o.getElementById('table2').style.display = "none"; o.getElementById('table3a').style.display = "none"; o.getElementById('table3b').style.display = "none"; o.getElementById('table3c').style.display = "none"; o.getElementById('table3d').style.display = "none"; o.getElementById('table3e').style.display = "none"; o.getElementById('table3f').style.display = "none"; o.getElementById('table3g').style.display = "none"; o.getElementById('table4').style.display = "none"; o.getElementById('table4a').style.display = "none"; o.getElementById('table4b').style.display = "none"; o.getElementById('table4c').style.display = "none"; o.getElementById('table4d').style.display = "none"; o.getElementById('table4e').style.display = "none"; o.getElementById('table4f').style.display = "none"; o.getElementById('table5').style.display = "none"; o.getElementById('table6').style.display = "none"; o.getElementById('table7').style.display = "none"; } function basicSettings() { var st=&LSetup(1,"%u",536,B);; if (st==0) { document.getElementById('bsrs').innerHTML="---"; } if (st==1) { document.getElementById('bsos').innerHTML="---"; } } function loadLocations() { var htype=&LState(1,"%d",28);&0xff; var stydd=document.getElementById('stype'); var n=0; sel=&LSetup(1,"%lu",536,B,);; switch (htype) { case 1: case 9: case 14: case 20: stydd.options[n++]=new Option("Transmitter Decoder",1,true,sel==1); break; case 8: stydd.options[n++]=new Option("Studio Encoder",0,true,sel==0); break; default: stydd.options[n++]=new Option("Studio Encoder",0,true,sel==0); stydd.options[n++]=new Option("Transmitter Decoder",1,false,sel==1); stydd.options[n++]=new Option("Studio Encoder/Decoder",2,false,sel==2); stydd.options[n++]=new Option("Transmitter Encoder/Decoder",3,false,sel==3); break; } } function def_hideshow(frame){ if (frame) object=parent.frames[frame].document; else object=document; clear(object); toggleDisplay('1'); aftChange(0); } function turnBackBold(speclink){ var anchors=document.links for (i=0;i=6) { o.getElementById('table4c').style.display="block"; } else { o.getElementById('table4c').style.display="none"; } } function setInputSource() { var tsrc=document.getElementById('isrc'); var htype=&LState(1,"%u",28); n=0; tsrc.options.length=0; sel=&LSetup(1,"%lu",510,B);; tsrc.options[n++]=new Option("Analog Line",0,false,sel==0); tsrc.options[n++]=new Option("Analog Line, external ADC",7,false,sel==7); if (htype==21) tsrc.options[n++]=new Option("AES/EBU",9,false,sel==9); } // dynamic sample rate based on Audio Format, i is the AF value function loadSampleRates(o) { var st=&LSetup(1,"%u",536,B);; var i=o.getElementById('aft').value; var srtdd=o.getElementById('srt'); srtdd.options.length=0; sel=&LSetup(1,"%lu",512,B);; n=0; if (i<6) { // Analog if (i <4) { srtdd.options[n++]=new Option("8 kHz",0,false,sel==0); srtdd.options[n++]=new Option("24 kHz",4,false,sel==4); // all analog mono } //if (i <4) { srtdd.options[n++]=new Option("12 kHz",1,false,sel==1); } // DISABLE if (i==4) { if (st>=2) { srtdd.options[n++]=new Option("32 kHz",5,false,sel==5); } // 32 Khz PCM only HD, stereo big endian srtdd.options[n++]=new Option("44.1 kHz",6,false,sel==6); // 44.1 Khz stereo big endian only /*if (st<2) {*/ srtdd.options[n++]=new Option("48 kHz",7,false,sel==7); // 48 Khz PCM only HD, stereo big endian } } else { // MPEG srtdd.options[n++]=new Option("16 kHz (MPEG2 Layer III)",2,false,sel==2); srtdd.options[n++]=new Option("22.05 kHz (MPEG2 Layer III)",3,false,sel==3); srtdd.options[n++]=new Option("24 kHz (MPEG2 Layer III)",4,false,sel==4); srtdd.options[n++]=new Option("32 kHz (MP3)",5,false,sel==5); srtdd.options[n++]=new Option("44.1 kHz (MP3)",6,false,sel==6); srtdd.options[n++]=new Option("48 kHz (MP3)",7,false,sel==7); } } function toggleDisplay(e) { /* st values, SE 0, TD 1, SED 2, TED 3 */ var st=&LSetup(1,"%u",536,B);; var o=parent.frames['config'].document; clear(o); switch(e) { case '1': o.getElementById('table1').style.display="block"; if (st!=1){ o.getElementById('table3a').style.display="block"; o.getElementById('table3b').style.display="block"; } if (st!=0){ o.getElementById('table3f').style.display="block"; } break; case '2': o.getElementById('table2').style.display="block"; break; case '3': o.getElementById('table3a').style.display="block"; if (st!=1) { o.getElementById('table3b').style.display="block"; o.getElementById('table3c').style.display="block"; } if (st!=0) { o.getElementById('table3d').style.display="block"; } o.getElementById('table3e').style.display="block"; if (st!=0) { o.getElementById('table3f').style.display="block"; o.getElementById('table3g').style.display="block"; } break; case '4': o.getElementById('table4').style.display="block"; // title, always if (st!=1) { o.getElementById('table4a').style.display="block"; o.getElementById('table4b').style.display="block"; if (st==0) showHideQlty(o); o.getElementById('table4d').style.display="block"; } o.getElementById('table4e').style.display="block"; // volume, always if (st!=0) o.getElementById('table4f').style.display="block"; // fading time break; case '5': o.getElementById('table5').style.display="block"; break; case '6': o.getElementById('table6').style.display="block"; break; case '7': o.getElementById('table7').style.display="block"; break; } } function aftChange(show) { var o=parent.frames['config'].document; if(show) showHideQlty(o); loadSampleRates(o); } // dynamic Audio Format options, inserting as per site type (st) function selAudioFormat(){ var st=&LSetup(1,"%u",536,B);; var aftdd=document.getElementById("aft"); aftdd.options.length=0; sel=&LSetup(1,"%u",511,B);; n=0; if (st!=1) { // analog aftdd.options[n++]=new Option("u-Law 8bit mono", 0, false, sel==0); aftdd.options[n++]=new Option("A-Law 8bit mono ", 1, false, sel==1); aftdd.options[n++]=new Option("PCM 16bit mono MSB", 2, false, sel==2); //aftdd.options[3]=new Option("PCM 16bit mono little endian", 3, false, sel==3); aftdd.options[n++]=new Option("PCM 16bit stereo MSB", 4, false, sel==4); //aftdd.options[5]=new Option("PCM 16bit stereo little endian", 5, false, sel==5); } if (st==0) { aftdd.options[n++]=new Option("MPEG mono", 6, false, sel==6); aftdd.options[n++]=new Option("MPEG stereo", 7, false, sel==7); } } ' Reflector Demo Application ' ' v.1.1 PK 20100407 Released for NAB ' v.1.2 AD 20100429 Added triple server auto selection at startup ' v.1.3 JP 20100602 Added routine 40000 gncfg=1 ' v.1.4 AD 20100628 Fixed buffr reflector command to "buffer" ' v.1.5 AD 20100702 Fixed decoder stereo issue (BUG 096.01) ' v.1.6 AD 20100723 Added status informations for html. dim ver$(32) ver$ = "1.6 (23 Jul 2010)" #define CFG_PORT 12345 #define AUDIO_PORT 40000 ' local port for sending/receiving audio #define RTP_SEND_TIME 4000 ' send RTP every 4s #define CFG_SEND_TIME 30000 ' send CFG request every 30 seconds #define CFG_TIMEOUT 300000 ' no answer from the config server within 10 retries causes the audio to stop #define BRTP_REQ_LEN 12 ' variables dim l,i,q,z ' NON TIMER general variables dim cfgip(2) ' 3 addresses available for the configuration server dim actip ' active used ip dim cfgid ' ID of the configuration request ' configuration answer - UDP packet dim _Mudp$(1500) dim udpl ' length of the last UDP packet received (lastlen) - see the UDP receiver dim cfgts ' timestamp of the last configuration; 0 = no config yet dim dst(1,1) ' streaming table for the LINK command dim gncfg ' get new configuration; if set to 1 there is a newer configuration on the server ' and it should be requested dim rstrt ' restart audio; if set to 1 the audio engine should restart with a new configuration in the ' cfg parameters dim cfg$ ' for the configuration parser: contains a new configuration dim brtp$(BRTP_REQ_LEN) ' BRTP request dim mac$(13) ' contains the MAC address without separators dim cfgto ' configuration timeout is running dim stop ' flag: no answer from the configuration server -> stop audio dim stp$,tmp$ dim state ' configuration parameters from the server #define MODE_DECODER 1 #define MODE_ENCODER 0 #define INPUT_LINE 1 #define INPUT_MIC 2 #define INPUT_OPTICAL 4 #define INPUT_COAX 5 dim mode ' direction of the audio communication: 0=encoder, 1=decoder dim stere ' stere/mono dim input ' input source dim vol ' volume in dB dim gain ' input gain in dB dim buffr ' how much to buffer on the decoder - in milliseconds dim qual ' MPEG encoder quality dim rport ' replicator's port number: encoder sending audio to rport, decoder sending BRTP requests to rport+1 dim rip$(30) ' replicator's IP address - for sending and receiving audio dim ssrc ' "reflector ID" - retrieved from the configuration server and send as SSRC in the encoded stream to identify the source device ' functions ' --------- ' dim gethx ' this doesn't work because BCL is broken ' workarounding with a gosub dim ghxp1$ dim gethx ' handles ' ------- ' 1 - configuration UDP socket ' 2 - audio UDP socket ' 7 - audio #define CFG_HANDLE 1 #define STREAM_HANDLE 2 #define AUDIO_HANDLE 7 #define ST_STARTING 0 #define ST_RESOLVING 1 #define ST_LOOKUP 2 #define ST_DETECTED 3 #define ST_CONF_UPDATED 4 #define ST_NO_REFLE 5 #define ST_DNS_NOT_SET 6 #define ST_LINK_ON 7 ' timers ' ------ ' 1 - setup configuration UDP request sent every minute ' 2 - BRTP request sent every 5s ' 3 - timeout timer if no config is received on timer3 gosub 4000 ' handle no response from the config server syslog "Reflector client v"+ver$ ' set up BRTP request mac$=sprintf$("%H",0) brtp$="BRX " ' emulation of gethx(mid$(mac$,1,4)) call with gosub ghxp1$=mid$(mac$,1,4) : gosub 5000 midset brtp$,5,-2,gethx ghxp1$=mid$(mac$,5,4) : gosub 5000 midset brtp$,7,-2,gethx ghxp1$=mid$(mac$,9,4) : gosub 5000 midset brtp$,9,-2,gethx ' Read server configuration open "STP:1200" as 0 if mediatype(0) then read 0, stp$ : close 0 9 for i=0 to 2 q=0 : tmp$=mid$(stp$,i*32+1,32) 10 if q<3 then syslog "Resolving "+tmp$ state=ST_RESOLVING cfgip(i)=resolve(tmp$) if cfgip(i)=0 then syslog "Cannot resolve server address "+str$(i+1)+" : "+tmp$ state=ST_DNS_NOT_SET delay 3000 : q=q+1 : goto 10 endif endif next i ' server check for i=0 to 2 if cfgip(i)<>0 then goto 12 next i state=ST_DNS_NOT_SET syslog "no server IP has been resolved" syslog "check URL's, DNS, Gateway setting, retrying in 10 seconds ..." : delay 10000 : goto 9 else syslog "can't open setup, exiting." : end endif 12 ' open configuration handle open "UDP:0.0.0.0:"+str$(CFG_PORT) as CFG_HANDLE ' server detection gosub 6000 ' link replies now on UDP gosub 20000 ' setup configuration request every minute on timer1 gosub 11000 gosub 11000 timer 1,CFG_SEND_TIME syslog "Waiting for initial configuration" gncfg=1 ' force configuration reload at startup gosub 11000 15 if rstrt=0 then goto 15 syslog "Initial configuration received" 20 dst(0,1)=rport dst(0,0)=resolve(rip$) rstrt=0 stop=0 ' main loop if mode=MODE_DECODER then syslog "Initialising audio: MP3 decoder, buffering "+str$(buffr)+" milliseconds" ' syslog "opening audio : " + "AUD:1,1,0,"+str$(buffr) open "AUD:1,1,0,"+str$(buffr) as AUDIO_HANDLE else ' disable CRC, disable MS stere, disable bit reservoir, emphasis none, copy, no copyright syslog "Initialising audio: MP3 encoder" ' buffer is ignored, RTP payload length is "auto" and SSRC from the config server open "AUD:2,1,"+str$(qual+&H8700+(1-stere)*2048)+",0,0,"+str$(ssrc) as AUDIO_HANDLE endif ' set audio parameters syslog "Configuring audio" write 7,str$(gain),-2 ' AD gain ' FIXME - convert dB into steps 0-15 write 7,str$(input),-3 ' input source 'write 7,str$(stere),-4 ' input mode stere/mono, removed, see BUG 096.01 'write 7,str$(1-stere),-5 ' output mode stere/mono, removed, see BUG 096.01 write 7,"1",-11 ' dB volume write 7,str$(vol),-12 open "UDP:0.0.0.0:"+str$(AUDIO_PORT) as STREAM_HANDLE if mode=MODE_DECODER then on timer2 gosub 30000 timer 2,RTP_SEND_TIME ' send the BRTP request 3x gosub 30000 gosub 30000 gosub 30000 endif state=ST_LINK_ON syslog "Starting audio transfer" link STREAM_HANDLE,AUDIO_HANDLE,dst 30 if stop<>0 then syslog "Configuration server timed out, going to idle" : goto 31 if rstrt<>0 then syslog "New configuration received, restarting" : goto 31 goto 30 31 syslog "Closing audio" ' Shutdown '--------- ' FIXME what's the proper sequence ? timer 2,0 ' disable BRTP requests close STREAM_HANDLE ' stop streaming close AUDIO_HANDLE if stop then goto 15 goto 20 ' configuration request handling '------------------------------- 11000 ' send config request local cfgrq$ if cfgto=0 then timer 3,CFG_TIMEOUT : cfgto=1 ': syslog "DEBUG: timeout start" if gncfg=1 then syslog "Sending configuration request" cfgrq$="id="+str$(cfgid)+"&mac="+mac$+"&get_config=fw_type=v.1,cfg_ver=4,set_ver=0" write CFG_HANDLE,cfgrq$,len(cfgrq$),sprintf$("%lA",actip),CFG_PORT else syslog "Sending ping to the configuration server" cfgrq$="id="+str$(cfgid)+"&mac="+mac$+"&ping" write CFG_HANDLE,cfgrq$,len(cfgrq$),sprintf$("%lA",actip),CFG_PORT endif cfgid=cfgid+1 return 12000 ' parse UDP answer ' request in _Mudp$; length in udpl (negative) local cmd$,keyw$,pos,newts ' cmd$ - command (they are spearated with "&") ' keyw$ - keyword within the command (before "=") ' pos - position within the string, for string search ' newts - new timestamp timer 3,0 ' disable config timeout timer cfgto=0 syslog "Received server response, parsing" midset _Mudp$,-udpl+1,1,0 ' terminate the UDP string 'syslog "DEBUG: "+_Mudp$ 12001 ' split the udp answer into commands separated with "&" pos=instr(1,_Mudp$,"&") if pos=0 then cmd$=_Mudp$ ' extract command _Mudp$="" ' empty _Mudp$ else cmd$=mid$(_Mudp$,1,pos-1) ' extract command _Mudp$=mid$(_Mudp$,pos+1) ' cut off the first command endif ' extract keyword from the command "cmd$" pos=instr(1,cmd$,"=") if pos=0 then keyw$=cmd$ ' extract keyword else keyw$=mid$(cmd$,1,pos-1) ' extract keyword endif if keyw$="ping" then newts=val(mid$(cmd$,pos+1+len("time_stamp="))) if newts<>cfgts then ' new configuration available; get it syslog "New configuration available" gncfg=1 cfgts=newts gosub 11000 endif goto 12002 endif if keyw$="status" then cfg$=mid$(cmd$,pos+1) if cfg$="no_config" then syslog "Device not configured" goto 12002 endif if keyw$="config" then cfg$=mid$(cmd$,pos+1) gosub 12100 ' parse configuration gncfg=0 rstrt=1 goto 12002 endif 12002 if len(_Mudp$)>0 then goto 12001 return 12100 ' parse configuration ' request in cfg$ local pos2,field$,keyw2$,val$,x ' position within the parsed string; configuration field; configuration keyword; value; temporary parameter syslog "Received a new configuration: "+cfg$ state=ST_CONF_UPDATED 12101 ' split the config string into fields separated with "," pos2=instr(1,cfg$,",") if pos2=0 then field$=cfg$ ' extract one cfg field cfg$="" ' empty cfg$ else field$=mid$(cfg$,1,pos2-1) ' extract one cfg field cfg$=mid$(cfg$,pos2+1) ' cut off the first field endif ' extract keyword from the config field pos2=instr(1,field$,"=") if pos2=0 then keyw2$=field$ ' extract keyword val$="" else keyw2$=mid$(field$,1,pos2-1) ' extract keyword val$=mid$(field$,pos2+1) endif if keyw2$="input" then if val$="line" then input=INPUT_LINE if val$="mic" then input=INPUT_MIC if val$="optical" then input=INPUT_OPTICAL if val$="coax" then input=INPUT_COAX goto 12102 endif if keyw2$="mode" then if val$="encoder" then mode=MODE_ENCODER else mode=MODE_DECODER goto 12102 endif if keyw2$="out_gain" then vol=val(val$) goto 12102 endif if keyw2$="in_gain" then gain=val(val$) goto 12102 endif if keyw2$="buffer" then buffr=val(val$) goto 12102 endif if keyw2$="audio_port" then rport=val(val$) goto 12102 endif if keyw2$="ref_ip" then rip$=val$ goto 12102 endif if keyw2$="ref_id" then ssrc=val(val$) goto 12102 endif if keyw2$="quality" then x=val(val$) if x=40 then stere=0 : qual=&H20 ' 22.0hkHz, quality 2 if x=64 then stere=0 : qual=&H01 ' 44.1kHz, quality 0 if x=80 then stere=1 : qual=&H31 ' 44.1kHz, quality 3 if x=140 then stere=1 : qual=&H71 ' 44.1kHz, highest quality (7) if x=192 then stere=1 : qual=&H73 ' 48kHz, highest quality (7) buffr=val(val$) goto 12102 endif 12102 if len(cfg$)>0 then goto 12101 return ' UDP receive handler '-------------------- 20000 ' check config handle if mediatype(CFG_HANDLE)=0 then goto 20001 udpl=lastlen(CFG_HANDLE) if udpl>=0 then goto 20001 read CFG_HANDLE,_Mudp$ gosub 12000 ' parse the configuration answer goto 20000 ' something received in the last loop, try again until the UDP FIFO is empty 20001 ' discard all blocks on stream handle if mediatype(STREAM_HANDLE)=0 then goto 20002 udpl=lastlen(STREAM_HANDLE) if udpl<0 then read STREAM_HANDLE,_Mudp$ : goto 20001 20002 return ' BRTP send request - timer handler '---------------------------------- 30000 ' send BRTP request write STREAM_HANDLE,brtp$,BRTP_REQ_LEN,rip$,rport '''syslog "Sending BRTP request" return ' configuration timeout - timer handler '-------------------------------------- 4000 'syslog "DEBUG: server timed out" stop=1 timer 3,0 ' disable timer cfgto=0 gncfg=1 ' force to send request to get configuration return 5000 ' gethx: converts ascii hex into a 16-bit integer 'local ghxp1$,tmp1,tmp2 local tmp1,tmp2 gethx=0 ghxp1$=lcase$(ghxp1$) for tmp1=1 to 4 gethx=gethx*16 tmp2=midget(ghxp1$,tmp1,1) if and(tmp2>=asc("0"),tmp2<=asc("9")) then gethx=gethx+tmp2-asc("0") if and(tmp2>=asc("a"),tmp2<=asc("f")) then gethx=gethx+tmp2-asc("a")+10 next tmp1 return 6000 ' server detection syslog "Reflector server detection ..." tmp$="id="+str$(cfgid)+"&mac="+mac$+"&ping" state=ST_LOOKUP for i=0 to 2 ' try ping command 3 times per server if cfgip(i) then for z=0 to 3 write CFG_HANDLE,tmp$,len(tmp$),sprintf$("%lA",cfgip(i)), CFG_PORT for q=0 to 10 l=lastlen(CFG_HANDLE) if l<0 then read CFG_HANDLE, _Mudp$ if instr(1,_Mudp$,"ping") then syslog "Using server "+str$(i)+" : "+sprintf$("%lA",cfgip(i)) actip=cfgip(i) state=ST_DETECTED return endif endif delay 100 next q next z syslog "Server "+sprintf$("%lA",cfgip(i))+" not available or device not registered in db" endif next i state=ST_NO_REFLE syslog "No Reflector service available, retrying in 10 seconds ..." : delay 10000 : goto 6000 return TB  gm4o8q<s@uD{PT48<LPmqu y }           XT T ` u%u* / 6=BHOV 1.6 (23 Jul 2010)=  ?Reflector client v \ %H   BRX  Z    ! D   ` Z    ! D   ` Z    ! D   `-STP:1200.4  L0 /` `  Z  `   `?Resolving ` ` ` M  ` ` M?Cannot resolve server address X `  : ` + ` `gFF`` ` ` `` ?no server IP has been resolved?check URL's, DNS, Gateway setting, retrying in 10 seconds ...+'EE#?can't open setup, exiting."F-UDP:0.0.0.0:X 90 .  =  =  > 0u?Waiting for initial configuration`  ` ?Initial configuration received`   ``   M  ` ` ` c?Initialising audio: MP3 decoder, buffering X `  milliseconds-AUD:1,1,0,X ` .E]?Initialising audio: MP3 encoder-AUD:2,1,X ` `  ,0,0,X ` .F?Configuring audio1 X ` 1 X ` 1 1  1 X `  -UDP:0.0.0.0:X @ .` &=  >       F` ?Starting audio transferO  ` `7?Configuration server timed out, going to idle~` 0?New configuration received, restarting~?Closing audio> //`N:` > ` ` ?Sending configuration request id=X ` &mac=&get_config=fw_type=v.1,cfg_ver=4,set_ver=01 # \ %lA ` 90En?Sending ping to the configuration server id=X ` &mac=&ping1 # \ %lA ` 90F` `!: > ` ?Received server response, parsingD `  ` $   & `   E" Z   `  Z  ` F` $  = `   E Z  ` F pingg` ) Z `# time_stamp= `` 3?New configuration available` ` ` FF statusB Z `  no_config?Device not configuredF config& Z `  ` ` F#  /!: ?Received a new configuration: ` ` $   , `   E" Z   `  Z  ` F` $  = `   E" Z  `  Z ` F inputV line`  mic`  optical`  coax` g F mode% encoder ` E` g F out_gain` )  g F in_gain` )  g F buffer` )  g F audio_port` )  g F ref_ip g F ref_id` )  g F quality{` )  ` ( ` `  ` @ ` ` ` P ` ` 1`  ` ` q`  ` ` s` )  g F#  !4   ` 2  `  0   4   ` 2  ` 0  !1    `!` > ` ` !: `  ^  ` ` `` %  `  H ` ' 0 ` ' 9 ` ``' 0 H ` ' a ` ' f ` ``' a  `!?Reflector server detection ... id=X ` &mac=&ping` ` ` ` ` 1  #  \ %lA ` ` 90`  ` 2  `^0 $   ping C?Using server X `  : \ %lA ` ` ` ` ` ` !FF+d``?Server \ %lA ` `  not available or device not registered in dbF`` ?No Reflector service available, retrying in 10 seconds ...+' !_TMR_LIQZCFGIPACTIPCFGIDUDPLCFGTSDSTGNCFGRSTRTCFGTOSTOPSTATEMODESTEREINPUTVOLGAINBUFFRQUALRPORTSSRCGETHXPOSNEWTSPOS2XTMP1TMP2VER$_MUDP$CFG$BRTP$MAC$STP$TMP$RIP$GHXP1$CFGRQ$CMD$KEYW$FIELD$KEYW2$VAL$HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: text/html
&LSetup(3,"%s",130,D,0,"");

NETWORK SETTINGS
Use SonicIP Yes No
IP Address . . .
Netmask . . .
Gateway IP Address . . .
Primary DNS . . .
Alternative DNS . . .
Syslog Address . . .
DHCP Host Name
Web Server Port

REFLECTOR CLIENT
Configurator Server 1  
Configurator Server 2  
Configurator Server 3  
&LSetup(3,"%s",130,D,0," "); &LSetup(3,"%s",130,D,!0," ");

SECURITY SETTINGS
Reset Function Enabled Disabled
Factory Defaults Enabled Disabled
Update Function Enabled Disabled
Set Password Old Password
New Password
HTTP/1.0 200 Content-type: text/html &L(0,"*",1);&LBAS(1,"%fs",STS$);HTTP/1.0 200 Content-type: text/html
Site Type:
Stream Mode:
Keep-Alive:

Connection Status:
Incoming Stream Status:
Outgoing Stream Status:

Audio Input:
Audio Format:

Input Audio Level (L):                              
Input Audio Level (R):                              
Output Audio Level (L):                              
Output Audio Level (R):                              

Relay 1:
Relay 2:
Relay 3:
Relay 4:

Remote Inputs:
Local Inputs:
Local Relays:
HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: text/html &L(0,"*",1); &LBAS(1,"%u",state); HTTP/1.0 200 Content-type: text/html

LOCATION
Site Type
 
NOTE: site-specific configuration page will be loaded ONLY after "Apply" button is pressed.
 
 
HTTP/1.0 200 Content-type: text/html
Help

Status screen

Note: see the system status page or the application status page for further details on the actual device configuration.

Site Type
Displays the current configured site type.

Stream Mode
Displays the current configured event to start streaming to the remote destination(s).

Keep-Alive
Displays the current configured keep-alive strategy.

Connection Status
Displays the actual connection state.

Incoming Stream Status
Displays the actual incoming stream status (ON/OFF).

Outgoing Stream Status
Displays the actual outgoing stream status (ON/OFF).

Audio Input
Displays the selected input source.

Audio Format
Displays the incoming audio format, or the local audio format if no valid incoming RTP payload is detected.

Input/Output Audio level
Displays the input and output audio levels in dB, and as visual peak level graphic bar in dB.

Relay 1 to 4
Shows the configured event for local relay switch.

Remote Inputs
Remote input state, lime color means active, gray mean inactive.

Local Inputs
Local input state, lime color means active, gray mean inactive.

Local Relays
Local relay state, lime color means active, gray mean inactive.

Dummy project which is linked by default if no other custom application is selected. HTTP/1.0 200 Content-type: text/html


Basic Settings
Network
Streaming
Audio
I/O and Control
Serial
Security
 
 
HTTP/1.0 200 Content-type: text/html
Reflector


Network
Reflector
Security
 
 
HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: text/html HTTP/1.0 200 Content-type: text/html
Help

Status screen

Note: see the system status page for further details on the actual device configuration.

The Barix Reflector service takes the difficulties out of streaming STL audio over the internet.

See more at www.barix.com
HTTP/1.0 200 Content-type: text/html
Help

Site Type
Select the device working mode.

NOTE: selecting an encoder/decoder (full duplex) site type, audio formats of both peers must match.
For the full-duplex links, MPEG audio formats are not supported. In case of existing MPEG audio settings, device will reboot using default uLaw 8Khz mono audio format. HTTP/1.0 200 Content-type: text/html
Help

Basic Settings
This section helps to setup a fast-startup configuration. It allows the configuration of the first Outgoing Stream destination and of the Incoming Stream socket. See Streaming section help for further information.
Network Settings
This section allows the configuration of the following device settings:
  • IP address
  • Netmask
  • Gateway
  • DNS
  • Syslog message destination server: if unset (default, set to 0.0.0.0) syslog messages are broadcasted
  • DHCP hostname
  • WEB server listening port
Streaming

Outgoing Stream:
This section is visible for the following site types:
  • Studio Encoder
  • Studio Encoder/Decoder
  • Transmitter Encoder/Decoder

Stream destinations
Up to 8 audio destinations can be configured, each one with the following fields: stream method, IP/URL and port.

Example:
Stream Method  URL              Port
Push (RTP)     192.168.2.30     4041
Multicast      239.255.231.187  4042
Pull (BRTP)    0.0.0.0          4043
Streaming Mode
Allows to select the condition to start streaming to the remote destination(s).
NOTE: if Streaming Mode is set to "never" but a destination ip and port is configured, device will start to send out the stream in anyway.

Input Trigger Level
Triggering input audio level if "send on level" mode is selected. Accepted range: 0-32767
[default: 1000]

Input Inactivity Timeout
Streaming starts/stops after this number of milliseconds:
- for "send on input1/input2", if the button is pressed/released (to prevent accident action)
- for "send on level", if input audio signal is more/less than "Input Trigger Level"
[default: 1000 msec]"

Output Trigger Level
Triggering output audio level, when relay setting "ON while OUT audio ON/OFF" is selected . Accepted range: 0-32767
[default: 1000]

Output Inactivity Timeout
Inactivity timeout for audio output. Used from the following features: - for "ON while OUT audio ON/OFF", to prevent fast switching of the relay contact.
[default: 1000 msec]"

Keep-alive Period
Set a period for sending keep-alive to the remote peer.


Incoming Stream:
For the incoming audio stream, following fields can be configured: stream method, IP/URL and port [default: RTP ANY:3030].

Example
Stream Method  URL              Port
Push (RTP)     0.0.0.0          4041
Multicast      239.255.231.187  4042
Pull (BRTP)    192.168.2.31     4043 
RTP delay
The RTP decoder keeps constant decoding latency within one frame accuracy. Set the required delay in milliseconds. To synchronise multiple receivers to the same stream, set all to the same value.
The delay value should be set large enough to cope with network jitter (difference in packets delivery time) and possible packet loss. Increase the value if you are experiencing audio dropout.
[default: 600 ms]

Recommended safe settings:
MP3 low bitrate 600ms
MP3 high bitrate 300ms
PCM 44.1/48kHz 80ms

For more details about the RTP settings please visit the Barix Wiki.

Audio
This section allows to configure:

Input Source
Select the desired hardware input.
Note: on Exstreamer 1000 only, the external ADC input circuit can be selected, to improve encoding performances at PCM 48Khz.

Input Gain
Select the desired input gain.

Output Audio Level
Select the desired output volume, in dB. The maximum volume depends on the hardware type and is typically 0 dB, however, on some devices volume can be up to +12 dB.

Fading Effect
Enable a fading effect of the audio on a new incoming stream or when an USB message needs to be played.

Format
Select the desired audio format.

Sample Rate
Select the desired sample rate.
NOTE: only the available sample rates for the selected audio format will be shown.

Quality
Field is visible for MPEG audio formats only, allows to select the desired MPEG quality. Higher is the quality, more the MPEG compression get decreased, increasing the bandwidth consumption.

I/O and Control
This section allows to configure every contact, with a selectable specific function, and all the device alarm-sending features:

Relay (1 to 8) Mode
Select the relay ON mode.

SNMP Destinations IP(s)
For alarm sending, set the desired list (colon separated) of SNMP destinations.

SMTP Server IP/DNS
For alarm sending, set the desired SMTP server.

Local e-mail (FROM:)
FROM mail address, for SMTP alarm service.

Destination e-mail(s) (TO:)
TO mail address, for SMTP alarm service.

Serial
This section allows to configure communication settings for serial ports 1 and 2.

Baud rate, parity, data bits, stop bits and handshake can be set for each port.

UDP/TCP Control Port for COM1/2
Local UDP/TCP port for serial gateway to COM1/2:
for UDP use a positive value (from 1 to 32768),
for TCP use a negative value (from -1 to -32768),
set to 0 to disable the gateway.

Any chars received on this port from network will be sent to COM1/2.
Any chars received on COM1/2 will be sent to:
- the latest remote UDP/TCP Host:Port that has already initated/established connection from the network
- else to the same UDP port number of current destination remote IP (by current keep-alive info)

TCP Serial Gateway
One device must be the listener (server), the other must try to connect to the listener device (client).

Server side setup: set Keep-alive Period as 0, the device will act as a TCP server, using the configured serial port (example -1000)

Client side setup: set the same TCP port number (-1000) and a keep alive period greater than 0.

UDP Serial Gateway
Set the same serial port (positive value) on both devices.

Set to a value between -32767 and 32768.

[default port is 0 (disabled)].

Security Settings
This section allows to configure the device password and other security settings.

Reset Function
Enable or disable the "Reset" function on the Reset button and on the WEB UI. In order to restart the device press the Reset button once.
Default: "enabled"

Factory Defaults
Enable or disable the "Factory Defaults" function on the Reset button. In order to revert all settings to factory defaults keep the Reset button pressed until the red LED starts blinking (approx. 10 seconds).
Default: "enabled"

Update Function
Enable or disable the WEB Update function of the device. If the Update function is disabled, the only way to update the firmware is to use the serial rescue.
Default: "enabled"

Set Password
This is visible as long as no password is set.
Enter a password (up to 25 characters) and hit the "Apply" button. After the restart you should close the browser window and open a new browser window. You will be asked to supply user name and password. The user name can be omitted but the password has to be supplied in order to see the web configuration.

Old Password / New Password
These fields are visible as long as a password is set.

To allow free access (clearing the password) enter the old password and leave the field "New Password" empty. Enter the old password in the password field above the "Apply" button as well and then hit the "Apply" button.
After the restart you will not be asked for user name and password anymore.

To change the password enter the old password and enter the new password in the field "New Password". Enter the old password in the password field above the "Apply" button as well and then hit the "Apply" button.
After the restart you will be asked for user name and password. The user name can be omitted but the new password has to be supplied in order to see the web configuration.