mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
Bug 1548097 - sort getContributingSources and getSynchronizationSources results r=jib
sort getContributingSources and getSynchronizationSources results Differential Revision: https://phabricator.services.mozilla.com/D29441 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
aff3eeba9f
commit
59dcd65631
@ -2199,13 +2199,13 @@ class RTCRtpReceiver {
|
||||
_getRtpSourcesByType(type) {
|
||||
this._fetchRtpSources();
|
||||
// Only return the values from within the last 10 seconds as per the spec
|
||||
let cutoffTime = this._rtpSourcesJsTimestamp - 10 * 1000;
|
||||
let sources = [...this._rtpSources.values()].filter(
|
||||
const cutoffTime = this._rtpSourcesJsTimestamp - 10 * 1000;
|
||||
return [...this._rtpSources.values()].filter(
|
||||
(entry) => {
|
||||
return entry.sourceType == type &&
|
||||
(entry.timestamp + entry.sourceClockOffset) >= cutoffTime;
|
||||
}).map(e => {
|
||||
let newEntry = {
|
||||
const newEntry = {
|
||||
source: e.source,
|
||||
timestamp: e.timestamp + e.sourceClockOffset,
|
||||
audioLevel: e.audioLevel,
|
||||
@ -2214,8 +2214,7 @@ class RTCRtpReceiver {
|
||||
Object.assign(newEntry, {voiceActivityFlag: e.voiceActivityFlag});
|
||||
}
|
||||
return newEntry;
|
||||
});
|
||||
return sources;
|
||||
}).sort((a, b) => b.timestamp - a.timestamp);
|
||||
}
|
||||
|
||||
getContributingSources() {
|
||||
|
@ -111,6 +111,24 @@
|
||||
is(JSON.stringify(contributingSources),
|
||||
JSON.stringify(remoteReceiver.getContributingSources()),
|
||||
"getContributingSources is cached");
|
||||
// Check that sources are sorted in descending order by time stamp
|
||||
const timestamp3 = SpWrap(test.pcLocal).mozGetNowInRtpSourceReferenceTime();
|
||||
// Larger offsets are further back in time
|
||||
const testOffsets = [3, 7, 5, 6, 1, 4];
|
||||
for (const offset of testOffsets) {
|
||||
SpWrap(test.pcLocal).mozInsertAudioLevelForContributingSource(
|
||||
localReceiver,
|
||||
offset, // Using offset for SSRC for convenience
|
||||
timestamp3 - offset,
|
||||
true,
|
||||
offset);
|
||||
}
|
||||
const sources = localReceiver.getContributingSources();
|
||||
const sourceOffsets = sources.map(s => s.source);
|
||||
is(JSON.stringify(sourceOffsets),
|
||||
JSON.stringify([...testOffsets].sort((a, b) => a - b)),
|
||||
`Contributing sources are sorted in descending order by timestamp:`
|
||||
+ ` ${JSON.stringify(sources)}`);
|
||||
};
|
||||
|
||||
var test;
|
||||
|
Loading…
Reference in New Issue
Block a user