Replace direct access to channel name with accessor functions
[asterisk/asterisk.git] / apps / app_test.c
index 64ce7b4..9e11866 100644 (file)
  * \ingroup applications
  */
 
+/*** MODULEINFO
+       <support_level>extended</support_level>
+ ***/
+
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
@@ -87,9 +91,10 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
        short *foo;
        struct timeval start;
        struct ast_frame *f;
-       int rformat;
-       rformat = chan->readformat;
-       if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
+       struct ast_format rformat;
+
+       ast_format_copy(&rformat, &chan->readformat);
+       if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
                ast_log(LOG_NOTICE, "Unable to set to linear mode!\n");
                return -1;
        }
@@ -106,7 +111,7 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
                        res = -1;
                        break;
                }
-               if ((f->frametype == AST_FRAME_VOICE) && (f->subclass == AST_FORMAT_SLINEAR)) {
+               if ((f->frametype == AST_FRAME_VOICE) && (f->subclass.format.id == AST_FORMAT_SLINEAR)) {
                        foo = (short *)f->data.ptr;
                        for (x=0;x<f->samples;x++) {
                                noise += abs(foo[x]);
@@ -116,8 +121,8 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
                ast_frfree(f);
        }
 
-       if (rformat) {
-               if (ast_set_read_format(chan, rformat)) {
+       if (rformat.id) {
+               if (ast_set_read_format(chan, &rformat)) {
                        ast_log(LOG_NOTICE, "Unable to restore original format!\n");
                        return -1;
                }
@@ -194,7 +199,7 @@ static int testclient_exec(struct ast_channel *chan, const char *data)
                snprintf(fn, sizeof(fn), "%s/testresults/%s-client.txt", ast_config_AST_LOG_DIR, testid);
                if ((f = fopen(fn, "w+"))) {
                        setlinebuf(f);
-                       fprintf(f, "CLIENTCHAN:    %s\n", chan->name);
+                       fprintf(f, "CLIENTCHAN:    %s\n", ast_channel_name(chan));
                        fprintf(f, "CLIENTTEST ID: %s\n", testid);
                        fprintf(f, "ANSWER:        PASS\n");
                        res = 0;
@@ -312,7 +317,7 @@ static int testclient_exec(struct ast_channel *chan, const char *data)
                } else
                        res = -1;
        } else {
-               ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", chan->name);
+               ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", ast_channel_name(chan));
                res = -1;
        }
        return res;
@@ -356,7 +361,7 @@ static int testserver_exec(struct ast_channel *chan, const char *data)
                snprintf(fn, sizeof(fn), "%s/testresults/%s-server.txt", ast_config_AST_LOG_DIR, testid);
                if ((f = fopen(fn, "w+"))) {
                        setlinebuf(f);
-                       fprintf(f, "SERVERCHAN:    %s\n", chan->name);
+                       fprintf(f, "SERVERCHAN:    %s\n", ast_channel_name(chan));
                        fprintf(f, "SERVERTEST ID: %s\n", testid);
                        fprintf(f, "ANSWER:        PASS\n");
                        ast_debug(1, "Processing Test ID '%s'\n", testid);
@@ -462,7 +467,7 @@ static int testserver_exec(struct ast_channel *chan, const char *data)
                } else
                        res = -1;
        } else {
-               ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", chan->name);
+               ast_log(LOG_NOTICE, "Did not read a test ID on '%s'\n", ast_channel_name(chan));
                res = -1;
        }
        return res;