Bug 1225722 - Implement getters in the conduits for currently active payload types. r=bwc

Differential Revision: https://phabricator.services.mozilla.com/D135866
This commit is contained in:
Andreas Pehrson 2022-02-01 23:12:28 +00:00
parent 64bad5940a
commit d78a1f4edd
6 changed files with 71 additions and 0 deletions

View File

@ -875,4 +875,34 @@ void WebrtcAudioConduit::DeliverPacket(rtc::CopyOnWriteBuffer packet,
}
}
Maybe<int> WebrtcAudioConduit::ActiveSendPayloadType() const {
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
auto stats = GetSenderStats();
if (!stats) {
return Nothing();
}
if (!stats->codec_payload_type) {
return Nothing();
}
return Some(*stats->codec_payload_type);
}
Maybe<int> WebrtcAudioConduit::ActiveRecvPayloadType() const {
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
auto stats = GetReceiverStats();
if (!stats) {
return Nothing();
}
if (!stats->codec_payload_type) {
return Nothing();
}
return Some(*stats->codec_payload_type);
}
} // namespace mozilla

View File

@ -29,6 +29,9 @@ struct DtmfEvent;
class WebrtcAudioConduit : public AudioSessionConduit,
public webrtc::RtcpEventObserver {
public:
Maybe<int> ActiveSendPayloadType() const override;
Maybe<int> ActiveRecvPayloadType() const override;
void OnRtpReceived(MediaPacket&& aPacket, webrtc::RTPHeader&& aHeader);
void OnRtcpReceived(MediaPacket&& aPacket);

View File

@ -115,6 +115,10 @@ class MediaSessionConduit {
virtual Type type() const = 0;
// Call thread only
virtual Maybe<int> ActiveSendPayloadType() const = 0;
virtual Maybe<int> ActiveRecvPayloadType() const = 0;
// Whether transport is currently sending and receiving packets
virtual void SetTransportActive(bool aActive) = 0;

View File

@ -1892,4 +1892,33 @@ bool WebrtcVideoConduit::HasH264Hardware() {
status == nsIGfxInfo::FEATURE_STATUS_OK;
}
Maybe<int> WebrtcVideoConduit::ActiveSendPayloadType() const {
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
if (!mSendStream) {
return Nothing();
}
if (mSendStreamConfig.rtp.payload_type == -1) {
return Nothing();
}
return Some(mSendStreamConfig.rtp.payload_type);
}
Maybe<int> WebrtcVideoConduit::ActiveRecvPayloadType() const {
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
auto stats = GetReceiverStats();
if (!stats) {
return Nothing();
}
if (stats->current_payload_type == -1) {
return Nothing();
}
return Some(stats->current_payload_type);
}
} // namespace mozilla

View File

@ -71,6 +71,9 @@ class WebrtcVideoConduit
// Returns true when both encoder and decoder are HW accelerated.
static bool HasH264Hardware();
Maybe<int> ActiveSendPayloadType() const override;
Maybe<int> ActiveRecvPayloadType() const override;
/**
* Function to attach Renderer end-point for the Media-Video conduit.
* @param aRenderer : Reference to the concrete mozilla Video renderer

View File

@ -24,6 +24,8 @@ class MockConduit : public MediaSessionConduit {
MockConduit() = default;
MOCK_CONST_METHOD0(type, Type());
MOCK_CONST_METHOD0(ActiveSendPayloadType, Maybe<int>());
MOCK_CONST_METHOD0(ActiveRecvPayloadType, Maybe<int>());
MOCK_METHOD1(SetTransportActive, void(bool));
MOCK_METHOD0(SenderRtpSendEvent, MediaEventSourceExc<MediaPacket>&());
MOCK_METHOD0(SenderRtcpSendEvent, MediaEventSourceExc<MediaPacket>&());