Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- 12151 discussions
Author: buklov
Date: Thu Apr 9 14:56:08 2009
New Revision: 12966
Log:
first release
Added:
freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c
Added: freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c Thu Apr 9 14:56:08 2009
@@ -0,0 +1,1509 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct(a)yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Anthony Minessale II <anthmct(a)yahoo.com>
+ * Michael B. Murdock <mike(a)mmurdock.org>
+ * Oleg Dolya <oleg.dolya(a)gmail.com>
+ * Boris Buklov <buklov(a)mail.ru>
+ *
+ * mod_say_ru.c -- Say for Russian
+ *
+ */
+
+#include <switch.h>
+#include <math.h>
+#include <ctype.h>
+
+typedef enum {
+ male, //мужского пола
+ female, //женского
+ it //оно
+} sex_t;
+
+
+
+typedef enum {
+ how_much, //сколько с полом
+ when, //какого - когда -- без пола
+ what_ //какая/какой/какое с полом
+} question_t; //вопрос
+
+
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_say_ru_load);
+SWITCH_MODULE_DEFINITION(mod_say_ru, mod_say_ru_load, NULL, NULL);
+
+#define say_num(num, t) { \
+ char tmp[80];\
+ switch_status_t tstatus;\
+ switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
+ if ((tstatus = ru_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
+ return tstatus;\
+ }}\
+
+#define say_file(...) {\
+ char tmp[80];\
+ switch_status_t tstatus;\
+ switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
+ if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
+ return tstatus;\
+ }\
+ if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
+ return SWITCH_STATUS_FALSE;\
+ }}\
+
+
+static switch_status_t ru_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
+{
+ char *p;
+
+ for (p = tosay; p && *p; p++) {
+ int a = tolower((int) *p);
+ if (a >= 48 && a <= 57) {
+ say_file("digits/%d.wav", a - 48);
+ } else {
+ if (type == SST_NAME_SPELLED) {
+ say_file("ascii/%d.wav", a);
+ } else if (type == SST_NAME_PHONETIC) {
+ say_file("phonetic-ascii/%d.wav", a);
+ }
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+//воспроизводить по 3 цифры
+static switch_status_t play_group( sex_t sex,question_t question, int a, int b, int c,
+ char *what,int last, switch_core_session_t *session, switch_input_args_t *args)
+{
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d sex=%d q=%d last=%d\n", a,b,c,sex,question,last);
+ if (a) {
+ if ((b==0)||(c==0)) { // если b и с равны 0 то сказать шестьсот, сестисотый, шестисотая
+ switch (question) {
+//------------------------------------------------------
+ case how_much: //сколько когда дальше нету цифр например 100 200...
+ switch (sex) { //пол
+ case male: //мужчина
+ say_file("digits/%d00.wav", a); //сто
+ if (what=="thousand") {
+ say_file("digits/thousands.wav");//тысяч
+ }
+ else if (what=="million") {
+ say_file("digits/millions.wav");//миллионов
+ }
+ //-------------
+ break;
+
+ case female: //женщина
+ say_file("digits/%d00.wav", a);//сто
+ if (what=="thousand") {
+ say_file("digits/thousands.wav");//тысяч
+ }
+ else if (what=="million") {
+ say_file("digits/millions.wav");//миллионов
+ }
+ break;
+ //-------------
+ case it: //оно
+ say_file("digits/%d00.wav", a);//сто
+ if (what=="thousand") {
+ say_file("digits/thousands.wav"); //тысяч
+ }
+ else if (what=="million") {
+ say_file("digits/millions.wav");//миллионов
+ }
+ break;
+ //-------------
+ }
+ break;
+//------------------------------------------------------
+ case what_: //какой/я/ое
+ switch (sex) { //пол
+ case male: //мужчина
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionx.wav");//тысячный
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/thousands.wav");//тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionm.wav");//Миллионный
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/millions.wav");//миллионов
+ }
+ }
+ else {
+ say_file("digits/h-%d00m.wav", a);//сотый двухсотый
+ }
+ break;
+
+ case female: //женщина
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionf.wav");//тысячная
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/thousands.wav");//тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionf.wav");//Миллионная
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/millions.wav");//миллионов
+ }
+ }
+ else {
+ say_file("digits/h-%d00f.wav", a);//сотая двухсотая
+ }
+ break;
+ case it: //оно
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionn.wav");//тысячное
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/thousands.wav");//тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionn.wav");//Миллионное
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/millions.wav");//миллионов
+ }
+ }
+ else {
+ say_file("digits/h-%d00n.wav", a);//сотого
+ }
+ break;
+ }
+ break;
+//-------------------------------------------------------
+ case when: //какого - когда без пола
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionx.wav");//тысячного
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/thousands.wav");//тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);//двухсот
+ say_file("digits/h-millionx.wav");//Миллионного
+ }
+ else {
+ say_file("digits/%d00.wav", a);//двести
+ say_file("digits/millions.wav");//миллионов
+ }
+ }
+ else {
+ say_file("digits/h-%d00x.wav", a);//сотого
+ }
+ break;
+ } //end switch (question)
+ }//end if ((b==0)||(c==0))
+ else // если есть ещё цифры
+ {
+ switch (question) {
+ case how_much:
+ say_file("digits/%d00.wav", a); //просто сто и тд
+ break;
+ case what_:
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);
+ }
+ else {
+ say_file("digits/%d00.wav", a); //сто
+ }
+ break;
+ case when:
+ if (last==0) {
+ say_file("digits/h-%d00xx.wav", a);
+ }
+ else {
+ say_file("digits/%d00.wav", a); //сто
+ }
+ break;
+ }
+ }
+ }//end if (a)
+ if (b) // если b больше 0
+ {
+ if (b > 1) { //если цифры больше 19
+ if (c==0) { // если c == нолю 20-30-40-50
+ switch (question) {
+//------------------------------------------------------
+ case how_much: //сколько когда дальше нету цифр например 10 20...
+ switch (sex) { //пол
+ case male: //мужчина
+ say_file("digits/%d0.wav", b); //двадцать
+ if (what=="thousand") {
+ say_file("digits/thousands.wav", b); //тысяч
+ }
+ else if (what=="millon") {
+ say_file("digits/millions.wav", b); //миллионов
+ }
+ //-------------
+ break;
+
+ case female: //женщина
+ say_file("digits/%d0.wav", b);//двадцать
+ if (what=="thousand") {
+ say_file("digits/thousands.wav", b); //тысяч
+ }
+ else if (what=="millon") {
+ say_file("digits/millions.wav", b); //миллионов
+ }
+ break;
+ //-------------
+ case it: //оно
+ say_file("digits/%d0.wav", b);// двадцать
+ if (what=="thousand") {
+ say_file("digits/thousands.wav", b); //тысяч
+ }
+ else if (what=="millon") {
+ say_file("digits/millions.wav", b); //миллионов
+ }
+ break;
+ //-------------
+ }
+ break;
+//------------------------------------------------------
+ case what_: //какой/я/ое >19 и c==0 20-30-40
+ switch (sex) { //пол
+ case male: //мужчина
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-thousandm.wav", b); //тысячный
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-millionm.wav", b); //миллионный
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d0m.wav", b);//двадцатый
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ }
+ }
+ break;
+ case female: //женщина
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-thousandf.wav", b); //тысячная
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-millionf.wav", b); //миллионная
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d0f.wav", b);//двадцатая
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ }
+ }
+ break;
+ case it: //оно
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-thousandn.wav", b); //тысячное
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-millionn.wav", b); //миллионное
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d0n.wav", b);//двадцатое
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ }
+ }
+ break;
+ }
+ break;
+//-------------------------------------------------------
+ case when: //какого - когда без пола
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-thousandx.wav", b); //тысячного
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d0xx.wav", b);//двадцати
+ say_file("digits/h-millionx.wav", b); //миллионного
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ say_file("digits/h-thousand.wav", b); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d0x.wav", b);//двадцатого
+ }
+ else {
+ say_file("digits/%d0.wav", b);//двадцать
+ }
+ }
+ break;
+ }
+ }//конец если c == нолю
+ else
+ {
+ say_file("digits/%d0.wav", b); // иначе просто двадцать .. и тд
+ }
+ }//конец если больше 19
+ else { //если цифры меньше 20
+ switch (question) {
+//------------------------------------------------------
+ case how_much: //сколько когда от 10 до 19
+ switch (sex) { //пол
+ case male: //мужчина
+ say_file("digits/%d%d.wav",b ,c); //девятнадцать
+ if (what=="thousand") {
+ say_file("digits/thousands.wav"); //тысяч
+ }
+ else if (what=="million") {
+ say_file("digits/millions.wav"); //миллионов
+ }
+ //-------------
+ break;
+ case female: //женщина
+ say_file("digits/%d%d.wav",b ,c);//девятнадцать
+ if (what=="thousand") {
+ say_file("digits/thousands.wav"); //тысяч
+ }
+ else if (what=="million") {
+ say_file("digits/millions.wav"); //миллионов
+ }
+ break;
+ //-------------
+ case it: //оно
+ say_file("digits/%d%d.wav",b ,c);// девятнадцать
+ if (what=="thousand") {
+ say_file("digits/thousands.wav"); //тысяч
+ }
+ else if (what=="million") {
+ say_file("digits/millions.wav"); //миллионов
+ }
+ break;
+ //-------------
+ }
+ break;
+//------------------------------------------------------
+ case what_: //какой/я/ое
+ switch (sex) { //пол
+ case male: //женщина
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-thousandm.wav"); //тысячный
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнацать
+ say_file("digits/h-thousand.wav"); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-millionm.wav"); //миллионный
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнадцать
+ say_file("digits/h-thousand.wav"); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d%dm.wav", b,c);//девятнадцатый
+ }
+ else {
+ say_file("digits/%d%d.wav");//девятнадцать
+ }
+ }
+ case female: //женщина
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-thousandf.wav"); //тысячная
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнацать
+ say_file("digits/h-thousand.wav"); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-millionf.wav"); //миллионная
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнадцать
+ say_file("digits/h-thousand.wav"); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d%df.wav", b,c);//девятнадцатая
+ }
+ else {
+ say_file("digits/%d%d.wav");//девятнадцать
+ }
+ }
+ break;
+ case it: //оно
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-thousandn.wav"); //тысячное
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнацать
+ say_file("digits/h-thousand.wav"); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-millionn.wav"); //миллионное
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнадцать
+ say_file("digits/h-thousand.wav"); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d%dn.wav", b,c);//девятнадцатое
+ }
+ else {
+ say_file("digits/%d%d.wav");//девятнадцать
+ }
+ }
+ break;
+ }
+ break;
+//-------------------------------------------------------
+ case when: //какого - когда без пола
+ if (what=="thousand") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-thousandx.wav"); //тысячного
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнацать
+ say_file("digits/h-thousand.wav"); //тысяч
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {
+ say_file("digits/h-%d%dxx.wav", b,c);//десяти, пятнадцати ..
+ say_file("digits/h-millionx.wav"); //миллионного
+ }
+ else {
+ say_file("digits/%d%d.wav", b,c);//девятнадцать
+ say_file("digits/h-thousand.wav"); //миллионов
+ }
+ }
+ else { //без миллионов и тысяч
+ if (last==0) {
+ say_file("digits/h-%d%dx.wav", b,c);//девятнадцатого
+ }
+ else {
+ say_file("digits/%d%d.wav");//девятнадцать
+ }
+ }
+
+ break;
+ }//конец если c == нолю
+ c=0; //что бы не проговаривать c
+ }// конец //если цифры меньше 20
+ }//конец if (b)
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group c \n");
+
+
+
+ if ((c)||(what=="zero")) {// последняя цифра (самая сложная) или проговорить ноль , для случает когда первые цифры нули
+ if (c>2||c==0) {//0 и 3-9
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group c 1\n");
+
+ switch (question)
+ {
+//------------------------------------------------------
+ case how_much: //сколько 3-9
+ switch (sex)
+ { //пол
+ case male: //мужчина
+ if (what=="thousand") { //тысяч
+ if ((c>2)&&(c<5)) {
+ say_file("digits/%d.wav", c);// три - четыре
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ else{
+ say_file("digits/%d.wav", c);// пять .. девять
+ say_file("digits/thousands.wav"); //тысяч
+ }
+ }
+ else if (what=="million") { //миллионов
+ if ((c>2)&&(c<5)) {
+ say_file("digits/%d.wav", c);// три четыре
+ say_file("digits/million-a.wav"); //миллиона
+ }
+ else{
+ say_file("digits/%d.wav", c);// пять .. девять
+ say_file("digits/millions.wav"); //миллионов
+ }
+ }
+ else {
+ say_file("digits/%d.wav", c);// три девять ноль
+ }
+ break;
+
+ case female: //женщина
+ if (what=="thousand") { //тысяч
+ if ((c>2)&&(c<5)) {
+ say_file("digits/%d.wav", c);// три - четыре
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ else{
+ say_file("digits/%d.wav", c);// пять .. девять
+ say_file("digits/thousands.wav"); //тысяч
+ }
+ }
+ else if (what=="million") { //миллионов
+ if ((c>2)&&(c<5)) {
+ say_file("digits/%d.wav", c);// три четыре
+ say_file("digits/million-a.wav"); //миллиона
+ }
+ else{
+ say_file("digits/%d.wav", c);// пять .. девять
+ say_file("digits/millions.wav"); //миллионов
+ }
+ }
+ else {
+ say_file("digits/%d.wav", c);// три девять ноль
+ }
+ break;
+
+ //-------------
+ case it: //оно
+ if (what=="thousand") { //тысяч
+ if ((c>2)&&(c<5)) {
+ say_file("digits/%d.wav", c);// три - четыре
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ else{
+ say_file("digits/%d.wav", c);// пять .. девять
+ say_file("digits/thousands.wav"); //тысяч
+ }
+ }
+ else if (what=="million") { //миллионов
+ if ((c>2)&&(c<5)) {
+ say_file("digits/%d.wav", c);// три четыре
+ say_file("digits/million-a.wav"); //миллиона
+ }
+ else{
+ say_file("digits/%d.wav", c);// пять .. девять
+ say_file("digits/millions.wav"); //миллионов
+ }
+ }
+ else {
+ say_file("digits/%d.wav", c);// три девять ноль
+ }
+ break;
+ }
+ break;
+//------------------------------------------------------
+ case what_: //какой/я/ое
+ switch (sex)
+ { //пол
+ case male: //мужчина
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-thousandm.wav"); //тысячный
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-millionm.wav"); //миллионный
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%dm.wav", c);//третий нулевой ..
+ }
+ break;
+ case female: //женщина
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-thousandf.wav"); //тысячная
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-millionf.wav"); //миллионная
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%df.wav", c);//третья нулевая ..
+ }
+ break;
+ case it: //оно
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-thousandn.wav"); //тысячное
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-millionn.wav"); //миллионное
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%dn.wav", c);//третье нулевое ..
+ }
+ break;
+ }
+ break;
+//-------------------------------------------------------
+ case when: //какого - когда без пола
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-thousandx.wav"); //тысячного
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ say_file("digits/h-millionx.wav"); //миллионого
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%dx.wav", c);//третьего нулевого ..
+ }
+ break;
+ }//конец switch (question)
+ } //конец //0 и 3-9
+ else if ((c==2)||(c==1)) { //1 2
+ switch (question) {
+//------------------------------------------------------
+ case how_much: //
+ switch (sex)
+ { //пол
+ case male: //мужчина
+ if (what=="thousand") {
+ if (c==1) {
+ say_file("digits/%df.wav", c); // одна две
+ say_file("digits/thousand.wav"); //тысяча
+ }
+ else{
+ say_file("digits/%df.wav", c); // одна две
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ say_file("digits/%d.wav", c); // один два
+ if (c==1) {
+ say_file("digits/million.wav", c); //миллион
+ }
+ else { //один два
+ say_file("digits/million-a.wav"); // миллиона
+ }
+ }
+ else { //просто один два
+ say_file("digits/%d.wav", c); // один два
+ }
+ break;
+ //-------------
+ case female: //женщина
+ if (what=="thousand") {
+ if (c==1) {
+ say_file("digits/%df.wav", c); // одна две
+ say_file("digits/thousand.wav"); //тысяча
+ }
+ else{
+ say_file("digits/%df.wav", c); // одна две
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ say_file("digits/%d.wav", c); // один два
+ if (c==1) {
+ say_file("digits/million.wav"); //миллион
+ }
+ else { //один два
+ say_file("digits/million-a.wav"); // миллиона
+ }
+ }
+ else { //просто одна две
+ say_file("digits/%df.wav", c); // одна две
+ }
+ break;
+ //-------------
+ case it: //оно
+ if (what=="thousand") {
+ if (c==1) {
+ say_file("digits/%df.wav", c); // одна две
+ say_file("digits/thousand.wav"); //тысяча
+ }
+ else{
+ say_file("digits/%df.wav", c); // одна две
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ say_file("digits/%d.wav", c); // один два
+ if (c==1) {
+ say_file("digits/million.wav"); //миллион
+ }
+ else { //один два
+ say_file("digits/million-a.wav"); // миллиона
+ }
+ }
+ else { //просто одно две
+ say_file("digits/%dn.wav", c); // одна две
+ }
+ break;
+ }
+ break;
+//------------------------------------------------------
+ case what_: //какой/я/ое
+ switch (sex)
+ { //пол
+ case male: //мужчина
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух,одна 2-х, ...
+ if (c!=1) { //не произность одна тысячный
+ say_file("digits/h-%dxx.wav", c);//одна, двух
+ }
+ say_file("digits/h-thousandm.wav"); //тысячный
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%df.wav", c);//одна две
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ if (c!=1) {
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ }
+ say_file("digits/h-millionm.wav"); //миллионный
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand-a.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%dm.wav", c);//третий нулевой ..
+ }
+ break;
+ case female: //женщина
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 1-х, 2-х ...
+ if (c!=1) { //не произность одна тысячная
+ say_file("digits/h-%dxx.wav", c);//одна, двух
+ }
+ say_file("digits/h-thousandf.wav"); //тысячная
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%df.wav", c);//две четыре ..
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ if (c!=1) {
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ }
+ say_file("digits/h-millionf.wav"); //миллионная
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand-a.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%df.wav", c);//третья нулевая ..
+ }
+ break;
+ case it: //оно
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 1-х, 2-х ...
+ if (c!=1) { //не произность одна тысячное
+ say_file("digits/h-%dxx.wav", c);//одна, двух
+ }
+ say_file("digits/h-thousandn.wav"); //тысячное
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%df.wav", c);//две ..
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ if (c!=1) {
+ say_file("digits/h-%dxx.wav", c);//одна, двух
+ }
+ say_file("digits/h-millionn.wav"); //миллионное
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand-a.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%dn.wav", c);//третье нулевое ..
+ }
+ break;
+ }
+ break;
+//-------------------------------------------------------
+ case when: //какого - когда без пола
+ if (what=="thousand") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ if (c!=1) { //не произность одна тысячного
+ say_file("digits/h-%dxx.wav", c);//одна, двух
+ }
+ say_file("digits/h-thousandx.wav"); //тысячного
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%df.wav", c);//две четыре ..
+ say_file("digits/thousands-i.wav"); //тысячи
+ }
+ }
+ else if (what=="million") {
+ if (last==0) {// если дальше нету цифр значит говорить двух, 3-х, 4-х ...
+ if (c!=1) {
+ say_file("digits/h-%dxx.wav", c);//одна, двух, трёх
+ }
+ say_file("digits/h-millionx.wav"); //миллионного
+ }
+ else { //если есть дальше цифры меньше 1000
+ say_file("digits/%d.wav", c);//три четыре ..
+ say_file("digits/thousand-a.wav"); //миллиона
+ }
+ }//просто цифры без тысяч
+ else{
+ say_file("digits/h-%dx.wav", c);//третьего нулевого ..
+ }
+ break;
+ }
+ }//else if ((c==2)||(c==1)) { //1 2
+
+ }//конец if ((c)||(what=="zero"))
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+
+static char *strip_commas(char *in, char *out, switch_size_t len)
+{
+ char *p = in, *q = out;
+ char *ret = out;
+ switch_size_t x = 0;
+
+ for (; p && *p; p++) {
+ if ((*p > 47 && *p < 58)) {
+ *q++ = *p;
+ } else if (*p != ',') {
+ ret = NULL;
+ break;
+ }
+
+ if (++x > len) {
+ ret = NULL;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
+{
+ char *p = in, *q = out;
+ char *ret = out;
+ switch_size_t x = 0;
+ // valid are 0 - 9, period (.), minus (-), and plus (+) - remove all others
+ for (; p && *p; p++) {
+ if ((*p > 47 && *p < 58) || *p == '.' || *p == '-' || *p == '+') {
+ *q++ = *p;
+ }
+
+ if (++x > len) {
+ ret = NULL;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+
+static switch_status_t ru_say_count(switch_core_session_t *session,
+ char *tosay, sex_t sex, question_t question, switch_input_args_t *args)
+{
+ int in;
+ int x = 0;
+ int places[9] = { 0 };
+ char sbuf[13] = "";
+
+ switch_status_t status;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ru_say_count %d %d %d other!\n", places[2], places[1], places[0]);
+
+ if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
+ return SWITCH_STATUS_GENERR;
+ }
+
+ in = atoi(tosay);
+ int in_ = in;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "int in=%d!\n", in);
+ if (in != 0) {
+ for (x = 8; x >= 0; x--) {
+ int num = (int) pow(10, x);
+ if ((places[(uint32_t) x] = in / num)) {
+ in -= places[(uint32_t) x] * num;
+ }
+ }
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "int in=%d \n", in);
+
+ if ((status = play_group(sex,question, places[8], places[7], places[6], "million",in%1000000, session, args)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million!\n", places[8], places[7], places[6]);
+ return status;
+ }
+ if ((status = play_group(sex,question, places[5], places[4], places[3], "thousand",in_%1000,session, args)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand!\n", places[5], places[4], places[3]);
+ return status;
+ }
+ if ((status = play_group(sex,question, places[2], places[1], places[0], NULL, 0,session, args)) != SWITCH_STATUS_SUCCESS)
+ {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d other!\n", places[2], places[1], places[0]);
+ return status;
+ }
+ } else { //если ноль что бы и его проговаривать в правильных падежах
+ if ((status = play_group(sex,question, places[2], places[1], places[0], "zero",0, session, args)) != SWITCH_STATUS_SUCCESS)
+ {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d other!\n", places[2], places[1], places[0]);
+ return status;
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t ru_say_general_count(switch_core_session_t *session,
+ char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
+{
+ switch_status_t status;
+ sex_t sex;
+ question_t question;
+
+ if (type== SST_MESSAGES)
+ {
+ sex=it;
+ question=how_much;
+ }
+ else if (type== SST_NUMBER||type==SST_PERSONS)
+ {
+ sex=male;
+ question=how_much;
+ }
+ else if (type== SST_ITEMS)
+ {
+ sex=male;
+ question=what_;
+ }
+ else
+ {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
+ return SWITCH_STATUS_FALSE;
+ }
+ status=ru_say_count(session,tosay,sex,question,args);
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type,
+ switch_say_method_t method,switch_input_args_t *args)
+{
+ char sbuf[16] = "";
+ char *dollars = NULL;
+ char *cents = NULL;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_money %s\n",tosay );
+ if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
+ return SWITCH_STATUS_GENERR;
+ }
+ dollars = sbuf;
+
+ if ((cents = strchr(sbuf, '.'))) {
+ *cents++ = '\0';
+ if (strlen(cents) > 2) {
+ cents[2] = '\0';
+ }
+ }
+ if (sbuf[0] == '+') {
+ dollars++;
+ }
+
+ if (sbuf[0] == '-') {
+ say_file("currency/minus.wav");
+ dollars++;
+ }
+ ru_say_count(session,dollars ,male,how_much,args);
+ int idollars = atoi(dollars)%100;
+ int idollar = atoi(dollars)%10;
+ if (idollars == 1 || (idollars > 20 && idollar == 1)) {/* рубль */
+ say_file("currency/dollar.wav");
+ }
+ else if ((idollars > 1 && idollars < 5) || (idollars > 20 && idollar > 1 && idollar < 5)) { /*рубля */
+ say_file("currency/dollar1.wav");
+ }
+ else { /*рублей */
+ say_file("currency/dollar2.wav");
+ }
+ /* Say cents */
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " %s\n",cents );
+ ru_say_count(session,cents ,female,how_much,args);
+ int icents = atoi(cents)%100;
+ int icent = atoi(cents)%10;
+ if (icents == 1 || (icents > 20 && icent == 1))
+ {
+ /* копейка */
+ say_file("currency/cent.wav");
+ }
+ else if ((icents > 1 && icents < 5) || (icents > 20 && icent > 1 && icent < 5))
+ {
+ /* копейки */
+ say_file("currency/cent1.wav");
+ }
+ else
+ {
+ /* копеек */
+ say_file("currency/cents.wav");
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
+ switch_input_args_t *args)
+{
+ int32_t t;
+ char tmp[80];
+ switch_time_t target = 0, target_now = 0;
+ switch_time_exp_t tm, tm_now;
+ uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ const char *tz = switch_channel_get_variable(channel, "timezone");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n",tosay, type,method );
+
+ if (type == SST_TIME_MEASUREMENT) {
+ int64_t hours = 0;
+ int64_t minutes = 0;
+ int64_t seconds = 0;
+ int64_t r = 0;
+
+ if (strchr(tosay, ':')) {
+ char *tme = switch_core_session_strdup(session, tosay);
+ char *p;
+
+ if ((p = strrchr(tme, ':'))) {
+ *p++ = '\0';
+ seconds = atoi(p);
+ if ((p = strchr(tme, ':'))) {
+ *p++ = '\0';
+ minutes = atoi(p);
+ if (tme) {
+ hours = atoi(tme);
+ }
+ } else {
+ minutes = atoi(tme);
+ }
+ }
+ } else {
+ if ((seconds = atol(tosay)) <= 0) {
+ seconds = (int64_t) switch_epoch_time_now(NULL);
+ }
+
+ if (seconds >= 60) {
+ minutes = seconds / 60;
+ r = seconds % 60;
+ seconds = r;
+ }
+
+ if (minutes >= 60) {
+ hours = minutes / 60;
+ r = minutes % 60;
+ minutes = r;
+ }
+ }
+
+ switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)hours);
+ ru_say_count(session,tmp ,male,how_much,args);
+ if (((hours%10) == 1) && (hours!=11)) {
+ /* час */
+ say_file("time/hour.wav");
+ }
+ else if (((hours%10>1)&&(hours%10<5)) &&((hours<12)||(hours>14))) {
+ say_file("time/hours-a.wav"); /* часа */
+ }
+ else {
+ say_file("time/hours.wav"); /* часов*/
+ }
+
+ switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)minutes); //перевести минуты в *char
+ ru_say_count(session,tmp ,female,how_much,args);
+ if (((minutes%10) == 1) && (minutes!=11)) {
+ say_file("time/minute.wav"); //минута
+ }
+ else if (((minutes%10>1)&&(minutes%10<5))&&((minutes<12)||(minutes>14))){
+ say_file("time/minutes-i.wav"); // минуты
+ }
+ else {
+ say_file("time/minutes.wav"); //минут
+ }
+
+ if (seconds!=0) {
+ switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)seconds);
+ ru_say_count(session,tmp ,female,how_much,args);
+ if (((seconds%10) == 1) && (seconds!=11)) {
+ say_file("time/second.wav"); // секунда
+ }
+ else if (((seconds%10>1)&&(seconds%10<5))&&((seconds<12)||(seconds>14))) {
+ say_file("time/seconds-i.wav"); // секуны
+ }
+ else {
+ say_file("time/seconds.wav"); //секунд
+ }
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ if ((t = atol(tosay)) > 0) {
+ target = switch_time_make(t, 0);
+ target_now = switch_micro_time_now();
+ } else {
+ target = switch_micro_time_now();
+ target_now = switch_micro_time_now();
+ }
+
+ if (tz) {
+ int check = atoi(tz);
+ if (check) {
+ switch_time_exp_tz(&tm, target, check);
+ switch_time_exp_tz(&tm_now, target_now, check);
+ } else {
+ switch_time_exp_tz_name(tz, &tm, target);
+ switch_time_exp_tz_name(tz, &tm_now, target_now);
+ }
+ } else {
+ switch_time_exp_lt(&tm, target);
+ switch_time_exp_lt(&tm_now, target_now);
+ }
+ switch (type) {
+ case SST_CURRENT_DATE_TIME:
+ say_date = say_time = 1;
+ break;
+ case SST_CURRENT_DATE:
+ say_date = 1;
+ break;
+ case SST_CURRENT_TIME:
+ say_time = 1;
+ break;
+ case SST_SHORT_DATE_TIME:
+ say_time = 1;
+ if (tm.tm_year != tm_now.tm_year) {
+ say_date = 1;
+ break;
+ }
+ if (tm.tm_yday == tm_now.tm_yday) {
+ say_today = 1;
+ break;
+ }
+ if (tm.tm_yday == tm_now.tm_yday - 1) {
+ say_yesterday = 1;
+ break;
+ }
+ if (tm.tm_yday >= tm_now.tm_yday - 5) {
+ say_dow = 1;
+ break;
+ }
+ if (tm.tm_mon != tm_now.tm_mon) {
+ say_month = say_day = say_dow = 1;
+ break;
+ }
+
+ say_month = say_day = say_dow = 1;
+
+ break;
+ default:
+ break;
+ }
+
+ if (say_today) {
+ say_file("time/today.wav");
+ }
+ if (say_yesterday) {
+ say_file("time/yesterday.wav");
+ }
+ if (say_dow) {
+ say_file("time/day-%d.wav", tm.tm_wday);
+ }
+ if (say_date) {
+ say_year = say_month = say_day = say_dow = 1;
+ say_today = say_yesterday = 0;
+ }
+ if (say_day) {
+ switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)tm.tm_mday);
+ ru_say_count(session,tmp ,male,when,args);
+ }
+ if (say_month) {
+ say_file("time/mon-%d.wav", tm.tm_mon);
+ }
+ if (say_year) {
+ switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)(tm.tm_year + 1900));
+ ru_say_count(session,tmp ,male,when,args);
+ say_file("time/h-year.wav");
+ }
+ if (say_month||say_year||say_date||say_dow)
+ {
+ say_file("time/at.wav");
+ }
+ if (say_time) {
+ switch_snprintf(tmp, sizeof(tmp), "%d:%d:%d",tm.tm_hour+1,tm.tm_min,tm.tm_sec);
+ ru_say_time(session, tmp, SST_TIME_MEASUREMENT, method, args);
+ }
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+static switch_status_t ru_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
+{
+ switch_say_callback_t say_cb = NULL;
+
+
+ switch (type) {
+ case SST_NUMBER:
+ case SST_ITEMS:
+ case SST_PERSONS:
+ case SST_MESSAGES:
+ say_cb = ru_say_general_count;
+ break;
+ case SST_TIME_MEASUREMENT:
+ say_cb = ru_say_time;
+ break;
+
+ case SST_CURRENT_DATE:
+ say_cb = ru_say_time;
+ break;
+
+ case SST_CURRENT_TIME:
+ say_cb = ru_say_time;
+ break;
+
+ case SST_CURRENT_DATE_TIME:
+ say_cb = ru_say_time;
+ break;
+ case SST_IP_ADDRESS:
+// say_cb = ru_ip;
+ break;
+ case SST_NAME_SPELLED:
+ case SST_NAME_PHONETIC:
+ say_cb = ru_spell;
+ break;
+ case SST_CURRENCY:
+ say_cb = ru_say_money;
+ break;
+ default:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
+ break;
+ }
+ if (say_cb) {
+ return say_cb(session, tosay, type, method, args);
+ }
+ return SWITCH_STATUS_FALSE;
+}
+
+
+
+SWITCH_MODULE_LOAD_FUNCTION(mod_say_ru_load)
+{
+ switch_say_interface_t *say_interface;
+ /* connect my internal structure to the blank pointer passed to me */
+ *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+ say_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SAY_INTERFACE);
+ say_interface->interface_name = "ru";
+ say_interface->say_function = ru_say;
+
+ /* indicate that the module should continue to be loaded */
+ return SWITCH_STATUS_SUCCESS;
+}
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
+ */
1
0
Author: brian
Date: Thu Apr 9 14:45:01 2009
New Revision: 12965
Log:
mkdir
Added:
freeswitch/trunk/src/mod/say/mod_say_ru/
1
0
09 Apr '09
Author: brian
Date: Thu Apr 9 14:38:15 2009
New Revision: 12964
Log:
extra paren
Modified:
freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Thu Apr 9 14:38:15 2009
@@ -1294,7 +1294,7 @@
return SWITCH_STATUS_SUCCESS;
}
- if (!switch_core_codec_ready(&globals.read_codec))) {
+ if (!switch_core_codec_ready(&globals.read_codec)) {
if (switch_core_codec_init(&globals.read_codec,
"L16",
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
1
0
Author: cypromis
Date: Thu Apr 9 12:48:06 2009
New Revision: 12963
Log:
deleted non existant old config files
added new config files
got rif of xml_ldap since the openldap build breaks on centos
some minor cleanups
builds fine with mock
Modified:
freeswitch/trunk/freeswitch.spec
Modified: freeswitch/trunk/freeswitch.spec
==============================================================================
--- freeswitch/trunk/freeswitch.spec (original)
+++ freeswitch/trunk/freeswitch.spec Thu Apr 9 12:48:06 2009
@@ -319,8 +319,8 @@
LOGGERS_MODULES="loggers/mod_console loggers/mod_logfile loggers/mod_syslog"
SAY_MODULES="say/mod_say_en say/mod_say_de say/mod_say_fr"
TIMERS_MODULES=
-DISABLED_MODULES="applications/mod_soundtouch languages/mod_spidermonkey_skel ast_tts/mod_cepstral asr_tts/mod_lumenvox directories/mod_ldap event_handlers/mod_event_test event_handlers/mod_radius_cdr event_handlers/mod_zeroconf languages/mod_managed languages/mod_java say/mod_say_it say/mod_say_es say/mod_say_nl"
-XML_INT_MODULES="xml_int/mod_xml_rpc xml_int/mod_xml_curl xml_int/mod_xml_cdr xml_int/mod_xml_ldap"
+DISABLED_MODULES="applications/mod_soundtouch languages/mod_spidermonkey_skel ast_tts/mod_cepstral asr_tts/mod_lumenvox event_handlers/mod_event_test event_handlers/mod_radius_cdr event_handlers/mod_zeroconf languages/mod_managed languages/mod_java say/mod_say_it say/mod_say_es say/mod_say_nl"
+XML_INT_MODULES="xml_int/mod_xml_rpc xml_int/mod_xml_curl xml_int/mod_xml_cdr "
MYMODULES="$PASSTHRU_CODEC_MODULES $SPIDERMONKEY_MODULES $APPLICATIONS_MODULES $ASR_TTS_MODULES $CODECS_MODULES $DIALPLANS_MODULES $DIRECTORIES_MODULES $ENDPOINTS_MODULES $EVENT_HANDLERS_MODULES $FORMATS_MODULES $LANGUAGES_MODULES $LOGGERS_MODULES $SAY_MODULES $TIMERS_MODULES $XML_INT_MODULES"
export MODULES=$MYMODULES
@@ -387,7 +387,7 @@
%{__install} -D -m 744 build/freeswitch.init.suse $RPM_BUILD_ROOT/etc/init.d/freeswitch
%else
# On RedHat like
-%{__install} -D -o root -g root -m 0755 build/freeswitch.init.redhat $RPM_BUILD_ROOT/etc/init.d/freeswitch
+%{__install} -D -m 0755 build/freeswitch.init.redhat $RPM_BUILD_ROOT/etc/init.d/freeswitch
%endif
# On SuSE make /usr/sbin/rcfreeswitch a link to /etc/init.d/freeswitch
%if 0%{?suse_version} > 100
@@ -457,7 +457,6 @@
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/m3ua.conf
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/extensions.conf
-%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/cmudict.0.6d
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/acl.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/alsa.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/conference.conf.xml
@@ -496,6 +495,7 @@
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/lcr.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/opal.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/unicall.conf.xml
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/memcache.conf.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/dialplan/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/dialplan/default/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/dialplan/public/*.xml
@@ -505,7 +505,7 @@
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/sip_profiles/internal/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/sip_profiles/external/*.xml
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/jingle_profiles/*.xml
-%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/grammar/Makefile
+%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/grammar/default.dic
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/grammar/model/communicator/*
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/grammar/model/wsj1/*
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/htdocs/*
@@ -566,7 +566,6 @@
%{prefix}/mod/mod_stress.so
%{prefix}/mod/mod_yaml.so
%{prefix}/mod/mod_shout.so
-%{prefix}/mod/mod_xml_ldap.so
%{prefix}/mod/mod_fax.so
%{prefix}/mod/mod_soundtouch.so
%{prefix}/mod/mod_vmd.so
@@ -630,7 +629,7 @@
%files python
%defattr(-,freeswitch,daemon)
%{prefix}/mod/mod_python*.so*
-%attr(0644, root, bin) /usr/lib/python2.4/site-packages/freeswitch.py
+%attr(0644, root, bin) /usr/lib/python2.4/site-packages/freeswitch.py*
%dir %attr(0750, freeswitch, daemon) %{prefix}/conf/autoload_configs
%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/python.conf.xml
@@ -784,7 +783,6 @@
- added mod/mod_stress.so
- added mod_yaml.so
- added mod_shout.so
-- added mod_xml_ldap.so
- added rpms or all sounds
- openzap is now its own rpm
- added french
1
0
09 Apr '09
Author: anthm
Date: Thu Apr 9 12:40:19 2009
New Revision: 12962
Log:
delay init of resources until the first time they are actually used to avoid unnecessary waste of resources in hardware codec
Modified:
freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c
Modified: freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c
==============================================================================
--- freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c (original)
+++ freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c Thu Apr 9 12:40:19 2009
@@ -117,11 +117,63 @@
return fd;
}
+static switch_status_t init_encoder(switch_codec_t *codec)
+{
+ struct dahdi_transcoder_formats fmts;
+ struct dahdi_context *context = codec->private_info;
+
+ fmts.srcfmt = DAHDI_FORMAT_ULAW;
+ fmts.dstfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
+ ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
+ context->encoding_fd = switch_dahdi_get_transcoder(&fmts);
+ if (context->decoding_fd < 0) {
+#ifdef DEBUG_DAHDI_CODEC
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "encoding requested and denied with %d/%d.\n",
+ fmts.srcfmt, fmts.dstfmt);
+#endif
+ return SWITCH_STATUS_FALSE;
+ }
+ /* ulaw requires 8 times more storage than g729 and 12 times more than G723, right? */
+ context->codec_r = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
+ ? 8 : 12;
+#ifdef DEBUG_DAHDI_CODEC
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding requested and granted with %d/%d.\n",
+ fmts.srcfmt, fmts.dstfmt);
+#endif
+
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+static switch_status_t init_decoder(switch_codec_t *codec)
+{
+ struct dahdi_transcoder_formats fmts;
+ struct dahdi_context *context = codec->private_info;
+
+ fmts.dstfmt = DAHDI_FORMAT_ULAW;
+ fmts.srcfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
+ ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
+ context->decoding_fd = switch_dahdi_get_transcoder(&fmts);
+ if (context->decoding_fd < 0) {
+#ifdef DEBUG_DAHDI_CODEC
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and denied with %d/%d.\n",
+ fmts.srcfmt, fmts.dstfmt);
+#endif
+ return SWITCH_STATUS_FALSE;
+ }
+#ifdef DEBUG_DAHDI_CODEC
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and granted with %d/%d.\n",
+ fmts.srcfmt, fmts.dstfmt);
+#endif
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
static switch_status_t switch_dahdi_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings)
{
uint32_t encoding, decoding;
struct dahdi_context *context = NULL;
- struct dahdi_transcoder_formats fmts;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Switch DAHDI init called.\n");
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
@@ -141,44 +193,10 @@
return SWITCH_STATUS_FALSE;
}
- if (encoding) {
- fmts.srcfmt = DAHDI_FORMAT_ULAW;
- fmts.dstfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
- ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
- context->encoding_fd = switch_dahdi_get_transcoder(&fmts);
- if (context->decoding_fd < 0) {
-#ifdef DEBUG_DAHDI_CODEC
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "encoding requested and denied with %d/%d.\n",
- fmts.srcfmt, fmts.dstfmt);
-#endif
- return SWITCH_STATUS_FALSE;
- }
- /* ulaw requires 8 times more storage than g729 and 12 times more than G723, right? */
- context->codec_r = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
- ? 8 : 12;
-#ifdef DEBUG_DAHDI_CODEC
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding requested and granted with %d/%d.\n",
- fmts.srcfmt, fmts.dstfmt);
-#endif
- }
- if (decoding) {
- fmts.dstfmt = DAHDI_FORMAT_ULAW;
- fmts.srcfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
- ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
- context->decoding_fd = switch_dahdi_get_transcoder(&fmts);
- if (context->decoding_fd < 0) {
-#ifdef DEBUG_DAHDI_CODEC
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and denied with %d/%d.\n",
- fmts.srcfmt, fmts.dstfmt);
-#endif
- return SWITCH_STATUS_FALSE;
- }
-#ifdef DEBUG_DAHDI_CODEC
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and granted with %d/%d.\n",
- fmts.srcfmt, fmts.dstfmt);
-#endif
- }
codec->private_info = context;
+ context->encoding_fd = -1;
+ context->decoding_fd = -1;
+
return SWITCH_STATUS_SUCCESS;
}
@@ -195,10 +213,19 @@
unsigned char ebuf_ulaw[decoded_data_len/2];
uint32_t i;
struct dahdi_context *context = NULL;
+ switch_status_t status;
+
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Switch DAHDI encode called to encode %d bytes.\n", decoded_data_len);
#endif
context = codec->private_info;
+
+ if (context->encoding_fd == -1) {
+ if ((status = init_encoder(codec)) != SWITCH_STATUS_SUCCESS) {
+ return status;
+ }
+ }
+
dbuf_linear = decoded_data;
ebuf_g729 = encoded_data;
for (i = 0; i < decoded_data_len / sizeof(short); i++) {
@@ -245,6 +272,8 @@
unsigned char *ebuf_g729;
uint32_t i;
struct dahdi_context *context;
+ switch_status_t status;
+
#ifdef DEBUG_DAHDI_CODEC
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Switch DAHDI decode called to decode %d bytes.\n", encoded_data_len);
#endif
@@ -253,6 +282,12 @@
dbuf_linear = decoded_data;
ebuf_g729 = encoded_data;
+ if (context->decoding_fd == -1) {
+ if ((status = init_decoder(codec)) != SWITCH_STATUS_SUCCESS) {
+ return status;
+ }
+ }
+
if (*flag & SWITCH_CODEC_FLAG_SILENCE) {
memset(dbuf_linear, 0, codec->implementation->decoded_bytes_per_packet);
*decoded_data_len = codec->implementation->decoded_bytes_per_packet;
1
0
Author: anthm
Date: Thu Apr 9 12:17:12 2009
New Revision: 12961
Log:
FSCORE-349 add flag to denote if a codec is init or not
Modified:
freeswitch/trunk/src/include/switch_frame.h
freeswitch/trunk/src/include/switch_loadable_module.h
freeswitch/trunk/src/include/switch_module_interfaces.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c
freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c
freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c
freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c
freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c
freeswitch/trunk/src/switch_core_codec.c
freeswitch/trunk/src/switch_core_io.c
freeswitch/trunk/src/switch_core_media_bug.c
freeswitch/trunk/src/switch_core_session.c
freeswitch/trunk/src/switch_ivr.c
freeswitch/trunk/src/switch_ivr_originate.c
Modified: freeswitch/trunk/src/include/switch_frame.h
==============================================================================
--- freeswitch/trunk/src/include/switch_frame.h (original)
+++ freeswitch/trunk/src/include/switch_frame.h Thu Apr 9 12:17:12 2009
@@ -68,7 +68,6 @@
switch_bool_t m;
/*! frame flags */
switch_frame_flag_t flags;
- switch_core_session_t *session;
};
SWITCH_END_EXTERN_C
Modified: freeswitch/trunk/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/trunk/src/include/switch_loadable_module.h (original)
+++ freeswitch/trunk/src/include/switch_loadable_module.h Thu Apr 9 12:17:12 2009
@@ -413,6 +413,7 @@
impl->destroy = destroy;
impl->codec_id = codec_interface->codec_id;
impl->next = codec_interface->implementations;
+ impl->impl_id = switch_core_codec_next_id();
codec_interface->implementations = impl;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %u\n",
@@ -427,6 +428,11 @@
}
+static inline switch_bool_t switch_core_codec_ready(switch_codec_t *codec)
+{
+ return (codec->flags & SWITCH_CODEC_FLAG_READY) ? SWITCH_TRUE : SWITCH_FALSE;
+}
+
Modified: freeswitch/trunk/src/include/switch_module_interfaces.h
==============================================================================
--- freeswitch/trunk/src/include/switch_module_interfaces.h (original)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h Thu Apr 9 12:17:12 2009
@@ -609,6 +609,7 @@
/*! deinitalize a codec handle using this implementation */
switch_core_codec_destroy_func_t destroy;
uint32_t codec_id;
+ uint32_t impl_id;
struct switch_codec_implementation *next;
};
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Thu Apr 9 12:17:12 2009
@@ -954,7 +954,8 @@
SWITCH_CODEC_FLAG_SILENCE = (1 << 4),
SWITCH_CODEC_FLAG_FREE_POOL = (1 << 5),
SWITCH_CODEC_FLAG_AAL2 = (1 << 6),
- SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7)
+ SWITCH_CODEC_FLAG_PASSTHROUGH = (1 << 7),
+ SWITCH_CODEC_FLAG_READY = (1 << 8)
} switch_codec_flag_enum_t;
typedef uint32_t switch_codec_flag_t;
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Apr 9 12:17:12 2009
@@ -4489,7 +4489,7 @@
switch_core_session_reset(member->session, SWITCH_TRUE, SWITCH_FALSE);
- if (member->read_codec.implementation) {
+ if (switch_core_codec_ready(&member->read_codec)) {
switch_core_codec_destroy(&member->read_codec);
}
Modified: freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c Thu Apr 9 12:17:12 2009
@@ -242,7 +242,7 @@
fail:
switch_core_session_set_read_codec(session, NULL);
- if (codec.implementation) {
+ if (switch_core_codec_ready(&codec)) {
switch_core_codec_destroy(&codec);
}
Modified: freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c Thu Apr 9 12:17:12 2009
@@ -678,11 +678,11 @@
switch_core_session_set_read_codec(session, NULL);
- if (read_codec.implementation) {
+ if (switch_core_codec_ready(&read_codec)) {
switch_core_codec_destroy(&read_codec);
}
- if (write_codec.implementation) {
+ if (switch_core_codec_ready(&write_codec)) {
switch_core_codec_destroy(&write_codec);
}
Modified: freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c Thu Apr 9 12:17:12 2009
@@ -346,11 +346,11 @@
switch_core_session_set_read_codec(session, read_codec);
}
- if (codec.implementation) {
+ if (switch_core_codec_ready(&codec)) {
switch_core_codec_destroy(&codec);
}
- if (vid_codec.implementation) {
+ if (switch_core_codec_ready(&vid_codec)) {
switch_core_codec_destroy(&vid_codec);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c Thu Apr 9 12:17:12 2009
@@ -931,11 +931,11 @@
{
deactivate_audio_device();
- if (globals.read_codec.implementation) {
+ if (switch_core_codec_ready(&globals.read_codec)) {
switch_core_codec_destroy(&globals.read_codec);
}
- if (globals.write_codec.implementation) {
+ if (switch_core_codec_ready(&globals.write_codec)) {
switch_core_codec_destroy(&globals.write_codec);
}
switch_core_hash_destroy(&globals.call_hash);
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Thu Apr 9 12:17:12 2009
@@ -1244,11 +1244,11 @@
tech_pvt->rtp_session = NULL;
}
- if (tech_pvt->read_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
- if (tech_pvt->write_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -1440,7 +1440,7 @@
}
}
- if (!tech_pvt->read_codec.implementation) {
+ if (!switch_core_codec_ready(&tech_pvt->read_codec) || !tech_pvt->read_codec.implementation) {
return SWITCH_STATUS_GENERR;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c Thu Apr 9 12:17:12 2009
@@ -498,11 +498,11 @@
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
switch_clear_flag_locked(tech_pvt, TFLAG_CODEC);
- if (tech_pvt->read_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
- if (tech_pvt->write_codec.implementation) {
+ if (!switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -1084,7 +1084,8 @@
if (channel && switch_channel_up(channel)) {
int bytes = 0, frames = 1;
- if (!switch_test_flag(tech_pvt, TFLAG_CODEC) || !tech_pvt->read_codec.implementation) {
+ if (!switch_test_flag(tech_pvt, TFLAG_CODEC) || !tech_pvt->read_codec.implementation ||
+ !switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
break;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c Thu Apr 9 12:17:12 2009
@@ -113,11 +113,11 @@
interval = codec->implementation->microseconds_per_packet / 1000;
}
- if (tech_pvt->read_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
- if (tech_pvt->write_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -133,7 +133,7 @@
NULL,
switch_core_session_get_pool(session));
- if (status != SWITCH_STATUS_SUCCESS || !tech_pvt->read_codec.implementation) {
+ if (status != SWITCH_STATUS_SUCCESS || !tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
goto end;
}
@@ -373,11 +373,11 @@
switch_core_timer_destroy(&tech_pvt->timer);
- if (tech_pvt->read_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
- if (tech_pvt->write_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c Thu Apr 9 12:17:12 2009
@@ -348,11 +348,11 @@
static void destroy_codecs(void)
{
- if (globals.read_codec.implementation) {
+ if (switch_core_codec_ready(&globals.read_codec)) {
switch_core_codec_destroy(&globals.read_codec);
}
- if (globals.write_codec.implementation) {
+ if (switch_core_codec_ready(&globals.write_codec)) {
switch_core_codec_destroy(&globals.write_codec);
}
@@ -1294,7 +1294,7 @@
return SWITCH_STATUS_SUCCESS;
}
- if (!globals.read_codec.implementation) {
+ if (!switch_core_codec_ready(&globals.read_codec))) {
if (switch_core_codec_init(&globals.read_codec,
"L16",
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
@@ -1306,7 +1306,7 @@
switch_assert(globals.read_codec.implementation);
- if (!globals.write_codec.implementation) {
+ if (!switch_core_codec_ready(&globals.write_codec)) {
if (switch_core_codec_init(&globals.write_codec,
"L16",
NULL,
Modified: freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c Thu Apr 9 12:17:12 2009
@@ -200,11 +200,11 @@
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
//switch_thread_cond_signal(tech_pvt->cond);
- if (tech_pvt->read_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
- if (tech_pvt->write_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c Thu Apr 9 12:17:12 2009
@@ -205,12 +205,12 @@
skypiax_signaling_write(tech_pvt, msg_to_skype);
}
- if (tech_pvt->read_codec.implementation) {
- switch_core_codec_destroy(&tech_pvt->read_codec);
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
+ switch_core_codec_destroy(&tech_pvt->read_codec);
}
- if (tech_pvt->write_codec.implementation) {
- switch_core_codec_destroy(&tech_pvt->write_codec);
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
+ switch_core_codec_destroy(&tech_pvt->write_codec);
}
memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu Apr 9 12:17:12 2009
@@ -379,11 +379,11 @@
sofia_clear_flag(tech_pvt, TFLAG_IO);
- if (tech_pvt->read_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_core_codec_destroy(&tech_pvt->read_codec);
}
- if (tech_pvt->write_codec.implementation) {
+ if (switch_core_codec_ready(&tech_pvt->write_codec)) {
switch_core_codec_destroy(&tech_pvt->write_codec);
}
@@ -665,7 +665,8 @@
tech_pvt->read_frame.datalen = 0;
sofia_set_flag_locked(tech_pvt, TFLAG_READING);
- if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
+ if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation ||
+ !switch_core_codec_ready(&tech_pvt->read_codec)) {
return SWITCH_STATUS_FALSE;
}
@@ -711,7 +712,7 @@
int frames = 1;
if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) {
- if (!tech_pvt->read_codec.implementation) {
+ if (!tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
*frame = NULL;
return SWITCH_STATUS_GENERR;
}
@@ -872,7 +873,7 @@
}
}
- if (!tech_pvt->read_codec.implementation) {
+ if (!tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
return SWITCH_STATUS_GENERR;
}
@@ -888,7 +889,7 @@
return SWITCH_STATUS_SUCCESS;
}
- if (sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation) {
+ if (sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
return SWITCH_STATUS_FALSE;
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Apr 9 12:17:12 2009
@@ -1752,7 +1752,7 @@
switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int force)
{
- if (tech_pvt->video_read_codec.implementation) {
+ if (tech_pvt->video_read_codec.implementation && switch_core_codec_ready(&tech_pvt->video_read_codec)) {
if (!force) {
return SWITCH_STATUS_SUCCESS;
}
@@ -1825,7 +1825,7 @@
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
- if (tech_pvt->read_codec.implementation) {
+ if (tech_pvt->read_codec.implementation && switch_core_codec_ready(&tech_pvt->read_codec)) {
if (!force) {
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
}
@@ -1885,7 +1885,7 @@
tech_pvt->read_frame.rate = tech_pvt->rm_rate;
ms = tech_pvt->write_codec.implementation->microseconds_per_packet / 1000;
- if (!tech_pvt->read_codec.implementation) {
+ if (!switch_core_codec_ready(&tech_pvt->read_codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c Thu Apr 9 12:17:12 2009
@@ -948,11 +948,11 @@
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
//switch_thread_cond_signal(tech_pvt->cond);
- if (tech_pvt->read_codec.implementation)
+ if (switch_core_codec_ready(&tech_pvt->read_codec))
switch_core_codec_destroy(&tech_pvt->read_codec);
- if (tech_pvt->write_codec.implementation)
+ if (switch_core_codec_ready(&tech_pvt->write_codec)
switch_core_codec_destroy(&tech_pvt->write_codec);
-
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel hangup\n", switch_channel_get_name(channel));
#if 0
Modified: freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c Thu Apr 9 12:17:12 2009
@@ -171,7 +171,7 @@
return SWITCH_STATUS_SUCCESS;
}
- if (!source->read_codec.implementation) {
+ if (!switch_core_codec_ready(&source->read_codec)) {
if (switch_core_codec_init(&source->read_codec,
"L16",
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
@@ -183,7 +183,7 @@
switch_assert(source->read_codec.implementation);
- if (!source->write_codec.implementation) {
+ if (!switch_core_codec_ready(&source->write_codec) {
if (switch_core_codec_init(&source->write_codec,
"L16",
NULL,
@@ -340,11 +340,11 @@
switch_mutex_lock(source->device_lock);
CloseAudioStream(source->audio_stream);
- if (source->read_codec.implementation) {
+ if (switch_core_codec_ready(&source->read_codec)) {
switch_core_codec_destroy(&source->read_codec);
switch_core_codec_destroy(&source->write_codec);
}
- if (source->write_codec.implementation) {
+ if (switch_core_codec_ready(&source->write_codec) {
switch_core_codec_destroy(&source->write_codec);
}
switch_mutex_unlock(source->device_lock);
Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c (original)
+++ freeswitch/trunk/src/switch_core_codec.c Thu Apr 9 12:17:12 2009
@@ -100,7 +100,7 @@
switch_mutex_lock(session->codec_read_mutex);
- if (codec && !codec->implementation) {
+ if (codec && (!codec->implementation || !switch_core_codec_ready(codec))) {
codec = NULL;
}
@@ -221,7 +221,7 @@
switch_mutex_lock(session->codec_write_mutex);
- if (!codec || !codec->implementation) {
+ if (!codec || !codec->implementation || !switch_core_codec_ready(codec)) {
if (session->real_write_codec) {
session->write_codec = session->real_write_codec;
session->write_impl = *session->real_write_codec->implementation;
@@ -301,7 +301,7 @@
char tmp[30];
switch_status_t status = SWITCH_STATUS_SUCCESS;
- if (!codec || !codec->implementation) {
+ if (!codec || !codec->implementation || !switch_core_codec_ready(codec)) {
if (session->video_read_codec) {
session->video_read_codec = NULL;
status = SWITCH_STATUS_SUCCESS;
@@ -345,7 +345,7 @@
switch_channel_t *channel = switch_core_session_get_channel(session);
char tmp[30];
switch_status_t status = SWITCH_STATUS_SUCCESS;
- if (!codec || !codec->implementation) {
+ if (!codec || !codec->implementation || !switch_core_codec_ready(codec)) {
if (session->video_write_codec) {
session->video_write_codec = NULL;
status = SWITCH_STATUS_SUCCESS;
@@ -493,7 +493,7 @@
implementation->init(codec, flags, codec_settings);
switch_mutex_init(&codec->mutex, SWITCH_MUTEX_NESTED, codec->memory_pool);
-
+ switch_set_flag(codec, SWITCH_CODEC_FLAG_READY);
return SWITCH_STATUS_SUCCESS;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec %s Exists but not at the desired implementation. %dhz %dms\n", codec_name, rate,
@@ -518,7 +518,7 @@
switch_assert(encoded_data != NULL);
switch_assert(decoded_data != NULL);
- if (!codec->implementation) {
+ if (!codec->implementation || !switch_core_codec_ready(codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
return SWITCH_STATUS_NOT_INITALIZED;
}
@@ -550,7 +550,7 @@
switch_assert(encoded_data != NULL);
switch_assert(decoded_data != NULL);
- if (!codec->implementation) {
+ if (!codec->implementation || !switch_core_codec_ready(codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec is not initialized!\n");
return SWITCH_STATUS_NOT_INITALIZED;
}
@@ -576,7 +576,7 @@
switch_assert(codec != NULL);
- if (!codec->implementation) {
+ if (!codec->implementation || !switch_core_codec_ready(codec)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec is not initialized!\n");
return SWITCH_STATUS_NOT_INITALIZED;
}
@@ -591,11 +591,10 @@
if (mutex) switch_mutex_lock(mutex);
codec->implementation->destroy(codec);
+ switch_clear_flag(codec, SWITCH_CODEC_FLAG_READY);
UNPROTECT_INTERFACE(codec->codec_interface);
- memset(codec, 0, sizeof(*codec));
-
if (mutex) switch_mutex_unlock(mutex);
if (free_pool) {
Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c (original)
+++ freeswitch/trunk/src/switch_core_io.c Thu Apr 9 12:17:12 2009
@@ -106,10 +106,11 @@
switch_status_t status = SWITCH_STATUS_FALSE;
int need_codec, perfect, do_bugs = 0, do_resample = 0, is_cng = 0;
unsigned int flag = 0;
+ switch_codec_implementation_t codec_impl;
switch_assert(session != NULL);
- if (!(session->read_codec && session->read_codec->implementation)) {
+ if (!(session->read_codec && session->read_codec->implementation && switch_core_codec_ready(session->read_codec))) {
if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_get_state(session->channel) == CS_HIBERNATE) {
*frame = &runtime.dummy_cng_frame;
return SWITCH_STATUS_SUCCESS;
@@ -202,16 +203,21 @@
switch_assert((*frame)->codec != NULL);
- if (((*frame)->codec && session->read_codec->implementation != (*frame)->codec->implementation)) {
- need_codec = TRUE;
- }
-
- if (!(session->read_codec && (*frame)->codec && (*frame)->codec->implementation)) {
+ switch_mutex_lock((*frame)->codec->mutex);
+ if (!(session->read_codec && (*frame)->codec && (*frame)->codec->implementation) && switch_core_codec_ready((*frame)->codec)) {
status = SWITCH_STATUS_FALSE;
+ switch_mutex_unlock((*frame)->codec->mutex);
goto done;
}
- if ((*frame)->codec->implementation->actual_samples_per_second != session->read_impl.actual_samples_per_second) {
+ codec_impl = *(*frame)->codec->implementation;
+ switch_mutex_unlock((*frame)->codec->mutex);
+
+ if (session->read_codec->implementation->impl_id != codec_impl.impl_id) {
+ need_codec = TRUE;
+ }
+
+ if (codec_impl.actual_samples_per_second != session->read_impl.actual_samples_per_second) {
do_resample = 1;
}
@@ -243,7 +249,7 @@
} else {
switch_codec_t *use_codec = read_frame->codec;
if (do_bugs) {
- if (!session->bug_codec.implementation) {
+ if (!switch_core_codec_ready(&session->bug_codec)) {
switch_core_codec_copy(read_frame->codec, &session->bug_codec, switch_core_session_get_pool(session));
}
use_codec = &session->bug_codec;
@@ -525,12 +531,10 @@
even_more_done:
- if (!*frame || !(*frame)->codec || !(*frame)->codec->implementation) {
+ if (!*frame || !(*frame)->codec || !(*frame)->codec->implementation || !switch_core_codec_ready((*frame)->codec)) {
*frame = &runtime.dummy_cng_frame;
}
- (*frame)->session = session;
-
switch_mutex_unlock(session->read_codec->mutex);
switch_mutex_unlock(session->codec_read_mutex);
@@ -579,7 +583,7 @@
return SWITCH_STATUS_SUCCESS;
}
- if (!(session->write_codec && session->write_codec->implementation) && !pass_cng) {
+ if (!(session->write_codec && switch_core_codec_ready(session->write_codec)) && !pass_cng) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s has no write codec.\n", switch_channel_get_name(session->channel));
return SWITCH_STATUS_FALSE;
}
@@ -924,7 +928,7 @@
- if (frame->codec && frame->codec->implementation) {
+ if (frame->codec && frame->codec->implementation && switch_core_codec_ready(frame->codec)) {
rate = frame->codec->implementation->actual_samples_per_second;
} else {
rate = session->write_impl.actual_samples_per_second;
Modified: freeswitch/trunk/src/switch_core_media_bug.c
==============================================================================
--- freeswitch/trunk/src/switch_core_media_bug.c (original)
+++ freeswitch/trunk/src/switch_core_media_bug.c Thu Apr 9 12:17:12 2009
@@ -334,7 +334,7 @@
status = SWITCH_STATUS_SUCCESS;
}
- if (session->bug_codec.implementation) {
+ if (switch_core_codec_ready(&session->bug_codec)) {
switch_core_codec_destroy(&session->bug_codec);
memset(&session->bug_codec, 0, sizeof(session->bug_codec));
}
@@ -389,7 +389,7 @@
}
}
- if (!session->bugs && session->bug_codec.implementation) {
+ if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
switch_core_codec_destroy(&session->bug_codec);
memset(&session->bug_codec, 0, sizeof(session->bug_codec));
}
@@ -427,7 +427,7 @@
switch_thread_rwlock_unlock(session->bug_rwlock);
}
- if (!session->bugs && session->bug_codec.implementation) {
+ if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
switch_core_codec_destroy(&session->bug_codec);
memset(&session->bug_codec, 0, sizeof(session->bug_codec));
}
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Thu Apr 9 12:17:12 2009
@@ -399,11 +399,11 @@
vid_read_codec = switch_core_session_get_video_read_codec(session);
- if (read_codec && read_codec->implementation) {
+ if (read_codec && read_codec->implementation && switch_core_codec_ready(read_codec)) {
char rc[80] = "", vrc[80] = "", tmp[160] = "";
switch_codec2str(read_codec, rc, sizeof(rc));
- if (vid_read_codec && vid_read_codec->implementation) {
+ if (vid_read_codec && vid_read_codec->implementation && switch_core_codec_ready(vid_read_codec)) {
vrc[0] = ',';
switch_codec2str(read_codec, vrc+1, sizeof(vrc) - 1);
switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE, vrc+1);
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Thu Apr 9 12:17:12 2009
@@ -342,7 +342,7 @@
break;
}
}
- if (conninfo->read_codec.implementation) {
+ if (switch_core_codec_ready(&conninfo->read_codec)) {
switch_core_codec_destroy(&conninfo->read_codec);
}
switch_socket_close(conninfo->socket);
Modified: freeswitch/trunk/src/switch_ivr_originate.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_originate.c (original)
+++ freeswitch/trunk/src/switch_ivr_originate.c Thu Apr 9 12:17:12 2009
@@ -833,7 +833,7 @@
switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
- if (write_codec.implementation) {
+ if (switch_core_codec_ready(&write_codec)) {
switch_core_codec_destroy(&write_codec);
}
@@ -2102,7 +2102,7 @@
switch_core_session_reset(oglobals.session, SWITCH_FALSE, SWITCH_TRUE);
}
- if (write_codec.implementation) {
+ if (switch_core_codec_ready(&write_codec)) {
switch_core_codec_destroy(&write_codec);
}
1
0
09 Apr '09
Author: mikej
Date: Thu Apr 9 10:28:52 2009
New Revision: 12960
Log:
fix windows calling conventions for modules with sub-modules broken in svn r12919
Modified:
freeswitch/trunk/src/include/switch_platform.h
freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp
freeswitch/trunk/src/mod/languages/mod_managed/switch_platform.i
freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
Modified: freeswitch/trunk/src/include/switch_platform.h
==============================================================================
--- freeswitch/trunk/src/include/switch_platform.h (original)
+++ freeswitch/trunk/src/include/switch_platform.h Thu Apr 9 10:28:52 2009
@@ -145,13 +145,16 @@
#define SWITCH_DECLARE_DATA __declspec(dllimport)
#endif
#if defined(SWITCH_MOD_DECLARE_STATIC)
-#define SWITCH_MOD_DECLARE(type) type __cdecl
+#define SWITCH_MOD_DECLARE(type) type __stdcall
+#define SWITCH_MOD_DECLARE_NONSTD(type) type __cdecl
#define SWITCH_MOD_DECLARE_DATA
#elif defined(MOD_EXPORTS)
#define SWITCH_MOD_DECLARE(type) __declspec(dllexport) type __stdcall
+#define SWITCH_MOD_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define SWITCH_MOD_DECLARE_DATA __declspec(dllexport)
#else
#define SWITCH_MOD_DECLARE(type) __declspec(dllimport) type __stdcall
+#define SWITCH_MOD_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define SWITCH_MOD_DECLARE_DATA __declspec(dllimport)
#endif
#define SIGHUP SIGTERM
@@ -170,6 +173,7 @@
#define SWITCH_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
#define SWITCH_DECLARE_DATA __attribute__((visibility("default")))
#define SWITCH_MOD_DECLARE(type) __attribute__((visibility("default"))) type
+#define SWITCH_MOD_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
#define SWITCH_MOD_DECLARE_DATA __attribute__((visibility("default")))
#define SWITCH_DECLARE_CLASS __attribute__((visibility("default")))
#else
@@ -177,6 +181,7 @@
#define SWITCH_DECLARE_NONSTD(type) type
#define SWITCH_DECLARE_DATA
#define SWITCH_MOD_DECLARE(type) type
+#define SWITCH_MOD_DECLARE_NONSTD(type) type
#define SWITCH_MOD_DECLARE_DATA
#define SWITCH_DECLARE_CLASS
#endif
Modified: freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp Thu Apr 9 10:28:52 2009
@@ -77,7 +77,7 @@
static executeBackgroundFunction executeBackgroundDelegate;
static loadAssemblyFunction loadAssemblyDelegate;
-SWITCH_MOD_DECLARE(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, loadAssemblyFunction loadAssembly)
+SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, loadAssemblyFunction loadAssembly)
{
runDelegate = run;
executeDelegate = execute;
@@ -88,7 +88,7 @@
// Sets up delegates (and anything else needed) on the ManagedSession object
// Called from ManagedSession.Initialize Managed -> this is Unmanaged code so all pointers are marshalled and prevented from GC
// Exported method.
-SWITCH_MOD_DECLARE(void) InitManagedSession(ManagedSession *session, inputFunction dtmfDelegate, hangupFunction hangupDelegate)
+SWITCH_MOD_DECLARE_NONSTD(void) InitManagedSession(ManagedSession *session, inputFunction dtmfDelegate, hangupFunction hangupDelegate)
{
switch_assert(session);
if (!session) {
Modified: freeswitch/trunk/src/mod/languages/mod_managed/switch_platform.i
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/switch_platform.i (original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/switch_platform.i Thu Apr 9 10:28:52 2009
@@ -31,6 +31,7 @@
#define SWITCH_DECLARE(type) type
#define SWITCH_DECLARE_NONSTD(type) type
#define SWITCH_MOD_DECLARE(type) type
+#define SWITCH_MOD_DECLARE_NONSTD(type) type
#define SWITCH_DECLARE_DATA
#define SWITCH_MOD_DECLARE_DATA
#define SWITCH_THREAD_FUNC
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_core_db/mod_spidermonkey_core_db.c Thu Apr 9 10:28:52 2009
@@ -332,7 +332,7 @@
/*.next */ NULL
};
-SWITCH_MOD_DECLARE(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
{
*module_interface = &DB_module_interface;
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_curl/mod_spidermonkey_curl.c Thu Apr 9 10:28:52 2009
@@ -240,7 +240,7 @@
/*.next */ NULL
};
-SWITCH_MOD_DECLARE(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
{
curl_global_init(CURL_GLOBAL_ALL);
*module_interface = &curl_module_interface;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_odbc/mod_spidermonkey_odbc.c Thu Apr 9 10:28:52 2009
@@ -533,7 +533,7 @@
/*.next */ NULL
};
-SWITCH_MOD_DECLARE(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
{
*module_interface = &odbc_module_interface;
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c Thu Apr 9 10:28:52 2009
@@ -324,7 +324,7 @@
/*.next */ NULL
};
-SWITCH_MOD_DECLARE(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
{
*module_interface = &socket_module_interface;
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_teletone/mod_spidermonkey_teletone.c Thu Apr 9 10:28:52 2009
@@ -346,7 +346,7 @@
/*.next */ NULL
};
-SWITCH_MOD_DECLARE(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
{
*module_interface = &teletone_module_interface;
return SWITCH_STATUS_SUCCESS;
1
0
09 Apr '09
Author: stkn
Date: Thu Apr 9 10:14:18 2009
New Revision: 12959
Log:
Fix C99 error, move var declaration out of the "for()" statement (no -std=c99?)
Modified:
freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c
Modified: freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c Thu Apr 9 10:14:18 2009
@@ -276,7 +276,8 @@
}
} else if (!strcasecmp(subcmd, "status")) {
switch_bool_t verbose = SWITCH_FALSE;
-
+ int x;
+
if (argc > 1) {
if (!strcasecmp(argv[1], "verbose")) {
verbose = SWITCH_TRUE;
@@ -291,7 +292,7 @@
server_list = memcached_server_list(memcached);
server_count = memcached_server_count(memcached);
stream->write_function(stream, "Servers: %d\n", server_count);
- for (int x=0; x < server_count; x++) {
+ for (x = 0; x < server_count; x++) {
stream->write_function(stream, " %s (%u)\n", memcached_server_name(memcached, server_list[x]), memcached_server_port(memcached, server_list[x]));
if (verbose == SWITCH_TRUE) {
char **list;
1
0
Author: anthm
Date: Thu Apr 9 08:13:59 2009
New Revision: 12958
Log:
add missing begin/end allow threads to read and play_and_get_digits methods
Modified:
freeswitch/trunk/src/switch_cpp.cpp
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Thu Apr 9 08:13:59 2009
@@ -755,7 +755,10 @@
timeout = 1;
}
+ begin_allow_threads();
switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, NULL, dtmf_buf, sizeof(dtmf_buf), timeout, valid_terminators);
+ end_allow_threads();
+
return dtmf_buf;
}
@@ -774,6 +777,7 @@
this_check((char *)"");
begin_allow_threads();
memset(dtmf_buf, 0, sizeof(dtmf_buf));
+ begin_allow_threads();
status = switch_play_and_get_digits( session,
(uint32_t) min_digits,
(uint32_t) max_digits,
@@ -786,6 +790,7 @@
dtmf_buf,
sizeof(dtmf_buf),
digits_regex);
+ end_allow_threads();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playAndGetDigits dtmf_buf: %s\n", dtmf_buf);
1
0
09 Apr '09
Author: anthm
Date: Thu Apr 9 07:48:42 2009
New Revision: 12957
Log:
MODAPP-253
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Thu Apr 9 07:48:42 2009
@@ -40,7 +40,7 @@
SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt)
{
switch_caller_extension_t *extension = NULL;
- char *argv[4] = { 0 };
+ char *argv[128] = { 0 };
int argc;
switch_channel_t *channel = switch_core_session_get_channel(session);
int x = 0;
1
0