[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "telephony-events2" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Aug 2 17:40:49 CDT 2011
branch "telephony-events2" has been created
at bebb64eeace7496c0da09b238f293ae35b296d36 (commit)
- Log -----------------------------------------------------------------
commit bebb64eeace7496c0da09b238f293ae35b296d36
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 2 17:41:20 2011 -0500
Setting up stuff on sources and sinks.
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index 3213402..3379cb4 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -16,6 +16,7 @@
#include "RTPSink.h"
#include "RtpStateReplicationIf.h"
+#include "RTPTelephonyEventSink.h"
#include <pjlib.h>
#include <pjmedia.h>
@@ -68,6 +69,11 @@ public:
RtpStreamSinkStateItemPtr mSinkStateItem;
/**
+ * TelephonyEvent Sink for RFC 4733 events
+ */
+ RTPTelephonyEventSinkPtr mTelephonyEventSink;
+
+ /**
* The parent session's id.
*/
string mSessionId;
@@ -80,7 +86,7 @@ StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(
const SessionAdapterPtr& session,
const PJMediaTransportPtr& transport,
const string& sessionId,
- const RTPOptionsPtr& /*options*/,
+ const RTPOptionsPtr& options,
RTPAllocationOutputsPtr& /*outputs*/) :
mSessionAdapter(session), mTransport(transport),
mSinkStateItem(new RtpStreamSinkStateItem),
@@ -90,6 +96,11 @@ StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(
mSinkStateItem->sessionId = sessionId;
mSinkStateItem->key = IceUtil::generateUUID();
mSinkStateItem->remotePort = 0;
+
+ if (options->handleTelephonyEvents)
+ {
+ mTelephonyEventSink = new RTPTelephonyEventSink();
+ }
};
/**
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index fa32f96..7f31dea 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -16,6 +16,7 @@
#include "RTPSource.h"
#include "RtpStateReplicationIf.h"
+#include "RTPTelephonyEventSource.h"
#include <pjlib.h>
#include <pjmedia.h>
@@ -163,6 +164,11 @@ public:
StreamSinkRTPPrx mSink;
/**
+ * Telephony event sink for RFC 4733 events
+ */
+ RTPTelephonyEventSourcePtr mTelephonyEventSource;
+
+ /**
* Lock that protects information contained.
*/
boost::shared_mutex mLock;
@@ -176,7 +182,7 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const SessionAdapterPtr& sessio
const string& sessionId,
const StreamSourceRTPPrx& source,
const StreamSinkRTPPrx& sink,
- const RTPOptionsPtr& /*options*/,
+ const RTPOptionsPtr& options,
RTPAllocationOutputsPtr& /*outputs*/) :
mSessionAdapter(session), mTransport(transport),
mSourceStateItem(new RtpStreamSourceStateItem),
@@ -187,6 +193,11 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const SessionAdapterPtr& sessio
pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
mSourceStateItem->sessionId = sessionId;
mSourceStateItem->key = IceUtil::generateUUID();
+
+ if (options->handleTelephonyEvents)
+ {
+ mTelephonyEventSource = new RTPTelephonyEventSource(&mIncomingSession);
+ }
}
/**
diff --git a/src/RTPTelephonyEventSink.h b/src/RTPTelephonyEventSink.h
index abc26db..7e1a160 100644
--- a/src/RTPTelephonyEventSink.h
+++ b/src/RTPTelephonyEventSink.h
@@ -38,3 +38,5 @@ public:
private:
AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx mSource;
};
+
+typedef IceUtil::Handle<RTPTelephonyEventSink> RTPTelephonyEventSinkPtr;
diff --git a/src/RTPTelephonyEventSource.cpp b/src/RTPTelephonyEventSource.cpp
index dd8b76c..7b1d40c 100644
--- a/src/RTPTelephonyEventSource.cpp
+++ b/src/RTPTelephonyEventSource.cpp
@@ -18,6 +18,15 @@
using namespace AsteriskSCF::SessionCommunications::V1;
+RTPTelephonyEventSource::RTPTelephonyEventSource(pjmedia_rtp_session *session)
+ : mSession(session)
+{
+}
+
+RTPTelephonyEventSource::~RTPTelephonyEventSource()
+{
+}
+
void RTPTelephonyEventSource::addSink_async(
const AMD_TelephonyEventSource_addSinkPtr& cb,
const TelephonyEventSinkPrx&,
@@ -33,3 +42,7 @@ void RTPTelephonyEventSource::getSinks_async(
cb->ice_response(TelephonyEventSinkSeq());
}
+TelephonyEventSourcePrx RTPTelephonyEventSource::getProxy()
+{
+ return mProxy;
+}
diff --git a/src/RTPTelephonyEventSource.h b/src/RTPTelephonyEventSource.h
index b53c8ed..67a7ed1 100644
--- a/src/RTPTelephonyEventSource.h
+++ b/src/RTPTelephonyEventSource.h
@@ -18,10 +18,13 @@
#include <AsteriskSCF/SessionCommunications/TelephonyEventsIf.h>
+#include "pjmedia.h"
+
class RTPTelephonyEventSource : public AsteriskSCF::SessionCommunications::V1::TelephonyEventSource
{
-
public:
+ RTPTelephonyEventSource(pjmedia_rtp_session *session);
+
void addSink_async(
const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr& cb,
const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink,
@@ -30,4 +33,15 @@ public:
void getSinks_async(
const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr& cb,
const Ice::Current&);
+
+ AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx getProxy();
+
+protected:
+ ~RTPTelephonyEventSource();
+
+private:
+ pjmedia_rtp_session *mSession;
+ AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx mProxy;
};
+
+typedef IceUtil::Handle<RTPTelephonyEventSource> RTPTelephonyEventSourcePtr;
commit c356be141c7f6cca773a9316a1ff4b3e392258af
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 2 16:41:09 2011 -0500
*Get options and outputs where they're needed.
*Create Telephony event source and sink classes.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 13185bd..b1ca3d0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,10 +5,14 @@ astscf_component_init(media_rtp_pjmedia)
astscf_component_add_files(media_rtp_pjmedia MediaRTPpjmedia.cpp)
astscf_component_add_files(media_rtp_pjmedia RTPSession.cpp)
astscf_component_add_files(media_rtp_pjmedia RTPSource.cpp)
+astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSource.cpp)
astscf_component_add_files(media_rtp_pjmedia RTPSink.cpp)
+astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSink.cpp)
astscf_component_add_files(media_rtp_pjmedia RTPSession.h)
astscf_component_add_files(media_rtp_pjmedia RTPSource.h)
+astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSource.h)
astscf_component_add_files(media_rtp_pjmedia RTPSink.h)
+astscf_component_add_files(media_rtp_pjmedia RTPTelephonyEventSink.h)
astscf_component_add_files(media_rtp_pjmedia RtpStateReplicatorListener.cpp)
astscf_component_add_files(media_rtp_pjmedia RtpStateReplicator.h)
astscf_component_add_files(media_rtp_pjmedia RTPConfiguration.cpp)
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 85585b3..dc91507 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -145,8 +145,8 @@ public:
const PJMediaEnvironmentPtr& env,
const AsteriskSCF::Media::RTP::V1::RTPServiceLocatorParamsPtr& params,
const AsteriskSCF::System::Component::V1::ReplicaPrx& replicaControl,
- const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStateReplicatorPrx>&,
- const ConfigurationServiceImplPtr&);
+ const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStateReplicatorPrx>&,
+ const ConfigurationServiceImplPtr&);
RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter,
const string& sessionIdentity,
@@ -207,8 +207,17 @@ public:
std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> getSenderReportListeners();
AsteriskSCF::Media::RTCP::V1::StatisticsPtr getSenderReportStatistics();
- RTPSessionPrx activate(const string& id);
- RTPSessionPrx activate(const Ice::Identity& id, const Ice::Identity& sourceId, const Ice::Identity& sinkId);
+ RTPSessionPrx activate(
+ const string& id,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs);
+
+ RTPSessionPrx activate(
+ const Ice::Identity& id,
+ const Ice::Identity& sourceId,
+ const Ice::Identity& sinkId,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs);
void destroy();
@@ -435,7 +444,7 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter,
const RTPServiceLocatorParamsPtr& params,
const ReplicaPrx& replicaService,
const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>& stateReplicator,
- const ConfigurationServiceImplPtr& configurationService) :
+ const ConfigurationServiceImplPtr& configurationService) :
mEnvironment(env),
mEndpoint(PJMediaEndpoint::create(env)),
mId(id),
@@ -850,23 +859,43 @@ void RTPSessionImpl::associatePayloadsImpl(const AsteriskSCF::Media::RTP::V1::Pa
}
}
-RTPSessionPrx RTPSessionImpl::activate(const string& id)
+RTPSessionPrx RTPSessionImpl::activate(
+ const string& id,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs)
{
assert(id == mId);
Ice::Identity sourceId(mAdapter->getCommunicator()->stringToIdentity(IceUtil::generateUUID()));
Ice::Identity sinkId(mAdapter->getCommunicator()->stringToIdentity(IceUtil::generateUUID()));
- return activate(mAdapter->getCommunicator()->stringToIdentity(id), sourceId, sinkId);
+ return activate(mAdapter->getCommunicator()->stringToIdentity(id), sourceId, sinkId, options, outputs);
}
-RTPSessionPrx RTPSessionImpl::activate(const Ice::Identity& id, const Ice::Identity& sourceId,
- const Ice::Identity& sinkId)
+RTPSessionPrx RTPSessionImpl::activate(
+ const Ice::Identity& id,
+ const Ice::Identity& sourceId,
+ const Ice::Identity& sinkId,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs)
{
mSessionAdapter.reset(new SessionAdapterImpl(this));
try
{
- mStreamSource = new StreamSourceRTPImpl(mSessionAdapter, mTransport, mId, StreamSourceRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sourceId)),
- StreamSinkRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sinkId)));
- mStreamSink = new StreamSinkRTPImpl(mSessionAdapter, mTransport, mId);
+ mStreamSource = new StreamSourceRTPImpl(
+ mSessionAdapter,
+ mTransport,
+ mId,
+ StreamSourceRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sourceId)),
+ StreamSinkRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sinkId)),
+ options,
+ outputs);
+
+ mStreamSink = new StreamSinkRTPImpl(
+ mSessionAdapter,
+ mTransport,
+ mId,
+ options,
+ outputs);
+
mRtcpSessionInterface = new RTCPSessionImpl(this);
mReceiverReport = new RTCPInformationImpl(&mRtcpSession.stat, &mRtcpSession.stat.rx);
mSenderReport = new RTCPInformationImpl(&mRtcpSession.stat, &mRtcpSession.stat.tx);
@@ -969,20 +998,20 @@ RTPSessionPrx AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::ObjectAdapt
const AsteriskSCF::System::Component::V1::ReplicaPrx& replicaControl,
const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>& stateReplicator,
const ConfigurationServiceImplPtr& configuration,
- const RTPOptionsPtr&,
- RTPAllocationOutputsPtr&)
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs)
{
RTPSessionImplPtr servant(new RTPSessionImpl(adapter, id, environment, params,
replicaControl, stateReplicator, configuration));
- return servant->activate(id);
+ return servant->activate(id, options, outputs);
}
ReplicationAdapterPtr AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::ObjectAdapterPtr& adapter,
const PJMediaEnvironmentPtr& environment,
const RtpSessionStateItemPtr& item,
const ConfigurationServiceImplPtr& configuration,
- const RTPOptionsPtr&,
- RTPAllocationOutputsPtr&)
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs)
{
RTPSessionImplPtr servant(new RTPSessionImpl(adapter,
adapter->getCommunicator()->identityToString(item->sessionIdentity),
@@ -990,7 +1019,7 @@ ReplicationAdapterPtr AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::Obj
item->port, item->formats, item->ipv6, item->srtp,
AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>(),
configuration));
- servant->activate(item->sessionIdentity, item->sourceIdentity, item->sinkIdentity);
+ servant->activate(item->sessionIdentity, item->sourceIdentity, item->sinkIdentity, options, outputs);
return ReplicationAdapterPtr(new ReplicationAdapterImpl(servant));
}
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index 687ded0..3213402 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -43,8 +43,12 @@ public:
/**
* Constructor for our StreamSinkRTPImplPriv class.
*/
- StreamSinkRTPImplPriv(const SessionAdapterPtr& sessionAdapter,
- const PJMediaTransportPtr& transport, const std::string&);
+ StreamSinkRTPImplPriv(
+ const SessionAdapterPtr& sessionAdapter,
+ const PJMediaTransportPtr& transport,
+ const std::string&,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs);
/**
* A structure containing outgoing pjmedia session data.
@@ -72,8 +76,12 @@ public:
/**
* Constructor for the StreamSinkRTPImplPriv class.
*/
-StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(const SessionAdapterPtr& session,
- const PJMediaTransportPtr& transport, const string& sessionId) :
+StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(
+ const SessionAdapterPtr& session,
+ const PJMediaTransportPtr& transport,
+ const string& sessionId,
+ const RTPOptionsPtr& /*options*/,
+ RTPAllocationOutputsPtr& /*outputs*/) :
mSessionAdapter(session), mTransport(transport),
mSinkStateItem(new RtpStreamSinkStateItem),
mSessionId(sessionId)
@@ -87,9 +95,13 @@ StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(const SessionAdapterPtr& session,
/**
* Constructor for the StreamSinkRTPImpl class.
*/
-StreamSinkRTPImpl::StreamSinkRTPImpl(const SessionAdapterPtr& session, const PJMediaTransportPtr& transport,
- const string& sessionId) :
- mImpl(new StreamSinkRTPImplPriv(session, transport, sessionId))
+StreamSinkRTPImpl::StreamSinkRTPImpl(
+ const SessionAdapterPtr& session,
+ const PJMediaTransportPtr& transport,
+ const string& sessionId,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs) :
+ mImpl(new StreamSinkRTPImplPriv(session, transport, sessionId, options, outputs))
{
}
diff --git a/src/RTPSink.h b/src/RTPSink.h
index 2036a14..0b87b77 100644
--- a/src/RTPSink.h
+++ b/src/RTPSink.h
@@ -24,9 +24,12 @@ class StreamSinkRTPImplPriv;
class StreamSinkRTPImpl : public AsteriskSCF::Media::RTP::V1::StreamSinkRTP
{
public:
- StreamSinkRTPImpl(const AsteriskSCF::PJMediaRTP::SessionAdapterPtr& sessionAdapter,
- const AsteriskSCF::PJMediaRTP::PJMediaTransportPtr& transport,
- const std::string& sessionId);
+ StreamSinkRTPImpl(
+ const AsteriskSCF::PJMediaRTP::SessionAdapterPtr& sessionAdapter,
+ const AsteriskSCF::PJMediaRTP::PJMediaTransportPtr& transport,
+ const std::string& sessionId,
+ const AsteriskSCF::Media::RTP::V1::RTPOptionsPtr& options,
+ AsteriskSCF::Media::RTP::V1::RTPAllocationOutputsPtr& outputs);
/**
* AsteriskSCF::Media::RTP::V1::StreamSinkRTP implementation.
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 8f501a9..fa32f96 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -116,7 +116,9 @@ public:
const PJMediaTransportPtr& transport,
const string& parentSessionId,
const StreamSourceRTPPrx& source,
- const StreamSinkRTPPrx& sink
+ const StreamSinkRTPPrx& sink,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs
);
/**
@@ -173,7 +175,9 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const SessionAdapterPtr& sessio
const PJMediaTransportPtr& transport,
const string& sessionId,
const StreamSourceRTPPrx& source,
- const StreamSinkRTPPrx& sink) :
+ const StreamSinkRTPPrx& sink,
+ const RTPOptionsPtr& /*options*/,
+ RTPAllocationOutputsPtr& /*outputs*/) :
mSessionAdapter(session), mTransport(transport),
mSourceStateItem(new RtpStreamSourceStateItem),
mSessionId(sessionId),
@@ -203,8 +207,10 @@ StreamSourceRTPImplPriv::~StreamSourceRTPImplPriv()
StreamSourceRTPImpl::StreamSourceRTPImpl(const SessionAdapterPtr& session,
const PJMediaTransportPtr& transport, const string& sessionId,
const StreamSourceRTPPrx& source,
- const StreamSinkRTPPrx& sink) :
- mImpl(new StreamSourceRTPImplPriv(session, transport, sessionId, source, sink))
+ const StreamSinkRTPPrx& sink,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs) :
+ mImpl(new StreamSourceRTPImplPriv(session, transport, sessionId, source, sink, options, outputs))
{
}
diff --git a/src/RTPSource.h b/src/RTPSource.h
index aeeff2c..ab3f38c 100644
--- a/src/RTPSource.h
+++ b/src/RTPSource.h
@@ -28,7 +28,9 @@ public:
const AsteriskSCF::PJMediaRTP::PJMediaTransportPtr& transport,
const std::string& parentSessionId,
const AsteriskSCF::Media::RTP::V1::StreamSourceRTPPrx& source,
- const AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx& sink);
+ const AsteriskSCF::Media::RTP::V1::StreamSinkRTPPrx& sink,
+ const AsteriskSCF::Media::RTP::V1::RTPOptionsPtr& options,
+ AsteriskSCF::Media::RTP::V1::RTPAllocationOutputsPtr& outputs);
void addSink(const AsteriskSCF::Media::V1::StreamSinkPrx&, const Ice::Current&);
void removeSink(const AsteriskSCF::Media::V1::StreamSinkPrx&, const Ice::Current&);
diff --git a/src/RTPTelephonyEventSink.cpp b/src/RTPTelephonyEventSink.cpp
new file mode 100644
index 0000000..c15f4f9
--- /dev/null
+++ b/src/RTPTelephonyEventSink.cpp
@@ -0,0 +1,43 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include "RTPTelephonyEventSink.h"
+
+using namespace AsteriskSCF::SessionCommunications::V1;
+
+void RTPTelephonyEventSink::write_async(
+ const AMD_TelephonyEventSink_writePtr& cb,
+ const TelephonyEventPtr&,
+ const Ice::Current&)
+{
+ cb->ice_response();
+}
+
+void RTPTelephonyEventSink::setSource_async(
+ const AMD_TelephonyEventSink_setSourcePtr& cb,
+ const TelephonyEventSourcePrx&,
+ const Ice::Current&)
+{
+ cb->ice_response();
+}
+
+void RTPTelephonyEventSink::getSource_async(
+ const AMD_TelephonyEventSink_getSourcePtr& cb,
+ const Ice::Current&)
+{
+ cb->ice_response(mSource);
+}
+
diff --git a/src/RTPTelephonyEventSink.h b/src/RTPTelephonyEventSink.h
new file mode 100644
index 0000000..abc26db
--- /dev/null
+++ b/src/RTPTelephonyEventSink.h
@@ -0,0 +1,40 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <AsteriskSCF/SessionCommunications/TelephonyEventsIf.h>
+
+class RTPTelephonyEventSink : public AsteriskSCF::SessionCommunications::V1::TelephonyEventSink
+{
+
+public:
+ void write_async(
+ const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_writePtr&,
+ const AsteriskSCF::SessionCommunications::V1::TelephonyEventPtr&,
+ const Ice::Current&);
+
+ void setSource_async(
+ const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_setSourcePtr&,
+ const AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx& source,
+ const Ice::Current&);
+
+ void getSource_async(
+ const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_getSourcePtr&,
+ const Ice::Current&);
+private:
+ AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx mSource;
+};
diff --git a/src/RTPTelephonyEventSource.cpp b/src/RTPTelephonyEventSource.cpp
new file mode 100644
index 0000000..dd8b76c
--- /dev/null
+++ b/src/RTPTelephonyEventSource.cpp
@@ -0,0 +1,35 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include "RTPTelephonyEventSource.h"
+
+using namespace AsteriskSCF::SessionCommunications::V1;
+
+void RTPTelephonyEventSource::addSink_async(
+ const AMD_TelephonyEventSource_addSinkPtr& cb,
+ const TelephonyEventSinkPrx&,
+ const Ice::Current&)
+{
+ cb->ice_response();
+}
+
+void RTPTelephonyEventSource::getSinks_async(
+ const AMD_TelephonyEventSource_getSinksPtr& cb,
+ const Ice::Current&)
+{
+ cb->ice_response(TelephonyEventSinkSeq());
+}
+
diff --git a/src/RTPTelephonyEventSource.h b/src/RTPTelephonyEventSource.h
new file mode 100644
index 0000000..b53c8ed
--- /dev/null
+++ b/src/RTPTelephonyEventSource.h
@@ -0,0 +1,33 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <AsteriskSCF/SessionCommunications/TelephonyEventsIf.h>
+
+class RTPTelephonyEventSource : public AsteriskSCF::SessionCommunications::V1::TelephonyEventSource
+{
+
+public:
+ void addSink_async(
+ const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr& cb,
+ const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink,
+ const Ice::Current&);
+
+ void getSinks_async(
+ const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr& cb,
+ const Ice::Current&);
+};
commit 2f6e2062d7d27b364fd48386fa4e1006f3dc6d87
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Aug 2 14:26:29 2011 -0500
Adjust allocation of RTP sessions to include RTP options and outputs.
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index 9b2933f..8f9b4e7 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -72,7 +72,11 @@ public:
RTPMediaServiceImpl(const Ice::ObjectAdapterPtr&, const ReplicaPrx&,
const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>&,
const ConfigurationServiceImplPtr&);
- RTPSessionPrx allocate(const RTPServiceLocatorParamsPtr&, const Ice::Current&);
+ RTPSessionPrx allocate(
+ const RTPServiceLocatorParamsPtr&,
+ const RTPOptionsPtr&,
+ RTPAllocationOutputsPtr&,
+ const Ice::Current&);
pj_pool_factory *getPoolFactory() { return mEnvironment->poolFactory(); };
PJMediaEnvironmentPtr getEnvironment()
@@ -491,10 +495,14 @@ RTPMediaServiceImpl::RTPMediaServiceImpl(const Ice::ObjectAdapterPtr& adapter, c
/**
* Implementation of the allocate method as defined in MediaRTPIf.ice
*/
-RTPSessionPrx RTPMediaServiceImpl::allocate(const RTPServiceLocatorParamsPtr& params, const Ice::Current&)
+RTPSessionPrx RTPMediaServiceImpl::allocate(
+ const RTPServiceLocatorParamsPtr& params,
+ const RTPOptionsPtr& options,
+ RTPAllocationOutputsPtr& outputs,
+ const Ice::Current&)
{
return AsteriskSCF::PJMediaRTP::RTPSession::create(mAdapter, IceUtil::generateUUID(), params, mEnvironment,
- mReplicaServicePrx, mStateReplicator, mConfigurationService);
+ mReplicaServicePrx, mStateReplicator, mConfigurationService, options, outputs);
}
/**
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index eb3bac8..85585b3 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -968,7 +968,9 @@ RTPSessionPrx AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::ObjectAdapt
const PJMediaEnvironmentPtr& environment,
const AsteriskSCF::System::Component::V1::ReplicaPrx& replicaControl,
const AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>& stateReplicator,
- const ConfigurationServiceImplPtr& configuration)
+ const ConfigurationServiceImplPtr& configuration,
+ const RTPOptionsPtr&,
+ RTPAllocationOutputsPtr&)
{
RTPSessionImplPtr servant(new RTPSessionImpl(adapter, id, environment, params,
replicaControl, stateReplicator, configuration));
@@ -976,9 +978,11 @@ RTPSessionPrx AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::ObjectAdapt
}
ReplicationAdapterPtr AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::ObjectAdapterPtr& adapter,
- const PJMediaEnvironmentPtr& environment,
- const RtpSessionStateItemPtr& item,
- const ConfigurationServiceImplPtr& configuration)
+ const PJMediaEnvironmentPtr& environment,
+ const RtpSessionStateItemPtr& item,
+ const ConfigurationServiceImplPtr& configuration,
+ const RTPOptionsPtr&,
+ RTPAllocationOutputsPtr&)
{
RTPSessionImplPtr servant(new RTPSessionImpl(adapter,
adapter->getCommunicator()->identityToString(item->sessionIdentity),
diff --git a/src/RTPSession.h b/src/RTPSession.h
index a4f8072..60f2e35 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -33,14 +33,18 @@ public:
const PJMediaEnvironmentPtr& environment,
const AsteriskSCF::System::Component::V1::ReplicaPrx& replicaControl,
const AsteriskSCF::Discovery::SmartProxy<
- AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStateReplicatorPrx>& stateReplicator,
- const ConfigurationServiceImplPtr& configuration
+ AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStateReplicatorPrx>& stateReplicator,
+ const ConfigurationServiceImplPtr& configuration,
+ const AsteriskSCF::Media::RTP::V1::RTPOptionsPtr&,
+ AsteriskSCF::Media::RTP::V1::RTPAllocationOutputsPtr&
);
static ReplicationAdapterPtr create(const Ice::ObjectAdapterPtr& objectAdapter,
const PJMediaEnvironmentPtr& environment,
const AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpSessionStateItemPtr& update,
- const ConfigurationServiceImplPtr& configuration
+ const ConfigurationServiceImplPtr& configuration,
+ const AsteriskSCF::Media::RTP::V1::RTPOptionsPtr&,
+ AsteriskSCF::Media::RTP::V1::RTPAllocationOutputsPtr&
);
};
} /* End of namespace RTPMedia */
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index e441f41..b393613 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -106,9 +106,12 @@ public:
localitem = newitem;
mImpl->mStateItems.insert(make_pair(item->sessionId, newitem));
- localitem->setSession(
- AsteriskSCF::PJMediaRTP::RTPSession::create(mImpl->mAdapter, mImpl->mEnvironment, item,
- mImpl->mConfigurationService));
+ //XXX We need to sort out the options and outputs here.
+ RTPOptionsPtr options(new RTPOptions);
+ RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
+ localitem->setSession(
+ AsteriskSCF::PJMediaRTP::RTPSession::create(mImpl->mAdapter, mImpl->mEnvironment, item,
+ mImpl->mConfigurationService, options, outputs));
}
else
{
diff --git a/test/TestRTPICE.cpp b/test/TestRTPICE.cpp
index 77393a9..e01fa3a 100644
--- a/test/TestRTPICE.cpp
+++ b/test/TestRTPICE.cpp
@@ -199,7 +199,9 @@ BOOST_AUTO_TEST_CASE(RtpSessionWithICEEnabled)
query->enableRTPOverICE = true;
query->enableTURN = false;
RTPSessionPrx sessionPrx;
- BOOST_REQUIRE_NO_THROW(sessionPrx = servicePrx->allocate(query));
+ RTPOptionsPtr options(new RTPOptions);
+ RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
+ BOOST_REQUIRE_NO_THROW(sessionPrx = servicePrx->allocate(query, options, outputs));
BOOST_REQUIRE(sessionPrx != 0);
sessionPrx->ice_ping(); // To silence unused arg warning.
sessionPrx->release();
@@ -253,7 +255,9 @@ BOOST_AUTO_TEST_CASE(RtpSessionAllocationFailure)
query->category = "rtp";
query->enableRTPOverICE = true;
query->enableTURN = true;
- RTPSessionPrx sessionPrx = servicePrx->allocate(query);
+ RTPOptionsPtr options(new RTPOptions);
+ RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
+ RTPSessionPrx sessionPrx = servicePrx->allocate(query, options, outputs);
sessionPrx->ice_ping();
}
catch (const SessionAllocationFailure& ex)
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index b6a4152..14d3e4c 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -478,10 +478,13 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
FormatSeq formats;
formats.push_back(format);
- // You might think "geez, this should deadlock due to state replication" but no, we use one ways for that
- boost::mutex::scoped_lock lock(Testbed.mLock);
+ // You might think "geez, this should deadlock due to state replication" but no, we use one ways for that
+ boost::mutex::scoped_lock lock(Testbed.mLock);
- Testbed.session = service->allocate(params);
+ RTPOptionsPtr options(new RTPOptions);
+ RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
+
+ Testbed.session = service->allocate(params, options, outputs);
// Give the RTP component time to replicate this session
Testbed.mCondition.wait(lock);
@@ -1194,7 +1197,10 @@ BOOST_AUTO_TEST_CASE(ReceiveUnknownRTPPacket)
FormatSeq formats;
formats.push_back(format);
- RTPSessionPrx session = service->allocate(params);
+ RTPOptionsPtr options(new RTPOptions);
+ RTPAllocationOutputsPtr outputs(new RTPAllocationOutputs);
+
+ RTPSessionPrx session = service->allocate(params, options, outputs);
PayloadMap mapping;
mapping.insert(make_pair(13, format));
commit 879bde1285172d86e0e5e2873d52dd67681bfb12
Author: Brent Eagles <beagles at digium.com>
Date: Tue Aug 2 11:55:08 2011 -0230
Fix inconsistencies with slice class member name renaming.
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index ccf8064..eb3bac8 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -695,8 +695,8 @@ void RTPSessionImpl::setRemoteDetails(const string& address, Ice::Int port)
*/
void RTPSessionImpl::setRemoteRtcpDetails(const std::string& address, Ice::Int port)
{
- mSessionStateItem->mRemoteRtcpAddress = address;
- mSessionStateItem->mRemoteRtcpPort = port;
+ mSessionStateItem->remoteRtcpAddress = address;
+ mSessionStateItem->remoteRtcpPort = port;
mStreamSource->setRemoteRtcpDetails(address, port);
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index c6c9615..b6a4152 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -667,8 +667,8 @@ BOOST_AUTO_TEST_CASE(VerifyReplicatedRTCPRemoteDetails)
Testbed.mCondition.wait(lock);
- BOOST_CHECK(Testbed.mListener->mSession->mRemoteRtcpAddress == address);
- BOOST_CHECK(Testbed.mListener->mSession->mRemoteRtcpPort == 10001);
+ BOOST_CHECK(Testbed.mListener->mSession->remoteRtcpAddress == address);
+ BOOST_CHECK(Testbed.mListener->mSession->remoteRtcpPort == 10001);
}
/**
commit 5cdf85964506bafba2394abb55b1982b910dfa03
Author: Mark Michelson <mmichelson at digium.com>
Date: Mon Aug 1 17:45:25 2011 -0500
Remove unnecessary 'm' prefix on slice data members.
diff --git a/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice b/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
index f3aae1f..4c44683 100644
--- a/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
@@ -41,7 +41,7 @@ module V1
unsliceable class RtpStateReplicatorParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
{
- string mName;
+ string name;
};
["visitor"] local class RtpStateItemVisitor
@@ -51,7 +51,7 @@ module V1
["visitor:RtpStateItemVisitor"] class RtpStateItem
{
string key;
- string mSessionId;
+ string sessionId;
};
sequence<RtpStateItem> RtpStateItemSeq;
@@ -74,8 +74,8 @@ module V1
class RtpGeneralStateItem extends RtpStateItem
{
- AsteriskSCF::Core::Discovery::V1::ServiceManagement *mServiceManagement;
- string mComparatorId;
+ AsteriskSCF::Core::Discovery::V1::ServiceManagement *serviceManagement;
+ string comparatorId;
};
/**
@@ -83,28 +83,28 @@ module V1
*/
class RtpSessionStateItem extends RtpStateItem
{
- Ice::Identity mSessionIdentity;
- int mPort;
- Ice::Identity mSinkIdentity;
- Ice::Identity mSourceIdentity;
- AsteriskSCF::Media::V1::FormatSeq mFormats;
- AsteriskSCF::Media::RTP::V1::PayloadMap mPayloadstoFormats;
- bool mIPv6;
- bool mSRTP;
- string mRemoteRtcpAddress;
- int mRemoteRtcpPort;
+ Ice::Identity sessionIdentity;
+ int port;
+ Ice::Identity sinkIdentity;
+ Ice::Identity sourceIdentity;
+ AsteriskSCF::Media::V1::FormatSeq formats;
+ AsteriskSCF::Media::RTP::V1::PayloadMap payloadstoFormats;
+ bool ipv6;
+ bool srtp;
+ string remoteRtcpAddress;
+ int remoteRtcpPort;
};
class RtpStreamSinkStateItem extends RtpStateItem
{
- AsteriskSCF::Media::V1::StreamSource *mSource;
- string mRemoteAddress;
- int mRemotePort;
+ AsteriskSCF::Media::V1::StreamSource *source;
+ string remoteAddress;
+ int remotePort;
};
class RtpStreamSourceStateItem extends RtpStateItem
{
- AsteriskSCF::Media::V1::StreamSinkSeq mSinks;
+ AsteriskSCF::Media::V1::StreamSinkSeq sinks;
};
}; /* module V1 */
diff --git a/src/MediaRTPpjmedia.cpp b/src/MediaRTPpjmedia.cpp
index c8304b3..9b2933f 100644
--- a/src/MediaRTPpjmedia.cpp
+++ b/src/MediaRTPpjmedia.cpp
@@ -361,7 +361,7 @@ public:
*/
virtual void suspend(const ::Ice::Current&)
{
- mGeneralState->mServiceManagement->suspend();
+ mGeneralState->serviceManagement->suspend();
}
/**
@@ -370,7 +370,7 @@ public:
*/
virtual void resume(const ::Ice::Current&)
{
- mGeneralState->mServiceManagement->unsuspend();
+ mGeneralState->serviceManagement->unsuspend();
}
/**
@@ -555,7 +555,7 @@ void MediaRTPpjmediaApp::start(const std::string&, const Ice::CommunicatorPtr& c
// Look for the configured state replicator or default one
RtpStateReplicatorParamsPtr replicatorParams = new RtpStateReplicatorParams();
replicatorParams->category = StateReplicatorDiscoveryCategory;
- replicatorParams->mName =
+ replicatorParams->name =
mCommunicator->getProperties()->getPropertyWithDefault("Rtp.StateReplicatorName", "default");
try
@@ -624,8 +624,8 @@ void MediaRTPpjmediaApp::start(const std::string&, const Ice::CommunicatorPtr& c
if (mReplicaService->isActive() == true)
{
- mGeneralState->mComparatorId = IceUtil::generateUUID();
- mManagement->addCompare(mGeneralState->mComparatorId, RTPMediaComparatorServiceProxy);
+ mGeneralState->comparatorId = IceUtil::generateUUID();
+ mManagement->addCompare(mGeneralState->comparatorId, RTPMediaComparatorServiceProxy);
}
@@ -654,10 +654,10 @@ void MediaRTPpjmediaApp::start(const std::string&, const Ice::CommunicatorPtr& c
if (mReplicaService->isActive() == true)
{
- mGeneralState->mServiceManagement = ServiceManagementPrx::uncheckedCast(
+ mGeneralState->serviceManagement = ServiceManagementPrx::uncheckedCast(
mManagement->addService(RTPMediaServiceProxy, "media_rtp_pjmedia"));
/* Now we can add some parameters to help find us. */
- mGeneralState->mServiceManagement->addLocatorParams(rtpparams, mGeneralState->mComparatorId);
+ mGeneralState->serviceManagement->addLocatorParams(rtpparams, mGeneralState->comparatorId);
}
ServiceLocatorParamsPtr genericparams = new ServiceLocatorParams();
@@ -691,7 +691,7 @@ void MediaRTPpjmediaApp::stop()
mComponentServiceManagement->unregister();
if (mReplicaService->isActive() == true)
{
- mGeneralState->mServiceManagement->unregister();
+ mGeneralState->serviceManagement->unregister();
}
if (mConfigurationManagement)
{
@@ -702,7 +702,7 @@ void MediaRTPpjmediaApp::stop()
mManagement->removeCompare(mConfigCompareGuid);
ServiceLocatorManagementPrx management =
ServiceLocatorManagementPrx::checkedCast(mCommunicator->propertyToProxy("ServiceLocatorManagementProxy"));
- management->removeCompare(mGeneralState->mComparatorId);
+ management->removeCompare(mGeneralState->comparatorId);
}
mCommunicator->destroy();
}
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 69c1fea..ccf8064 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -468,18 +468,18 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter,
if (mEnvironment->srtpConfig() && mEnvironment->srtpConfig()->isSRTPEnabled() && params->srtpCapable)
{
mTransport = SRTPTransport::create(mTransport, mEndpoint, configurationService);
- mSessionStateItem->mSRTP = true;
+ mSessionStateItem->srtp = true;
}
else
{
- mSessionStateItem->mSRTP = false;
+ mSessionStateItem->srtp = false;
}
// Initialize our session state item enough so that the state items for the source and sink can also be initialized.
- mSessionStateItem->key = mSessionStateItem->mSessionId = IceUtil::generateUUID();
- mSessionStateItem->mSessionIdentity = mAdapter->getCommunicator()->stringToIdentity(mId);
- mSessionStateItem->mFormats = params->formats;
- mSessionStateItem->mIPv6 = params->ipv6;
+ mSessionStateItem->key = mSessionStateItem->sessionId = IceUtil::generateUUID();
+ mSessionStateItem->sessionIdentity = mAdapter->getCommunicator()->stringToIdentity(mId);
+ mSessionStateItem->formats = params->formats;
+ mSessionStateItem->ipv6 = params->ipv6;
pjmedia_rtcp_init(&mRtcpSession, NULL, 8000, 160, 0);
}
@@ -594,7 +594,7 @@ void RTPSessionImpl::release(const Ice::Current&)
*/
void RTPSessionImpl::associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap& mappings, const Ice::Current&)
{
- mSessionStateItem->mPayloadstoFormats = mappings;
+ mSessionStateItem->payloadstoFormats = mappings;
associatePayloadsImpl(mappings);
// Only the session has changed so push a single update out for it
@@ -710,9 +710,9 @@ void RTPSessionImpl::setRemoteRtcpDetails(const std::string& address, Ice::Int p
*/
FormatPtr RTPSessionImpl::getFormat(int payload)
{
- PayloadMap::iterator it = mSessionStateItem->mPayloadstoFormats.find(payload);
+ PayloadMap::iterator it = mSessionStateItem->payloadstoFormats.find(payload);
- if (it == mSessionStateItem->mPayloadstoFormats.end())
+ if (it == mSessionStateItem->payloadstoFormats.end())
{
return 0;
}
@@ -878,18 +878,18 @@ RTPSessionPrx RTPSessionImpl::activate(const Ice::Identity& id, const Ice::Ident
if (mSessionStateItem)
{
- mSessionStateItem->key = mSessionStateItem->mSessionId = mId;
- mSessionStateItem->mSessionIdentity = id;
- mSessionStateItem->mFormats = mFormats;
- mSessionStateItem->mSourceIdentity = sourceId;
- mSessionStateItem->mSinkIdentity = sinkId;
+ mSessionStateItem->key = mSessionStateItem->sessionId = mId;
+ mSessionStateItem->sessionIdentity = id;
+ mSessionStateItem->formats = mFormats;
+ mSessionStateItem->sourceIdentity = sourceId;
+ mSessionStateItem->sinkIdentity = sinkId;
if (mTransport->localAddress())
{
- mSessionStateItem->mPort = mTransport->localAddress()->port();
+ mSessionStateItem->port = mTransport->localAddress()->port();
}
else
{
- mSessionStateItem->mPort = 0;
+ mSessionStateItem->port = 0;
}
replicateState(mSessionStateItem, mStreamSink->getStateItem(), mStreamSource->getStateItem());
}
@@ -933,20 +933,20 @@ public:
void update(const RtpSessionStateItemPtr& item)
{
- mImpl->associatePayloadsImpl(item->mPayloadstoFormats);
- mImpl->setRemoteRtcpDetails(item->mRemoteRtcpAddress, item->mRemoteRtcpPort);
+ mImpl->associatePayloadsImpl(item->payloadstoFormats);
+ mImpl->setRemoteRtcpDetails(item->remoteRtcpAddress, item->remoteRtcpPort);
}
void update(const RtpStreamSinkStateItemPtr& item)
{
- mImpl->getSinkServant()->setSourceImpl(item->mSource);
- mImpl->getSinkServant()->setRemoteDetailsImpl(item->mRemoteAddress, item->mRemotePort);
- mImpl->getSourceServant()->setRemoteDetails(item->mRemoteAddress, item->mRemotePort);
+ mImpl->getSinkServant()->setSourceImpl(item->source);
+ mImpl->getSinkServant()->setRemoteDetailsImpl(item->remoteAddress, item->remotePort);
+ mImpl->getSourceServant()->setRemoteDetails(item->remoteAddress, item->remotePort);
}
void update(const RtpStreamSourceStateItemPtr& item)
{
- mImpl->getSourceServant()->setSinksImpl(item->mSinks);
+ mImpl->getSourceServant()->setSinksImpl(item->sinks);
}
void destroy()
@@ -981,12 +981,12 @@ ReplicationAdapterPtr AsteriskSCF::PJMediaRTP::RTPSession::create(const Ice::Obj
const ConfigurationServiceImplPtr& configuration)
{
RTPSessionImplPtr servant(new RTPSessionImpl(adapter,
- adapter->getCommunicator()->identityToString(item->mSessionIdentity),
+ adapter->getCommunicator()->identityToString(item->sessionIdentity),
environment,
- item->mPort, item->mFormats, item->mIPv6, item->mSRTP,
+ item->port, item->formats, item->ipv6, item->srtp,
AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx>(),
configuration));
- servant->activate(item->mSessionIdentity, item-> mSourceIdentity, item->mSinkIdentity);
+ servant->activate(item->sessionIdentity, item->sourceIdentity, item->sinkIdentity);
return ReplicationAdapterPtr(new ReplicationAdapterImpl(servant));
}
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index 8184c1a..687ded0 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -79,9 +79,9 @@ StreamSinkRTPImplPriv::StreamSinkRTPImplPriv(const SessionAdapterPtr& session,
mSessionId(sessionId)
{
pjmedia_rtp_session_init(&mOutgoingSession, 0, pj_rand());
- mSinkStateItem->mSessionId = sessionId;
+ mSinkStateItem->sessionId = sessionId;
mSinkStateItem->key = IceUtil::generateUUID();
- mSinkStateItem->mRemotePort = 0;
+ mSinkStateItem->remotePort = 0;
};
/**
@@ -99,7 +99,7 @@ StreamSinkRTPImpl::StreamSinkRTPImpl(const SessionAdapterPtr& session, const PJM
void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, const Ice::Current&)
{
// Don't even bother if no remote address information is present
- if (mImpl->mSinkStateItem->mRemoteAddress.empty() || !mImpl->mSinkStateItem->mRemotePort)
+ if (mImpl->mSinkStateItem->remoteAddress.empty() || !mImpl->mSinkStateItem->remotePort)
{
return;
}
@@ -165,7 +165,7 @@ void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, co
*/
void StreamSinkRTPImpl::setSource(const AsteriskSCF::Media::V1::StreamSourcePrx& source, const Ice::Current&)
{
- mImpl->mSinkStateItem->mSource = source;
+ mImpl->mSinkStateItem->source = source;
mImpl->mSessionAdapter->replicateState(mImpl->mSinkStateItem);
}
@@ -175,7 +175,7 @@ void StreamSinkRTPImpl::setSource(const AsteriskSCF::Media::V1::StreamSourcePrx&
*/
AsteriskSCF::Media::V1::StreamSourcePrx StreamSinkRTPImpl::getSource(const Ice::Current&)
{
- return mImpl->mSinkStateItem->mSource;
+ return mImpl->mSinkStateItem->source;
}
/**
@@ -208,8 +208,8 @@ void StreamSinkRTPImpl::setRemoteDetails(const string& address, Ice::Int port, c
/* We do store it though in case we have not yet received a packet from the remote side but
* are asked for the remote address. It is also stored for replication purposes.
*/
- mImpl->mSinkStateItem->mRemoteAddress = address;
- mImpl->mSinkStateItem->mRemotePort = port;
+ mImpl->mSinkStateItem->remoteAddress = address;
+ mImpl->mSinkStateItem->remotePort = port;
mImpl->mSessionAdapter->replicateState(mImpl->mSinkStateItem);
}
@@ -222,9 +222,9 @@ std::string StreamSinkRTPImpl::getRemoteAddress(const Ice::Current&)
if (mImpl->mTransport && mImpl->mTransport->remoteAddress())
{
string address = mImpl->mTransport->remoteAddress()->hostname();
- return (address != "0.0.0.0") ? address : mImpl->mSinkStateItem->mRemoteAddress;
+ return (address != "0.0.0.0") ? address : mImpl->mSinkStateItem->remoteAddress;
}
- return mImpl->mSinkStateItem->mRemoteAddress;
+ return mImpl->mSinkStateItem->remoteAddress;
}
/**
@@ -235,9 +235,9 @@ Ice::Int StreamSinkRTPImpl::getRemotePort(const Ice::Current&)
if (mImpl->mTransport && mImpl->mTransport->remoteAddress())
{
int port = mImpl->mTransport->remoteAddress()->port();
- return (port != 0) ? port : mImpl->mSinkStateItem->mRemotePort;
+ return (port != 0) ? port : mImpl->mSinkStateItem->remotePort;
}
- return mImpl->mSinkStateItem->mRemotePort;
+ return mImpl->mSinkStateItem->remotePort;
}
/**
@@ -250,11 +250,11 @@ RtpStreamSinkStateItemPtr StreamSinkRTPImpl::getStateItem()
void StreamSinkRTPImpl::setRemoteDetailsImpl(const std::string& host, Ice::Int port)
{
- mImpl->mSinkStateItem->mRemoteAddress = host;
- mImpl->mSinkStateItem->mRemotePort = port;
+ mImpl->mSinkStateItem->remoteAddress = host;
+ mImpl->mSinkStateItem->remotePort = port;
}
void StreamSinkRTPImpl::setSourceImpl(const AsteriskSCF::Media::V1::StreamSourcePrx& proxy)
{
- mImpl->mSinkStateItem->mSource = proxy;
+ mImpl->mSinkStateItem->source = proxy;
}
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 4ae46f9..8f501a9 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -181,7 +181,7 @@ StreamSourceRTPImplPriv::StreamSourceRTPImplPriv(const SessionAdapterPtr& sessio
mSink(sink)
{
pjmedia_rtp_session_init(&mIncomingSession, 0, 0);
- mSourceStateItem->mSessionId = sessionId;
+ mSourceStateItem->sessionId = sessionId;
mSourceStateItem->key = IceUtil::generateUUID();
}
@@ -216,15 +216,15 @@ void StreamSourceRTPImpl::addSink(const AsteriskSCF::Media::V1::StreamSinkPrx& s
boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
// Do not allow the same sink to be added multiple times
- if (std::find(mImpl->mSourceStateItem->mSinks.begin(),
- mImpl->mSourceStateItem->mSinks.end(),
+ if (std::find(mImpl->mSourceStateItem->sinks.begin(),
+ mImpl->mSourceStateItem->sinks.end(),
sink) !=
- mImpl->mSourceStateItem->mSinks.end())
+ mImpl->mSourceStateItem->sinks.end())
{
return;
}
- mImpl->mSourceStateItem->mSinks.push_back(sink);
+ mImpl->mSourceStateItem->sinks.push_back(sink);
mImpl->mSessionAdapter->replicateState(mImpl->mSourceStateItem);
}
@@ -236,9 +236,9 @@ void StreamSourceRTPImpl::removeSink(const AsteriskSCF::Media::V1::StreamSinkPrx
{
boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
- mImpl->mSourceStateItem->mSinks.erase(std::remove(mImpl->mSourceStateItem->mSinks.begin(),
- mImpl->mSourceStateItem->mSinks.end(),
- sink), mImpl->mSourceStateItem->mSinks.end());
+ mImpl->mSourceStateItem->sinks.erase(std::remove(mImpl->mSourceStateItem->sinks.begin(),
+ mImpl->mSourceStateItem->sinks.end(),
+ sink), mImpl->mSourceStateItem->sinks.end());
mImpl->mSessionAdapter->replicateState(mImpl->mSourceStateItem);
}
@@ -248,7 +248,7 @@ void StreamSourceRTPImpl::removeSink(const AsteriskSCF::Media::V1::StreamSinkPrx
*/
AsteriskSCF::Media::V1::StreamSinkSeq StreamSourceRTPImpl::getSinks(const Ice::Current&)
{
- return mImpl->mSourceStateItem->mSinks;
+ return mImpl->mSourceStateItem->sinks;
}
/**
@@ -356,7 +356,7 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
}
}
- if (source->mImpl->mSourceStateItem->mSinks.empty())
+ if (source->mImpl->mSourceStateItem->sinks.empty())
{
// No sinks present so frames can not go anywhere
return;
@@ -408,8 +408,8 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
boost::shared_lock<boost::shared_mutex> lock(source->mImpl->mLock);
- for (StreamSinkSeq::iterator sink = source->mImpl->mSourceStateItem->mSinks.begin();
- sink != source->mImpl->mSourceStateItem->mSinks.end();
+ for (StreamSinkSeq::iterator sink = source->mImpl->mSourceStateItem->sinks.begin();
+ sink != source->mImpl->mSourceStateItem->sinks.end();
++sink)
{
try
@@ -570,5 +570,5 @@ RtpStreamSourceStateItemPtr StreamSourceRTPImpl::getStateItem()
void StreamSourceRTPImpl::setSinksImpl(const AsteriskSCF::Media::V1::StreamSinkSeq& sinks)
{
boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
- mImpl->mSourceStateItem->mSinks = sinks;
+ mImpl->mSourceStateItem->sinks = sinks;
}
diff --git a/src/RtpStateReplicatorApp.cpp b/src/RtpStateReplicatorApp.cpp
index 7c97d4d..8d5129b 100644
--- a/src/RtpStateReplicatorApp.cpp
+++ b/src/RtpStateReplicatorApp.cpp
@@ -118,7 +118,7 @@ public:
bool isSupported(const ServiceLocatorParamsPtr ¶ms, const Ice::Current &)
{
RtpStateReplicatorParamsPtr sipParams = RtpStateReplicatorParamsPtr::dynamicCast(params);
- if (sipParams->mName == mName)
+ if (sipParams->name == mName)
{
return true;
}
diff --git a/src/RtpStateReplicatorListener.cpp b/src/RtpStateReplicatorListener.cpp
index 9ceb5a5..e441f41 100644
--- a/src/RtpStateReplicatorListener.cpp
+++ b/src/RtpStateReplicatorListener.cpp
@@ -91,20 +91,20 @@ public:
void visitRtpGeneralStateItem(const RtpGeneralStateItemPtr &item)
{
- mImpl->mGeneralState->mServiceManagement = item->mServiceManagement;
- mImpl->mGeneralState->mComparatorId = item->mComparatorId;
+ mImpl->mGeneralState->serviceManagement = item->serviceManagement;
+ mImpl->mGeneralState->comparatorId = item->comparatorId;
}
void visitRtpSessionStateItem(const RtpSessionStateItemPtr &item)
{
- map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = mImpl->mStateItems.find(item->mSessionId);
+ map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i = mImpl->mStateItems.find(item->sessionId);
boost::shared_ptr<RtpStateReplicatorItem> localitem;
if (i == mImpl->mStateItems.end())
{
boost::shared_ptr<RtpStateReplicatorItem> newitem(new RtpStateReplicatorItem());
localitem = newitem;
- mImpl->mStateItems.insert(make_pair(item->mSessionId, newitem));
+ mImpl->mStateItems.insert(make_pair(item->sessionId, newitem));
localitem->setSession(
AsteriskSCF::PJMediaRTP::RTPSession::create(mImpl->mAdapter, mImpl->mEnvironment, item,
@@ -128,7 +128,7 @@ public:
void visitRtpStreamSinkStateItem(const RtpStreamSinkStateItemPtr &item)
{
map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i =
- mImpl->mStateItems.find(item->mSessionId);
+ mImpl->mStateItems.find(item->sessionId);
if (i != mImpl->mStateItems.end())
{
i->second->getSession()->update(item);
@@ -138,7 +138,7 @@ public:
void visitRtpStreamSourceStateItem(const RtpStreamSourceStateItemPtr &item)
{
map<string, boost::shared_ptr<RtpStateReplicatorItem> >::iterator i =
- mImpl->mStateItems.find(item->mSessionId);
+ mImpl->mStateItems.find(item->sessionId);
if (i != mImpl->mStateItems.end())
{
i->second->getSession()->update(item);
diff --git a/test/TestRTPpjmedia.cpp b/test/TestRTPpjmedia.cpp
index ca15d65..c6c9615 100644
--- a/test/TestRTPpjmedia.cpp
+++ b/test/TestRTPpjmedia.cpp
@@ -393,7 +393,7 @@ BOOST_AUTO_TEST_CASE(ReplicatorFound)
{
RtpStateReplicatorParamsPtr params = new RtpStateReplicatorParams();
params->category = StateReplicatorDiscoveryCategory;
- params->mName = "default";
+ params->name = "default";
Testbed.mStateReplicator = RtpStateReplicatorPrx::uncheckedCast(Testbed.locator->locate(params));
@@ -450,8 +450,8 @@ BOOST_AUTO_TEST_CASE(CheckReplicatedGeneralStateItem)
}
BOOST_CHECK(Testbed.mListener->mGeneral);
- BOOST_CHECK(Testbed.mListener->mGeneral->mServiceManagement);
- BOOST_CHECK(Testbed.mListener->mGeneral->mComparatorId.size());
+ BOOST_CHECK(Testbed.mListener->mGeneral->serviceManagement);
+ BOOST_CHECK(Testbed.mListener->mGeneral->comparatorId.size());
}
/**
@@ -506,25 +506,25 @@ BOOST_AUTO_TEST_CASE(AllocateRTPSession)
BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSession)
{
BOOST_CHECK(Testbed.mListener->mSession);
- BOOST_CHECK(Testbed.mListener->mSession->mSessionIdentity == Testbed.session->ice_getIdentity());
+ BOOST_CHECK(Testbed.mListener->mSession->sessionIdentity == Testbed.session->ice_getIdentity());
#ifdef IPV6_TEST
- BOOST_CHECK(Testbed.mListener->mSession->mIPv6 == true);
+ BOOST_CHECK(Testbed.mListener->mSession->ipv6 == true);
#else
- BOOST_CHECK(Testbed.mListener->mSession->mIPv6 == false);
+ BOOST_CHECK(Testbed.mListener->mSession->ipv6 == false);
#endif
StreamSinkSeq sinks = Testbed.session->getSinks();
StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(sinks.front());
- BOOST_CHECK(Testbed.mListener->mSession->mSinkIdentity == sink->ice_getIdentity());
+ BOOST_CHECK(Testbed.mListener->mSession->sinkIdentity == sink->ice_getIdentity());
StreamSourceSeq sources = Testbed.session->getSources();
StreamSourceRTPPrx source = StreamSourceRTPPrx::uncheckedCast(sources.front());
- BOOST_CHECK(Testbed.mListener->mSession->mSourceIdentity == source->ice_getIdentity());
- BOOST_CHECK(Testbed.mListener->mSession->mPort == source->getLocalPort());
+ BOOST_CHECK(Testbed.mListener->mSession->sourceIdentity == source->ice_getIdentity());
+ BOOST_CHECK(Testbed.mListener->mSession->port == source->getLocalPort());
- BOOST_CHECK(!Testbed.mListener->mSession->mRemoteRtcpAddress.size());
- BOOST_CHECK(!Testbed.mListener->mSession->mRemoteRtcpPort);
+ BOOST_CHECK(!Testbed.mListener->mSession->remoteRtcpAddress.size());
+ BOOST_CHECK(!Testbed.mListener->mSession->remoteRtcpPort);
}
/**
@@ -533,9 +533,9 @@ BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSession)
BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSink)
{
BOOST_CHECK(Testbed.mListener->mSink);
- BOOST_CHECK(!Testbed.mListener->mSink->mSource);
- BOOST_CHECK(!Testbed.mListener->mSink->mRemoteAddress.size());
- BOOST_CHECK(!Testbed.mListener->mSink->mRemotePort);
+ BOOST_CHECK(!Testbed.mListener->mSink->source);
+ BOOST_CHECK(!Testbed.mListener->mSink->remoteAddress.size());
+ BOOST_CHECK(!Testbed.mListener->mSink->remotePort);
}
/**
@@ -544,7 +544,7 @@ BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSink)
BOOST_AUTO_TEST_CASE(ConfirmInitialReplicatedRTPSource)
{
BOOST_CHECK(Testbed.mListener->mSource);
- BOOST_CHECK(Testbed.mListener->mSource->mSinks.empty());
+ BOOST_CHECK(Testbed.mListener->mSource->sinks.empty());
}
/**
@@ -1038,8 +1038,8 @@ BOOST_AUTO_TEST_CASE(ConfirmPopulatedReplicatedRTPSink)
StreamSourceSeq sources = Testbed.session->getSources();
StreamSourceRTPPrx source = StreamSourceRTPPrx::uncheckedCast(sources.front());
- BOOST_CHECK(Testbed.mListener->mSink->mRemoteAddress == source->getLocalAddress());
- BOOST_CHECK(Testbed.mListener->mSink->mRemotePort == source->getLocalPort());
+ BOOST_CHECK(Testbed.mListener->mSink->remoteAddress == source->getLocalAddress());
+ BOOST_CHECK(Testbed.mListener->mSink->remotePort == source->getLocalPort());
}
/**
@@ -1047,7 +1047,7 @@ BOOST_AUTO_TEST_CASE(ConfirmPopulatedReplicatedRTPSink)
*/
BOOST_AUTO_TEST_CASE(ConfirmPopulatedReplicatedRTPSource)
{
- BOOST_CHECK(Testbed.mListener->mSource->mSinks.front() == Testbed.sink);
+ BOOST_CHECK(Testbed.mListener->mSource->sinks.front() == Testbed.sink);
}
/**
commit cdfa9be9fd76f722c1a801b8ecd0f1960ae543bd
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Aug 1 11:51:26 2011 -0300
Add support for sending and receiving of RTCP. This also adds support for getting statistic information from RTP originated sinks and sources.
diff --git a/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice b/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
index ff9d0d2..f3aae1f 100644
--- a/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/MediaRTPPJMedia/RtpStateReplicationIf.ice
@@ -91,6 +91,8 @@ module V1
AsteriskSCF::Media::RTP::V1::PayloadMap mPayloadstoFormats;
bool mIPv6;
bool mSRTP;
+ string mRemoteRtcpAddress;
+ int mRemoteRtcpPort;
};
class RtpStreamSinkStateItem extends RtpStateItem
@@ -104,6 +106,7 @@ module V1
{
AsteriskSCF::Media::V1::StreamSinkSeq mSinks;
};
+
}; /* module V1 */
}; /* module MediaRTPPJMedia */
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 88fca37..69c1fea 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -33,18 +33,108 @@
#include <AsteriskSCF/Media/MediaIf.h>
#include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+#include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
#include <AsteriskSCF/System/Component/ReplicaIf.h>
using namespace std;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::Media::RTP::V1;
+using namespace AsteriskSCF::Media;
using namespace AsteriskSCF::Replication::MediaRTPPJMedia::V1;
using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::Discovery;
using namespace AsteriskSCF::PJMediaRTP;
/**
+ * RTCP Information Interface implementation.
+ */
+class RTCPInformationImpl : public RTCP::V1::Information
+{
+public:
+ RTCPInformationImpl(pjmedia_rtcp_stat *general, pjmedia_rtcp_stream_stat *stream) :
+ mGeneralStatistics(general), mStreamStatistics(stream) { }
+
+ RTCP::V1::StatisticsPtr getStatistics(const Ice::Current&)
+ {
+ RTCP::V1::StatisticsPtr statistics = new RTCP::V1::Statistics();
+
+ statistics->roundTripDelay = new RTCP::V1::ExtendedDetails();
+ statistics->roundTripDelay->maximum = mGeneralStatistics->rtt.max;
+ statistics->roundTripDelay->minimum = mGeneralStatistics->rtt.min;
+ statistics->roundTripDelay->last = mGeneralStatistics->rtt.last;
+ statistics->roundTripDelay->mean = mGeneralStatistics->rtt.mean;
+
+ statistics->packets = mStreamStatistics->pkt;
+ statistics->discardedPackets = mStreamStatistics->discard;
+ statistics->lostPackets = mStreamStatistics->loss;
+ statistics->outOfOrderPackets = mStreamStatistics->reorder;
+ statistics->duplicatePackets = mStreamStatistics->dup;
+
+ statistics->loss = new RTCP::V1::ExtendedDetails();
+ statistics->loss->maximum = mStreamStatistics->loss_period.max;
+ statistics->loss->minimum = mStreamStatistics->loss_period.min;
+ statistics->loss->last = mStreamStatistics->loss_period.last;
+ statistics->loss->mean = mStreamStatistics->loss_period.mean;
+
+ statistics->jitter = new RTCP::V1::ExtendedDetails();
+ statistics->jitter->maximum = mStreamStatistics->jitter.max;
+ statistics->jitter->minimum = mStreamStatistics->jitter.min;
+ statistics->jitter->last = mStreamStatistics->jitter.last;
+ statistics->jitter->mean = mStreamStatistics->jitter.mean;
+
+ return statistics;
+ }
+
+ void addListener(const RTCP::V1::InformationListenerPrx& listener, const Ice::Current&)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ mListeners.push_back(listener);
+ }
+
+ void removeListener(const RTCP::V1::InformationListenerPrx& listener, const Ice::Current&)
+ {
+ boost::unique_lock<boost::shared_mutex> lock(mLock);
+ mListeners.erase(std::remove(mListeners.begin(), mListeners.end(), listener), mListeners.end());
+ }
+
+ /**
+ * Implementation specific function which returns a copy of the listeners.
+ */
+ std::vector<RTCP::V1::InformationListenerPrx> getListeners()
+ {
+ boost::shared_lock<boost::shared_mutex> lock(mLock);
+ return mListeners;
+ }
+
+private:
+ /**
+ * Lock to protect the listeners.
+ */
+ boost::shared_mutex mLock;
+
+ /**
+ * Listeners present.
+ */
+ std::vector<RTCP::V1::InformationListenerPrx> mListeners;
+
+ /**
+ * Structure where general RTCP information is.
+ */
+ pjmedia_rtcp_stat *mGeneralStatistics;
+
+ /**
+ * Structure where stream RTCP information is.
+ */
+ pjmedia_rtcp_stream_stat *mStreamStatistics;
+};
+
+/**
+ * Smart pointer for the above RTCPInformationImpl class.
+ */
+typedef IceUtil::Handle<RTCPInformationImpl> RTCPInformationImplPtr;
+
+/**
* Implementation of the RTPSession interface as defined in MediaRTPIf.ice
*/
class RTPSessionImpl : public AsteriskSCF::Media::RTP::V1::SRTPSession
@@ -99,6 +189,8 @@ public:
*/
StreamSourceRTPImplPtr getSourceServant();
StreamSinkRTPImplPtr getSinkServant();
+ PJMediaTransportPtr getTransport();
+
void replicateState(const AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpSessionStateItemPtr&,
const AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStreamSinkStateItemPtr&,
@@ -108,6 +200,12 @@ public:
const AsteriskSCF::Replication::MediaRTPPJMedia::V1::RtpStreamSourceStateItemPtr&);
void associatePayloadsImpl(const AsteriskSCF::Media::RTP::V1::PayloadMap& payloadMap);
+ void setRemoteRtcpDetails(const std::string&, Ice::Int);
+ pjmedia_rtcp_session* getRtcpSession();
+ std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> getReceiverReportListeners();
+ AsteriskSCF::Media::RTCP::V1::StatisticsPtr getReceiverReportStatistics();
+ std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> getSenderReportListeners();
+ AsteriskSCF::Media::RTCP::V1::StatisticsPtr getSenderReportStatistics();
RTPSessionPrx activate(const string& id);
RTPSessionPrx activate(const Ice::Identity& id, const Ice::Identity& sourceId, const Ice::Identity& sinkId);
@@ -193,6 +291,26 @@ private:
* A proxy to the state replicator where we are sending updates to.
*/
AsteriskSCF::Discovery::SmartProxy<RtpStateReplicatorPrx> mStateReplicator;
+
+ /**
+ * RTCP session for this RTP session.
+ */
+ pjmedia_rtcp_session mRtcpSession;
+
+ /**
+ * A pointer to the RTCP session interface.
+ */
+ RTCP::V1::RTCPSessionPtr mRtcpSessionInterface;
+
+ /**
+ * RTCP information for Receiver Report.
+ */
+ RTCPInformationImplPtr mReceiverReport;
+
+ /**
+ * RTCP information for Sender Report.
+ */
+ RTCPInformationImplPtr mSenderReport;
};
/**
@@ -200,6 +318,42 @@ private:
*/
typedef IceUtil::Handle<RTPSessionImpl> RTPSessionImplPtr;
+/**
+ * Implementation of the RTCPSession interface as defined in MediaRTCPIf.ice
+ */
+class RTCPSessionImpl : public RTCP::V1::RTCPSession
+{
+public:
+ /**
+ * Constructor for this implementation.
+ */
+ RTCPSessionImpl(const RTPSessionImplPtr& session) : mSession(session) { }
+
+ /**
+ * Method used to retrieve the port our RTCP session is listening on.
+ */
+ int getLocalPort(const Ice::Current&)
+ {
+ pjmedia_transport_info transportInfo;
+
+ pjmedia_transport_info_init(&transportInfo);
+ pjmedia_transport_get_info(mSession->getTransport()->getTransport(), &transportInfo);
+
+ return pj_sockaddr_get_port(&transportInfo.sock_info.rtcp_addr_name);
+ }
+
+ void setRemoteDetails(const std::string& address, Ice::Int port, const Ice::Current&)
+ {
+ mSession->setRemoteRtcpDetails(address, port);
+ }
+
+private:
+ /**
+ * Pointer to the RTP session.
+ */
+ RTPSessionImplPtr mSession;
+};
+
//
// Provides an adapter to the session implementation without having to expose the entire header file. This is a
// step-wise decoupling of the session implementation from the other objects in this component. The whole
@@ -243,6 +397,31 @@ public:
mServant->setRemoteDetails(host, port);
}
+ pjmedia_rtcp_session* getRtcpSession()
+ {
+ return mServant->getRtcpSession();
+ }
+
+ std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> getReceiverReportListeners()
+ {
+ return mServant->getReceiverReportListeners();
+ }
+
+ AsteriskSCF::Media::RTCP::V1::StatisticsPtr getReceiverReportStatistics()
+ {
+ return mServant->getReceiverReportStatistics();
+ }
+
+ std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> getSenderReportListeners()
+ {
+ return mServant->getSenderReportListeners();
+ }
+
+ AsteriskSCF::Media::RTCP::V1::StatisticsPtr getSenderReportStatistics()
+ {
+ return mServant->getSenderReportStatistics();
+ }
+
private:
RTPSessionImplPtr mServant;
};
@@ -301,6 +480,8 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter,
mSessionStateItem->mSessionIdentity = mAdapter->getCommunicator()->stringToIdentity(mId);
mSessionStateItem->mFormats = params->formats;
mSessionStateItem->mIPv6 = params->ipv6;
+
+ pjmedia_rtcp_init(&mRtcpSession, NULL, 8000, 160, 0);
}
/**
@@ -340,6 +521,8 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter,
{
mTransport = SRTPTransport::create(mTransport, mEndpoint, configurationService);
}
+
+ pjmedia_rtcp_init(&mRtcpSession, NULL, 8000, 160, 0);
}
/**
@@ -383,16 +566,6 @@ std::string RTPSessionImpl::getId(const Ice::Current&)
}
/**
- * Implementation of the useRTCP method as defined in MediaRTPIf.ice
- */
-void RTPSessionImpl::useRTCP(bool, const Ice::Current&)
-{
- //
- // TODO.
- //
-}
-
-/**
* Implementation of the release method as defined in MediaRTPIf.ice
*/
void RTPSessionImpl::release(const Ice::Current&)
@@ -404,7 +577,7 @@ void RTPSessionImpl::release(const Ice::Current&)
mAdapter->remove(mStreamSourceProxy->ice_getIdentity());
mAdapter->remove(mStreamSinkProxy->ice_getIdentity());
- /* Since both the source and sink have a pointer back to the session we need to get rid of them,
+ /* Since the source and sink have a pointer back to the session we need to get rid of them,
* which will in turn get rid of ourselves once we are removed from the ASM.
*/
mStreamSource = 0;
@@ -450,6 +623,56 @@ void RTPSessionImpl::start(const string& suiteName, const string& key, bool enab
}
/**
+ * API call which returns the RTCP session used for this RTP session.
+ *
+ * @return A pointer to the RTCP session.
+ */
+pjmedia_rtcp_session* RTPSessionImpl::getRtcpSession()
+{
+ return &mRtcpSession;
+}
+
+/**
+ * API call which returns the listeners wanting statistics for receiving as they change.
+ *
+ * @return A copy of the listeners wanting the statistics.
+ */
+std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> RTPSessionImpl::getReceiverReportListeners()
+{
+ return mReceiverReport->getListeners();
+}
+
+/**
+ * API call which returns current statistics for receiving.
+ *
+ * @return The current receiving statistics.
+ */
+AsteriskSCF::Media::RTCP::V1::StatisticsPtr RTPSessionImpl::getReceiverReportStatistics()
+{
+ return mReceiverReport->getStatistics(Ice::Current());
+}
+
+/**
+ * API call which returns the listeners wanting statistics for sending as they change.
+ *
+ * @return A copy of the listeners wanting the statistics.
+ */
+std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> RTPSessionImpl::getSenderReportListeners()
+{
+ return mSenderReport->getListeners();
+}
+
+/**
+ * API call which returns current statistics for sending.
+ *
+ * @return The current sending statistics.
+ */
+AsteriskSCF::Media::RTCP::V1::StatisticsPtr RTPSessionImpl::getSenderReportStatistics()
+{
+ return mSenderReport->getStatistics(Ice::Current());
+}
+
+/**
* API call which returns the formats the RTP session is expected to carry.
*
* @return A sequence of media formats.
@@ -468,6 +691,19 @@ void RTPSessionImpl::setRemoteDetails(const string& address, Ice::Int port)
}
/**
+ * API call which calls into RTPSourceImpl in order to setup transport.
+ */
+void RTPSessionImpl::setRemoteRtcpDetails(const std::string& address, Ice::Int port)
+{
+ mSessionStateItem->mRemoteRtcpAddress = address;
+ mSessionStateItem->mRemoteRtcpPort = port;
+
+ mStreamSource->setRemoteRtcpDetails(address, port);
+
+ replicateState(mSessionStateItem, 0, 0);
+}
+
+/**
* API call which returns a media format based on payload.
*
* @return The media format corresponding to the payload.
@@ -511,6 +747,11 @@ StreamSinkRTPImplPtr RTPSessionImpl::getSinkServant()
return mStreamSink;
}
+PJMediaTransportPtr RTPSessionImpl::getTransport()
+{
+ return mTransport;
+}
+
/**
* API call which replicates state items.
*/
@@ -623,10 +864,17 @@ RTPSessionPrx RTPSessionImpl::activate(const Ice::Identity& id, const Ice::Ident
mSessionAdapter.reset(new SessionAdapterImpl(this));
try
{
- mStreamSource = new StreamSourceRTPImpl(mSessionAdapter, mTransport, mId);
+ mStreamSource = new StreamSourceRTPImpl(mSessionAdapter, mTransport, mId, StreamSourceRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sourceId)),
+ StreamSinkRTPPrx::uncheckedCast(mAdapter->createDirectProxy(sinkId)));
mStreamSink = new StreamSinkRTPImpl(mSessionAdapter, mTransport, mId);
+ mRtcpSessionInterface = new RTCPSessionImpl(this);
+ mReceiverReport = new RTCPInformationImpl(&mRtcpSession.stat, &mRtcpSession.stat.rx);
+ mSenderReport = new RTCPInformationImpl(&mRtcpSession.stat, &mRtcpSession.stat.tx);
mStreamSourceProxy = StreamSourceRTPPrx::uncheckedCast(mAdapter->add(mStreamSource, sourceId));
mStreamSinkProxy = StreamSinkRTPPrx::uncheckedCast(mAdapter->add(mStreamSink, sinkId));
+ mAdapter->addFacet(mRtcpSessionInterface, id, RTCP::V1::SessionFacet);
+ mAdapter->addFacet(mReceiverReport, sourceId, RTCP::V1::Facet);
+ mAdapter->addFacet(mSenderReport, sinkId, RTCP::V1::Facet);
if (mSessionStateItem)
{
@@ -686,6 +934,7 @@ public:
void update(const RtpSessionStateItemPtr& item)
{
mImpl->associatePayloadsImpl(item->mPayloadstoFormats);
+ mImpl->setRemoteRtcpDetails(item->mRemoteRtcpAddress, item->mRemoteRtcpPort);
}
void update(const RtpStreamSinkStateItemPtr& item)
diff --git a/src/RTPSession.h b/src/RTPSession.h
index b6f6d54..a4f8072 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -19,6 +19,7 @@
#include <AsteriskSCF/Discovery/SmartProxy.h>
#include <boost/shared_ptr.hpp>
+
namespace AsteriskSCF
{
namespace PJMediaRTP
diff --git a/src/RTPSink.cpp b/src/RTPSink.cpp
index 7d3d07b..8184c1a 100644
--- a/src/RTPSink.cpp
+++ b/src/RTPSink.cpp
@@ -154,6 +154,9 @@ void StreamSinkRTPImpl::write(const AsteriskSCF::Media::V1::FrameSeq& frames, co
/* TODO: Transmission failed... what to do? */
continue;
}
+
+ // Update RTCP information
+ pjmedia_rtcp_tx_rtp(mImpl->mSessionAdapter->getRtcpSession(), static_cast<unsigned int>((*frame)->payload.size()));
}
}
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index ed3ad97..4ae46f9 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -22,16 +22,19 @@
#include <Ice/Ice.h>
#include <IceUtil/UUID.h>
+#include <IceUtil/Timer.h>
#include <boost/thread.hpp>
#include <AsteriskSCF/Media/MediaIf.h>
#include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+#include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
#include <AsteriskSCF/logger.h>
#include <AsteriskSCF/System/Component/ReplicaIf.h>
using namespace std;
using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::Media;
using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::Media::RTP::V1;
using namespace AsteriskSCF::Replication::MediaRTPPJMedia::V1;
@@ -44,6 +47,63 @@ Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaRTP");
}
/**
+ * TimerTask implementation which sends RTCP at a defined interval.
+ */
+class RtcpTransmission : public IceUtil::TimerTask
+{
+public:
+ RtcpTransmission(const SessionAdapterPtr& sessionAdapter, const StreamSinkRTPPrx& sink, const PJMediaTransportPtr& transport) :
+ mSessionAdapter(sessionAdapter), mSink(sink), mTransport(transport) { }
+
+ void runTimerTask()
+ {
+ void *packet;
+ int packet_size;
+
+ pjmedia_rtcp_build_rtcp(mSessionAdapter->getRtcpSession(), &packet, &packet_size);
+ pjmedia_transport_send_rtcp(mTransport->getTransport(), packet, packet_size);
+
+ std::vector<RTCP::V1::InformationListenerPrx> listeners = mSessionAdapter->getSenderReportListeners();
+
+ // If no listeners exist don't bother getting the statistics
+ if (listeners.empty())
+ {
+ return;
+ }
+
+ RTCP::V1::StatisticsPtr statistics = mSessionAdapter->getSenderReportStatistics();
+
+ for (std::vector<RTCP::V1::InformationListenerPrx>::const_iterator listener = listeners.begin();
+ listener != listeners.end();
+ ++listener)
+ {
+ (*listener)->sinkStatisticsUpdated(mSink, statistics);
+ }
+ }
+
+private:
+ /**
+ * A pointer to the session adapter.
+ */
+ SessionAdapterPtr mSessionAdapter;
+
+ /**
+ * Proxy to the sink.
+ */
+ StreamSinkRTPPrx mSink;
+
+ /**
+ * Pointer to the transport used for communication.
+ */
+ PJMediaTransportPtr mTransport;
+};
+
+/**
+ * Smart pointer for the above RtcpTransmission class.
+ */
+typedef IceUtil::Handle<RtcpTransmission> RtcpTransmissionPtr;
+
+/**
* Private implementation details for the StreamSourceRTPImpl class.
*/
class StreamSourceRTPImplPriv
@@ -53,8 +113,16 @@ public:
* Constructor for our StreamSourceRTPImplPriv class.
*/
StreamSourceRTPImplPriv(const SessionAdapterPtr& sessionAdapter,
- const PJMediaTransportPtr& transport,
- const string& parentSessionId);
+ const PJMediaTransportPtr& transport,
+ const string& parentSessionId,
+ const StreamSourceRTPPrx& source,
... 7260 lines suppressed ...
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list