Merged revisions 79207 via svnmerge from
authorJoshua Colp <jcolp@digium.com>
Mon, 13 Aug 2007 14:55:17 +0000 (14:55 +0000)
committerJoshua Colp <jcolp@digium.com>
Mon, 13 Aug 2007 14:55:17 +0000 (14:55 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r79207 | file | 2007-08-13 11:51:09 -0300 (Mon, 13 Aug 2007) | 2 lines

Add an API call to allow the engine to know that DTMF was received.

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@79208 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_speech_utils.c
include/asterisk/speech.h
res/res_speech.c

index 13aa709..df2fe46 100644 (file)
@@ -662,6 +662,7 @@ static int speech_background(struct ast_channel *chan, void *data)
                        /* Free the frame we received */
                        switch (f->frametype) {
                        case AST_FRAME_DTMF:
                        /* Free the frame we received */
                        switch (f->frametype) {
                        case AST_FRAME_DTMF:
+                               ast_speech_dtmf(speech, f->subclass);
                                if (dtmf_terminator != '\0' && f->subclass == dtmf_terminator) {
                                        done = 1;
                                } else {
                                if (dtmf_terminator != '\0' && f->subclass == dtmf_terminator) {
                                        done = 1;
                                } else {
index e040629..e4d0c76 100644 (file)
@@ -87,6 +87,8 @@ struct ast_speech_engine {
        int (*deactivate)(struct ast_speech *speech, char *grammar_name);
        /*! Write audio to the speech engine */
        int (*write)(struct ast_speech *speech, void *data, int len);
        int (*deactivate)(struct ast_speech *speech, char *grammar_name);
        /*! Write audio to the speech engine */
        int (*write)(struct ast_speech *speech, void *data, int len);
+       /*! Signal DTMF was received */
+       int (*dtmf)(struct ast_speech *speech, char dtmf);
        /*! Prepare engine to accept audio */
        int (*start)(struct ast_speech *speech);
        /*! Change an engine specific setting */
        /*! Prepare engine to accept audio */
        int (*start)(struct ast_speech *speech);
        /*! Change an engine specific setting */
@@ -134,6 +136,8 @@ struct ast_speech *ast_speech_new(char *engine_name, int formats);
 int ast_speech_destroy(struct ast_speech *speech);
 /*! \brief Write audio to the speech engine */
 int ast_speech_write(struct ast_speech *speech, void *data, int len);
 int ast_speech_destroy(struct ast_speech *speech);
 /*! \brief Write audio to the speech engine */
 int ast_speech_write(struct ast_speech *speech, void *data, int len);
+/*! \brief Signal to the engine that DTMF was received */
+int ast_speech_dtmf(struct ast_speech *speech, char dtmf);
 /*! \brief Change an engine specific attribute */
 int ast_speech_change(struct ast_speech *speech, char *name, const char *value);
 /*! \brief Change the type of results we want */
 /*! \brief Change an engine specific attribute */
 int ast_speech_change(struct ast_speech *speech, char *name, const char *value);
 /*! \brief Change the type of results we want */
index ed815b6..82614a5 100644 (file)
@@ -153,6 +153,21 @@ int ast_speech_write(struct ast_speech *speech, void *data, int len)
        return speech->engine->write(speech, data, len);
 }
 
        return speech->engine->write(speech, data, len);
 }
 
+/*! \brief Signal to the engine that DTMF was received */
+int ast_speech_dtmf(struct ast_speech *speech, char dtmf)
+{
+       int res = 0;
+
+       if (speech->state != AST_SPEECH_STATE_READY)
+               return -1;
+
+       if (speech->engine->dtmf != NULL) {
+               res = speech->engine->dtmf(speech, dtmf);
+       }
+
+       return res;
+}
+
 /*! \brief Change an engine specific attribute */
 int ast_speech_change(struct ast_speech *speech, char *name, const char *value)
 {
 /*! \brief Change an engine specific attribute */
 int ast_speech_change(struct ast_speech *speech, char *name, const char *value)
 {