[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Aug 24 20:58:49 CDT 2010
branch "master" has been updated
via b7636edd7ebbe27407c947b7b1655dea0f6b8de8 (commit)
via febe3922ea165c4de8ac7505b10f1f1e00db85df (commit)
via 0903fbdf651c2ffed555115867c58d269844c003 (commit)
via 71c8f1e04cc3a88fb4a8d73a330d6dad6e0466a1 (commit)
via 5d2d0bfe089b838017e1f1368c04a83756ca57f1 (commit)
via 69211d3b0366ef2617ec5c138914784507ff825f (commit)
from c2fab6f7dbd9d9238181dc30de0e8f16782a8273 (commit)
Summary of changes:
src/CMakeLists.txt | 2 +
src/PJSipManager.cpp | 8 ++--
src/PJSipManager.h | 8 ++--
src/PJSipSessionModule.cpp | 121 ++++++++++++++++++++++++++++++--------------
src/PJSipSessionModule.h | 5 ++
5 files changed, 98 insertions(+), 46 deletions(-)
- Log -----------------------------------------------------------------
commit b7636edd7ebbe27407c947b7b1655dea0f6b8de8
Merge: febe392 c2fab6f
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 24 21:00:06 2010 -0500
Merge branch 'master' of git.asterisk.org:asterisk-scf/integration/sip
commit febe3922ea165c4de8ac7505b10f1f1e00db85df
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 24 20:53:58 2010 -0500
Put PJSipManager in the proper namespace: SipChannelService
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 63d164b..6a4ce1b 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -5,7 +5,7 @@
namespace Hydra
{
-namespace SIP
+namespace SipChannelService
{
PJSipManager *PJSipManager::mInstance(new PJSipManager);
@@ -128,6 +128,6 @@ bool PJSipManager::setTransports(pjsip_endpoint *endpoint)
return true;
}
-}; //End namespace SIP
+}; //End namespace SipChannelService
}; //End namespace Hydra
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 9a59f04..46d9c3e 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -10,7 +10,7 @@
namespace Hydra
{
-namespace SIP
+namespace SipChannelService
{
/**
@@ -61,6 +61,6 @@ private:
bool setTransports(pjsip_endpoint *endpoint);
};
-}; //End namespace SIP
+}; //End namespace SipChannelService
}; //End namespace Hydra
commit 0903fbdf651c2ffed555115867c58d269844c003
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 24 20:49:17 2010 -0500
Continue the non boost::shared_ptrness of PJSipManager.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 802ea58..0c6430d 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -291,8 +291,8 @@ PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
mInvCallback.on_redirected = invOnRedirected;
}
- boost::shared_ptr<PJSipManager> manager = PJSipManager::getInstance();
- pjsip_endpoint *endpt = PJSipManager.getEndpoint();
+ PJSipManager *manager = PJSipManager::getInstance();
+ pjsip_endpoint *endpt = manager.getEndpoint();
pjsip_inv_usage_init(endpt, &mInvCallback);
manager.registerModule(mModule);
}
commit 71c8f1e04cc3a88fb4a8d73a330d6dad6e0466a1
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 24 20:48:10 2010 -0500
Switch the PJSipManager to not use boost::shared_ptr and just use a plain Jane pointer instead.
diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index bf94263..63d164b 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -8,7 +8,7 @@ namespace Hydra
namespace SIP
{
-boost::shared_ptr<PJSipManager> PJSipManager::mInstance(new PJSipManager);
+PJSipManager *PJSipManager::mInstance(new PJSipManager);
static void *monitorThread(void *endpt)
{
@@ -23,7 +23,7 @@ static void *monitorThread(void *endpt)
return NULL;
}
-boost::shared_ptr<PJSipManager> PJSipManager::getInstance()
+PJSipManager *PJSipManager::getInstance()
{
return mInstance;
}
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index f8e9e8b..9a59f04 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -27,7 +27,7 @@ public:
/**
* Get the singleton PJSipManager instance
*/
- static boost::shared_ptr<PJSipManager> getInstance();
+ static PJSipManager *getInstance();
/**
* Get a handle to the PJSipEndpoint for operations
* that may require it
@@ -50,7 +50,7 @@ public:
protected:
PJSipManager();
private:
- static boost::shared_ptr<PJSipManager> mInstance;
+ static PJSipManager *mInstance;
pjsip_endpoint *mEndpoint;
std::vector<pjsip_module *> mModules;
pj_thread_t *mPjThread;
commit 5d2d0bfe089b838017e1f1368c04a83756ca57f1
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 24 20:43:28 2010 -0500
Added PJSipSessionModule to build script.
It doesn't compile right now. I've whittled down
the compilation errors to just a couple at this point.
I'll try to get these on my own tonight but they may
just need to wait until tomorrow when I can ask for
assistance.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c0d23fd..bf877fc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,6 +24,8 @@ hydra_component_add_file(SipChannelService SipEndpoint.cpp)
hydra_component_add_file(SipChannelService SipEndpoint.h)
hydra_component_add_file(SipChannelService PJSipManager.cpp)
hydra_component_add_file(SipChannelService PJSipManager.h)
+hydra_component_add_file(SipChannelService PJSipSessionModule.cpp)
+hydra_component_add_file(SipChannelService PJSipSessionModule.h)
hydra_component_add_ice_libraries(SipChannelService IceStorm)
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index b0205e5..802ea58 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -1,4 +1,11 @@
-#include "PJSipModule.h"
+#include <Core/Endpoint/EndpointIf.h>
+#include <Core/Routing/RoutingIf.h>
+#include <Core/Bridging/BridgeServiceIf.h>
+
+#include "PJSipSessionModule.h"
+#include "SipChannelServiceDataModel.h"
+#include "SipEndpoint.h"
+#include "PJSipManager.h"
namespace Hydra
{
@@ -49,26 +56,27 @@ static void handle_new_invite(pjsip_rx_data *rdata)
//XXX Put caller identification code in here!
- SipChannelServiceDataModel dataModel = SipChannelServiceDataModel::getInstance();
- SipEndpointFactory factory = dataModel.getEndpointFactory();
+ SipChannelServiceDataModel &dataModel = SipChannelServiceDataModel::getInstance();
+ boost::shared_ptr<SipEndpointFactory> factory = dataModel.getEndpointFactory();
//XXX Hardcoded "Butt" is bad for a lot of reasons,
//but for now have it there just so stuff'll compile!
- SipEndpoint caller = factory.getEndpoint("Butt");
+ SipEndpoint *caller = factory->getEndpoint("Butt");
//We've created our calling endpoint. Now we need to look up the destination.
- pjsip_uri ruri = rdata.msg.line.req.uri;
+ pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
std::string destination("");
if (PJSIP_URI_SCHEME_IS_SIP(ruri) || PJSIP_URI_SCHEME_IS_SIPS(ruri))
{
- pjsip_sip_uri sipRuri = static_cast<pjsip_sip_uri>(ruri);
+ pjsip_sip_uri *sipRuri = (pjsip_sip_uri *)ruri;
//For now, we only know about destination "100" so we'll
//grab that from the URI to pass to the locator.
- location = pj_strbuf(sipRuri->user);
+ destination = pj_strbuf(&sipRuri->user);
}
LocatorRegistryPrx locator = dataModel.getRoutingService();
+ EndpointSeq endpoints;
try
{
- std::vector<BaseEndpointPrx> endpoints = locator->lookup(destination);
+ endpoints = locator->lookup(destination);
}
catch (DestinationNotFoundException destEx)
{
@@ -79,13 +87,13 @@ static void handle_new_invite(pjsip_rx_data *rdata)
std::cerr << "[WARNING] Invalid parameters in endpoint lookup. " << std::endl;
}
BridgeFactoryPrx bridgeFactory = dataModel.getBridgeFactory();
- BridgePrx bridge = bridgeFactory.createBridge(caller, endpoints, 0);
+ BridgePrx bridge = bridgeFactory->createBridge(caller, endpoints, 0);
}
static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
{
pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
- switch (rdata->msg->line.request.method.id)
+ switch (rdata->msg_info.msg->line.req.method.id)
{
case PJSIP_INVITE_METHOD:
{
@@ -128,23 +136,21 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
}
break;
}
- case PJSIP_PRACK_METHOD:
- {
- //Potentially need to handle some SDP changes here.
- break;
- }
- case PJSIP_UPDATE_METHOD:
+ case PJSIP_REGISTER_METHOD:
+ case PJSIP_OPTIONS_METHOD:
{
- //Potentially need to handle some SDP changes here.
- break;
+ //Not for us to handle.
+ return PJ_FALSE;
}
- default:
+ case PJSIP_OTHER_METHOD:
{
+ //Potentially need to handle some SDP changes here on UPDATE/PRACK.
//This is all for now. Later we'll have support for
//REFER and INFO. SUBSCRIBE, NOTIFY, REGISTER, and
//PUBLISH fall into other modules' responsibilities.
return PJ_FALSE;
}
+ }
return PJ_TRUE;
}
@@ -159,7 +165,7 @@ static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)
//Message is in dialog. So now let's find out what
//method we're dealing with here so we'll know how to
//handle the message.
- switch (rdata->msg->line.request.method.id)
+ switch (rdata->msg_info.msg->line.req.method.id)
{
case PJSIP_INVITE_METHOD:
{
@@ -178,18 +184,6 @@ static pj_bool_t sessionOnReceiveResponse(pjsip_rx_data *rdata)
//terminate the call.
break;
}
- case PJSIP_UPDATE_METHOD:
- {
- //On a 200 OK, we'll want to check the SDP for changes.
- //Most other responses we won't care about. 401 and 407
- //mean it's auth time.
- break;
- }
- case PJSIP_PRACK_METHOD:
- {
- //Same as UPDATE, afaik.
- break;
- }
case PJSIP_BYE_METHOD:
{
//We'll mostly not care about this response, except for
@@ -217,16 +211,15 @@ static pj_status_t sessionOnTransmitRequest(pjsip_tx_data *data)
return PJ_SUCCESS;
}
-static pj_status_t sessionOnTrasmitResponse(pjsip_tx_data *data)
+static pj_status_t sessionOnTransmitResponse(pjsip_tx_data *data)
{
//stub
return PJ_SUCCESS;
}
-static pj_status_t sessionOnTransactionStateChange(pjsip_transaction *tsx, pjsip_event *event)
+static void sessionOnTransactionStateChange(pjsip_transaction *tsx, pjsip_event *event)
{
//stub
- return PJ_SUCCESS;
}
static void invOnStateChanged(pjsip_inv_session *inv, pjsip_event *event)
@@ -239,7 +232,7 @@ static void invOnNewSession(pjsip_inv_session *inv, pjsip_event *event)
//stub
}
-static void invOnTransactionStateChanged(psjip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
+static void invOnTransactionStateChanged(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
{
//stub
}
@@ -267,12 +260,13 @@ static void invOnSendAck(pjsip_inv_session *inv, pjsip_rx_data *rdata)
static pjsip_redirect_op invOnRedirected(pjsip_inv_session *inv, const pjsip_uri *target, const pjsip_event *e)
{
//stub
- return PJ_SIP_REDIRECT_REJECT;
+ return PJSIP_REDIRECT_REJECT;
}
-PJSipModule::PJSipModule()
+PJSipSessionModule::PJSipSessionModule() : mName("Session Module")
{
- mModule.name = "Session Module";
+ // XXX Set the module name here. It's a pain in the neck
+ // to deal with pj_str_t in C++...
mModule.priority = PJSIP_MOD_PRIORITY_APPLICATION;
mModule.load = sessionLoad;
mModule.start = sessionStart;
@@ -281,11 +275,10 @@ PJSipModule::PJSipModule()
mModule.on_rx_request = sessionOnReceiveRequest;
mModule.on_rx_response = sessionOnReceiveResponse;
mModule.on_tx_request = sessionOnTransmitRequest;
- mModule.on_tx_response = sessionOnTramsmitResponse;
- mModule.on_tx_response = sessionOnTramsmitResponse;
+ mModule.on_tx_response = sessionOnTransmitResponse;
mModule.on_tsx_state = sessionOnTransactionStateChange;
- if (pjsip_inv_usage_instance() == -1)
+ if (pjsip_inv_usage_instance()->id == -1)
{
pj_bzero(&mInvCallback, sizeof(&mInvCallback));
mInvCallback.on_state_changed = invOnStateChanged;
@@ -298,9 +291,9 @@ PJSipModule::PJSipModule()
mInvCallback.on_redirected = invOnRedirected;
}
- Boost::shared_ptr<PJSipManager> manager = PJSipManager::getInstance();
+ boost::shared_ptr<PJSipManager> manager = PJSipManager::getInstance();
pjsip_endpoint *endpt = PJSipManager.getEndpoint();
- pjsip_inv_usage_init(endpt, mModule, mInvCallback);
+ pjsip_inv_usage_init(endpt, &mInvCallback);
manager.registerModule(mModule);
}
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index 307cf24..618e8d2 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -1,3 +1,7 @@
+#include <pjsip.h>
+#include <pjsip_ua.h>
+#include <pjlib.h>
+
namespace Hydra
{
@@ -12,6 +16,7 @@ private:
pjsip_module mModule;
pjsip_inv_callback mInvCallback;
pjsip_ua_init_param mUaParam;
+ const std::string mName;
};
}; //end namespace SipChannelService
commit 69211d3b0366ef2617ec5c138914784507ff825f
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 24 16:41:34 2010 -0500
Added some handling for a new INVITE.
Next commit will be to fix up any compilation problems I run across.
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 195bc49..b0205e5 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -6,6 +6,10 @@ namespace Hydra
namespace SipChannelService
{
+using namespace Hydra::Core::Routing::V1;
+using namespace Hydra::Core::Bridging::V1;
+using namespace Hydra::Core::Endpoint::V1;
+
static pj_status_t sessionLoad(pjsip_endpoint *endpt)
{
//stub
@@ -30,6 +34,54 @@ static pj_status_t sessionUnload()
return PJ_SUCCESS;
}
+static void handle_new_invite(pjsip_rx_data *rdata)
+{
+ //What do we do here?
+ //
+ //First we need to identify who this is coming from.
+ //If it's someone we recognize, then we can figure
+ //out whether we need to send a 401/407 request.
+ //For now, we don't have any sort of configured users,
+ //so we skip this step. Instead, we'll skip ahead to
+ //creating an endpoint, creating the invite session,
+ //sending a 100 trying, finding the remote endpoint
+ //to call, and placing a call to it.
+
+ //XXX Put caller identification code in here!
+
+ SipChannelServiceDataModel dataModel = SipChannelServiceDataModel::getInstance();
+ SipEndpointFactory factory = dataModel.getEndpointFactory();
+ //XXX Hardcoded "Butt" is bad for a lot of reasons,
+ //but for now have it there just so stuff'll compile!
+ SipEndpoint caller = factory.getEndpoint("Butt");
+
+ //We've created our calling endpoint. Now we need to look up the destination.
+ pjsip_uri ruri = rdata.msg.line.req.uri;
+ std::string destination("");
+ if (PJSIP_URI_SCHEME_IS_SIP(ruri) || PJSIP_URI_SCHEME_IS_SIPS(ruri))
+ {
+ pjsip_sip_uri sipRuri = static_cast<pjsip_sip_uri>(ruri);
+ //For now, we only know about destination "100" so we'll
+ //grab that from the URI to pass to the locator.
+ location = pj_strbuf(sipRuri->user);
+ }
+ LocatorRegistryPrx locator = dataModel.getRoutingService();
+ try
+ {
+ std::vector<BaseEndpointPrx> endpoints = locator->lookup(destination);
+ }
+ catch (DestinationNotFoundException destEx)
+ {
+ std::cerr << "[WARNING] Could not find destination " << destEx.destination << std::endl;
+ }
+ catch (InvalidParamsException invalEx)
+ {
+ std::cerr << "[WARNING] Invalid parameters in endpoint lookup. " << std::endl;
+ }
+ BridgeFactoryPrx bridgeFactory = dataModel.getBridgeFactory();
+ BridgePrx bridge = bridgeFactory.createBridge(caller, endpoints, 0);
+}
+
static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
{
pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
@@ -39,9 +91,7 @@ static pj_bool_t sessionOnReceiveRequest(pjsip_rx_data *rdata)
{
if (dlg == NULL)
{
- // New incoming INVITE.
- // This is where some really good
- // meaty goodness will be. Oh yeah.
+ handle_new_invite(rdata);
}
else
{
@@ -249,6 +299,8 @@ PJSipModule::PJSipModule()
}
Boost::shared_ptr<PJSipManager> manager = PJSipManager::getInstance();
+ pjsip_endpoint *endpt = PJSipManager.getEndpoint();
+ pjsip_inv_usage_init(endpt, mModule, mInvCallback);
manager.registerModule(mModule);
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list