From f2055745ebadd21ec118584d36243e5e0f8f9212 Mon Sep 17 00:00:00 2001 From: Robert Joly Date: Wed, 28 Jan 2009 03:12:36 +0000 Subject: [PATCH] Removed the construction of new OpalMediaFormat instances from FS codecs, need for H.323 capabilities makes this impossible, OPAL must know about the codec a priori (and how to make H.323 capability from it) or it cannot be used. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11534 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_opal/mod_opal.cpp | 65 +++++++------------------ src/mod/endpoints/mod_opal/mod_opal.h | 5 -- 2 files changed, 17 insertions(+), 53 deletions(-) diff --git a/src/mod/endpoints/mod_opal/mod_opal.cpp b/src/mod/endpoints/mod_opal/mod_opal.cpp index 8aad7c7757..f4b188bbfa 100644 --- a/src/mod/endpoints/mod_opal/mod_opal.cpp +++ b/src/mod/endpoints/mod_opal/mod_opal.cpp @@ -351,6 +351,21 @@ bool FSManager::Initialise(switch_loadable_module_interface_t *iface) AddRouteEntry("iax2:.* = local:"); // config option for direct routing AddRouteEntry("local:.* = h323:"); // config option for direct routing + // Make sure all known codecs are instantiated, + // these are ones we know how to translate into H.323 capabilities + GetOpalG728(); + GetOpalG729(); + GetOpalG729A(); + GetOpalG729B(); + GetOpalG729AB(); + GetOpalG7231_6k3(); + GetOpalG7231_5k3(); + GetOpalG7231A_6k3(); + GetOpalG7231A_5k3(); + GetOpalGSM0610(); + GetOpalGSMAMR(); + GetOpaliLBC(); + /* For compatibility with the algorithm in FSConnection::SetCodecs() we need to set all audio media formats to be 1 frame per packet */ OpalMediaFormatList allCodecs = OpalMediaFormat::GetAllRegisteredMediaFormats(); @@ -469,49 +484,6 @@ OpalLocalConnection *FSEndPoint::CreateConnection(OpalCall & call, void *userDat } -bool FSEndPoint::AddMediaFormat(const switch_codec_implementation_t *codec) -{ - OpalMediaType mediaType; - - switch (codec->codec_type) { - case SWITCH_CODEC_TYPE_AUDIO: - mediaType = OpalMediaType::Audio(); - break; - - case SWITCH_CODEC_TYPE_VIDEO: - mediaType = OpalMediaType::Video(); - break; - - case SWITCH_CODEC_TYPE_T38: - mediaType = OpalMediaType::Fax(); - break; - - default: - return false; - } - - OpalMediaFormat * newMediaFormat = new OpalMediaFormat(codec->iananame, - mediaType, - (RTP_DataFrame::PayloadTypes) codec->ianacode, - codec->iananame, - codec->codec_type == SWITCH_CODEC_TYPE_AUDIO, - codec->bits_per_second, - codec->encoded_bytes_per_packet, - codec->samples_per_packet, - codec->samples_per_second); - if (newMediaFormat == NULL || !newMediaFormat->IsValid()) { - return false; - } - - // Save pointer so will auto delete allocated objects on destruction. - m_globalMediaFormats.Append(newMediaFormat); - - PTRACE(2, "mod_opal\tNew OPAL media format created for FS codec: iananame=" << codec->iananame - << ", ianacode=" << codec->ianacode << ", rate=" << codec->samples_per_second); - return true; -} - - /////////////////////////////////////////////////////////////////////// FSConnection::FSConnection(OpalCall & call, FSEndPoint & endpoint) @@ -680,11 +652,8 @@ void FSConnection::SetCodecs() // See if we have a match by name alone switchFormat = codec->iananame; if (!switchFormat.IsValid()) { - // Add the new name to OPAL's global lists - if (m_endpoint.AddMediaFormat(codec)) { - // Now we finally have it - switchFormat = codec->iananame; - } + PTRACE(2, "mod_opal\tCould not match FS codec " << codec->iananame << " to OPAL media format."); + continue; } } diff --git a/src/mod/endpoints/mod_opal/mod_opal.h b/src/mod/endpoints/mod_opal/mod_opal.h index d4a096c680..fc9d91b7fb 100644 --- a/src/mod/endpoints/mod_opal/mod_opal.h +++ b/src/mod/endpoints/mod_opal/mod_opal.h @@ -114,11 +114,6 @@ class FSEndPoint:public OpalLocalEndPoint { virtual bool OnIncomingCall(OpalLocalConnection &); virtual OpalLocalConnection *CreateConnection(OpalCall &, void *); - - bool AddMediaFormat(const switch_codec_implementation_t *codec); - - private: - PList m_globalMediaFormats; };