2016-04-17 Fred Gleason <fredg@paravelsystems.com>

* Added an 'rlm_walltime' RLM in 'rlm/rlm_walltime.c'.
This commit is contained in:
Fred Gleason
2016-04-17 20:09:11 -04:00
parent b22f8d7d54
commit a6e7c05c31
7 changed files with 263 additions and 4 deletions

View File

@@ -15070,3 +15070,5 @@
2016-04-14 Fred Gleason <fredg@paravelsystems.com>
* Removed the libXmu from the list of tested libraries for Qt3 in
'acinclude.m4'.
2016-04-17 Fred Gleason <fredg@paravelsystems.com>
* Added an 'rlm_walltime' RLM in 'rlm/rlm_walltime.c'.

View File

@@ -2,10 +2,7 @@
##
## Top level automake.am for Rivendell
##
## (C) Copyright 2002-2014 Fred Gleason <fredg@paravelsystems.com>
##
## $Id: Makefile.am,v 1.16.4.5 2013/09/12 23:26:09 cvs Exp $
## $Date: 2013/09/12 23:26:09 $
## (C) Copyright 2002-2016 Fred Gleason <fredg@paravelsystems.com>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2 as
@@ -49,6 +46,7 @@ EXTRA_DIST = my.cnf-master\
rlm_spottrap.conf\
rlm_twitter.conf\
rlm_udp.conf\
rlm_walltime.conf\
rlm_xds.conf\
rlm_xmpad.conf

61
conf/rlm_walltime.conf Normal file
View File

@@ -0,0 +1,61 @@
; rlm_walltime.conf
;
; This is the sample configuration file for the 'rlm_walltime' module for
; Rivendell, which can be used to output Now & Next data to one or more
; Walltime clocks.
;
; To enable this module, add it to the 'Loadable Modules' list in
; RDAdmin->ManageHosts->RDAirPlay->ConfigureNow&Next. The 'Argument'
; field should point to the location of this file.
; Section Header
;
; One section per remote UDP port is configured, starting with 'Udp1' and
; working up consecutively
[Walltime1]
; IP Address
;
; The IP address of the remote UDP port, in dotted-quad notation.
IpAddress=127.0.0.1
; UDP Port
;
; The UDP port number of the remote UDP port, in the range 0 - 65,535.
UdpPort=6060
; Format String. The template for the HTML sent to the Walltime web display
; each time RDAirPlay changes play state, including any wildcards as
; placeholders for metadata values.
;
; The list of available wildcards can be found in the 'metadata_wildcards.txt'
; file in the Rivendell documentation directory.
;
FormatString=<body bgcolor="#000000"><table cellspacing="2" cellpadding="2" border="0"><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr><tr><td><font size="6" color="white">%t</font>></td></tr><tr><td>&nbsp;</td></tr><tr><td><font size="5" color="red">%a</font><td></tr></table></body>
; Clock Address.
;
; The IP address of the Walltime clock unit.
;
ClockAddress=127.0.0.1
; Log Selection
;
; Set the status for each log to 'Yes', 'No' or 'Onair' to indicate whether
; state changes on that log should be output on this udp port. If set
; to 'Onair', then output will be generated only if RDAirPlays OnAir flag
; is active.
;
MasterLog=Yes
Aux1Log=Yes
Aux2Log=Yes
; Additional UDP destinations can be configured by adding new sections...
;[Walltime2]
;FormatString=Artist: %a
;IpAddress=192.168.10.22
;UdpPort=6060
;MasterLog=Yes
;Aux1Log=No
;Aux2Log=Onair

View File

@@ -336,6 +336,7 @@ rm -rf $RPM_BUILD_ROOT
%doc docs/tables/users.txt
%doc docs/tables/version.txt
%doc docs/asound.conf-sample
%doc conf/rlm_walltime.conf
%doc conf/rlm_serial.conf
%doc conf/rlm_udp.conf
%doc conf/rlm_twitter.conf

View File

@@ -32,6 +32,7 @@ OBJS = rlm_ando.rlm\
rlm_test.rlm\
rlm_twitter.rlm\
rlm_udp.rlm \
rlm_walltime.rlm\
rlm_xmpad.rlm
%.rlm: %.c

View File

@@ -38,6 +38,7 @@ RLM_MODULES=rlm_ando.rlm\
rlm_test.rlm\
rlm_twitter.rlm\
rlm_udp.rlm\
rlm_walltime.rlm\
rlm_xds.rlm\
rlm_xmpad.rlm
@@ -75,6 +76,7 @@ EXTRA_DIST = Makefile-example\
rlm_test.c\
rlm_twitter.c\
rlm_udp.c\
rlm_walltime.c\
rlm_xds.c\
rlm_xmpad.c

194
rlm/rlm_walltime.c Normal file
View File

@@ -0,0 +1,194 @@
/* rlm_walltime.c
*
* (C) Copyright 2016 Fred Gleason <fredg@paravelsystems.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* This is a Rivendell Loadable Module. It sends Now&Next PAD data to
* to one or more Walltime clock displays as specified in the configuration
* file pointed to by the plugin argument.
*
* To compile this module, just do:
*
* gcc -shared -o rlm_walltime.rlm rlm_walltime.c
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <rlm/rlm.h>
int rlm_walltime_devs;
char *rlm_walltime_addresses;
uint16_t *rlm_walltime_ports;
char *rlm_walltime_formats;
char *rlm_walltime_clock_addresses;
int *rlm_walltime_masters;
int *rlm_walltime_aux1s;
int *rlm_walltime_aux2s;
int rlm_walltime_GetLogStatus(void *ptr,const char *arg,const char *section,
const char *logname)
{
const char *tag=RLMGetStringValue(ptr,arg,section,logname,"");
if(strcasecmp(tag,"yes")==0) {
return 1;
}
if(strcasecmp(tag,"on")==0) {
return 1;
}
if(strcasecmp(tag,"true")==0) {
return 1;
}
if(strcasecmp(tag,"no")==0) {
return 0;
}
if(strcasecmp(tag,"off")==0) {
return 0;
}
if(strcasecmp(tag,"false")==0) {
return 0;
}
if(strcasecmp(tag,"onair")==0) {
return 2;
}
return 0;
}
void rlm_walltime_RLMStart(void *ptr,const char *arg)
{
char address[17];
char section[256];
char errtext[256];
int i=1;
rlm_walltime_devs=0;
rlm_walltime_addresses=NULL;
rlm_walltime_ports=NULL;
rlm_walltime_formats=NULL;
rlm_walltime_clock_addresses=NULL;
rlm_walltime_masters=NULL;
rlm_walltime_aux1s=NULL;
rlm_walltime_aux2s=NULL;
sprintf(section,"Walltime%d",i++);
strncpy(address,RLMGetStringValue(ptr,arg,section,"IpAddress",""),15);
if(strlen(address)==0) {
RLMLog(ptr,LOG_WARNING,"rlm_walltime: no walltime destinations specified");
return;
}
while(strlen(address)>0) {
rlm_walltime_addresses=
realloc(rlm_walltime_addresses,(rlm_walltime_devs+1)*(rlm_walltime_devs+1)*16);
strcpy(rlm_walltime_addresses+16*rlm_walltime_devs,address);
rlm_walltime_ports=realloc(rlm_walltime_ports,(rlm_walltime_devs+1)*sizeof(uint16_t));
rlm_walltime_ports[rlm_walltime_devs]=
RLMGetIntegerValue(ptr,arg,section,"UdpPort",0);
rlm_walltime_formats=realloc(rlm_walltime_formats,(rlm_walltime_devs+1)*8192);
strncpy(rlm_walltime_formats+8192*rlm_walltime_devs,
RLMGetStringValue(ptr,arg,section,"FormatString",""),8192);
rlm_walltime_clock_addresses=
realloc(rlm_walltime_clock_addresses,(rlm_walltime_devs+1)*(rlm_walltime_devs+1)*16);
strncpy(rlm_walltime_clock_addresses+16*rlm_walltime_devs,
RLMGetStringValue(ptr,arg,section,"ClockAddress",""),15);
rlm_walltime_masters=realloc(rlm_walltime_masters,
(rlm_walltime_devs+1)*sizeof(int));
rlm_walltime_masters[rlm_walltime_devs]=
rlm_walltime_GetLogStatus(ptr,arg,section,"MasterLog");
rlm_walltime_aux1s=realloc(rlm_walltime_aux1s,
(rlm_walltime_devs+1)*sizeof(int));
rlm_walltime_aux1s[rlm_walltime_devs]=
rlm_walltime_GetLogStatus(ptr,arg,section,"Aux1Log");
rlm_walltime_aux2s=realloc(rlm_walltime_aux2s,
(rlm_walltime_devs+1)*sizeof(int));
rlm_walltime_aux2s[rlm_walltime_devs]=
rlm_walltime_GetLogStatus(ptr,arg,section,"Aux2Log");
sprintf(errtext,"rlm_walltime: configured destination \"%s:%d\"",address,
rlm_walltime_ports[rlm_walltime_devs]);
rlm_walltime_devs++;
RLMLog(ptr,LOG_INFO,errtext);
sprintf(section,"Walltime%d",i++);
strncpy(address,RLMGetStringValue(ptr,arg,section,"IpAddress",""),15);
}
}
void rlm_walltime_RLMFree(void *ptr)
{
free(rlm_walltime_addresses);
free(rlm_walltime_ports);
free(rlm_walltime_formats);
free(rlm_walltime_clock_addresses);
free(rlm_walltime_masters);
free(rlm_walltime_aux1s);
free(rlm_walltime_aux2s);
}
void rlm_walltime_RLMPadDataSent(void *ptr,const struct rlm_svc *svc,
const struct rlm_log *log,
const struct rlm_pad *now,
const struct rlm_pad *next)
{
int i;
int flag=0;
char timer[1500];
FILE *f;
for(i=0;i<rlm_walltime_devs;i++) {
switch(log->log_mach) {
case 0:
flag=rlm_walltime_masters[i];
break;
case 1:
flag=rlm_walltime_aux1s[i];
break;
case 2:
flag=rlm_walltime_aux2s[i];
break;
}
if((flag==1)||((flag==2)&&(log->log_onair!=0))) {
f=fopen("/var/www/html/walltime/walltime.html","w");
if(now->rlm_len==0) {
snprintf(timer,1500,
"SP!RS!WU http://%s/walltime/walltime.html!",
rlm_walltime_clock_addresses+16*i);
fprintf(f,"<body bgcolor=\"#000000\">&nbsp;</body>");
}
else {
snprintf(timer,1500,
"SM D!PS %d!ST!WU http://%s/walltime/walltime.html!",
now->rlm_len/1000,
rlm_walltime_clock_addresses+16*i);
fprintf(f,"%s\n",
RLMResolveNowNextEncoded(ptr,now,next,rlm_walltime_formats+8192*i,
RLM_ENCODE_XML));
}
fclose(f);
RLMSendUdp(ptr,rlm_walltime_addresses+i*16,rlm_walltime_ports[i],
timer,strlen(timer));
RLMLog(ptr,LOG_INFO,"rlm_walltime: sending pad update!");
}
}
}