[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "rtcp" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Jul 11 18:06:51 CDT 2011
branch "rtcp" has been updated
via dd244752577ee9d4ceb35759160299b0eb3014ab (commit)
from 0665e06e6544ef26990e5379040e0b9915af7a8e (commit)
Summary of changes:
src/RTPSession.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++-
src/RTPSession.h | 5 ++++
src/RTPSource.cpp | 38 ++++++++++++++++++++++++++++++++-
3 files changed, 100 insertions(+), 3 deletions(-)
- Log -----------------------------------------------------------------
commit dd244752577ee9d4ceb35759160299b0eb3014ab
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jul 11 20:07:33 2011 -0300
Call listeners at the appropriate time.
diff --git a/src/RTPSession.cpp b/src/RTPSession.cpp
index 060bf98..d2cd88c 100644
--- a/src/RTPSession.cpp
+++ b/src/RTPSession.cpp
@@ -68,6 +68,24 @@ public:
pjmedia_rtcp_build_rtcp(mSession->getRtcpSession(), &packet, &packet_size);
pjmedia_transport_send_rtcp(mSession->getTransport(), packet, packet_size);
+
+ std::vector<RTCP::V1::InformationListenerPrx> listeners = mSession->getSenderReportListeners();
+
+ // If no listeners exist don't bother getting the statistics
+ if (listeners.empty())
+ {
+ return;
+ }
+
+ RTCP::V1::StatisticsPtr statistics = mSession->getSenderReportStatistics();
+ StreamSinkRTPPrx sink = StreamSinkRTPPrx::uncheckedCast(mSession->getSinks(Ice::Current()).front());
+
+ for (std::vector<RTCP::V1::InformationListenerPrx>::const_iterator listener = listeners.begin();
+ listener != listeners.end();
+ ++listener)
+ {
+ (*listener)->sinkStatisticsUpdated(sink, statistics);
+ }
}
private:
@@ -359,8 +377,6 @@ RTPSessionImpl::RTPSessionImpl(const Ice::ObjectAdapterPtr& adapter, const RTPSe
mImpl->mSessionStateItem->mFormats = params->formats;
mImpl->mSessionStateItem->mIPv6 = params->ipv6;
- // TODO Initialize the RTCP session with some default settings
-
/* First up for our own stuff is... a source! Media needs to come from somewhere, you know. */
mImpl->mStreamSource = new StreamSourceRTPImpl(this, mImpl->mSessionStateItem->key);
mImpl->mStreamSourceProxy = StreamSourceRTPPrx::uncheckedCast(mImpl->mAdapter->addWithUUID(mImpl->mStreamSource));
@@ -545,6 +561,46 @@ pjmedia_rtcp_session* RTPSessionImpl::getRtcpSession()
}
/**
+ * 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 mImpl->mReceiverReport->getListeners();
+}
+
+/**
+ * API call which returns current statistics for receiving.
+ *
+ * @return The current receiving statistics.
+ */
+AsteriskSCF::Media::RTCP::V1::StatisticsPtr RTPSessionImpl::getReceiverReportStatistics()
+{
+ return mImpl->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 mImpl->mSenderReport->getListeners();
+}
+
+/**
+ * API call which returns current statistics for sending.
+ *
+ * @return The current sending statistics.
+ */
+AsteriskSCF::Media::RTCP::V1::StatisticsPtr RTPSessionImpl::getSenderReportStatistics()
+{
+ return mImpl->mSenderReport->getStatistics(Ice::Current());
+}
+
+/**
* API call which returns the formats the RTP session is expected to carry.
*
* @return A sequence of media formats.
diff --git a/src/RTPSession.h b/src/RTPSession.h
index 8dca6fd..3c52ef4 100644
--- a/src/RTPSession.h
+++ b/src/RTPSession.h
@@ -10,6 +10,7 @@
#include <boost/shared_ptr.hpp>
#include <AsteriskSCF/Discovery/SmartProxy.h>
+#include <AsteriskSCF/Media/RTP/MediaRTCPIf.h>
#include "RTPConfiguration.h"
@@ -58,6 +59,10 @@ public:
AsteriskSCF::Media::RTP::V1::RTPSessionPrx getProxy();
pjmedia_transport* getTransport();
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();
AsteriskSCF::Media::V1::FormatSeq getFormats();
void associatePayloads(const AsteriskSCF::Media::RTP::V1::PayloadMap&, const Ice::Current&);
void setRemoteDetails(const std::string& address, Ice::Int port);
diff --git a/src/RTPSource.cpp b/src/RTPSource.cpp
index 049950c..73a2aa9 100644
--- a/src/RTPSource.cpp
+++ b/src/RTPSource.cpp
@@ -24,6 +24,7 @@
#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>
@@ -218,7 +219,24 @@ static void receiveRTP(void *userdata, void *packet, pj_ssize_t size)
// Update RTCP information
pjmedia_rtcp_rx_rtp2(source->mImpl->mSession->getRtcpSession(), pj_ntohs(header->seq), pj_ntohl(header->ts),
- payload_size, (rtpStatus.status.flag.bad || !payload_size) ? PJ_TRUE : PJ_FALSE);
+ payload_size, ((rtpStatus.status.value && rtpStatus.status.flag.bad) || !payload_size)
+ ? PJ_TRUE : PJ_FALSE);
+
+ // If the SSRC has changed contact any appropriate listeners
+ if (rtpStatus.status.value && rtpStatus.status.flag.badssrc)
+ {
+ std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> listeners =
+ source->mImpl->mSession->getReceiverReportListeners();
+ StreamSourceRTPPrx streamSource = StreamSourceRTPPrx::uncheckedCast(
+ source->mImpl->mSession->getSources(Ice::Current()).front());
+
+ for (std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx>::const_iterator listener = listeners.begin();
+ listener != listeners.end();
+ ++listener)
+ {
+ (*listener)->sourceSsrcChanged(streamSource, source->mImpl->mIncomingSession.peer_ssrc);
+ }
+ }
if (source->mImpl->mSourceStateItem->mSinks.empty())
{
@@ -303,6 +321,24 @@ static void receiveRTCP(void *userdata, void *packet, pj_ssize_t size)
}
pjmedia_rtcp_rx_rtcp(source->mImpl->mSession->getRtcpSession(), packet, size);
+
+ std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx> listeners =
+ source->mImpl->mSession->getReceiverReportListeners();
+
+ if (listeners.empty())
+ {
+ return;
+ }
+
+ AsteriskSCF::Media::RTCP::V1::StatisticsPtr statistics = source->mImpl->mSession->getReceiverReportStatistics();
+ StreamSourceRTPPrx streamSource = StreamSourceRTPPrx::uncheckedCast(source->mImpl->mSession->getSources(Ice::Current()).front());
+
+ for (std::vector<AsteriskSCF::Media::RTCP::V1::InformationListenerPrx>::const_iterator listener = listeners.begin();
+ listener != listeners.end();
+ ++listener)
+ {
+ (*listener)->sourceStatisticsUpdated(streamSource, statistics);
+ }
}
/**
-----------------------------------------------------------------------
--
asterisk-scf/integration/media_rtp_pjmedia.git
More information about the asterisk-scf-commits
mailing list