Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow replacement of GSM/WAV49 audio archives with other formats #492

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dev/.codespellignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ writen
noice
noicd
requestor
slin
22 changes: 14 additions & 8 deletions apps/app_rpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2959,6 +2959,7 @@ static inline int rpt_any_hangups(struct rpt *myrpt)
static inline void log_keyed(struct rpt *myrpt)
{
char mydate[100], myfname[512];
const char *myformat;
time_t myt;

if (myrpt->monstream) {
Expand All @@ -2971,7 +2972,9 @@ static inline void log_keyed(struct rpt *myrpt)
time(&myt);
strftime(mydate, sizeof(mydate) - 1, "%Y%m%d%H%M%S", localtime(&myt));
sprintf(myfname, "%s/%s/%s", myrpt->p.archivedir, myrpt->name, mydate);
myrpt->monstream = ast_writefile(myfname, "wav49", "app_rpt Air Archive", O_CREAT | O_APPEND, 0, 0644);
myformat = myrpt->p.archiveformat ? myrpt->p.archiveformat : "wav49";
myrpt->monstream =
ast_writefile(myfname, myformat, "app_rpt Air Archive", O_CREAT | O_APPEND, 0, 0644);
if (myrpt->p.monminblocks) {
blocksleft = diskavail(myrpt);
if (blocksleft >= myrpt->p.monminblocks) {
Expand Down Expand Up @@ -3792,18 +3795,19 @@ static inline int rxchannel_read(struct rpt *myrpt, const int lasttx)
if (myrpt->p.archivedir) {
if (myrpt->p.duplex < 2) {
char myfname[512], mydate[100];
const char *myformat;
long blocksleft;
time_t myt;

time(&myt);
strftime(mydate, sizeof(mydate) - 1, "%Y%m%d%H%M%S", localtime(&myt));
sprintf(myfname, "%s/%s/%s", myrpt->p.archivedir, myrpt->name, mydate);
myformat = myrpt->p.archiveformat ? myrpt->p.archiveformat : "wav49";
if (myrpt->p.monminblocks) {
blocksleft = diskavail(myrpt);
if (blocksleft >= myrpt->p.monminblocks) {
myrpt->monstream =
ast_writefile(myfname, "wav49", "app_rpt Air Archive", O_CREAT | O_APPEND, 0,
0644);
ast_writefile(myfname, myformat, "app_rpt Air Archive", O_CREAT | O_APPEND, 0, 0644);
}
}
}
Expand Down Expand Up @@ -7081,16 +7085,18 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
b1 = b;
if (myrpt->p.archivedir) {
char mycmd[512], mydate[100];
const char *myformat;
time_t myt;
long blocksleft;

mkdir(myrpt->p.archivedir, 0700);
sprintf(mycmd, "%s/%s", myrpt->p.archivedir, myrpt->name);
snprintf(mycmd, sizeof(mycmd), "%s/%s", myrpt->p.archivedir, myrpt->name);
mkdir(mycmd, 0775);
time(&myt);
strftime(mydate, sizeof(mydate) - 1, "%Y%m%d%H%M%S", localtime(&myt));
sprintf(mycmd, "mixmonitor start %s %s/%s/%s.wav49 a", ast_channel_name(chan), myrpt->p.archivedir, myrpt->name,
mydate);
strftime(mydate, sizeof(mydate), "%Y%m%d%H%M%S", localtime(&myt));
myformat = myrpt->p.archiveformat ? myrpt->p.archiveformat : "wav49";
snprintf(mycmd, sizeof(mycmd), "mixmonitor start %s %s/%s/%s.%s a",
ast_channel_name(chan), myrpt->p.archivedir, myrpt->name, myformat, mydate);
if (myrpt->p.monminblocks) {
blocksleft = diskavail(myrpt);
if (myrpt->p.remotetimeout) {
Expand All @@ -7100,7 +7106,7 @@ static int rpt_exec(struct ast_channel *chan, const char *data)
ast_cli_command(nullfd, mycmd);
} else
ast_cli_command(nullfd, mycmd);
sprintf(mycmd, "CONNECT,%s", b1);
snprintf(mycmd, sizeof(mycmd), "CONNECT,%s", b1);
donodelog(myrpt, mycmd);
rpt_update_links(myrpt);
doconpgm(myrpt, b1);
Expand Down
1 change: 1 addition & 0 deletions apps/app_rpt/app_rpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ struct rpt {
struct rpt_xlat inxlat;
struct rpt_xlat outxlat;
const char *archivedir;
const char *archiveformat;
int authlevel;
const char *csstanzaname;
const char *skedstanzaname;
Expand Down
1 change: 1 addition & 0 deletions apps/app_rpt/rpt_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ void load_rpt_vars(int n, int init)

RPT_CONFIG_VAR(patchconnect, "patchconnect");
RPT_CONFIG_VAR(archivedir, "archivedir");
RPT_CONFIG_VAR(archiveformat, "archiveformat");
RPT_CONFIG_VAR_INT(authlevel, "authlevel");

val = ast_variable_retrieve(cfg, cat, "parrot");
Expand Down
29 changes: 28 additions & 1 deletion configs/rpt/rpt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,36 @@ parrottime = 1000 ; Set the amount of time in milliseconds
; module app_gps.so will need to be enabled

; *** Status Reporting ***
; Uncomment the statpost line to report the status of your node to stats.allstarlink.org
;
; Uncomment the following "statpost_url" line to enable status reporting
; of all of your nodes to "stats.allstarlink.org". To enable reporting
; of a single node then add the line (without the leading ";") to the
; per-node stanza(s).
;
;statpost_url = http://stats.allstarlink.org/uhandler ; Status updates

; *** Audio Archiving ***
;
; The following "archivedir" line can be used to enable a simple log and
; audio recorder of the activity on a node. When enabled, a series of
; recordings, one for each active COR on the node. The file(s) will be
; named with the date and time down to the 1/100th of a second. This
; logging can be useful in debugging, policing, or other creative things.
;
; The "archiveformat" line can be used to specify the format of the audio
; recordings. By default, the format will be "wav49" (GSM in a .WAV file).
; Other options you may consider include "wav" (SLIN in a .wav file) and
; "gsm" (GSM in straight gsm format).
;
; The "archivedir" and "archiveformat" lines can be enabled here (affecting
; all nodes) or in the per-node stanzas (for recording of individual nodes).
;
; Note: enabling these recordings can adversly impact the CPU utilization
; on the device and consume large amounts of the available storage.
;
;archivedir = /var/spool/asterisk/monitor ; top-level recording directory
;archiveformat = wav49 ; audio format (default = wav49)

;;; End of node-main template

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down