main/cdrs: Preserve context/extension when executing a Macro or GoSub
[asterisk/asterisk.git] / apps / app_echo.c
index 48e6714..d8b2079 100644 (file)
@@ -40,12 +40,15 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 /*** DOCUMENTATION
        <application name="Echo" language="en_US">
                <synopsis>
 /*** DOCUMENTATION
        <application name="Echo" language="en_US">
                <synopsis>
-                       Echo audio, video, DTMF back to the calling party
+                       Echo media, DTMF back to the calling party
                </synopsis>
                <syntax />
                <description>
                </synopsis>
                <syntax />
                <description>
-                       <para>Echos back any audio, video or DTMF frames read from the calling 
-                       channel back to itself. Note: If '#' detected application exits</para>
+                       <para>Echos back any media or DTMF frames read from the calling 
+                       channel back to itself. This will not echo CONTROL, MODEM, or NULL
+                       frames. Note: If '#' detected application exits.</para>
+                       <para>This application does not automatically answer and should be
+                       preceeded by an application such as Answer() or Progress().</para>
                </description>
        </application>
  ***/
                </description>
        </application>
  ***/
@@ -55,11 +58,6 @@ static const char app[] = "Echo";
 static int echo_exec(struct ast_channel *chan, const char *data)
 {
        int res = -1;
 static int echo_exec(struct ast_channel *chan, const char *data)
 {
        int res = -1;
-       struct ast_format format;
-
-       ast_best_codec(chan->nativeformats, &format);
-       ast_set_write_format(chan, &format);
-       ast_set_read_format(chan, &format);
 
        while (ast_waitfor(chan, -1) > -1) {
                struct ast_frame *f = ast_read(chan);
 
        while (ast_waitfor(chan, -1) > -1) {
                struct ast_frame *f = ast_read(chan);
@@ -68,7 +66,10 @@ static int echo_exec(struct ast_channel *chan, const char *data)
                }
                f->delivery.tv_sec = 0;
                f->delivery.tv_usec = 0;
                }
                f->delivery.tv_sec = 0;
                f->delivery.tv_usec = 0;
-               if (ast_write(chan, f)) {
+               if (f->frametype != AST_FRAME_CONTROL
+                       && f->frametype != AST_FRAME_MODEM
+                       && f->frametype != AST_FRAME_NULL
+                       && ast_write(chan, f)) {
                        ast_frfree(f);
                        goto end;
                }
                        ast_frfree(f);
                        goto end;
                }