зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1441260 - unify API for setting extmaps in AudioConduit r=dminor,mjf
MozReview-Commit-ID: 8PmvQyk32WW --HG-- extra : rebase_source : 160ba11194fd823c5e90ccde9bddd7632efa9369
This commit is contained in:
Родитель
8e43da7d18
Коммит
cb1016c774
|
@ -42,6 +42,7 @@ static const char* acLogTag ="WebrtcAudioSessionConduit";
|
|||
// 32 bytes is what WebRTC CodecInst expects
|
||||
const unsigned int WebrtcAudioConduit::CODEC_PLNAME_SIZE = 32;
|
||||
|
||||
using LocalDirection = MediaSessionConduitLocalDirection;
|
||||
/**
|
||||
* Factory Method for AudioConduit
|
||||
*/
|
||||
|
@ -612,49 +613,56 @@ WebrtcAudioConduit::ConfigureRecvMediaCodecs(
|
|||
}
|
||||
|
||||
MediaConduitErrorCode
|
||||
WebrtcAudioConduit::EnableAudioLevelExtension(bool aEnabled,
|
||||
uint8_t aId,
|
||||
bool aDirectionIsSend,
|
||||
bool aLevelIsSsrc)
|
||||
WebrtcAudioConduit::SetLocalRTPExtensions(LocalDirection aDirection,
|
||||
const RtpExtList& extensions)
|
||||
{
|
||||
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;
|
||||
CSFLogDebug(LOGTAG, "%s direction: %s", __FUNCTION__,
|
||||
MediaSessionConduit::LocalDirectionToString(aDirection).c_str());
|
||||
bool isSend = aDirection == LocalDirection::kSend;
|
||||
constexpr bool kEnableExt = true;
|
||||
constexpr bool kSsrcLevel = true;
|
||||
constexpr bool kCsrcLevel = false;
|
||||
for(const auto& extension : extensions) {
|
||||
int ret = 0;
|
||||
// ssrc-audio-level RTP header extension
|
||||
if (extension.uri == webrtc::RtpExtension::kAudioLevelUri) {
|
||||
if (isSend) {
|
||||
ret = mPtrVoERTP_RTCP->SetSendAudioLevelIndicationStatus(mChannel,
|
||||
kEnableExt,
|
||||
extension.id);
|
||||
} else {
|
||||
ret = mPtrRTP->SetReceiveAudioLevelIndicationStatus(mChannel,
|
||||
kEnableExt,
|
||||
extension.id,
|
||||
kSsrcLevel);
|
||||
}
|
||||
}
|
||||
// csrc-audio-level RTP header extension
|
||||
if (extension.uri == webrtc::RtpExtension::kCsrcAudioLevelUri) {
|
||||
if (isSend) {
|
||||
CSFLogError(LOGTAG, "%s SetSendAudioLevelIndicationStatus Failed"
|
||||
" can not send CSRC audio levels.", __FUNCTION__);
|
||||
return kMediaConduitMalformedArgument;
|
||||
}
|
||||
ret = mPtrRTP->SetReceiveAudioLevelIndicationStatus(mChannel,
|
||||
kEnableExt,
|
||||
extension.id,
|
||||
kCsrcLevel);
|
||||
}
|
||||
// MID RTP header extension
|
||||
if (aDirection == LocalDirection::kSend &&
|
||||
extension.uri == webrtc::RtpExtension::kMIdUri) {
|
||||
ret = mPtrVoERTP_RTCP->SetSendMIDStatus(mChannel, kEnableExt,
|
||||
extension.id);
|
||||
}
|
||||
// Handle errors
|
||||
if (ret == -1) {
|
||||
CSFLogError(LOGTAG, "Failed %s setting extension %s with id %d",
|
||||
__FUNCTION__, extension.uri.c_str(),
|
||||
static_cast<int>(extension.id));
|
||||
return kMediaConduitUnknownError;
|
||||
}
|
||||
ret = mPtrVoERTP_RTCP->SetSendAudioLevelIndicationStatus(mChannel,
|
||||
aEnabled,
|
||||
aId) == -1;
|
||||
} else {
|
||||
ret = mPtrRTP->SetReceiveAudioLevelIndicationStatus(mChannel,
|
||||
aEnabled,
|
||||
aId,
|
||||
aLevelIsSsrc) == -1;
|
||||
}
|
||||
if (ret) {
|
||||
CSFLogError(LOGTAG, "%s SetSendAudioLevelIndicationStatus Failed", __FUNCTION__);
|
||||
return kMediaConduitUnknownError;
|
||||
}
|
||||
return kMediaConduitNoError;
|
||||
}
|
||||
|
||||
MediaConduitErrorCode
|
||||
WebrtcAudioConduit::EnableMIDExtension(bool enabled, uint8_t id)
|
||||
{
|
||||
CSFLogDebug(LOGTAG, "%s %d %d ", __FUNCTION__, enabled, id);
|
||||
|
||||
if (mPtrVoERTP_RTCP->SetSendMIDStatus(mChannel, enabled, id) == -1)
|
||||
{
|
||||
CSFLogError(LOGTAG, "%s SetSendMIDStatus Failed", __FUNCTION__);
|
||||
return kMediaConduitUnknownError;
|
||||
}
|
||||
|
||||
return kMediaConduitNoError;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,12 +97,8 @@ public:
|
|||
const std::vector<AudioCodecConfig* >& codecConfigList) override;
|
||||
|
||||
MediaConduitErrorCode
|
||||
EnableAudioLevelExtension(bool aEnabled,
|
||||
uint8_t aId,
|
||||
bool aDirectionIsSend,
|
||||
bool aLevelIsSsrc = true) override;
|
||||
|
||||
virtual MediaConduitErrorCode EnableMIDExtension(bool enabled, uint8_t id) override;
|
||||
SetLocalRTPExtensions(MediaSessionConduitLocalDirection aDirection,
|
||||
const RtpExtList& extensions) override;
|
||||
|
||||
/**
|
||||
* Register External Transport to this Conduit. RTP and RTCP frames from the VoiceEngine
|
||||
|
|
|
@ -34,6 +34,11 @@ class VideoFrame;
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
enum class MediaSessionConduitLocalDirection : int {
|
||||
kSend,
|
||||
kRecv
|
||||
};
|
||||
|
||||
using RtpExtList = std::vector<webrtc::RtpExtension>;
|
||||
|
||||
// Wrap the webrtc.org Call class adding mozilla add/ref support.
|
||||
|
@ -182,6 +187,12 @@ protected:
|
|||
public:
|
||||
enum Type { AUDIO, VIDEO } ;
|
||||
|
||||
static std::string
|
||||
LocalDirectionToString(const MediaSessionConduitLocalDirection aDirection) {
|
||||
return aDirection == MediaSessionConduitLocalDirection::kSend ?
|
||||
"send" : "receive";
|
||||
}
|
||||
|
||||
virtual Type type() const = 0;
|
||||
|
||||
/**
|
||||
|
@ -241,15 +252,17 @@ public:
|
|||
virtual std::vector<unsigned int> GetLocalSSRCs() const = 0;
|
||||
|
||||
/**
|
||||
* Adds negotiated RTP extensions
|
||||
* XXX Move to MediaSessionConduit
|
||||
* Adds negotiated RTP header extensions to the the conduit. Unknown extensions
|
||||
* are ignored.
|
||||
* @param aDirection the local direction to set the RTP header extensions for
|
||||
* @param aExtensions the RTP header extensions to set
|
||||
* @return if all extensions were set it returns a success code,
|
||||
* if an extension fails to set it may immediately return an error code
|
||||
* TODO webrtc.org 64 update: make return type void again
|
||||
*/
|
||||
virtual void
|
||||
SetLocalRTPExtensions(bool aIsSend, const RtpExtList& extensions) = 0;
|
||||
/**
|
||||
* Returns the negotiated RTP extensions
|
||||
*/
|
||||
virtual RtpExtList GetLocalRTPExtensions(bool aIsSend) const = 0;
|
||||
virtual MediaConduitErrorCode
|
||||
SetLocalRTPExtensions(MediaSessionConduitLocalDirection aDirection,
|
||||
const RtpExtList& aExtensions) = 0;
|
||||
|
||||
virtual bool GetRemoteSSRC(unsigned int* ssrc) = 0;
|
||||
virtual bool SetRemoteSSRC(unsigned int ssrc) = 0;
|
||||
|
@ -357,12 +370,9 @@ public:
|
|||
|
||||
Type type() const override { return VIDEO; }
|
||||
|
||||
void
|
||||
SetLocalRTPExtensions(bool aIsSend,
|
||||
MediaConduitErrorCode
|
||||
SetLocalRTPExtensions(MediaSessionConduitLocalDirection aDirection,
|
||||
const RtpExtList& extensions) override = 0;
|
||||
|
||||
RtpExtList GetLocalRTPExtensions(bool aIsSend) const override = 0;
|
||||
|
||||
/**
|
||||
* Function to attach Renderer end-point of the Media-Video conduit.
|
||||
* @param aRenderer : Reference to the concrete Video renderer implementation
|
||||
|
@ -461,12 +471,9 @@ public:
|
|||
|
||||
Type type() const override { return AUDIO; }
|
||||
|
||||
void
|
||||
SetLocalRTPExtensions(bool aIsSend,
|
||||
const RtpExtList& extensions) override {};
|
||||
|
||||
RtpExtList
|
||||
GetLocalRTPExtensions(bool aIsSend) const override {return RtpExtList();}
|
||||
MediaConduitErrorCode
|
||||
SetLocalRTPExtensions(MediaSessionConduitLocalDirection aDirection,
|
||||
const RtpExtList& extensions) override = 0;
|
||||
/**
|
||||
* Function to deliver externally captured audio sample for encoding and transport
|
||||
* @param audioData [in]: Pointer to array containing a frame of audio
|
||||
|
@ -531,21 +538,6 @@ public:
|
|||
*/
|
||||
virtual MediaConduitErrorCode ConfigureRecvMediaCodecs(
|
||||
const std::vector<AudioCodecConfig* >& recvCodecConfigList) = 0;
|
||||
/**
|
||||
* Function to enable the audio level extension
|
||||
* @param aEnabled: enable extension
|
||||
* @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,
|
||||
bool aLevelIsSsrc = true) = 0;
|
||||
virtual MediaConduitErrorCode
|
||||
EnableMIDExtension(bool enabled, uint8_t id) = 0;
|
||||
|
||||
virtual bool SetDtmfPayloadType(unsigned char type, int freq) = 0;
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ static const char* vcLogTag = "WebrtcVideoSessionConduit";
|
|||
#endif
|
||||
#define LOGTAG vcLogTag
|
||||
|
||||
using LocalDirection = MediaSessionConduitLocalDirection;
|
||||
|
||||
static const int kNullPayloadType = -1;
|
||||
static const char* kUlpFecPayloadName = "ulpfec";
|
||||
static const char* kRedPayloadName = "red";
|
||||
|
@ -320,20 +322,15 @@ WebrtcVideoConduit::~WebrtcVideoConduit()
|
|||
Destroy();
|
||||
}
|
||||
|
||||
void
|
||||
WebrtcVideoConduit::SetLocalRTPExtensions(bool aIsSend,
|
||||
const RtpExtList & aExtensions)
|
||||
MediaConduitErrorCode
|
||||
WebrtcVideoConduit::SetLocalRTPExtensions(LocalDirection aDirection,
|
||||
const RtpExtList& aExtensions)
|
||||
{
|
||||
auto& extList = aIsSend ? mSendStreamConfig.rtp.extensions :
|
||||
mRecvStreamConfig.rtp.extensions;
|
||||
auto& extList = aDirection == LocalDirection::kSend ?
|
||||
mSendStreamConfig.rtp.extensions :
|
||||
mRecvStreamConfig.rtp.extensions;
|
||||
extList = aExtensions;
|
||||
}
|
||||
|
||||
RtpExtList
|
||||
WebrtcVideoConduit::GetLocalRTPExtensions(bool aIsSend) const
|
||||
{
|
||||
return aIsSend ? mSendStreamConfig.rtp.extensions :
|
||||
mRecvStreamConfig.rtp.extensions;
|
||||
return kMediaConduitNoError;
|
||||
}
|
||||
|
||||
bool WebrtcVideoConduit::SetLocalSSRCs(const std::vector<unsigned int> & aSSRCs)
|
||||
|
|
|
@ -78,13 +78,9 @@ public:
|
|||
//VoiceEngine defined constant for Payload Name Size.
|
||||
static const unsigned int CODEC_PLNAME_SIZE;
|
||||
|
||||
/**
|
||||
* Add rtp extensions to the the VideoSendStream
|
||||
*/
|
||||
void
|
||||
SetLocalRTPExtensions(bool aIsSend, const RtpExtList& extensions) override;
|
||||
|
||||
RtpExtList GetLocalRTPExtensions(bool aIsSend) const override;
|
||||
MediaConduitErrorCode
|
||||
SetLocalRTPExtensions(MediaSessionConduitLocalDirection aDirection,
|
||||
const RtpExtList& aExtensions) override;
|
||||
|
||||
/**
|
||||
* Set up A/V sync between this (incoming) VideoConduit and an audio conduit.
|
||||
|
|
|
@ -32,6 +32,8 @@ namespace mozilla {
|
|||
|
||||
MOZ_MTLOG_MODULE("transceiverimpl")
|
||||
|
||||
using LocalDirection = MediaSessionConduitLocalDirection;
|
||||
|
||||
TransceiverImpl::TransceiverImpl(
|
||||
const std::string& aPCHandle,
|
||||
JsepTransceiver* aJsepTransceiver,
|
||||
|
@ -727,36 +729,7 @@ TransceiverImpl::UpdateAudioConduit()
|
|||
" ConfigureRecvMediaCodecs failed: " << error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const SdpExtmapAttributeList::Extmap* audioLevelExt =
|
||||
details.GetExt(webrtc::RtpExtension::kAudioLevelUri);
|
||||
if (audioLevelExt) {
|
||||
MOZ_MTLOG(ML_DEBUG, "Calling EnableAudioLevelExtension");
|
||||
error = conduit->EnableAudioLevelExtension(true,
|
||||
audioLevelExt->entry,
|
||||
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;
|
||||
}
|
||||
}
|
||||
UpdateConduitRtpExtmap(details, LocalDirection::kRecv);
|
||||
}
|
||||
|
||||
if (mJsepTransceiver->mSendTrack.GetNegotiatedDetails() &&
|
||||
|
@ -787,36 +760,7 @@ TransceiverImpl::UpdateAudioConduit()
|
|||
" ConfigureSendMediaCodec failed: " << error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Should these be genericized like they are in the video conduit case?
|
||||
const SdpExtmapAttributeList::Extmap* audioLevelExt =
|
||||
details.GetExt(webrtc::RtpExtension::kAudioLevelUri);
|
||||
|
||||
if (audioLevelExt) {
|
||||
MOZ_MTLOG(ML_DEBUG, "Calling EnableAudioLevelExtension");
|
||||
error = conduit->EnableAudioLevelExtension(true,
|
||||
audioLevelExt->entry,
|
||||
true);
|
||||
|
||||
if (error) {
|
||||
MOZ_MTLOG(ML_ERROR, mPCHandle << "[" << mMid << "]: " << __FUNCTION__ <<
|
||||
" EnableAudioLevelExtension failed: " << error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
const SdpExtmapAttributeList::Extmap* midExt =
|
||||
details.GetExt(webrtc::RtpExtension::kMIdUri);
|
||||
|
||||
if (midExt) {
|
||||
MOZ_MTLOG(ML_DEBUG, "Calling EnableMIDExtension");
|
||||
error = conduit->EnableMIDExtension(true, midExt->entry);
|
||||
|
||||
if (error) {
|
||||
MOZ_MTLOG(ML_ERROR, "EnableMIDExtension failed: " << error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
UpdateConduitRtpExtmap(details, LocalDirection::kSend);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -923,7 +867,7 @@ TransceiverImpl::UpdateVideoConduit()
|
|||
mJsepTransceiver->mRecvTrack.GetActive()) {
|
||||
const auto& details(*mJsepTransceiver->mRecvTrack.GetNegotiatedDetails());
|
||||
|
||||
UpdateVideoExtmap(details, false);
|
||||
UpdateConduitRtpExtmap(details, LocalDirection::kRecv);
|
||||
|
||||
PtrVector<VideoCodecConfig> configs;
|
||||
nsresult rv = NegotiatedDetailsToVideoCodecConfigs(details, &configs);
|
||||
|
@ -952,7 +896,7 @@ TransceiverImpl::UpdateVideoConduit()
|
|||
mSendTrack) {
|
||||
const auto& details(*mJsepTransceiver->mSendTrack.GetNegotiatedDetails());
|
||||
|
||||
UpdateVideoExtmap(details, true);
|
||||
UpdateConduitRtpExtmap(details, LocalDirection::kSend);
|
||||
|
||||
nsresult rv = ConfigureVideoCodecMode(*conduit);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -1020,8 +964,8 @@ TransceiverImpl::ConfigureVideoCodecMode(VideoSessionConduit& aConduit)
|
|||
}
|
||||
|
||||
void
|
||||
TransceiverImpl::UpdateVideoExtmap(const JsepTrackNegotiatedDetails& aDetails,
|
||||
bool aSending)
|
||||
TransceiverImpl::UpdateConduitRtpExtmap(const JsepTrackNegotiatedDetails& aDetails,
|
||||
const LocalDirection aDirection)
|
||||
{
|
||||
std::vector<webrtc::RtpExtension> extmaps;
|
||||
// @@NG read extmap from track
|
||||
|
@ -1035,7 +979,7 @@ TransceiverImpl::UpdateVideoExtmap(const JsepTrackNegotiatedDetails& aDetails,
|
|||
mConduit.get());
|
||||
|
||||
if (!extmaps.empty()) {
|
||||
conduit->SetLocalRTPExtensions(aSending, extmaps);
|
||||
conduit->SetLocalRTPExtensions(aDirection, extmaps);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,10 @@ namespace mozilla {
|
|||
class PeerIdentity;
|
||||
class PeerConnectionMedia;
|
||||
class JsepTransceiver;
|
||||
enum class MediaSessionConduitLocalDirection : int;
|
||||
class MediaSessionConduit;
|
||||
class VideoSessionConduit;
|
||||
class AudioSessionConduit;
|
||||
class MediaPipelineReceive;
|
||||
class MediaPipelineTransmit;
|
||||
class MediaPipeline;
|
||||
|
@ -132,9 +134,8 @@ private:
|
|||
nsresult UpdateAudioConduit();
|
||||
nsresult UpdateVideoConduit();
|
||||
nsresult ConfigureVideoCodecMode(VideoSessionConduit& aConduit);
|
||||
// This will eventually update audio extmap too
|
||||
void UpdateVideoExtmap(const JsepTrackNegotiatedDetails& aDetails,
|
||||
bool aSending);
|
||||
void UpdateConduitRtpExtmap(const JsepTrackNegotiatedDetails& aDetails,
|
||||
const MediaSessionConduitLocalDirection aDir);
|
||||
void Stop();
|
||||
|
||||
const std::string mPCHandle;
|
||||
|
|
Загрузка…
Ссылка в новой задаче