* Version 0.0.55
*/
+//#define DEBUG_RTP_PACKETS
#include "mod_h323.h"
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, mod_h323_globals.codec_string);
if (h323_process->Initialise(*module_interface)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "H323 mod initialized and running\n");
+#ifdef WIN32
+ return SWITCH_STATUS_NOUNLOAD; /* Unload doesn't work right now, at least not in Windows */
+#else
return SWITCH_STATUS_SUCCESS;
+#endif
}
delete h323_process;
FSProcess::FSProcess()
: PLibraryProcess("Test", "mod_h323", 1, 0, AlphaCode, 1)
, m_h323endpoint(NULL){
- PTrace::SetLevel(4);
- PTrace::SetOptions(PTrace::TraceLevel);
- PTrace::SetStream(new FSTrace);
}
FSProcess::~FSProcess(){
/* Update tracing level for h323 */
PTrace::SetLevel(mod_h323_globals.trace_level);
PTrace::SetOptions(PTrace::TraceLevel);
+ PTrace::SetStream(new FSTrace);
m_freeswitch = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(iface, SWITCH_ENDPOINT_INTERFACE);
m_freeswitch->interface_name = modulename;
}
if (format) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"capability '%s' format '%s' %d",(const char*)fname,format,pload);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"capability '%s' format '%s' %d\n",(const char*)fname,format,pload);
if (capabName)
*capabName = fname;
if (dataFormat)
switch_status_t FSH323Connection::read_audio_frame(switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
{
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame [%p]\n",this);
+#endif
/*switch_channel_t *channel = NULL;
h323_private_t *tech_pvt = NULL;
if (!switch_channel_ready(m_fsChannel)) {
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n");
+#endif
return SWITCH_STATUS_FALSE;
}
if (!switch_core_codec_ready(&tech_pvt->read_codec )) {
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
+#endif
return SWITCH_STATUS_FALSE;
}
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame ---> switch_rtp_zerocopy_read_frame start\n");
+#endif
switch_status_t status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame ---> switch_rtp_zerocopy_read_frame stop\n");
+#endif
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
+#endif
return status;
}
}
} else {
switch_mutex_unlock(tech_pvt->h323_io_mutex);
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"--------->TFLAG_IO OFF\n");
+#endif
switch_yield(10000);
}
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
*frame = &tech_pvt->read_frame;
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
+#endif
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
{
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame [%p]\n",this);
+#endif
/*switch_channel_t *channel = NULL;
h323_private_t *tech_pvt = NULL;
switch_assert(tech_pvt != NULL);
if (!switch_channel_ready(m_fsChannel)) {
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
+#endif
return SWITCH_STATUS_FALSE;
}
if (switch_channel_ready(m_fsChannel)) {
switch_yield(10000);
} else {
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
+#endif
return SWITCH_STATUS_GENERR;
}
}
if (!switch_core_codec_ready(&tech_pvt->read_codec) || !tech_pvt->read_codec.implementation) {
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
+#endif
return SWITCH_STATUS_GENERR;
}
if ((frame->flags & SFF_CNG)) {
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
+#endif
return SWITCH_STATUS_SUCCESS;
}
}
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
+#ifdef DEBUG_RTP_PACKETS
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
+#endif
return status;
}
if (trylock == 1) {
const PString currentToken(me->GetCallToken());
FSH323Connection *connection = (FSH323Connection *)me->GetEndPoint()->FindConnectionWithLock(currentToken);
- connection->Unlock();
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
+ if (connection) {
+ connection->Unlock();
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> connection->UnLock()\n");
+ }
me->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
} else if (trylock == -1) {
- me->Unlock();
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
+ /* Failed to lock - just go on */
}
me->SetQ931Cause(cause);
me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));