@ -42,7 +42,7 @@
/*** DOCUMENTATION
< function name = " VOLUME " language = " en_US " >
< synopsis >
Set the TX or RX volume of a channel .
Set or get the TX or RX volume of a channel .
< / synopsis >
< syntax >
< parameter name = " direction " required = " true " >
@ -221,9 +221,55 @@ static int volume_write(struct ast_channel *chan, const char *cmd, char *data, c
return 0 ;
}
static int volume_read ( struct ast_channel * chan , const char * cmd , char * data , char * buffer , size_t buflen )
{
struct ast_datastore * datastore = NULL ;
struct volume_information * vi = NULL ;
/* Separate options from argument */
AST_DECLARE_APP_ARGS ( args ,
AST_APP_ARG ( direction ) ;
AST_APP_ARG ( options ) ;
) ;
if ( ! chan ) {
ast_log ( LOG_WARNING , " No channel was provided to %s function. \n " , cmd ) ;
return - 1 ;
}
AST_STANDARD_APP_ARGS ( args , data ) ;
ast_channel_lock ( chan ) ;
if ( ! ( datastore = ast_channel_datastore_find ( chan , & volume_datastore , NULL ) ) ) {
ast_channel_unlock ( chan ) ;
return - 1 ; /* no active audiohook, nothing to read */
} else {
ast_channel_unlock ( chan ) ;
vi = datastore - > data ;
}
/* Obtain current gain using volume information structure */
if ( ast_strlen_zero ( args . direction ) ) {
ast_log ( LOG_ERROR , " Direction must be specified for VOLUME function \n " ) ;
return - 1 ;
}
if ( ! strcasecmp ( args . direction , " tx " ) ) {
snprintf ( buffer , buflen , " %f " , vi - > tx_gain ) ;
} else if ( ! strcasecmp ( args . direction , " rx " ) ) {
snprintf ( buffer , buflen , " %f " , vi - > rx_gain ) ;
} else {
ast_log ( LOG_ERROR , " Direction must be either RX or TX \n " ) ;
}
return 0 ;
}
static struct ast_custom_function volume_function = {
. name = " VOLUME " ,
. write = volume_write ,
. read = volume_read ,
} ;
static int unload_module ( void )