mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 01:44:42 +00:00
Bug 1916579 - normalize webrtc codec name capitalizatoin in GLEAN probes;r=bwc
Differential Revision: https://phabricator.services.mozilla.com/D220985
This commit is contained in:
parent
e5d3610c6d
commit
0ac20b472e
@ -1483,6 +1483,13 @@ void RTCRtpSender::SyncToJsep(JsepTransceiver& aJsepTransceiver) const {
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to upper case codec names for GLEAN probes
|
||||
auto upCase(const std::string& str) -> std::string {
|
||||
std::string result;
|
||||
std::transform(str.begin(), str.end(), result.end(), ::toupper);
|
||||
return result;
|
||||
}
|
||||
|
||||
Maybe<RTCRtpSender::VideoConfig> RTCRtpSender::GetNewVideoConfig() {
|
||||
// It is possible for SDP to signal that there is a send track, but there not
|
||||
// actually be a send track, according to the specification; all that needs to
|
||||
@ -1593,17 +1600,18 @@ Maybe<RTCRtpSender::VideoConfig> RTCRtpSender::GetNewVideoConfig() {
|
||||
// Log codec information we are tracking
|
||||
if (!mHaveLoggedOtherFec &&
|
||||
!GetJsepTransceiver().mSendTrack.GetFecCodecName().empty()) {
|
||||
const auto name = upCase(GetJsepTransceiver().mSendTrack.GetFecCodecName());
|
||||
mozilla::glean::codec_stats::other_fec_signaled
|
||||
.Get(nsDependentCString(
|
||||
GetJsepTransceiver().mSendTrack.GetFecCodecName().c_str()))
|
||||
.Get(nsDependentCString(name.c_str()))
|
||||
.Add(1);
|
||||
mHaveLoggedOtherFec = true;
|
||||
}
|
||||
if (!mHaveLoggedVideoPreferredCodec &&
|
||||
!GetJsepTransceiver().mSendTrack.GetVideoPreferredCodec().empty()) {
|
||||
const auto name =
|
||||
upCase(GetJsepTransceiver().mSendTrack.GetVideoPreferredCodec());
|
||||
mozilla::glean::codec_stats::video_preferred_codec
|
||||
.Get(nsDependentCString(
|
||||
GetJsepTransceiver().mSendTrack.GetVideoPreferredCodec().c_str()))
|
||||
.Get(nsDependentCString(name.c_str()))
|
||||
.Add(1);
|
||||
mHaveLoggedVideoPreferredCodec = true;
|
||||
}
|
||||
@ -1685,9 +1693,10 @@ Maybe<RTCRtpSender::AudioConfig> RTCRtpSender::GetNewAudioConfig() {
|
||||
|
||||
if (!mHaveLoggedAudioPreferredCodec &&
|
||||
!GetJsepTransceiver().mSendTrack.GetAudioPreferredCodec().empty()) {
|
||||
const auto name =
|
||||
upCase(GetJsepTransceiver().mSendTrack.GetAudioPreferredCodec());
|
||||
mozilla::glean::codec_stats::audio_preferred_codec
|
||||
.Get(nsDependentCString(
|
||||
GetJsepTransceiver().mSendTrack.GetAudioPreferredCodec().c_str()))
|
||||
.Get(nsDependentCString(name.c_str()))
|
||||
.Add(1);
|
||||
mHaveLoggedAudioPreferredCodec = true;
|
||||
}
|
||||
|
@ -460,7 +460,7 @@
|
||||
pc1.setRemoteDescription(answer);
|
||||
|
||||
// Validate logging shows flexfec counted once ulpfec negotiated twice and preferred video VP9 since no VP8 was offered.
|
||||
let flexfecOffered = await GleanTest.codecStats.otherFecSignaled.flexfec.testGetValue() || 0;
|
||||
let flexfecOffered = await GleanTest.codecStats.otherFecSignaled.FLEXFEC.testGetValue() || 0;
|
||||
ok(flexfecOffered == 1, "checkFlexfecOffered glean should count flexfec being offered" + flexfecOffered);
|
||||
let ulpfecNegotiated = await GleanTest.codecStats.ulpfecNegotiated.negotiated.testGetValue() || 0;
|
||||
ok(ulpfecNegotiated == 2, "checkUlpfecNegotiated glean should show ulpfec negotiated");
|
||||
@ -510,7 +510,7 @@
|
||||
pc1.setRemoteDescription(answer);
|
||||
|
||||
// We should show CN as the preferred codec from the offer and the answer should prefer G722 since opus was removed.
|
||||
let preferredAudioCodecFAKECodec = await GleanTest.codecStats.audioPreferredCodec.FAKECodec.testGetValue() || 0;
|
||||
let preferredAudioCodecFAKECodec = await GleanTest.codecStats.audioPreferredCodec.FAKECODEC.testGetValue() || 0;
|
||||
ok(preferredAudioCodecFAKECodec == 1, "checkPreferredAudioCodec Glean should show preferred audio codec FAKECodec " + preferredAudioCodecFAKECodec);
|
||||
let preferredAudioCodecG722 = await GleanTest.codecStats.audioPreferredCodec.G722.testGetValue() || 0;
|
||||
ok(preferredAudioCodecG722 == 1, "checkPreferredAudioCodec Glean should show preferred audio codec G722 " + preferredAudioCodecG722);
|
||||
@ -729,6 +729,35 @@
|
||||
});
|
||||
},
|
||||
|
||||
async function checkCodecCaseEquivalence() {
|
||||
const pc1 = new RTCPeerConnection();
|
||||
const pc2 = new RTCPeerConnection();
|
||||
await gleanResetTestValues();
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
|
||||
const sender = pc1.addTrack(stream.getTracks()[0]);
|
||||
await pc1.setLocalDescription();
|
||||
let offer = pc1.localDescription;
|
||||
// Set a video codec using a lower case name to ensure that GLEAN
|
||||
// probes are case-insensitive.
|
||||
const sdp = offer.sdp.replaceAll('VP8','vp8');
|
||||
await pc2.setRemoteDescription({type: 'offer', sdp});
|
||||
const answer = await pc2.createAnswer();
|
||||
await pc2.setLocalDescription(answer);
|
||||
await pc1.setRemoteDescription(answer);
|
||||
|
||||
|
||||
// Check that the codec name is always upper case
|
||||
let preferredVideoCodecVP8UCase = await GleanTest.codecStats.videoPreferredCodec.VP8.testGetValue() || 0;
|
||||
ok(preferredVideoCodecVP8UCase == 2, "checkPreferredVideoCodec glean should show preferred video codec VP8" + preferredVideoCodecVP8UCase);
|
||||
|
||||
// Check that the bin for the lower case codec name does not exist
|
||||
let preferredVideoCodecVP8LCase = await GleanTest.codecStats.videoPreferredCodec.vp8.testGetValue();
|
||||
ok(preferredVideoCodecVP8LCase === null, "checkPreferredVideoCodec glean should show preferred video codec vp8" + preferredVideoCodecVP8LCase);
|
||||
|
||||
// The other probes of concern are covered by other tests which inherently
|
||||
// use lower case or mixed case codec names: FAKECodec, flexfec.
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
runNetworkTest(async () => {
|
||||
|
Loading…
Reference in New Issue
Block a user