Bug 1439076 - P1 - negotiate csrc-audio-level RTP header
MozReview-Commit-ID: 3S2VYuQ7Qkg
--- a/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
+++ b/media/webrtc/signaling/src/jsep/JsepSessionImpl.cpp
@@ -2057,16 +2057,18 @@ JsepSessionImpl::SetupDefaultCodecs()
red->UpdateRedundantEncodings(mSupportedCodecs.values);
}
void
JsepSessionImpl::SetupDefaultRtpExtensions()
{
AddAudioRtpExtension(webrtc::RtpExtension::kAudioLevelUri,
SdpDirectionAttribute::Direction::kSendrecv);
+ AddAudioRtpExtension(webrtc::RtpExtension::kCsrcAudioLevelUri,
+ SdpDirectionAttribute::Direction::kRecvonly);
AddAudioRtpExtension(webrtc::RtpExtension::kMIdUri,
SdpDirectionAttribute::Direction::kSendrecv);
AddVideoRtpExtension(webrtc::RtpExtension::kAbsSendTimeUri,
SdpDirectionAttribute::Direction::kSendrecv);
AddVideoRtpExtension(webrtc::RtpExtension::kTimestampOffsetUri,
SdpDirectionAttribute::Direction::kSendrecv);
AddVideoRtpExtension(webrtc::RtpExtension::kMIdUri,
SdpDirectionAttribute::Direction::kSendrecv);
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.cpp
@@ -609,30 +609,38 @@ WebrtcAudioConduit::ConfigureRecvMediaCo
DumpCodecDB();
return kMediaConduitNoError;
}
MediaConduitErrorCode
WebrtcAudioConduit::EnableAudioLevelExtension(bool aEnabled,
uint8_t aId,
- bool aDirectionIsSend)
+ bool aDirectionIsSend,
+ bool aLevelIsSsrc)
{
CSFLogDebug(LOGTAG, "%s %d %d %d", __FUNCTION__, aEnabled, aId,
aDirectionIsSend);
bool ret;
if (aDirectionIsSend) {
+ if (!aLevelIsSsrc) {
+ CSFLogError(LOGTAG,
+ "%s SetSendAudioLevelIndicationStatus Failed"
+ " can not send CSRC audio levels.", __FUNCTION__);
+ return kMediaConduitMalformedArgument;
+ }
ret = mPtrVoERTP_RTCP->SetSendAudioLevelIndicationStatus(mChannel,
aEnabled,
aId) == -1;
} else {
ret = mPtrRTP->SetReceiveAudioLevelIndicationStatus(mChannel,
aEnabled,
- aId) == -1;
+ aId,
+ aLevelIsSsrc) == -1;
}
if (ret) {
CSFLogError(LOGTAG, "%s SetSendAudioLevelIndicationStatus Failed", __FUNCTION__);
return kMediaConduitUnknownError;
}
return kMediaConduitNoError;
}
--- a/media/webrtc/signaling/src/media-conduit/AudioConduit.h
+++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.h
@@ -94,17 +94,18 @@ public:
* transmission sub-system on the engine.
*/
virtual MediaConduitErrorCode ConfigureRecvMediaCodecs(
const std::vector<AudioCodecConfig* >& codecConfigList) override;
MediaConduitErrorCode
EnableAudioLevelExtension(bool aEnabled,
uint8_t aId,
- bool aDirectionIsSend) override;
+ bool aDirectionIsSend,
+ bool aLevelIsSsrc = true) override;
virtual MediaConduitErrorCode EnableMIDExtension(bool enabled, uint8_t id) override;
/**
* Register External Transport to this Conduit. RTP and RTCP frames from the VoiceEngine
* shall be passed to the registered transport for transporting externally.
*/
virtual MediaConduitErrorCode SetTransmitterTransport(RefPtr<TransportInterface> aTransport) override;
--- a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
+++ b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h
@@ -537,17 +537,18 @@ public:
* @param aId: the RTP extension header ID to use
* @param aDirectionIsSend: indicates whether to set the extension on the
* sender or the receiver side
* returns an error if the extension could not be set
*/
virtual MediaConduitErrorCode
EnableAudioLevelExtension(bool aEnabled,
uint8_t aId,
- bool aDirectionIsSend) = 0;
+ bool aDirectionIsSend,
+ bool aLevelIsSsrc = true) = 0;
virtual MediaConduitErrorCode
EnableMIDExtension(bool enabled, uint8_t id) = 0;
virtual bool SetDtmfPayloadType(unsigned char type, int freq) = 0;
virtual bool InsertDTMFTone(int channel, int eventCode, bool outOfBand,
int lengthMs, int attenuationDb) = 0;
--- a/media/webrtc/signaling/src/peerconnection/TransceiverImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/TransceiverImpl.cpp
@@ -737,16 +737,31 @@ TransceiverImpl::UpdateAudioConduit()
false);
if (error) {
MOZ_MTLOG(ML_ERROR, mPCHandle << "[" << mMid << "]: " << __FUNCTION__ <<
" EnableAudioLevelExtension failed: " << error);
return NS_ERROR_FAILURE;
}
}
+
+ const SdpExtmapAttributeList::Extmap* csrcAudioLevelExt =
+ details.GetExt(webrtc::RtpExtension::kCsrcAudioLevelUri);
+ if (csrcAudioLevelExt) {
+ MOZ_MTLOG(ML_DEBUG, "Calling EnableAudioLevelExtension for CSRCs");
+ error = conduit->EnableAudioLevelExtension(true,
+ csrcAudioLevelExt->entry,
+ false,
+ false);
+ if (error) {
+ MOZ_MTLOG(ML_ERROR, mPCHandle << "[" << mMid << "]: " << __FUNCTION__ <<
+ " EnableAudioLevelExtension for CSRCs failed: " << error);
+ return NS_ERROR_FAILURE;
+ }
+ }
}
if (mJsepTransceiver->mSendTrack.GetNegotiatedDetails() &&
mJsepTransceiver->mSendTrack.GetActive()) {
const auto& details(*mJsepTransceiver->mSendTrack.GetNegotiatedDetails());
PtrVector<AudioCodecConfig> configs;
nsresult rv = NegotiatedDetailsToAudioCodecConfigs(details, &configs);
--- a/media/webrtc/trunk/webrtc/voice_engine/channel.cc
+++ b/media/webrtc/trunk/webrtc/voice_engine/channel.cc
@@ -2610,31 +2610,33 @@ int Channel::GetLocalSSRC(unsigned int&
return 0;
}
int Channel::GetRemoteSSRC(unsigned int& ssrc) {
ssrc = rtp_receiver_->SSRC();
return 0;
}
-int Channel::SetSendAudioLevelIndicationStatus(bool enable, unsigned char id) {
+int Channel::SetSendAudioLevelIndicationStatus(bool enable,
+ unsigned char id) {
_includeAudioLevelIndication = enable;
return SetSendRtpHeaderExtension(enable, kRtpExtensionAudioLevel, id);
}
int Channel::SetSendMIDStatus(bool enable, unsigned char id) {
return SetSendRtpHeaderExtension(enable, kRtpExtensionMId, id);
}
int Channel::SetReceiveAudioLevelIndicationStatus(bool enable,
- unsigned char id) {
- rtp_header_parser_->DeregisterRtpHeaderExtension(kRtpExtensionAudioLevel);
- if (enable &&
- !rtp_header_parser_->RegisterRtpHeaderExtension(kRtpExtensionAudioLevel,
- id)) {
+ unsigned char id,
+ bool isLevelSsrc) {
+ const webrtc::RTPExtensionType& rtpExt = isLevelSsrc ?
+ kRtpExtensionAudioLevel : kRtpExtensionCsrcAudioLevel;
+ rtp_header_parser_->DeregisterRtpHeaderExtension(rtpExt);
+ if (enable && !rtp_header_parser_->RegisterRtpHeaderExtension(rtpExt, id)) {
return -1;
}
return 0;
}
void Channel::EnableSendTransportSequenceNumber(int id) {
int ret =
SetSendRtpHeaderExtension(true, kRtpExtensionTransportSequenceNumber, id);
--- a/media/webrtc/trunk/webrtc/voice_engine/channel.h
+++ b/media/webrtc/trunk/webrtc/voice_engine/channel.h
@@ -297,17 +297,17 @@ class Channel
// VoERTP_RTCP
int SetLocalMID(const char* mid);
int SetLocalSSRC(unsigned int ssrc);
int GetLocalSSRC(unsigned int& ssrc);
int GetRemoteSSRC(unsigned int& ssrc);
int SetSendAudioLevelIndicationStatus(bool enable, unsigned char id);
int SetSendMIDStatus(bool enable, unsigned char id);
- int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id);
+ int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id, bool isLevelSsrc);
int SetSendAbsoluteSenderTimeStatus(bool enable, unsigned char id);
int SetReceiveAbsoluteSenderTimeStatus(bool enable, unsigned char id);
void EnableSendTransportSequenceNumber(int id);
void EnableReceiveTransportSequenceNumber(int id);
void RegisterSenderCongestionControlObjects(
RtpPacketSender* rtp_packet_sender,
TransportFeedbackObserver* transport_feedback_observer,
--- a/media/webrtc/trunk/webrtc/voice_engine/channel_proxy.cc
+++ b/media/webrtc/trunk/webrtc/voice_engine/channel_proxy.cc
@@ -51,19 +51,21 @@ void ChannelProxy::SetNACKStatus(bool en
}
void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
RTC_DCHECK_EQ(0, error);
}
-void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) {
+void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id,
+ bool isLevelSsrc) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
- int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id);
+ int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id,
+ isLevelSsrc);
RTC_DCHECK_EQ(0, error);
}
void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
channel()->EnableSendTransportSequenceNumber(id);
}
--- a/media/webrtc/trunk/webrtc/voice_engine/channel_proxy.h
+++ b/media/webrtc/trunk/webrtc/voice_engine/channel_proxy.h
@@ -50,17 +50,18 @@ class ChannelProxy {
explicit ChannelProxy(const ChannelOwner& channel_owner);
virtual ~ChannelProxy();
virtual void SetRTCPStatus(bool enable);
virtual void SetLocalSSRC(uint32_t ssrc);
virtual void SetRTCP_CNAME(const std::string& c_name);
virtual void SetNACKStatus(bool enable, int max_packets);
virtual void SetSendAudioLevelIndicationStatus(bool enable, int id);
- virtual void SetReceiveAudioLevelIndicationStatus(bool enable, int id);
+ virtual void SetReceiveAudioLevelIndicationStatus(bool enable, int id,
+ bool isLevelSsrc = true);
virtual void EnableSendTransportSequenceNumber(int id);
virtual void EnableReceiveTransportSequenceNumber(int id);
virtual void RegisterSenderCongestionControlObjects(
RtpPacketSender* rtp_packet_sender,
TransportFeedbackObserver* transport_feedback_observer,
PacketRouter* packet_router);
virtual void RegisterReceiverCongestionControlObjects(
PacketRouter* packet_router);
--- a/media/webrtc/trunk/webrtc/voice_engine/include/voe_rtp_rtcp.h
+++ b/media/webrtc/trunk/webrtc/voice_engine/include/voe_rtp_rtcp.h
@@ -129,17 +129,18 @@ class WEBRTC_DLLEXPORT VoERTP_RTCP {
// Sets the status of sending MID on a specific |channel|.
virtual int SetSendMIDStatus(int channel, bool enable, unsigned char id = 1) = 0;
// Sets the status of receiving rtp-audio-level-indication on a specific
// |channel|.
virtual int SetReceiveAudioLevelIndicationStatus(int channel,
bool enable,
- unsigned char id = 1) {
+ unsigned char id = 1,
+ bool isLevelSsrc = true) {
// TODO(wu): Remove default implementation once talk is updated.
return 0;
}
// Sets the RTCP status on a specific |channel|.
virtual int SetRTCPStatus(int channel, bool enable) = 0;
// Gets the RTCP status on a specific |channel|.
--- a/media/webrtc/trunk/webrtc/voice_engine/voe_rtp_rtcp_impl.cc
+++ b/media/webrtc/trunk/webrtc/voice_engine/voe_rtp_rtcp_impl.cc
@@ -166,17 +166,18 @@ int VoERTP_RTCPImpl::SetSendMIDStatus(in
return -1;
}
return channelPtr->SetSendMIDStatus(enable, id);
}
int VoERTP_RTCPImpl::SetReceiveAudioLevelIndicationStatus(int channel,
bool enable,
- unsigned char id) {
+ unsigned char id,
+ bool isLevelSsrc) {
WEBRTC_TRACE(
kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetReceiveAudioLevelIndicationStatus(channel=%d, enable=%d, id=%u)",
channel, enable, id);
if (!_shared->statistics().Initialized()) {
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
}
@@ -193,17 +194,18 @@ int VoERTP_RTCPImpl::SetReceiveAudioLeve
voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel);
voe::Channel* channel_ptr = ch.channel();
if (channel_ptr == NULL) {
_shared->SetLastError(
VE_CHANNEL_NOT_VALID, kTraceError,
"SetReceiveAudioLevelIndicationStatus() failed to locate channel");
return -1;
}
- return channel_ptr->SetReceiveAudioLevelIndicationStatus(enable, id);
+ return channel_ptr->SetReceiveAudioLevelIndicationStatus(enable, id,
+ isLevelSsrc);
}
int VoERTP_RTCPImpl::SetRTCPStatus(int channel, bool enable) {
WEBRTC_TRACE(kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1),
"SetRTCPStatus(channel=%d, enable=%d)", channel, enable);
if (!_shared->statistics().Initialized()) {
_shared->SetLastError(VE_NOT_INITED, kTraceError);
return -1;
--- a/media/webrtc/trunk/webrtc/voice_engine/voe_rtp_rtcp_impl.h
+++ b/media/webrtc/trunk/webrtc/voice_engine/voe_rtp_rtcp_impl.h
@@ -39,17 +39,18 @@ class VoERTP_RTCPImpl : public VoERTP_RT
// RTP Header Extension for Client-to-Mixer Audio Level Indication
int SetSendAudioLevelIndicationStatus(int channel,
bool enable,
unsigned char id) override;
int SetSendMIDStatus(int channel, bool enable, unsigned char id = 1) override;
int SetReceiveAudioLevelIndicationStatus(int channel,
bool enable,
- unsigned char id) override;
+ unsigned char id,
+ bool isLevelSsrc = true) override;
// Statistics
int GetRTPStatistics(int channel,
unsigned int& averageJitterMs,
unsigned int& maxJitterMs,
unsigned int& discardedPackets,
unsigned int& cumulativeLost) override;