Bug 1419093 - P2 - update rtp source impl & unit tests r=mjf

Update the c++ side with the new WebIDL definitions, note that
many fields are now required. See P1 for more details.


MozReview-Commit-ID: FKHi86Nj7UO

--HG--
extra : rebase_source : 7491551b46a9fb0e8c8cba77861b01f90ea95644
This commit is contained in:
Nico Grunbaum 2017-12-18 19:24:01 -06:00
Родитель 2aa7b3a269
Коммит e30c99af1c
3 изменённых файлов: 28 добавлений и 14 удалений

Просмотреть файл

@ -265,14 +265,14 @@ public:
bool ssrcFound = false;
bool csrcFound = true;
for (auto& entry : outLevels) {
if (entry.mSource.Value() == ssrc) {
if (entry.mSource == ssrc) {
ssrcFound = true;
EXPECT_EQ(entry.mSourceType.Value(),
EXPECT_EQ(entry.mSourceType,
dom::RTCRtpSourceEntryType::Synchronization);
}
if (entry.mSource.Value() == csrc) {
if (entry.mSource == csrc) {
csrcFound = true;
EXPECT_EQ(entry.mSourceType.Value(),
EXPECT_EQ(entry.mSourceType,
dom::RTCRtpSourceEntryType::Contributing);
}
}
@ -305,19 +305,19 @@ public:
bool csrc0Found = true;
bool csrc1Found = true;
for (auto& entry : outLevels) {
if (entry.mSource.Value() == ssrc) {
if (entry.mSource == ssrc) {
ssrcFound = true;
EXPECT_EQ(entry.mSourceType.Value(),
EXPECT_EQ(entry.mSourceType,
dom::RTCRtpSourceEntryType::Synchronization);
}
if (entry.mSource.Value() == csrc0) {
if (entry.mSource == csrc0) {
csrc0Found = true;
EXPECT_EQ(entry.mSourceType.Value(),
EXPECT_EQ(entry.mSourceType,
dom::RTCRtpSourceEntryType::Contributing);
}
if (entry.mSource.Value() == csrc1) {
if (entry.mSource == csrc1) {
csrc1Found = true;
EXPECT_EQ(entry.mSourceType.Value(),
EXPECT_EQ(entry.mSourceType,
dom::RTCRtpSourceEntryType::Contributing);
}
}

Просмотреть файл

@ -7,6 +7,17 @@ namespace mozilla {
using EntryType = dom::RTCRtpSourceEntryType;
double
RtpSourceObserver::RtpSourceEntry::ToLinearAudioLevel() const
{
// Spec indicates that a value of 127 should be set to 0
if (audioLevel == 127) {
return 0;
}
// All other values are calculated as 10^(-rfc_level/20)
return std::pow(10, -static_cast<double>(audioLevel) / 20);
}
RtpSourceObserver::RtpSourceObserver() :
mLevelGuard("RtpSourceObserver::mLevelGuard") {}
@ -51,11 +62,11 @@ RtpSourceObserver::GetRtpSources(const int64_t aTimeNow,
const RtpSourceEntry* entry = it.second.FindClosestNotAfter(aTimeNow);
if (entry) {
dom::RTCRtpSourceEntry domEntry;
domEntry.mSource.Construct(GetSourceFromKey(it.first));
domEntry.mSourceType.Construct(GetTypeFromKey(it.first));
domEntry.mTimestamp.Construct(entry->jitterAdjustedTimestamp);
domEntry.mSource = GetSourceFromKey(it.first);
domEntry.mSourceType = GetTypeFromKey(it.first);
domEntry.mTimestamp = entry->jitterAdjustedTimestamp;
if (entry->hasAudioLevel) {
domEntry.mAudioLevel.Construct(entry->audioLevel);
domEntry.mAudioLevel.Construct(entry->ToLinearAudioLevel());
}
outSources.AppendElement(std::move(domEntry));
}

Просмотреть файл

@ -62,6 +62,9 @@ private:
hasAudioLevel = aHasAudioLevel && !(aAudioLevel & 0x80);
audioLevel = aAudioLevel;
}
// Sets the audio level nullable according to the linear scale
// outlined in the webrtc-pc spec.
double ToLinearAudioLevel() const;
// Time this information was received + jitter
int64_t jitterAdjustedTimestamp = 0;
bool hasAudioLevel = false;