forked from Mirrors/freeswitch
iax
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@91 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
46b0e12a66
commit
655338b453
|
@ -181,6 +181,8 @@ static void audio_bridge_function(switch_core_session *session, char *data)
|
|||
|
||||
if (switch_core_session_outgoing_channel(session, chan_type, caller_profile, &peer_session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "DOH!\n");
|
||||
switch_channel_hangup(caller_channel);
|
||||
return;
|
||||
} else {
|
||||
struct switch_core_thread_session this_audio_thread, other_audio_thread;
|
||||
time_t start;
|
||||
|
|
|
@ -88,15 +88,17 @@ struct private_object {
|
|||
};
|
||||
|
||||
#ifdef WIN32
|
||||
void gettimeofday( struct timeval* tv, void* tz )
|
||||
{
|
||||
struct _timeb curSysTime;
|
||||
_ftime(&curSysTime);
|
||||
tv->tv_sec = curSysTime.time;
|
||||
tv->tv_usec = curSysTime.millitm * 1000;
|
||||
#include <Mmsystem.h>
|
||||
|
||||
return ;
|
||||
int gettimeofday(struct timeval *tp, void *tz)
|
||||
{
|
||||
DWORD now;
|
||||
now = timeGetTime();
|
||||
tp->tv_sec = now / 1000;
|
||||
tp->tv_usec = (now % 1000) * 1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
static void set_global_dialplan(char *dialplan)
|
||||
{
|
||||
|
@ -444,6 +446,7 @@ static switch_status channel_on_hangup(switch_core_session *session)
|
|||
assert(tech_pvt != NULL);
|
||||
|
||||
switch_clear_flag(tech_pvt, TFLAG_IO);
|
||||
switch_thread_cond_signal(tech_pvt->cond);
|
||||
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
|
@ -615,20 +618,27 @@ static switch_status channel_read_frame(switch_core_session *session, switch_fra
|
|||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
//tech_pvt->read_frame.datalen = 0;
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
switch_thread_cond_wait(tech_pvt->cond, tech_pvt->mutex);
|
||||
while (switch_test_flag(tech_pvt, TFLAG_IO) && !switch_test_flag(tech_pvt, TFLAG_VOICE)) {
|
||||
switch_yield(1000);
|
||||
}
|
||||
|
||||
for(;;) {
|
||||
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
//printf("WTF %d\n", tech_pvt->read_frame.datalen);
|
||||
*frame = &tech_pvt->read_frame;
|
||||
switch_clear_flag(tech_pvt, TFLAG_VOICE);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
switch_thread_cond_wait(tech_pvt->cond, tech_pvt->mutex);
|
||||
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
while (switch_test_flag(tech_pvt, TFLAG_IO) && !switch_test_flag(tech_pvt, TFLAG_VOICE)) {
|
||||
switch_yield(1000);
|
||||
}
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
switch_clear_flag(tech_pvt, TFLAG_VOICE);
|
||||
if(!tech_pvt->read_frame.datalen) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*frame = &tech_pvt->read_frame;
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
@ -645,11 +655,15 @@ static switch_status channel_write_frame(switch_core_session *session, switch_fr
|
|||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
if(!switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
|
||||
switch_swap_linear(frame->data, frame->datalen / 2);
|
||||
switch_swap_linear(frame->data, (int)frame->datalen / 2);
|
||||
}
|
||||
|
||||
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, frame->datalen, tech_pvt->write_codec.implementation->samples_per_frame);
|
||||
iax_send_voice(tech_pvt->iax_session, tech_pvt->codec, frame->data, (int)frame->datalen, tech_pvt->write_codec.implementation->samples_per_frame);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
|
@ -710,6 +724,10 @@ static const switch_loadable_module_interface channel_module_interface = {
|
|||
|
||||
|
||||
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface) {
|
||||
|
||||
#ifdef WIN32
|
||||
timeBeginPeriod(1);
|
||||
#endif
|
||||
|
||||
if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
|
||||
|
@ -920,8 +938,8 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
|
|||
|
||||
switch_clear_flag(tech_pvt, TFLAG_IO);
|
||||
switch_clear_flag(tech_pvt, TFLAG_VOICE);
|
||||
|
||||
if ((channel = switch_core_session_get_channel(tech_pvt->session))) {
|
||||
switch_thread_cond_signal(tech_pvt->cond);
|
||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hangup %s\n", switch_channel_get_name(channel));
|
||||
switch_set_flag(tech_pvt, TFLAG_HANGUP);
|
||||
switch_channel_hangup(channel);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual C++ Express 2005
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeSwitchConsole", "FreeSwitchConsole.vcproj", "{1AF3A893-F7BE-43DD-B697-8AB2397C0D67}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF}
|
||||
|
@ -107,14 +107,4 @@ Global
|
|||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{DCC13474-28DF-47CA-A8EB-72F8CE9A78C5} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
{2988EB83-785F-45D4-8731-8E1E4345177E} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
{45DF84ED-D24A-4FF6-B5B0-0A9A5FDB9552} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
{B1FE4613-3F4B-4DAF-9714-2472BF8F56AE} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
{78100236-7CEA-4948-96CC-E8ED3160329C} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
{5844AFE1-AA3E-4BDB-A9EF-119AEF19DF88} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
{FE3540C5-3303-46E0-A69E-D92F775687F1} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
{E1794405-29D4-466D-9BE3-DD2344C2A663} = {AC923B27-D665-490E-94F5-FA40E1607FB6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="libapr-1.lib libiax2.lib Ws2_32.lib Iphlpapi.lib"
|
||||
AdditionalDependencies="libapr-1.lib Ws2_32.lib Iphlpapi.lib libiax2.lib Winmm.lib"
|
||||
OutputFile="$(OutDir)/mod/mod_IaxChan.dll"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="$(InputDir)..\..\libs\apr\Debug;$(InputDir)..\..\libs\iax\Debug"
|
||||
|
|
Loading…
Reference in New Issue