00001 /* 00002 * Copyright 2008-2010 Arsen Chaloyan 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 * $Id: mpf_named_event.h 1474 2010-02-07 20:51:47Z achaloyan $ 00017 */ 00018 00019 #ifndef MPF_NAMED_EVENT_H 00020 #define MPF_NAMED_EVENT_H 00021 00022 /** 00023 * @file mpf_named_event.h 00024 * @brief MPF Named Events (RFC4733/RFC2833) 00025 */ 00026 00027 #include "mpf_codec_descriptor.h" 00028 00029 APT_BEGIN_EXTERN_C 00030 00031 /** Named event declaration */ 00032 typedef struct mpf_named_event_frame_t mpf_named_event_frame_t; 00033 00034 00035 /** Named event (RFC4733/RFC2833, out-of-band DTMF) */ 00036 struct mpf_named_event_frame_t { 00037 /** event (DTMF, tone) identifier */ 00038 apr_uint32_t event_id: 8; 00039 #if (APR_IS_BIGENDIAN == 1) 00040 /** end of event */ 00041 apr_uint32_t edge: 1; 00042 /** reserved */ 00043 apr_uint32_t reserved: 1; 00044 /** tone volume */ 00045 apr_uint32_t volume: 6; 00046 #else 00047 /** tone volume */ 00048 apr_uint32_t volume: 6; 00049 /** reserved */ 00050 apr_uint32_t reserved: 1; 00051 /** end of event */ 00052 apr_uint32_t edge: 1; 00053 #endif 00054 /** event duration */ 00055 apr_uint32_t duration: 16; 00056 }; 00057 00058 /** Create named event descriptor */ 00059 MPF_DECLARE(mpf_codec_descriptor_t*) mpf_event_descriptor_create(apr_uint16_t sampling_rate, apr_pool_t *pool); 00060 00061 /** Check whether the specified descriptor is named event one */ 00062 MPF_DECLARE(apt_bool_t) mpf_event_descriptor_check(const mpf_codec_descriptor_t *descriptor); 00063 00064 /** Convert DTMF character to event identifier */ 00065 MPF_DECLARE(apr_uint32_t) mpf_dtmf_char_to_event_id(const char dtmf_char); 00066 00067 /** Convert event identifier to DTMF character */ 00068 MPF_DECLARE(char) mpf_event_id_to_dtmf_char(const apr_uint32_t event_id); 00069 00070 00071 APT_END_EXTERN_C 00072 00073 #endif /* MPF_NAMED_EVENT_H */