Adds new GetRemoteRTCPSenderInfo() and GetRemoteRTCPReportBlocks APIs to VoE.

BUG=559
TEST=manual tests using Windows UI client.

Review URL: https://webrtc-codereview.appspot.com/735011

git-svn-id: http://webrtc.googlecode.com/svn/trunk@2655 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrika@webrtc.org 2012-08-22 08:53:55 +00:00
parent f61dc9be41
commit 8a2fc88459
5 changed files with 139 additions and 0 deletions

View File

@ -5404,6 +5404,66 @@ Channel::GetRTPStatistics(
return 0; return 0;
} }
int Channel::GetRemoteRTCPSenderInfo(SenderInfo* sender_info) {
if (sender_info == NULL) {
_engineStatisticsPtr->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"GetRemoteRTCPSenderInfo() invalid sender_info.");
return -1;
}
// Get the sender info from the latest received RTCP Sender Report.
RTCPSenderInfo rtcp_sender_info;
if (_rtpRtcpModule->RemoteRTCPStat(&rtcp_sender_info) != 0) {
_engineStatisticsPtr->SetLastError(VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"GetRemoteRTCPSenderInfo() failed to read RTCP SR sender info.");
return -1;
}
sender_info->NTP_timestamp_high = rtcp_sender_info.NTPseconds;
sender_info->NTP_timestamp_low = rtcp_sender_info.NTPfraction;
sender_info->RTP_timestamp = rtcp_sender_info.RTPtimeStamp;
sender_info->sender_packet_count = rtcp_sender_info.sendPacketCount;
sender_info->sender_octet_count = rtcp_sender_info.sendOctetCount;
return 0;
}
int Channel::GetRemoteRTCPReportBlocks(
std::vector<ReportBlock>* report_blocks) {
if (report_blocks == NULL) {
_engineStatisticsPtr->SetLastError(VE_INVALID_ARGUMENT, kTraceError,
"GetRemoteRTCPReportBlock()s invalid report_blocks.");
return -1;
}
// Get the report blocks from the latest received RTCP Sender or Receiver
// Report. Each element in the vector contains the sender's SSRC and a
// report block according to RFC 3550.
std::vector<RTCPReportBlock> rtcp_report_blocks;
if (_rtpRtcpModule->RemoteRTCPStat(&rtcp_report_blocks) != 0) {
_engineStatisticsPtr->SetLastError(VE_RTP_RTCP_MODULE_ERROR, kTraceError,
"GetRemoteRTCPReportBlocks() failed to read RTCP SR/RR report block.");
return -1;
}
if (rtcp_report_blocks.empty())
return 0;
std::vector<RTCPReportBlock>::const_iterator it = rtcp_report_blocks.begin();
for (; it != rtcp_report_blocks.end(); ++it) {
ReportBlock report_block;
report_block.sender_SSRC = it->remoteSSRC;
report_block.source_SSRC = it->sourceSSRC;
report_block.fraction_lost = it->fractionLost;
report_block.cumulative_num_packets_lost = it->cumulativeLost;
report_block.extended_highest_sequence_number = it->extendedHighSeqNum;
report_block.interarrival_jitter = it->jitter;
report_block.last_SR_timestamp = it->lastSR;
report_block.delay_since_last_SR = it->delaySinceLastSR;
report_blocks->push_back(report_block);
}
return 0;
}
int int
Channel::GetRTPStatistics(CallStatistics& stats) Channel::GetRTPStatistics(CallStatistics& stats)
{ {

View File

@ -51,6 +51,8 @@ class VoERTPObserver;
class VoERTCPObserver; class VoERTCPObserver;
struct CallStatistics; struct CallStatistics;
struct ReportBlock;
struct SenderInfo;
namespace voe namespace voe
{ {
@ -341,6 +343,8 @@ public:
int GetRTPStatistics(unsigned int& averageJitterMs, int GetRTPStatistics(unsigned int& averageJitterMs,
unsigned int& maxJitterMs, unsigned int& maxJitterMs,
unsigned int& discardedPackets); unsigned int& discardedPackets);
int GetRemoteRTCPSenderInfo(SenderInfo* sender_info);
int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks);
int GetRTPStatistics(CallStatistics& stats); int GetRTPStatistics(CallStatistics& stats);
int SetFECStatus(bool enable, int redPayloadtype); int SetFECStatus(bool enable, int redPayloadtype);
int GetFECStatus(bool& enabled, int& redPayloadtype); int GetFECStatus(bool& enabled, int& redPayloadtype);

View File

@ -40,6 +40,7 @@
#ifndef WEBRTC_VOICE_ENGINE_VOE_RTP_RTCP_H #ifndef WEBRTC_VOICE_ENGINE_VOE_RTP_RTCP_H
#define WEBRTC_VOICE_ENGINE_VOE_RTP_RTCP_H #define WEBRTC_VOICE_ENGINE_VOE_RTP_RTCP_H
#include <vector>
#include "common_types.h" #include "common_types.h"
namespace webrtc { namespace webrtc {
@ -87,6 +88,27 @@ struct CallStatistics
int packetsReceived; int packetsReceived;
}; };
// See section 6.4.1 in http://www.ietf.org/rfc/rfc3550.txt for details.
struct SenderInfo {
uint32_t NTP_timestamp_high;
uint32_t NTP_timestamp_low;
uint32_t RTP_timestamp;
uint32_t sender_packet_count;
uint32_t sender_octet_count;
};
// See section 6.4.2 in http://www.ietf.org/rfc/rfc3550.txt for details.
struct ReportBlock {
uint32_t sender_SSRC; // SSRC of sender
uint32_t source_SSRC;
uint8_t fraction_lost;
uint32_t cumulative_num_packets_lost;
uint32_t extended_highest_sequence_number;
uint32_t interarrival_jitter;
uint32_t last_SR_timestamp;
uint32_t delay_since_last_SR;
};
// VoERTP_RTCP // VoERTP_RTCP
class WEBRTC_DLLEXPORT VoERTP_RTCP class WEBRTC_DLLEXPORT VoERTP_RTCP
{ {
@ -173,6 +195,18 @@ public:
// Gets RTCP statistics for a specific |channel|. // Gets RTCP statistics for a specific |channel|.
virtual int GetRTCPStatistics(int channel, CallStatistics& stats) = 0; virtual int GetRTCPStatistics(int channel, CallStatistics& stats) = 0;
// Gets the sender info part of the last received RTCP Sender Report (SR)
// on a specified |channel|.
virtual int GetRemoteRTCPSenderInfo(
int channel, SenderInfo* sender_info) = 0;
// Gets the report block parts of the last received RTCP Sender Report (SR),
// or RTCP Receiver Report (RR) on a specified |channel|. Each vector
// element also contains the SSRC of the sender in addition to a report
// block.
virtual int GetRemoteRTCPReportBlocks(
int channel, std::vector<ReportBlock>* receive_blocks) = 0;
// Sends an RTCP APP packet on a specific |channel|. // Sends an RTCP APP packet on a specific |channel|.
virtual int SendApplicationDefinedRTCPPacket( virtual int SendApplicationDefinedRTCPPacket(
int channel, const unsigned char subType, unsigned int name, int channel, const unsigned char subType, unsigned int name,

View File

@ -476,6 +476,42 @@ int VoERTP_RTCPImpl::GetRTCPStatistics(int channel, CallStatistics& stats)
return channelPtr->GetRTPStatistics(stats); return channelPtr->GetRTPStatistics(stats);
} }
int VoERTP_RTCPImpl::GetRemoteRTCPSenderInfo(int channel,
SenderInfo* sender_info) {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRemoteRTCPSenderInfo(channel=%d)", channel);
if (!_shared->statistics().Initialized()) {
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channel_ptr = sc.ChannelPtr();
if (channel_ptr == NULL) {
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRemoteRTCPSenderInfo() failed to locate channel");
return -1;
}
return channel_ptr->GetRemoteRTCPSenderInfo(sender_info);
}
int VoERTP_RTCPImpl::GetRemoteRTCPReportBlocks(
int channel, std::vector<ReportBlock>* report_blocks) {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"GetRemoteRTCPReportBlocks(channel=%d)", channel);
if (!_shared->statistics().Initialized()) {
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
voe::ScopedChannel sc(_shared->channel_manager(), channel);
voe::Channel* channel_ptr = sc.ChannelPtr();
if (channel_ptr == NULL) {
_shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
"GetRemoteRTCPReportBlocks() failed to locate channel");
return -1;
}
return channel_ptr->GetRemoteRTCPReportBlocks(report_blocks);
}
int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype) int VoERTP_RTCPImpl::SetFECStatus(int channel, bool enable, int redPayloadtype)
{ {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),

View File

@ -82,6 +82,11 @@ public:
virtual int GetRTCPStatistics(int channel, CallStatistics& stats); virtual int GetRTCPStatistics(int channel, CallStatistics& stats);
virtual int GetRemoteRTCPSenderInfo(int channel, SenderInfo* sender_info);
virtual int GetRemoteRTCPReportBlocks(
int channel, std::vector<ReportBlock>* report_blocks);
// FEC // FEC
virtual int SetFECStatus(int channel, virtual int SetFECStatus(int channel,
bool enable, bool enable,