UniMRCP  1.7.0
mpf_dtmf_detector.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009-2010 Tomas Valenta, Arsen Chaloyan
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MPF_DTMF_DETECTOR_H
18 #define MPF_DTMF_DETECTOR_H
19 
20 /**
21  * @file mpf_dtmf_detector.h
22  * @brief DTMF detector
23  *
24  * Detector of DTMF tones sent both out-of-band (RFC4733) and in-band (audio).
25  */
26 
27 #include "apr.h"
28 #include "apr_pools.h"
29 #include "apt.h"
30 #include "mpf_frame.h"
31 #include "mpf_stream.h"
32 
34 
35 /** DTMF detector band */
37  /** Detect tones in-band */
39  /** Detect named events out-of-band */
41  /** Detect both in-band and out-of-band digits */
44 
45 /** Opaque MPF DTMF detector structure definition */
47 
48 
49 /**
50  * Create MPF DTMF detector (advanced).
51  * @param stream A stream to get digits from.
52  * @param band One of:
53  * - MPF_DTMF_DETECTOR_INBAND: detect audible tones only
54  * - MPF_DTMF_DETECTOR_OUTBAND: detect out-of-band named-events only
55  * - MPF_DTMF_DETECTOR_BOTH: detect digits in both bands if supported by
56  * stream. When out-of-band digit arrives, in-band detection is turned off.
57  * @param pool Memory pool to allocate DTMF detector from.
58  * @return The object or NULL on error.
59  * @see mpf_dtmf_detector_create
60  */
62  const struct mpf_audio_stream_t *stream,
63  enum mpf_dtmf_detector_band_e band,
64  struct apr_pool_t *pool);
65 
66 /**
67  * Create MPF DTMF detector (simple). Calls mpf_dtmf_detector_create_ex
68  * with band = MPF_DTMF_DETECTOR_BOTH if out-of-band supported by the stream,
69  * MPF_DTMF_DETECTOR_INBAND otherwise.
70  * @param stream A stream to get digits from.
71  * @param pool Memory pool to allocate DTMF detector from.
72  * @return The object or NULL on error.
73  * @see mpf_dtmf_detector_create_ex
74  */
75 static APR_INLINE struct mpf_dtmf_detector_t *mpf_dtmf_detector_create(
76  const struct mpf_audio_stream_t *stream,
77  struct apr_pool_t *pool)
78 {
79  return mpf_dtmf_detector_create_ex(stream,
81  pool);
82 }
83 
84 /**
85  * Get DTMF digit from buffer of digits detected so far and remove it.
86  * @param detector The detector.
87  * @return DTMF character [0-9*#A-D] or NUL if the buffer is empty.
88  */
90 
91 /**
92  * Retrieve how many digits was lost due to full buffer.
93  * @param detector The detector.
94  * @return Number of lost digits.
95  */
96 MPF_DECLARE(apr_size_t) mpf_dtmf_detector_digits_lost(const struct mpf_dtmf_detector_t *detector);
97 
98 /**
99  * Empty the buffer and reset detection states.
100  * @param detector The detector.
101  */
103 
104 /**
105  * Detect DTMF digits in the frame.
106  * @param detector The detector.
107  * @param frame Frame object passed in stream_write().
108  */
110  struct mpf_dtmf_detector_t *detector,
111  const struct mpf_frame_t *frame);
112 
113 /**
114  * Free all resources associated with the detector.
115  * @param detector The detector.
116  */
118 
120 
121 #endif /* MPF_DTMF_DETECTOR_H */
Definition: mpf_stream.h:37
Definition: mpf_dtmf_detector.h:42
mpf_codec_descriptor_t * tx_event_descriptor
Definition: mpf_stream.h:57
struct mpf_dtmf_detector_t * mpf_dtmf_detector_create_ex(const struct mpf_audio_stream_t *stream, enum mpf_dtmf_detector_band_e band, struct apr_pool_t *pool)
MPF Bidirectional Stream.
#define APT_END_EXTERN_C
Definition: apt.h:38
Definition: mpf_dtmf_detector.h:40
char mpf_dtmf_detector_digit_get(struct mpf_dtmf_detector_t *detector)
void mpf_dtmf_detector_destroy(struct mpf_dtmf_detector_t *detector)
Definition: mpf_frame.h:50
mpf_dtmf_detector_band_e
Definition: mpf_dtmf_detector.h:36
#define MPF_DECLARE(type)
Definition: mpf.h:40
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
MPF Audio/Video/Named-event Frame.
void mpf_dtmf_detector_reset(struct mpf_dtmf_detector_t *detector)
APR Toolkit Definitions.
apr_size_t mpf_dtmf_detector_digits_lost(const struct mpf_dtmf_detector_t *detector)
struct mpf_dtmf_detector_t mpf_dtmf_detector_t
Definition: mpf_dtmf_detector.h:46
Definition: mpf_dtmf_detector.h:38
void mpf_dtmf_detector_get_frame(struct mpf_dtmf_detector_t *detector, const struct mpf_frame_t *frame)