Freeswitch-trunk
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
September 2006
- 6 participants
- 257 discussions
[commit] r2752 - in freeswitch/trunk/src: . mod/applications/mod_commands mod/endpoints/mod_iax
by Freeswitch SVN 19 Sep '06
by Freeswitch SVN 19 Sep '06
19 Sep '06
Author: anthm
Date: Tue Sep 19 11:33:02 2006
New Revision: 2752
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_core.c
freeswitch/trunk/src/switch_ivr.c
Log:
fix a bunch of stuff you want this version
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Tue Sep 19 11:33:02 2006
@@ -126,7 +126,6 @@
if (dest && (session = switch_core_session_locate(dest))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
- switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
switch_core_session_rwunlock(session);
stream->write_function(stream, "OK\n");
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 Tue Sep 19 11:33:02 2006
@@ -952,12 +952,10 @@
if (globals.calls == 0) {
waitlen = 10000;
- } else if (globals.calls == 1) {
- waitlen = 1000;
} else if (globals.calls < 10) {
- waitlen = 100;
+ waitlen = 1000;
} else {
- waitlen = 10;
+ waitlen = 500;
}
switch_yield(waitlen);
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Tue Sep 19 11:33:02 2006
@@ -846,12 +846,14 @@
for (index = 0; index < SWITCH_MAX_STATE_HANDLERS; index++) {
channel->state_handlers[index] = NULL;
}
+
if (state_handler) {
for (index = 0; index < i; index++) {
channel->state_handlers[index] = new_handlers[i];
}
}
+ channel->state_handler_index = i;
}
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel,
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Tue Sep 19 11:33:02 2006
@@ -2892,9 +2892,6 @@
endstate = switch_channel_get_state(session->channel);
- if (endstate >= CS_HANGUP) {
- goto done;
- }
if (midstate == endstate) {
switch_thread_cond_wait(session->cond, session->mutex);
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Tue Sep 19 11:33:02 2006
@@ -1354,7 +1354,11 @@
switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
}
switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
-
+
+ if (!switch_channel_test_flag(channel, CF_TRANSFER)) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ }
+
return SWITCH_STATUS_FALSE;
}
@@ -1406,23 +1410,33 @@
assert(channel != NULL);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM TRANSMIT\n");
+ switch_channel_clear_state_handler(channel, NULL);
+ if (!switch_channel_test_flag(channel, CF_ORIGINATOR)) {
+ switch_channel_set_flag(channel, CF_TAGGED);
+ return SWITCH_STATUS_FALSE;
+ }
+
if ((other_session = switch_channel_get_private(channel, "_uuid_bridge_"))) {
switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
switch_channel_state_t state = switch_channel_get_state(other_channel);
+ switch_channel_state_t mystate = switch_channel_get_state(channel);
switch_event_t *event;
uint8_t ready_a, ready_b;
switch_caller_profile_t *profile, *new_profile;
+ switch_channel_clear_flag(channel, CF_TRANSFER);
switch_channel_set_private(channel, "_uuid_bridge_", NULL);
- while (state <= CS_HANGUP && state != CS_TRANSMIT) {
+
+ while (mystate <= CS_HANGUP && state <= CS_HANGUP && !switch_channel_test_flag(other_channel, CF_TAGGED)) {
switch_yield(1000);
state = switch_channel_get_state(other_channel);
+ mystate = switch_channel_get_state(channel);
}
- switch_channel_clear_flag(channel, CF_TRANSFER);
- switch_channel_clear_flag(other_channel, CF_TRANSFER);
+ switch_channel_clear_flag(other_channel, CF_TRANSFER|CF_TAGGED);
+
switch_core_session_reset(session);
switch_core_session_reset(other_session);
@@ -2053,7 +2067,11 @@
switch_channel_event_set_data(caller_channel, event);
switch_event_fire(&event);
}
-
+
+ if (switch_channel_get_state(caller_channel) != CS_EXECUTE && !switch_channel_test_flag(caller_channel, CF_TRANSFER)) {
+ switch_channel_hangup(caller_channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ }
+
this_audio_thread->objs[0] = NULL;
this_audio_thread->objs[1] = NULL;
this_audio_thread->objs[2] = NULL;
@@ -2063,13 +2081,7 @@
switch_mutex_lock(this_audio_thread->mutex);
this_audio_thread->running = 0;
switch_mutex_unlock(this_audio_thread->mutex);
-
- if (!switch_channel_test_flag(peer_channel, CF_TRANSFER) &&
- switch_channel_get_state(peer_channel) < CS_HANGUP) {
- switch_core_session_kill_channel(peer_session, SWITCH_SIG_KILL);
- switch_channel_hangup(peer_channel, SWITCH_CAUSE_NORMAL_CLEARING);
- }
-
+
switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
if (other_audio_thread->running > 0) {
@@ -2118,8 +2130,12 @@
* inturrupt anything they are already doing.
* originatee_session will fall asleep and originator_session will bridge to it
*/
-
+
+ switch_channel_clear_state_handler(originator_channel, NULL);
+ switch_channel_clear_state_handler(originatee_channel, NULL);
+ switch_channel_set_flag(originator_channel, CF_ORIGINATOR);
switch_channel_add_state_handler(originator_channel, &uuid_bridge_state_handlers);
+ switch_channel_add_state_handler(originatee_channel, &uuid_bridge_state_handlers);
switch_channel_set_private(originator_channel, "_uuid_bridge_", originatee_session);
/* switch_channel_set_state_flag sets flags you want to be set when the next stat change happens */
1
0
[commit] r2750 - in freeswitch/trunk/src/dotnet: . Marshaling Marshaling/Types Switch Types
by Freeswitch SVN 19 Sep '06
by Freeswitch SVN 19 Sep '06
19 Sep '06
Author: james
Date: Tue Sep 19 08:47:44 2006
New Revision: 2750
Added:
freeswitch/trunk/src/dotnet/Ivr.cs
freeswitch/trunk/src/dotnet/Log.cs
freeswitch/trunk/src/dotnet/Marshaling/CodecMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/SpeechHandleMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/TimerMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/TimerMarshal.cs
freeswitch/trunk/src/dotnet/Switch/Event.cs
freeswitch/trunk/src/dotnet/Switch/Log.cs
freeswitch/trunk/src/dotnet/Types/Codec.cs
freeswitch/trunk/src/dotnet/Types/EventCallback.cs
freeswitch/trunk/src/dotnet/Types/EventType.cs
freeswitch/trunk/src/dotnet/Types/LogLevel.cs
freeswitch/trunk/src/dotnet/Types/SpeechHandle.cs
freeswitch/trunk/src/dotnet/Types/StateHandlerTable.cs
freeswitch/trunk/src/dotnet/Types/Timer.cs
Modified:
freeswitch/trunk/src/dotnet/Common.cs
freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj
freeswitch/trunk/src/dotnet/Makefile
freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs
freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs
freeswitch/trunk/src/dotnet/Module.cs
freeswitch/trunk/src/dotnet/Switch/Channel.cs
freeswitch/trunk/src/dotnet/Switch/Ivr.cs
freeswitch/trunk/src/dotnet/Types/Channel.cs
freeswitch/trunk/src/dotnet/Types/CoreSession.cs
freeswitch/trunk/src/dotnet/Types/Event.cs
freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs
freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs
freeswitch/trunk/src/dotnet/Types/Module.cs
freeswitch/trunk/src/dotnet/Types/StreamHandle.cs
Log:
Update, changing core assembly name to FreeSwitch.NET.dll as to not conflict with the real freeswitch.dll on Windows.
Modified: freeswitch/trunk/src/dotnet/Common.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Common.cs (original)
+++ freeswitch/trunk/src/dotnet/Common.cs Tue Sep 19 08:47:44 2006
@@ -32,7 +32,7 @@
using System;
using System.Reflection;
-namespace FreeSwitch.NET
+namespace FreeSwitch
{
public class Common
{
Modified: freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj
==============================================================================
--- freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj (original)
+++ freeswitch/trunk/src/dotnet/FreeSwitch.NET.csproj Tue Sep 19 08:47:44 2006
@@ -7,8 +7,8 @@
<ProjectGuid>{251CAABC-16C3-4593-A491-603B908094E0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>FreeSwitch.NET</RootNamespace>
- <AssemblyName>Freeswitch</AssemblyName>
+ <RootNamespace>FreeSwitch</RootNamespace>
+ <AssemblyName>FreeSwitch.NET</AssemblyName>
<StartupObject>
</StartupObject>
<SignAssembly>true</SignAssembly>
@@ -42,11 +42,17 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Common.cs" />
+ <Compile Include="Log.cs" />
+ <Compile Include="Ivr.cs" />
<Compile Include="Marshaling\BufferMarshaler.cs" />
<Compile Include="Marshaling\CallerExtensionMarshaler.cs" />
<Compile Include="Marshaling\CallerProfileMarshaler.cs" />
<Compile Include="Marshaling\ChannelMarshaler.cs" />
<Compile Include="Marshaling\ChannelTimetableMarshaler.cs" />
+ <Compile Include="Marshaling\CodecMarshaler.cs" />
+ <Compile Include="Marshaling\StateHandlerTableMarshaler.cs" />
+ <Compile Include="Marshaling\TimerMarshaler.cs" />
+ <Compile Include="Marshaling\SpeechHandleMarshaler.cs" />
<Compile Include="Marshaling\StreamHandleMarshaler.cs" />
<Compile Include="Marshaling\CoreSessionMarshaler.cs" />
<Compile Include="Marshaling\EventMarshaler.cs" />
@@ -65,6 +71,9 @@
<Compile Include="Marshaling\Types\CodecInterfaceMarshal.cs" />
<Compile Include="Marshaling\Types\CodecMarshal.cs" />
<Compile Include="Marshaling\Types\CodecTypeMarshal.cs" />
+ <Compile Include="Marshaling\Types\StateHandlerTableMarshal.cs" />
+ <Compile Include="Marshaling\Types\TimerMarshal.cs" />
+ <Compile Include="Marshaling\Types\SpeechHandleMarshal.cs" />
<Compile Include="Marshaling\Types\StreamHandleMarshal.cs" />
<Compile Include="Marshaling\Types\TypesMarshal.cs" />
<Compile Include="Marshaling\Types\FileHandleMarshal.cs" />
@@ -79,6 +88,8 @@
<Compile Include="Switch\CallerProfile.cs" />
<Compile Include="Switch\Channel.cs" />
<Compile Include="Switch\Console.cs" />
+ <Compile Include="Switch\Log.cs" />
+ <Compile Include="Switch\Event.cs" />
<Compile Include="Switch\StreamHandle.cs" />
<Compile Include="Switch\CoreSession.cs" />
<Compile Include="Switch\Ivr.cs" />
@@ -96,6 +107,13 @@
<Compile Include="Modules\Application.cs" />
<Compile Include="Types\ApplicationFunction.cs" />
<Compile Include="Types\CallCause.cs" />
+ <Compile Include="Types\Codec.cs" />
+ <Compile Include="Types\LogLevel.cs" />
+ <Compile Include="Types\StateHandlerTable.cs" />
+ <Compile Include="Types\Timer.cs" />
+ <Compile Include="Types\SpeechHandle.cs" />
+ <Compile Include="Types\EventCallback.cs" />
+ <Compile Include="Types\EventType.cs" />
<Compile Include="Types\InputCallbackFunction.cs" />
<Compile Include="Types\InputType.cs" />
<Compile Include="Types\ModuleInterfaces.cs" />
Added: freeswitch/trunk/src/dotnet/Ivr.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Ivr.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using FreeSwitch.Types;
+using FreeSwitch.Marshaling.Types;
+
+namespace FreeSwitch
+{
+ public class Ivr
+ {
+ public static Status MultiThreadedBridge(CoreSession session, CoreSession peerSession, InputCallbackFunction dtmfCallback)
+ {
+ return Switch.switch_ivr_multi_threaded_bridge(session, peerSession, dtmfCallback, IntPtr.Zero, IntPtr.Zero);
+ }
+
+ public static Status Originate(CoreSession session, CoreSession peerSession, CallCause callCause, string data, uint timelimit)
+ {
+ IntPtr callCausePtr = Marshal.AllocHGlobal(4);
+ IntPtr dataPtr = Marshal.StringToHGlobalAnsi(data);
+
+ Marshal.StructureToPtr(callCause, callCausePtr, true);
+
+ return Switch.switch_ivr_originate(session, ref peerSession, callCausePtr, dataPtr, timelimit, null, null, null, null);
+ }
+
+ public static Status RecordFile(CoreSession coreSession, FileHandle fileHandle, string file, DtmfCallbackFunction dtmfCallbackFunction)
+ {
+ Byte[] filename = Encoding.Default.GetBytes(file);
+
+ Console.WriteLine("File: {0}", file);
+
+ dtmfCallbackFunction(coreSession, "1");
+ dtmfCallbackFunction(coreSession, "2");
+ dtmfCallbackFunction(coreSession, "3");
+
+ Encoding ansiEncoding = Encoding.GetEncoding(1252);
+ //filename = Encoding.Convert(Encoding.Default, ansiEncoding, filename);
+
+ Console.WriteLine("Filename: {0}", file);
+ //Console.WriteLine("Status record: {0}", status.ToString());
+ return Status.Success;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/src/dotnet/Log.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Log.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,16 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using FreeSwitch.Types;
+using FreeSwitch.Marshaling.Types;
+
+namespace FreeSwitch
+{
+ public class Log
+ {
+ public static void Printf(LogLevel level, string message)
+ {
+ Switch.switch_log_printf(null, "File", "Func.NET", 123, level, message);
+ }
+ }
+}
\ No newline at end of file
Modified: freeswitch/trunk/src/dotnet/Makefile
==============================================================================
--- freeswitch/trunk/src/dotnet/Makefile (original)
+++ freeswitch/trunk/src/dotnet/Makefile Tue Sep 19 08:47:44 2006
@@ -2,7 +2,7 @@
$(MODNAME).so:
/usr/local/freeswitch/bin/gmcs -debug -unsafe -t:library -keyfile:public.snk \
- -out:FreeSwitch.dll -reference:Mono.Posix.dll \
+ -out:FreeSwitch.NET.dll -reference:Mono.Posix.dll \
Properties/AssemblyInfo.cs \
Marshaling/Types/ApiInterfaceMarshal.cs \
Marshaling/Types/ApplicationInterfaceMarshal.cs \
@@ -24,26 +24,35 @@
Marshaling/Types/IOEventHooksMarshal.cs \
Marshaling/Types/LoadableModuleInterfaceMarshal.cs \
Marshaling/Types/LoadableModuleMarshal.cs \
+ Marshaling/Types/SpeechHandleMarshal.cs \
+ Marshaling/Types/StateHandlerTableMarshal.cs \
Marshaling/Types/StreamHandleMarshal.cs \
Marshaling/Types/TypesMarshal.cs \
+ Marshaling/Types/TimerMarshal.cs \
Marshaling/BufferMarshaler.cs \
Marshaling/CallerExtensionMarshaler.cs \
Marshaling/CallerProfileMarshaler.cs \
Marshaling/ChannelMarshaler.cs \
Marshaling/ChannelTimetableMarshaler.cs \
+ Marshaling/CodecMarshaler.cs \
Marshaling/CoreSessionMarshaler.cs \
Marshaling/EventMarshaler.cs \
Marshaling/FileHandleMarshaler.cs \
Marshaling/MemoryPoolMarshaler.cs \
+ Marshaling/SpeechHandleMarshaler.cs \
+ Marshaling/StateHandlerTableMarshaler.cs \
Marshaling/StreamHandleMarshaler.cs \
+ Marshaling/TimerMarshaler.cs \
Modules/Api.cs \
Modules/Application.cs \
Switch/CallerProfile.cs \
Switch/Channel.cs \
Switch/Console.cs \
Switch/CoreSession.cs \
+ Switch/Event.cs \
Switch/Ivr.cs \
Switch/LoadableModule.cs \
+ Switch/Log.cs \
Switch/StreamHandle.cs \
Types/ApiFunction.cs \
Types/ApplicationFunction.cs \
@@ -56,24 +65,33 @@
Types/ChannelFlag.cs \
Types/ChannelState.cs \
Types/ChannelTimetable.cs \
+ Types/Codec.cs \
Types/CoreSession.cs \
Types/DtmfCallbackFunction.cs \
Types/InputCallbackFunction.cs \
Types/InputType.cs \
Types/Event.cs \
+ Types/EventCallback.cs \
+ Types/EventType.cs \
Types/FileHandle.cs \
Types/LoadableModule.cs \
Types/LoadableModuleInterface.cs \
+ Types/LogLevel.cs \
Types/MemoryPool.cs \
Types/Module.cs \
Types/Status.cs \
+ Types/SpeechHandle.cs \
+ Types/StateHandlerTable.cs \
Types/StreamHandle.cs \
Types/TextChannel.cs \
+ Types/Timer.cs \
Common.cs \
Module.cs \
+ Ivr.cs \
+ Log.cs \
clean:
rm -fr *.dll
install:
- cp -f FreeSwitch.dll /usr/local/freeswitch/lib/
+ cp -f FreeSwitch.NET.dll /usr/local/freeswitch/lib/
Added: freeswitch/trunk/src/dotnet/Marshaling/CodecMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/CodecMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,82 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * CodecMarshaler.cs --
+ *
+ */
+using System;
+using System.Collections;
+using FreeSwitch.Marshaling.Types;
+using FreeSwitch.Types;
+using System.Runtime.InteropServices;
+
+namespace FreeSwitch.Marshaling
+{
+ class CodecMarshaler : ICustomMarshaler
+ {
+ private static CodecMarshaler Instance = new CodecMarshaler();
+
+ public static ICustomMarshaler GetInstance(string s)
+ {
+ return Instance;
+ }
+
+ public void CleanUpManagedData(object o)
+ {
+ }
+
+ public void CleanUpNativeData(IntPtr pNativeData)
+ {
+ }
+
+ public int GetNativeDataSize()
+ {
+ return IntPtr.Size;
+ }
+
+ public IntPtr MarshalManagedToNative(object obj)
+ {
+ Codec streamHandleObj = (Codec)obj;
+
+ return streamHandleObj.marshaledObject.Handle;
+ }
+
+ public object MarshalNativeToManaged(IntPtr codecPtr)
+ {
+ CodecMarshal codecMarshal = new CodecMarshal();
+ Codec codecObj = new Codec();
+
+
+ Marshal.PtrToStructure(codecPtr, codecMarshal);
+
+ codecObj.marshaledObject = new HandleRef(codecMarshal, codecPtr);
+
+ return codecObj;
+ }
+ }
+}
\ No newline at end of file
Modified: freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs (original)
+++ freeswitch/trunk/src/dotnet/Marshaling/CoreSessionMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -61,14 +61,36 @@
public IntPtr MarshalManagedToNative(object obj)
{
CoreSession coreSession = (CoreSession)obj;
-
- return coreSession.marshaledObject.Handle;
+
+ Console.WriteLine("CoreSession: Marshalling Managed to Native");
+
+ if (coreSession.marshaledObject.Handle != IntPtr.Zero)
+ {
+
+ Console.WriteLine("Returning: 0x{0:x}", coreSession.marshaledObject.Handle.ToInt32());
+ return coreSession.marshaledObject.Handle;
+ }
+ else
+ {
+ CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal();
+ IntPtr coreSessionPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CoreSessionMarshal)));
+
+ Marshal.StructureToPtr(coreSessionMarshal, coreSessionPtr, true);
+
+ coreSession.marshaledObject = new HandleRef(coreSessionMarshal, coreSessionPtr);
+
+ Console.WriteLine("CoreSession: NO OBJECT EXISTS OMG");
+ Console.WriteLine("Returning: 0x{0:x}", coreSession.marshaledObject.Handle.ToInt32());
+ return coreSession.marshaledObject.Handle;
+ }
}
public object MarshalNativeToManaged(IntPtr coreSessionPtr)
{
CoreSessionMarshal coreSessionMarshal = new CoreSessionMarshal();
CoreSession coreSession = new CoreSession();
+
+ Console.WriteLine("CoreSession: Marshalling Native to Managed");
Marshal.PtrToStructure(coreSessionPtr, coreSessionMarshal);
Added: freeswitch/trunk/src/dotnet/Marshaling/SpeechHandleMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/SpeechHandleMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,81 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * SpeechHandleMarshaler.cs --
+ *
+ */
+using System;
+using System.Collections;
+using FreeSwitch.Marshaling.Types;
+using FreeSwitch.Types;
+using System.Runtime.InteropServices;
+
+namespace FreeSwitch.Marshaling
+{
+ class SpeechHandleMarshaler : ICustomMarshaler
+ {
+ private static SpeechHandleMarshaler Instance = new SpeechHandleMarshaler();
+
+ public static ICustomMarshaler GetInstance(string s)
+ {
+ return Instance;
+ }
+
+ public void CleanUpManagedData(object o)
+ {
+ }
+
+ public void CleanUpNativeData(IntPtr pNativeData)
+ {
+ }
+
+ public int GetNativeDataSize()
+ {
+ return IntPtr.Size;
+ }
+
+ public IntPtr MarshalManagedToNative(object obj)
+ {
+ SpeechHandle speechHandleObj = (SpeechHandle)obj;
+
+ return speechHandleObj.marshaledObject.Handle;
+ }
+
+ public object MarshalNativeToManaged(IntPtr speechHandlePtr)
+ {
+ SpeechHandleMarshal speechHandleMarshal = new SpeechHandleMarshal();
+ SpeechHandle speechHandleObj = new SpeechHandle();
+
+ Marshal.PtrToStructure(speechHandlePtr, speechHandleMarshal);
+
+ speechHandleObj.marshaledObject = new HandleRef(speechHandleMarshal, speechHandlePtr);
+
+ return speechHandleObj;
+ }
+ }
+}
Added: freeswitch/trunk/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/StateHandlerTableMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,81 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * StateHandlerTableMarshaler.cs --
+ *
+ */
+using System;
+using System.Collections;
+using FreeSwitch.Marshaling.Types;
+using FreeSwitch.Types;
+using System.Runtime.InteropServices;
+
+namespace FreeSwitch.Marshaling
+{
+ class StateHandlerTableMarshaler : ICustomMarshaler
+ {
+ private static StateHandlerTableMarshaler Instance = new StateHandlerTableMarshaler();
+
+ public static ICustomMarshaler GetInstance(string s)
+ {
+ return Instance;
+ }
+
+ public void CleanUpManagedData(object o)
+ {
+ }
+
+ public void CleanUpNativeData(IntPtr pNativeData)
+ {
+ }
+
+ public int GetNativeDataSize()
+ {
+ return IntPtr.Size;
+ }
+
+ public IntPtr MarshalManagedToNative(object obj)
+ {
+ StateHandlerTable stateHandlerTableObj = (StateHandlerTable)obj;
+
+ return stateHandlerTableObj.marshaledObject.Handle;
+ }
+
+ public object MarshalNativeToManaged(IntPtr stateHandlerTablePtr)
+ {
+ StateHandlerTableMarshal stateHandlerTableMarshal = new StateHandlerTableMarshal();
+ StateHandlerTable stateHandlerTableObj = new StateHandlerTable();
+
+ Marshal.PtrToStructure(stateHandlerTablePtr, stateHandlerTableMarshal);
+
+ stateHandlerTableObj.marshaledObject = new HandleRef(stateHandlerTableMarshal, stateHandlerTablePtr);
+
+ return stateHandlerTableObj;
+ }
+ }
+}
Added: freeswitch/trunk/src/dotnet/Marshaling/TimerMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/TimerMarshaler.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,81 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * TimerMarshaler.cs --
+ *
+ */
+using System;
+using System.Collections;
+using FreeSwitch.Marshaling.Types;
+using FreeSwitch.Types;
+using System.Runtime.InteropServices;
+
+namespace FreeSwitch.Marshaling
+{
+ class TimerMarshaler : ICustomMarshaler
+ {
+ private static TimerMarshaler Instance = new TimerMarshaler();
+
+ public static ICustomMarshaler GetInstance(string s)
+ {
+ return Instance;
+ }
+
+ public void CleanUpManagedData(object o)
+ {
+ }
+
+ public void CleanUpNativeData(IntPtr pNativeData)
+ {
+ }
+
+ public int GetNativeDataSize()
+ {
+ return IntPtr.Size;
+ }
+
+ public IntPtr MarshalManagedToNative(object obj)
+ {
+ Timer timerObj = (Timer)obj;
+
+ return timerObj.marshaledObject.Handle;
+ }
+
+ public object MarshalNativeToManaged(IntPtr timerPtr)
+ {
+ TimerMarshal timerMarshal = new TimerMarshal();
+ Timer timerObj = new Timer();
+
+ Marshal.PtrToStructure(timerPtr, timerMarshal);
+
+ timerObj.marshaledObject = new HandleRef(timerMarshal, timerPtr);
+
+ return timerObj;
+ }
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs (original)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/CodecMarshal.cs Tue Sep 19 08:47:44 2006
@@ -38,9 +38,9 @@
{
internal IntPtr codec_interface;
internal IntPtr implementation;
- //internal CodecSettingsMarshal codec_settings;
+ internal IntPtr codec_settings;
internal UInt32 flags;
- //internal MemoryPoolMarshal memory_pool;
+ internal IntPtr memory_pool;
internal IntPtr private_info;
}
}
Added: freeswitch/trunk/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/SpeechHandleMarshal.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,53 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * SpeechHandleMarshal.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Types;
+
+namespace FreeSwitch.Marshaling.Types
+{
+ [StructLayout(LayoutKind.Sequential)]
+ internal class SpeechHandleMarshal
+ {
+ internal IntPtr speech_interface;
+ internal UInt32 flags;
+ internal IntPtr name;
+ internal UInt32 rate;
+ internal UInt32 speed;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=80)]
+ internal byte[] voice;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=80)]
+ internal byte[] engine;
+ internal IntPtr memory_pool;
+ internal IntPtr private_info;
+ }
+}
Added: freeswitch/trunk/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/StateHandlerTableMarshal.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,49 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * StateHandlerTableMarshal.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Types;
+
+namespace FreeSwitch.Marshaling.Types
+{
+ [StructLayout(LayoutKind.Sequential)]
+ internal class StateHandlerTableMarshal
+ {
+ internal IntPtr on_init;
+ internal IntPtr on_ring;
+ internal IntPtr on_execute;
+ internal IntPtr on_hangup;
+ internal IntPtr on_loopback;
+ internal IntPtr on_transmit;
+ internal IntPtr on_hold;
+ }
+}
\ No newline at end of file
Modified: freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs (original)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/StreamHandleMarshal.cs Tue Sep 19 08:47:44 2006
@@ -43,6 +43,8 @@
internal IntPtr end;
internal int data_size;
internal int data_len;
+ internal int alloc_len;
+ internal int alloc_chunk;
internal IntPtr _event;
}
}
Added: freeswitch/trunk/src/dotnet/Marshaling/Types/TimerMarshal.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Marshaling/Types/TimerMarshal.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,49 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * TimerMarshal.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Types;
+
+namespace FreeSwitch.Marshaling.Types
+{
+ [StructLayout(LayoutKind.Sequential)]
+ internal class TimerMarshal
+ {
+ int interval;
+ UInt32 flags;
+ uint samples;
+ uint samplecount;
+ IntPtr timer_interface;
+ IntPtr memory_pool;
+ IntPtr private_info;
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Module.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Module.cs (original)
+++ freeswitch/trunk/src/dotnet/Module.cs Tue Sep 19 08:47:44 2006
@@ -34,12 +34,11 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
-using FreeSwitch.NET;
using FreeSwitch.Types;
using FreeSwitch.Modules;
using FreeSwitch.Marshaling.Types;
-namespace FreeSwitch.NET
+namespace FreeSwitch
{
/// <summary>
/// Base class for all Freeswitch.NET modules
@@ -92,20 +91,26 @@
/* Set the module_name field of the LoadableModuleInterface */
module_interface.module_name = Marshal.StringToHGlobalAnsi(filename);
- /* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/
- Api apiIndex = (Api)apiInterfaces[0];
-
- module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal)));
-
- Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true);
-
- /* For each Application interface */
- Application applicationIndex = (Application)applicationInterfaces[0];
-
- module_interface.application_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApplicationInterfaceMarshal)));
-
- Marshal.StructureToPtr(applicationIndex.handle.Wrapper, module_interface.application_interface, true);
+ if (apiInterfaces.Count > 0)
+ {
+ /* Grab the first ApiInterface in our array and add a pointer to this in our ModuleInterface*/
+ Api apiIndex = (Api)apiInterfaces[0];
+ module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal)));
+
+ Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true);
+ }
+
+ if (applicationInterfaces.Count > 0)
+ {
+ /* For each Application interface */
+ Application applicationIndex = (Application)applicationInterfaces[0];
+
+ module_interface.application_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApplicationInterfaceMarshal)));
+
+ Marshal.StructureToPtr(applicationIndex.handle.Wrapper, module_interface.application_interface, true);
+ }
+
/* Finally, marshal the moduleinterface class and return */
Marshal.StructureToPtr(module_interface, module, true);
@@ -200,6 +205,10 @@
module.module_shutdown);
}
-
+ public string Name
+ {
+ set { name = value; }
+ get { return name; }
+ }
}
}
Modified: freeswitch/trunk/src/dotnet/Switch/Channel.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Switch/Channel.cs (original)
+++ freeswitch/trunk/src/dotnet/Switch/Channel.cs Tue Sep 19 08:47:44 2006
@@ -85,6 +85,15 @@
Channel channel);
[DllImport("freeswitch")]
+ [return: MarshalAs(UnmanagedType.LPStr)]
+ public extern static
+ string switch_channel_get_variable(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))]
+ Channel channel,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string varname);
+
+ [DllImport("freeswitch")]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
public extern static
CallerProfile switch_channel_get_originator_caller_profile(
Added: freeswitch/trunk/src/dotnet/Switch/Event.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Switch/Event.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,52 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * Channel.cs --
+ *
+ */
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using FreeSwitch.Types;
+using FreeSwitch.Marshaling;
+
+namespace FreeSwitch
+{
+ public partial class Switch
+ {
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_event_bind(
+ [MarshalAs(UnmanagedType.LPStr)]
+ string id,
+ EventType eventType,
+ string subClassName,
+ EventCallback callback,
+ IntPtr userData);
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Switch/Ivr.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Switch/Ivr.cs (original)
+++ freeswitch/trunk/src/dotnet/Switch/Ivr.cs Tue Sep 19 08:47:44 2006
@@ -41,11 +41,66 @@
public partial class Switch
{
[DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_sleep(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ UInt32 ms);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_park(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_collect_digits_callback(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ InputCallbackFunction dtmfCallback,
+ IntPtr buf,
+ uint buflen);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_collect_digits_count(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string buffer,
+ uint buflen,
+ uint maxdigits,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string terminators,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string terminator,
+ uint timeout);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_record_session(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string file,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
+ FileHandle fh);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_stop_record_session(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string file);
+
+ [DllImport("freeswitch")]
extern public static
Status switch_ivr_play_file(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))]
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(FileHandleMarshaler))]
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
FileHandle fh,
[MarshalAs(UnmanagedType.LPStr)]
string file,
@@ -57,26 +112,91 @@
[DllImport("freeswitch")]
public extern static
+ Status switch_ivr_record_file(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
+ FileHandle fh,
+ IntPtr file,
+ InputCallbackFunction input_callback,
+ IntPtr buf,
+ uint buflen);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_speak_text_handle(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(SpeechHandleMarshaler))]
+ SpeechHandle sh,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CodecMarshaler))]
+ Codec codec,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(TimerMarshaler))]
+ Timer timer,
+ InputCallbackFunction dtmfCallback,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string text,
+ IntPtr buf,
+ uint buflen);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_speak_text(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string tts_name,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string voice_name,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string timer_name,
+ uint rate,
+ InputCallbackFunction dtmfCallback,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string text,
+ IntPtr buf,
+ uint buflen);
+
+ [DllImport("freeswitch")]
+ public extern static
+ Status switch_ivr_originate(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ ref CoreSession bleg,
+ IntPtr cause,
+ IntPtr bridgeto,
+ UInt32 timelimit_sec,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StateHandlerTableMarshaler))]
+ StateHandlerTable table,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string cid_name_override,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string cid_num_override,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
+ CallerProfile caller_profile_override);
+
+ [DllImport("freeswitch")]
+ public extern static
Status switch_ivr_multi_threaded_bridge(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession peer_session,
- uint timelimit,
- IntPtr dtmf_callback,
+ InputCallbackFunction dtmfCallback,
IntPtr session_data,
IntPtr peer_session_data);
[DllImport("freeswitch")]
public extern static
- Status switch_ivr_record_file(
+ Status switch_ivr_session_transfer(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
CoreSession session,
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(FileHandleMarshaler))]
- FileHandle fh,
- IntPtr file,
- InputCallbackFunction input_callback,
- IntPtr buf,
- uint buflen);
+ [MarshalAs(UnmanagedType.LPStr)]
+ string extension,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string dialplan,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string context);
}
}
Added: freeswitch/trunk/src/dotnet/Switch/Log.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Switch/Log.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,62 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * Log.cs --
+ *
+ */
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using FreeSwitch.Types;
+using FreeSwitch.Marshaling;
+using FreeSwitch.Marshaling.Types;
+
+namespace FreeSwitch
+{
+ /*
+ src/switch_log.c:SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level)
+ src/switch_log.c:SWITCH_DECLARE(switch_log_level_t) switch_log_str2level(const char *str)
+ src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_bind_logger(switch_log_function_t function, switch_log_level_t level)
+ src/switch_log.c:SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file, const char *func, int line, switch_log_level_t level, char *fmt, ...)
+ src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool)
+ src/switch_log.c:SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void)
+ */
+ public partial class Switch
+ {
+ [DllImport("freeswitch")]
+ public extern static
+ void switch_log_printf(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
+ Channel channel,
+ string file,
+ string func,
+ int line,
+ LogLevel level,
+ string format);
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Types/Channel.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/Channel.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/Channel.cs Tue Sep 19 08:47:44 2006
@@ -219,5 +219,15 @@
{
return Switch.switch_channel_answer(this);
}
+
+ public ChannelState Hangup(CallCause cause)
+ {
+ return Switch.switch_channel_perform_hangup(this, "file", "func", 666, cause);
+ }
+
+ public string GetVariable(string varname)
+ {
+ return Switch.switch_channel_get_variable(this, varname);
+ }
}
}
Added: freeswitch/trunk/src/dotnet/Types/Codec.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/Codec.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * Codec.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Marshaling;
+using FreeSwitch.Marshaling.Types;
+
+namespace FreeSwitch.Types
+{
+ public class Codec
+ {
+ internal HandleRef marshaledObject;
+
+ }
+}
\ No newline at end of file
Modified: freeswitch/trunk/src/dotnet/Types/CoreSession.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/CoreSession.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/CoreSession.cs Tue Sep 19 08:47:44 2006
@@ -109,7 +109,7 @@
get
{
CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper;
-
+
if (coreSessionMarshal.thread_running <= 0)
return false;
else
Modified: freeswitch/trunk/src/dotnet/Types/Event.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/Event.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/Event.cs Tue Sep 19 08:47:44 2006
@@ -101,20 +101,4 @@
public string Name;
public string Value;
}
-
- public enum EventType
- {
- SWITCH_EVENT_CUSTOM,
- SWITCH_EVENT_CHANNEL_STATE,
- SWITCH_EVENT_CHANNEL_ANSWER,
- SWITCH_EVENT_CHANNEL_HANGUP,
- SWITCH_EVENT_API,
- SWITCH_EVENT_LOG,
- SWITCH_EVENT_INBOUND_CHAN,
- SWITCH_EVENT_OUTBOUND_CHAN,
- SWITCH_EVENT_STARTUP,
- SWITCH_EVENT_SHUTDOWN,
- SWITCH_EVENT_ALL
- }
-
}
Added: freeswitch/trunk/src/dotnet/Types/EventCallback.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/EventCallback.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,41 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * EventCallback.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Marshaling;
+
+namespace FreeSwitch.Types
+{
+ public delegate void EventCallback(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(EventMarshaler))]
+ Event _event);
+}
\ No newline at end of file
Added: freeswitch/trunk/src/dotnet/Types/EventType.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/EventType.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,72 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * EventType.cs --
+ *
+ */
+using System;
+using System.Collections;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace FreeSwitch.Types
+{
+ public enum EventType
+ {
+ Custom,
+ Create,
+ Destroy,
+ State,
+ Answer,
+ Hangup,
+ Execute,
+ Bridge,
+ UnBridge,
+ Progress,
+ Outgoing,
+ Park,
+ UnPark,
+ Api,
+ Log,
+ InboundChan,
+ OutboundChan,
+ Startup,
+ Shutdown,
+ Publish,
+ UnPublish,
+ Talk,
+ NoTalk,
+ SessionCrash,
+ ModuleLoad,
+ Dtmf,
+ Message,
+ Codec,
+ BackgroundJob,
+ All
+ }
+}
\ No newline at end of file
Modified: freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/InputCallbackFunction.cs Tue Sep 19 08:47:44 2006
@@ -36,7 +36,7 @@
namespace FreeSwitch.Types
{
public delegate Status InputCallbackFunction(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))]
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))]
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string input,
Modified: freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/LoadableModuleInterface.cs Tue Sep 19 08:47:44 2006
@@ -37,11 +37,7 @@
namespace FreeSwitch.Types
{
- public delegate Status WriteFunction(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))]
- StreamHandle streamHandle,
- [MarshalAs(UnmanagedType.LPStr)]
- string fmt);
+
//public delegate void ModuleLoad();
Added: freeswitch/trunk/src/dotnet/Types/LogLevel.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/LogLevel.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,51 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * LogLevel.cs --
+ *
+ */
+using System;
+using System.Collections;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace FreeSwitch.Types
+{
+ public enum LogLevel
+ {
+ Console,
+ Debug,
+ Info,
+ Notice,
+ Warning,
+ Error,
+ Crit,
+ Alert,
+ Emerg
+ }
+}
\ No newline at end of file
Modified: freeswitch/trunk/src/dotnet/Types/Module.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/Module.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/Module.cs Tue Sep 19 08:47:44 2006
@@ -49,11 +49,13 @@
CoreSession session,
[MarshalAs(UnmanagedType.LPStr)]
string data);
-
+
public delegate Status
ApiFunction(
[MarshalAs(UnmanagedType.LPStr)]
- string command,
+ string input,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CoreSessionMarshaler))]
+ CoreSession session,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))]
StreamHandle streamHandle);
}
Added: freeswitch/trunk/src/dotnet/Types/SpeechHandle.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/SpeechHandle.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,66 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * SpeechHandle.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Marshaling;
+using FreeSwitch.Marshaling.Types;
+
+namespace FreeSwitch.Types
+{
+ /*
+ internal IntPtr speech_interface;
+ internal UInt32 flags;
+ internal IntPtr name;
+ internal UInt32 rate;
+ internal UInt32 speed;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
+ internal byte[] voice;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
+ internal byte[] engine;
+ internal IntPtr memory_pool;
+ internal IntPtr private_info;
+ */
+ public class SpeechHandle
+ {
+ internal HandleRef marshaledObject;
+
+ public UInt32 flags
+ {
+ get
+ {
+ SpeechHandleMarshal speechHandleMarshal = (SpeechHandleMarshal)marshaledObject.Wrapper;
+
+ return speechHandleMarshal.flags;
+ }
+ }
+ }
+}
Added: freeswitch/trunk/src/dotnet/Types/StateHandlerTable.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/StateHandlerTable.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * StateHandlerTable.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Marshaling;
+using FreeSwitch.Marshaling.Types;
+
+namespace FreeSwitch.Types
+{
+ public class StateHandlerTable
+ {
+ internal HandleRef marshaledObject;
+
+ }
+}
Modified: freeswitch/trunk/src/dotnet/Types/StreamHandle.cs
==============================================================================
--- freeswitch/trunk/src/dotnet/Types/StreamHandle.cs (original)
+++ freeswitch/trunk/src/dotnet/Types/StreamHandle.cs Tue Sep 19 08:47:44 2006
@@ -30,20 +30,26 @@
*
*/
using System;
-using System.Runtime.InteropServices;
+using System.Runtime.InteropServices;
+using FreeSwitch.Marshaling;
using FreeSwitch.Marshaling.Types;
namespace FreeSwitch.Types
-{
+{
+ public delegate Status StreamHandleWriteFunction(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))]
+ StreamHandle streamHandle,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string fmt);
+
public class StreamHandle
{
internal HandleRef marshaledObject;
- internal WriteFunction writeFunction;
public void Write(string data)
{
StreamHandleMarshal streamHandleMarshal = (StreamHandleMarshal)marshaledObject.Wrapper;
- WriteFunction writeFunction = (WriteFunction)Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(WriteFunction));
+ StreamHandleWriteFunction writeFunction = (StreamHandleWriteFunction)Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(StreamHandleWriteFunction));
writeFunction(this, data);
}
Added: freeswitch/trunk/src/dotnet/Types/Timer.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/dotnet/Types/Timer.cs Tue Sep 19 08:47:44 2006
@@ -0,0 +1,44 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * Timer.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using FreeSwitch.Marshaling;
+using FreeSwitch.Marshaling.Types;
+
+namespace FreeSwitch.Types
+{
+ public class Timer
+ {
+ internal HandleRef marshaledObject;
+
+ }
+}
1
0
[commit] r2748 - in freeswitch/trunk/src: . include mod/applications/mod_commands
by Freeswitch SVN 19 Sep '06
by Freeswitch SVN 19 Sep '06
19 Sep '06
Author: anthm
Date: Mon Sep 18 22:18:24 2006
New Revision: 2748
Modified:
freeswitch/trunk/src/include/switch_channel.h
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/switch_channel.c
freeswitch/trunk/src/switch_ivr.c
Log:
add uuid_bridge api call and ivr function Usage: uuid_bridge <uuid> <other_uuid> *should* take 2 existing channels and bridge them
Modified: freeswitch/trunk/src/include/switch_channel.h
==============================================================================
--- freeswitch/trunk/src/include/switch_channel.h (original)
+++ freeswitch/trunk/src/include/switch_channel.h Mon Sep 18 22:18:24 2006
@@ -248,6 +248,13 @@
SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flags);
/*!
+ \brief Set given flag(s) on a given channel to be applied on the next state change
+ \param channel channel on which to set flag(s)
+ \param flags or'd list of flags to set
+*/
+SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flags);
+
+/*!
\brief Clear given flag(s) from a channel
\param channel channel to clear flags from
\param flags or'd list of flags to clear
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Mon Sep 18 22:18:24 2006
@@ -233,6 +233,15 @@
*/
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context);
+
+/*!
+ \brief Bridge two existing sessions
+ \param originator_uuid the uuid of the originator
+ \param originatee_uuid the uuid of the originator
+ \return SWITCH_STATUS_SUCCESS if all is well
+*/
+SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(char *originator_uuid, char *originatee_uuid);
+
/** @} */
SWITCH_END_EXTERN_C
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Mon Sep 18 22:18:24 2006
@@ -178,7 +178,28 @@
+static switch_status_t uuid_bridge_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
+{
+ char *argv[4] = {0};
+ int argc = 0;
+ if (isession) {
+ return SWITCH_STATUS_FALSE;
+ }
+
+ argc = switch_separate_string(cmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+
+ if (argc != 2) {
+ stream->write_function(stream, "Invalid Parameters\nUsage: uuid_bridge <uuid> <other_uuid>\n");
+ } else {
+ switch_ivr_uuid_bridge(argv[0], argv[1]);
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+
static switch_status_t pause_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{
switch_core_session_t *session = NULL;
@@ -415,11 +436,19 @@
}
+
+static switch_api_interface_t uuid_bridge_api_interface = {
+ /*.interface_name */ "uuid_bridge",
+ /*.desc */ "uuid_bridge",
+ /*.function */ uuid_bridge_function,
+ /*.next */ NULL
+};
+
static switch_api_interface_t status_api_interface = {
/*.interface_name */ "status",
/*.desc */ "status",
/*.function */ status_function,
- /*.next */ NULL
+ /*.next */ &uuid_bridge_api_interface
};
static switch_api_interface_t show_api_interface = {
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Mon Sep 18 22:18:24 2006
@@ -98,6 +98,7 @@
switch_core_session_t *session;
switch_channel_state_t state;
uint32_t flags;
+ uint32_t state_flags;
switch_caller_profile_t *caller_profile;
switch_caller_profile_t *originator_caller_profile;
switch_caller_profile_t *originatee_caller_profile;
@@ -374,6 +375,15 @@
switch_set_flag_locked(channel, flags);
}
+SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flags)
+{
+ assert(channel != NULL);
+
+ switch_mutex_lock(channel->flag_mutex);
+ channel->state_flags |= flags;
+ switch_mutex_unlock(channel->flag_mutex);
+}
+
SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flags)
{
assert(channel != NULL);
@@ -395,7 +405,7 @@
SWITCH_DECLARE(unsigned int) switch_channel_ready(switch_channel_t *channel)
{
assert(channel != NULL);
- return (channel->state > CS_RING && channel->state < CS_HANGUP) ? 1 : 0;
+ return (channel->state > CS_RING && channel->state < CS_HANGUP && !switch_test_flag(channel, CF_TRANSFER)) ? 1 : 0;
}
static const char *state_names[] = {
@@ -616,6 +626,12 @@
}
}
done:
+
+ if (channel->state_flags) {
+ channel->flags |= channel->state_flags;
+ channel->state_flags = 0;
+ }
+
switch_mutex_unlock(channel->flag_mutex);
return channel->state;
}
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Mon Sep 18 22:18:24 2006
@@ -1396,6 +1396,98 @@
/*.on_hold */ audio_bridge_on_hold,
};
+
+static switch_status_t uuid_bridge_on_transmit(switch_core_session_t *session)
+{
+ switch_channel_t *channel = NULL;
+ switch_core_session_t *other_session;
+
+ channel = switch_core_session_get_channel(session);
+ assert(channel != NULL);
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CUSTOM TRANSMIT\n");
+
+ if ((other_session = switch_channel_get_private(channel, "_uuid_bridge_"))) {
+ switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+ switch_channel_state_t state = switch_channel_get_state(other_channel);
+ switch_event_t *event;
+ uint8_t ready_a, ready_b;
+ switch_caller_profile_t *profile, *new_profile;
+
+ switch_channel_set_private(channel, "_uuid_bridge_", NULL);
+ while (state <= CS_HANGUP && state != CS_TRANSMIT) {
+ switch_yield(1000);
+ state = switch_channel_get_state(other_channel);
+ }
+
+ switch_channel_clear_flag(channel, CF_TRANSFER);
+ switch_channel_clear_flag(other_channel, CF_TRANSFER);
+
+ switch_core_session_reset(session);
+ switch_core_session_reset(other_session);
+
+ ready_a = switch_channel_ready(channel);
+ ready_b = switch_channel_ready(other_channel);
+
+ if (!ready_a || !ready_b) {
+ if (!ready_a) {
+ switch_channel_hangup(other_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
+
+ if (!ready_b) {
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
+ return SWITCH_STATUS_FALSE;
+ }
+
+ /* add another profile to both sessions for CDR's sake */
+ if ((profile = switch_channel_get_caller_profile(channel))) {
+ new_profile = switch_caller_profile_clone(session, profile);
+ new_profile->destination_number = switch_core_session_strdup(session, switch_core_session_get_uuid(other_session));
+ switch_channel_set_caller_profile(channel, new_profile);
+ }
+
+ if ((profile = switch_channel_get_caller_profile(other_channel))) {
+ new_profile = switch_caller_profile_clone(other_session, profile);
+ new_profile->destination_number = switch_core_session_strdup(other_session, switch_core_session_get_uuid(session));
+ switch_channel_set_caller_profile(other_channel, new_profile);
+ }
+
+ /* fire events that will change the data table from "show channels" */
+ if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(channel, event);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "uuid_bridge");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", switch_core_session_get_uuid(other_session));
+ switch_event_fire(&event);
+ }
+
+ if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
+ switch_channel_event_set_data(other_channel, event);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application", "uuid_bridge");
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Application-Data", switch_core_session_get_uuid(session));
+ switch_event_fire(&event);
+ }
+
+ switch_ivr_multi_threaded_bridge(session, other_session, NULL, NULL, NULL);
+ } else {
+ switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+ }
+
+
+
+ return SWITCH_STATUS_FALSE;
+}
+
+static const switch_state_handler_table_t uuid_bridge_state_handlers = {
+ /*.on_init */ NULL,
+ /*.on_ring */ NULL,
+ /*.on_execute */ NULL,
+ /*.on_hangup */ NULL,
+ /*.on_loopback */ NULL,
+ /*.on_transmit */ uuid_bridge_on_transmit,
+ /*.on_hold */ NULL
+};
+
struct key_collect {
char *key;
char *file;
@@ -2009,6 +2101,48 @@
}
+SWITCH_DECLARE(switch_status_t) switch_ivr_uuid_bridge(char *originator_uuid, char *originatee_uuid)
+{
+ switch_core_session_t *originator_session, *originatee_session;
+ switch_channel_t *originator_channel, *originatee_channel;
+ switch_status_t status = SWITCH_STATUS_FALSE;
+
+ if ((originator_session = switch_core_session_locate(originator_uuid))) {
+ if ((originatee_session = switch_core_session_locate(originatee_uuid))) {
+ originator_channel = switch_core_session_get_channel(originator_session);
+ originatee_channel = switch_core_session_get_channel(originatee_session);
+
+ /* override transmit state for originator_channel to bridge to originatee_channel
+ * install pointer to originatee_session into originator_channel
+ * set CF_TRANSFER on both channels and change state to CS_TRANSMIT to
+ * inturrupt anything they are already doing.
+ * originatee_session will fall asleep and originator_session will bridge to it
+ */
+
+ switch_channel_add_state_handler(originator_channel, &uuid_bridge_state_handlers);
+ switch_channel_set_private(originator_channel, "_uuid_bridge_", originatee_session);
+
+ /* switch_channel_set_state_flag sets flags you want to be set when the next stat change happens */
+ switch_channel_set_state_flag(originator_channel, CF_TRANSFER);
+ switch_channel_set_state_flag(originatee_channel, CF_TRANSFER);
+
+ /* release the read locks we have on the channels */
+ switch_core_session_rwunlock(originator_session);
+ switch_core_session_rwunlock(originatee_session);
+
+ /* change the states and let the chips fall where they may */
+ switch_channel_set_state(originator_channel, CS_TRANSMIT);
+ switch_channel_set_state(originatee_channel, CS_TRANSMIT);
+
+ } else {
+ switch_core_session_rwunlock(originator_session);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no channel for uuid %s\n", originatee_uuid);
+ }
+ }
+
+ return status;
+
+}
SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_t *session, char *extension, char *dialplan, char *context)
{
1
0
[commit] r2747 - in freeswitch/trunk/src: . include mod/applications/mod_commands
by Freeswitch SVN 18 Sep '06
by Freeswitch SVN 18 Sep '06
18 Sep '06
Author: anthm
Date: Mon Sep 18 18:22:25 2006
New Revision: 2747
Modified:
freeswitch/trunk/src/include/switch_core.h
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/switch_core.c
Log:
pull down stack size another 128k, make the sql use mem cache and add session count to the status command
Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h (original)
+++ freeswitch/trunk/src/include/switch_core.h Mon Sep 18 18:22:25 2006
@@ -361,6 +361,12 @@
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session_t **session);
/*!
+ \brief Provide the total number of sessions
+ \return the total number of allocated sessions
+*/
+SWITCH_DECLARE(uint32_t) switch_core_session_count(void);
+
+/*!
\brief Allocate and return a new session from the core based on a given endpoint module name
\param endpoint_name the name of the endpoint module
\param pool the pool to use
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Mon Sep 18 18:22:25 2006
@@ -118,7 +118,7 @@
typedef struct switch_directories switch_directories;
SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
-#define SWITCH_THREAD_STACKSIZE 384 * 1024
+#define SWITCH_THREAD_STACKSIZE 256 * 1024
#define SWITCH_RECCOMMENDED_BUFFER_SIZE 2048
#define SWITCH_MAX_CODECS 30
#define SWITCH_MAX_STATE_HANDLERS 30
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Mon Sep 18 18:22:25 2006
@@ -39,6 +39,7 @@
{
uint8_t html = 0;
switch_core_time_duration_t duration;
+ char *http;
if (session) {
return SWITCH_STATUS_FALSE;
@@ -46,7 +47,11 @@
switch_core_measure_time(switch_core_uptime(), &duration);
- if (cmd && strstr(cmd, "html")) {
+ if (stream->event) {
+ http = switch_event_get_header(stream->event, "http-host");
+ }
+
+ if (http || (cmd && strstr(cmd, "html"))) {
html = 1;
stream->write_function(stream, "<h1>FreeSWITCH Status</h1>\n<b>");
}
@@ -61,6 +66,8 @@
duration.mms, duration.mms == 1 ? "" : "s"
);
+ stream->write_function(stream, "%d sessions\n", switch_core_session_count());
+
if (html) {
stream->write_function(stream, "</b>\n");
}
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Mon Sep 18 18:22:25 2006
@@ -143,11 +143,7 @@
/* The main runtime obj we keep this hidden for ourselves */
static struct switch_core_runtime runtime;
-/* Mutex and conditional for sql lite */
-static switch_mutex_t *SWITCH_SQL_MUTEX;
-static switch_thread_cond_t *SWITCH_SQL_CONDITIONAL;
-
static void db_pick_path(char *dbname, char *buf, switch_size_t size)
{
@@ -3068,6 +3064,7 @@
}
}
+
SWITCH_DECLARE(void) switch_core_session_launch_thread(switch_core_session_t *session, switch_thread_start_t func,
void *obj)
{
@@ -3169,6 +3166,11 @@
return session;
}
+SWITCH_DECLARE(uint32_t) switch_core_session_count(void)
+{
+ return runtime.session_count;
+}
+
SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(char *endpoint_name, switch_memory_pool_t *pool)
{
const switch_endpoint_interface_t *endpoint_interface;
@@ -3185,7 +3187,13 @@
{
char *errmsg;
switch_status_t status = SWITCH_STATUS_FALSE;
+ uint8_t forever = 0;
+ if (!retries) {
+ forever = 1;
+ retries = 1000;
+ }
+
while(retries > 0) {
switch_core_db_exec(
db,
@@ -3195,10 +3203,14 @@
&errmsg
);
if (errmsg) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR\n[%s]\n[%s]\n", sql,errmsg);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n", errmsg);
switch_core_db_free(errmsg);
switch_yield(100000);
retries--;
+ if (retries == 0 && forever) {
+ retries = 1000;
+ continue;
+ }
} else {
status = SWITCH_STATUS_SUCCESS;
break;
@@ -3208,76 +3220,76 @@
return status;
}
+#ifdef DO_EVENTS
+#define SQLLEN 1024 * 64
static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, void *obj)
{
void *pop;
uint32_t itterations = 0;
- uint8_t trans = 0;
- switch_time_t last_commit = switch_time_now();
- uint32_t freq = 1000, target = 1000, diff = 0;
-
- //if these are null we have big problems
- assert(SWITCH_SQL_MUTEX != NULL);
- assert(SWITCH_SQL_CONDITIONAL != NULL);
+ uint8_t trans = 0, nothing_in_queue = 0;
+ uint32_t freq = 1000, target = 1000;
+ uint32_t len = 0;
+ uint32_t sql_len = SQLLEN;
+ char *sqlbuf = (char *) malloc(sql_len);
if (!runtime.event_db) {
runtime.event_db = switch_core_db_handle();
}
switch_queue_create(&runtime.sql_queue, SWITCH_SQL_QUEUE_LEN, runtime.memory_pool);
- switch_mutex_lock(SWITCH_SQL_MUTEX);
-
for(;;) {
if (switch_queue_trypop(runtime.sql_queue, &pop) == SWITCH_STATUS_SUCCESS) {
char *sql = (char *) pop;
+ uint32_t newlen;
if (sql) {
if (itterations == 0) {
- char *isql = "begin transaction CORE1;";
- if (switch_core_db_persistant_execute(runtime.event_db, isql, 25) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", isql);
- } else {
- trans = 1;
- }
+ char *isql = "begin transaction CORE1;\n";
+ switch_core_db_persistant_execute(runtime.event_db, isql, 0);
+ trans = 1;
+
}
itterations++;
-
- if (switch_core_db_persistant_execute(runtime.event_db, sql, 25) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", sql);
+ newlen = strlen(sql) + 2;
+ if (len + newlen > sql_len) {
+ sql_len = len + SQLLEN;
+ if (!(sqlbuf = realloc(sqlbuf, sql_len))) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread ending on mem err\n");
+ break;
+ }
}
+ snprintf(sqlbuf + len, sql_len - len, "%s;\n", sql);
+ len += newlen;
switch_core_db_free(sql);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "SQL thread ending\n");
break;
}
} else {
- //Are we currently in a transaction, wait accordingly
- if(trans) {
- //we need to finish a transaction in a bit, wait around until we have more work or that time comes
- switch_thread_cond_timedwait(SWITCH_SQL_CONDITIONAL, SWITCH_SQL_MUTEX, (freq * 1000) + last_commit - switch_time_now());
- } else {
- //wait until we have more work
- switch_thread_cond_wait(SWITCH_SQL_CONDITIONAL, SWITCH_SQL_MUTEX);
- }
+ nothing_in_queue = 1;
}
-
- if (diff < freq) {
- diff = (uint32_t)((switch_time_now() - last_commit) / 1000);
- }
- if (trans && (itterations == target || diff >= freq)) {
- char *sql = "end transaction CORE1";
- if (switch_core_db_persistant_execute(runtime.event_db, sql, 25) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL exec error! [%s]\n", sql);
- }
- last_commit = switch_time_now();
+
+ if (trans && ((itterations == target) || nothing_in_queue)) {
+ char *isql = "end transaction CORE1";
+
+ switch_core_db_persistant_execute(runtime.event_db, sqlbuf, 0);
+ switch_core_db_persistant_execute(runtime.event_db, isql, 0);
itterations = 0;
trans = 0;
- diff = 0;
+ nothing_in_queue = 0;
+ len = 0;
+ *sqlbuf = '\0';
}
+ if (nothing_in_queue) {
+ switch_yield(freq);
+ }
}
+
+
+ free(sqlbuf);
return NULL;
}
@@ -3289,10 +3301,6 @@
assert(runtime.memory_pool != NULL);
- //create the mutex and conditional
- switch_mutex_init(&SWITCH_SQL_MUTEX, SWITCH_MUTEX_NESTED, runtime.memory_pool);
- switch_thread_cond_create(&SWITCH_SQL_CONDITIONAL, runtime.memory_pool);
-
switch_threadattr_create(&thd_attr, runtime.memory_pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -3300,7 +3308,6 @@
}
-#ifdef DO_EVENTS
static void core_event_handler(switch_event_t *event)
{
char *sql = NULL;
@@ -3400,16 +3407,6 @@
if (sql) {
switch_queue_push(runtime.sql_queue, sql);
-
- //See if we need to wake up the sql thread
- if(switch_mutex_trylock(SWITCH_SQL_MUTEX) == SWITCH_STATUS_SUCCESS) {
- //wake up the SQL thread
- switch_thread_cond_signal(SWITCH_SQL_CONDITIONAL);
-
- //give up our lock
- switch_mutex_unlock(SWITCH_SQL_MUTEX);
- }
-
sql = NULL;
}
}
@@ -3542,7 +3539,10 @@
assert(runtime.memory_pool != NULL);
switch_log_init(runtime.memory_pool);
+
+#ifdef DO_EVENTS
switch_core_sql_thread_launch();
+#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Allocated memory pool. Sessions are %u bytes\n", sizeof(switch_core_session_t));
switch_event_init(runtime.memory_pool);
@@ -3716,14 +3716,6 @@
switch_event_shutdown();
switch_queue_push(runtime.sql_queue, NULL);
- //See if we need to wake up the sql thread
- if(switch_mutex_trylock(SWITCH_SQL_MUTEX) == SWITCH_STATUS_SUCCESS) {
- //wake up the SQL thread
- switch_thread_cond_signal(SWITCH_SQL_CONDITIONAL);
-
- //give up our lock
- switch_mutex_unlock(SWITCH_SQL_MUTEX);
- }
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n");
while (switch_queue_size(runtime.sql_queue) > 0) {
1
0
18 Sep '06
Author: brian
Date: Mon Sep 18 13:37:46 2006
New Revision: 2745
Modified:
freeswitch/trunk/src/mod/languages/mod_ruby/mod_ruby.c
Log:
this code absolutely doesn't work
Modified: freeswitch/trunk/src/mod/languages/mod_ruby/mod_ruby.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_ruby/mod_ruby.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_ruby/mod_ruby.c Mon Sep 18 13:37:46 2006
@@ -42,11 +42,8 @@
#include <ruby.h>
-
const char modname[] = "mod_ruby";
-
-
static void ruby_function(switch_core_session_t *session, char *data)
{
char *uuid = switch_core_session_get_uuid(session);
@@ -56,7 +53,6 @@
int argc, state;
char *argv[5];
char ruby_code[1024];
- //void*** tsrm_ls = NULL;
snprintf(mydata, len, "%s %s", uuid, data);
@@ -70,16 +66,14 @@
ruby_script("embedded");
rb_load_file(data);
- rb_p(rb_eval_string_protect(argv[1], &state));
- if (state) {
+ rb_p(rb_eval_string_protect(argv[1], &state));
+ if (state) {
VALUE error = rb_inspect(rb_gv_get("$!"));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Your code is broken. \nHere is the error I found: %s\n",error);
- }
+ }
state = ruby_exec();
state = ruby_cleanup(state);
ruby_finalize();
-
-
}
static const switch_application_interface_t ruby_application_interface = {
@@ -105,24 +99,6 @@
/* connect my internal structure to the blank pointer passed to me */
*module_interface = &ruby_module_interface;
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
-
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
-
-/*
- Called when the system shuts down
- SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
- {
- return SWITCH_STATUS_SUCCESS;
- }
-*/
-
-/*
- If it exists, this is called in it's own thread when the module-load completes
- SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
- {
- return SWITCH_STATUS_SUCCESS;
- }
-*/
1
0
18 Sep '06
Author: anthm
Date: Mon Sep 18 12:32:47 2006
New Revision: 2744
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Log:
sofia tweak
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 Mon Sep 18 12:32:47 2006
@@ -609,13 +609,13 @@
if (switch_test_flag(tech_pvt, TFLAG_ANS)) {
nua_bye(tech_pvt->nh, TAG_END());
} else {
- if (switch_test_flag(tech_pvt, TFLAG_INBOUND))
+ if (switch_test_flag(tech_pvt, TFLAG_INBOUND)) {
nua_respond(tech_pvt->nh, sip_cause, NULL, TAG_END());
- else
+ } else {
nua_cancel(tech_pvt->nh, TAG_END());
+ }
}
}
- nua_handle_bind(tech_pvt->nh, NULL);
nua_handle_destroy(tech_pvt->nh);
tech_pvt->nh = NULL;
}
1
0
18 Sep '06
Author: anthm
Date: Mon Sep 18 10:30:12 2006
New Revision: 2742
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
Log:
add nat buster flag to sofia
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 Mon Sep 18 10:30:12 2006
@@ -727,7 +727,7 @@
bw = tech_pvt->read_codec.implementation->bits_per_second;
ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
- flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_MINI);
+ flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_MINI | SWITCH_RTP_FLAG_AUTOADJ);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "RTP [%s] %s:%d->%s:%d codec: %u ms: %d\n",
switch_channel_get_name(channel),
1
0
18 Sep '06
Author: brian
Date: Mon Sep 18 09:30:11 2006
New Revision: 2741
Modified:
freeswitch/trunk/src/mod/languages/mod_python/Makefile
Log:
tweak and remove stuff that is cearly from the php makefile.
Modified: freeswitch/trunk/src/mod/languages/mod_python/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/Makefile (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/Makefile Mon Sep 18 09:30:11 2006
@@ -1,4 +1,4 @@
-LCFLAGS=-fPIC -DZTS -DPTHREADS -Xlinker
+LCFLAGS=-fPIC
CFLAGS += -fPIC -I$(PREFIX)/include/python2.4/
PYMOD=freeswitch
LDFLAGS=-lpython2.4 -Xlinker -L$(PREFIX)/lib/python2.4/config/
1
0
18 Sep '06
Author: mikej
Date: Mon Sep 18 09:26:41 2006
New Revision: 2740
Modified:
freeswitch/trunk/src/mod/languages/mod_python/Makefile
Log:
revert
Modified: freeswitch/trunk/src/mod/languages/mod_python/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/Makefile (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/Makefile Mon Sep 18 09:26:41 2006
@@ -1,4 +1,4 @@
-LCFLAGS=-fPIC -DZTS -DPTHREADS
+LCFLAGS=-fPIC -DZTS -DPTHREADS -Xlinker
CFLAGS += -fPIC -I$(PREFIX)/include/python2.4/
PYMOD=freeswitch
LDFLAGS=-lpython2.4 -Xlinker -L$(PREFIX)/lib/python2.4/config/
@@ -31,7 +31,7 @@
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).o $(OBJS) Makefile
- $(CC) $(LCFLAGS) -shared -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
+ $(CC) $(LCFLAGS) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
clean:
rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
1
0
18 Sep '06
Author: docelmo
Date: Mon Sep 18 07:47:25 2006
New Revision: 2739
Modified:
freeswitch/trunk/src/mod/languages/mod_python/Makefile
Log:
Fix linking problem
Modified: freeswitch/trunk/src/mod/languages/mod_python/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/Makefile (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/Makefile Mon Sep 18 07:47:25 2006
@@ -1,4 +1,4 @@
-LCFLAGS=-fPIC -DZTS -DPTHREADS -Xlinker
+LCFLAGS=-fPIC -DZTS -DPTHREADS
CFLAGS += -fPIC -I$(PREFIX)/include/python2.4/
PYMOD=freeswitch
LDFLAGS=-lpython2.4 -Xlinker -L$(PREFIX)/lib/python2.4/config/
@@ -31,7 +31,7 @@
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).o $(OBJS) Makefile
- $(CC) $(LCFLAGS) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
+ $(CC) $(LCFLAGS) -shared -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
clean:
rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
1
0