提交 1b5daa6b authored 作者: Anthony Minessale's avatar Anthony Minessale

add adjustable buffering to mod_shout (see example in config file)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5303 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 5ce66989
...@@ -9,6 +9,7 @@ int PySession::streamfile(char *file, PyObject *pyfunc, char *funcargs, int star ...@@ -9,6 +9,7 @@ int PySession::streamfile(char *file, PyObject *pyfunc, char *funcargs, int star
switch_input_args_t args = { 0 }, *ap = NULL; switch_input_args_t args = { 0 }, *ap = NULL;
struct input_callback_state cb_state = { 0 }; struct input_callback_state cb_state = { 0 };
switch_file_handle_t fh = { 0 }; switch_file_handle_t fh = { 0 };
char *prebuf;
sanity_check(-1); sanity_check(-1);
cb_state.funcargs = funcargs; cb_state.funcargs = funcargs;
...@@ -31,6 +32,13 @@ int PySession::streamfile(char *file, PyObject *pyfunc, char *funcargs, int star ...@@ -31,6 +32,13 @@ int PySession::streamfile(char *file, PyObject *pyfunc, char *funcargs, int star
ap = &args; ap = &args;
} }
if ((prebuf = switch_channel_get_variable(this->channel, "stream_prebuffer"))) {
int maybe = atoi(prebuf);
if (maybe > 0) {
fh.prebuf = maybe;
}
}
this->begin_allow_threads(); this->begin_allow_threads();
cb_state.threadState = threadState; // pass threadState so the dtmfhandler can pick it up cb_state.threadState = threadState; // pass threadState so the dtmfhandler can pick it up
......
...@@ -1357,6 +1357,7 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv ...@@ -1357,6 +1357,7 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv
switch_file_handle_t fh = { 0 }; switch_file_handle_t fh = { 0 };
JSFunction *function; JSFunction *function;
switch_input_args_t args = { 0 }; switch_input_args_t args = { 0 };
char *prebuf;
if (!jss || !jss->session) { if (!jss || !jss->session) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "You must call the session.originate method before calling this method!\n");
...@@ -1404,6 +1405,14 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv ...@@ -1404,6 +1405,14 @@ static JSBool session_streamfile(JSContext * cx, JSObject * obj, uintN argc, jsv
JS_ValueToInt32(cx, argv[3], &samps); JS_ValueToInt32(cx, argv[3], &samps);
fh.samples = samps; fh.samples = samps;
} }
if ((prebuf = switch_channel_get_variable(channel, "stream_prebuffer"))) {
int maybe = atoi(prebuf);
if (maybe > 0) {
fh.prebuf = maybe;
}
}
cb_state.extra = &fh; cb_state.extra = &fh;
cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE); cb_state.ret = BOOLEAN_TO_JSVAL(JS_FALSE);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论