/*.application_interface*/ NULL
};
+static int dump_info(void);
+static void make_call(char *dest);
SWITCH_MOD_DECLARE(switch_status) switch_module_load(const switch_loadable_module_interface **interface, char *filename) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "OH OH no pool\n");
return SWITCH_STATUS_TERM;
}
-
+\r
+ Pa_Initialize();\r
+ dump_info();
/* connect my internal structure to the blank pointer passed to me */
*interface = &channel_module_interface;
return SWITCH_STATUS_SUCCESS;
}
-/*
+
SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
{
- int res;
- int netfd;
- int refresh;
- struct private_object *tech_pvt = NULL;
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "sleep\n");
+
+ switch_yield(500000);
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "sleep\n");
+
+ make_call("1000");
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "sleep\n");
- load_config();
-
- running = 0;
-
return SWITCH_STATUS_TERM;
}
SWITCH_MOD_DECLARE(switch_status) switch_module_shutdown(void)
{
- int x = 0;
+ Pa_Terminate();\r
+
+ return SWITCH_STATUS_SUCCESS;
+}
- running = -1;
- while (running) {
- if (x++ > 1000) {
- break;
+
+static int dump_info(void)\r
+{\r
+ int i,j;\r
+ int numDevices;\r
+ const PaDeviceInfo *pdi;\r
+ PaError err;\r
+ numDevices = Pa_CountDevices();\r
+ if( numDevices < 0 )\r
+ {\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "ERROR: Pa_CountDevices returned 0x%x\n", numDevices );\r
+ err = numDevices;\r
+ goto error;\r
+ }\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Number of devices = %d\n", numDevices );\r
+ for( i=0; i<numDevices; i++ )\r
+ {\r
+ pdi = Pa_GetDeviceInfo( i );\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "---------------------------------------------- #%d", i );\r
+ if( i == Pa_GetDefaultInputDeviceID() ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " DefaultInput");\r
+ if( i == Pa_GetDefaultOutputDeviceID() ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " DefaultOutput");\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "\nName = %s\n", pdi->name );\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Max Inputs = %d", pdi->maxInputChannels );\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, ", Max Outputs = %d\n", pdi->maxOutputChannels );\r
+ if( pdi->numSampleRates == -1 )\r
+ {\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Sample Rate Range = %f to %f\n", pdi->sampleRates[0], pdi->sampleRates[1] );\r
+ }\r
+ else\r
+ {\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Sample Rates =");\r
+ for( j=0; j<pdi->numSampleRates; j++ )\r
+ {\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, " %8.2f,", pdi->sampleRates[j] );\r
+ }\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "\n");\r
+ }\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Native Sample Formats = ");\r
+ if( pdi->nativeSampleFormats & paInt8 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt8, ");\r
+ if( pdi->nativeSampleFormats & paUInt8 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paUInt8, ");\r
+ if( pdi->nativeSampleFormats & paInt16 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt16, ");\r
+ if( pdi->nativeSampleFormats & paInt32 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt32, ");\r
+ if( pdi->nativeSampleFormats & paFloat32 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paFloat32, ");\r
+ if( pdi->nativeSampleFormats & paInt24 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paInt24, ");\r
+ if( pdi->nativeSampleFormats & paPackedInt24 ) switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "paPackedInt24, ");\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "\n");\r
+ }\r
+ \r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "----------------------------------------------\n");\r
+ return 0;\r
+error:\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "An error occured while using the portaudio stream\n" );\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Error number: %d\n", err );\r
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE_CLEAN, "Error message: %s\n", Pa_GetErrorText( err ) );\r
+ return err;\r
+}\r
+\r
+static void make_call(char *dest)\r
+{\r
+ switch_core_session *session;
+
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE, "New Inbound Channel\n");
+ if ((session = switch_core_session_request(&channel_endpoint_interface, NULL))) {
+ struct private_object *tech_pvt;
+ switch_channel *channel;
+ if ((tech_pvt = (struct private_object *) switch_core_session_alloc(session, sizeof(struct private_object)))) {
+ memset(tech_pvt, 0, sizeof(*tech_pvt));
+ channel = switch_core_session_get_channel(session);
+ switch_core_session_set_private(session, tech_pvt);
+ tech_pvt->session = session;
+ } else {
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
+ switch_core_session_destroy(&session);
+ return;
}
- switch_yield(20000);
- }
- return SWITCH_STATUS_SUCCESS;
-}
-*/
\ No newline at end of file
+
+ if ((tech_pvt->caller_profile = switch_caller_profile_new(session,
+ globals.dialplan,
+ "Test This Shit",
+ "1231231234",
+ NULL,
+ NULL,
+ dest))) {
+ char name[128];
+ switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
+ snprintf(name, sizeof(name), "PortAudio/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
+ switch_channel_set_name(channel, name);
+ }
+ tech_pvt->session = session;
+
+ if (switch_core_codec_init(&tech_pvt->read_codec,
+ "L16",
+ 0,
+ 0,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
+ return;
+ } else {
+ if (switch_core_codec_init(&tech_pvt->write_codec,
+ "L16",
+ 0,
+ 0,
+ SWITCH_CODEC_FLAG_ENCODE |SWITCH_CODEC_FLAG_DECODE, NULL) != SWITCH_STATUS_SUCCESS) {
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't load codec?\n");
+ switch_core_codec_destroy(&tech_pvt->read_codec);
+ return;
+ }
+ }
+
+
+ switch_channel_set_state(channel, CS_INIT);
+ switch_core_session_thread_launch(session);
+ }
+\r
+}
\ No newline at end of file