Bug 1624967 - Display entire SDP history about:webrtc;r=dminor,webidl,smaug,flod

Differential Revision: https://phabricator.services.mozilla.com/D78866
This commit is contained in:
Nico Grunbaum 2020-06-10 13:51:41 +00:00
Родитель 87986ab67c
Коммит 5442b2eb88
6 изменённых файлов: 59 добавлений и 5 удалений

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

@ -87,6 +87,9 @@ struct ParamTraits<
}
};
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::dom::RTCSdpHistoryEntryInternal,
mTimestamp, mIsLocal, mSdp);
DEFINE_IPC_SERIALIZER_WITH_FIELDS(
mozilla::dom::RTCStatsCollection, mIceCandidatePairStats,
mIceCandidateStats, mInboundRtpStreamStats, mOutboundRtpStreamStats,
@ -97,8 +100,8 @@ DEFINE_IPC_SERIALIZER_WITH_FIELDS(
DEFINE_IPC_SERIALIZER_WITH_SUPER_CLASS_AND_FIELDS(
mozilla::dom::RTCStatsReportInternal, mozilla::dom::RTCStatsCollection,
mClosed, mLocalSdp, mPcid, mRemoteSdp, mTimestamp, mCallDurationMs,
mIceRestarts, mIceRollbacks, mOfferer);
mClosed, mLocalSdp, mSdpHistory, mPcid, mRemoteSdp, mTimestamp,
mCallDurationMs, mIceRestarts, mIceRollbacks, mOfferer);
typedef mozilla::dom::RTCStats RTCStats;

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

@ -173,6 +173,13 @@ dictionary RTCVideoFrameHistoryInternal {
sequence<RTCVideoFrameHistoryEntryInternal> entries = [];
};
// This is for tracking the flow of SDP for about:webrtc
dictionary RTCSdpHistoryEntryInternal {
required DOMHighResTimeStamp timestamp;
required boolean isLocal;
required DOMString sdp;
};
// This is intended to be a list of dictionaries that inherit from RTCStats
// (with some raw ICE candidates thrown in). Unfortunately, we cannot simply
// store a sequence<RTCStats> because of slicing. So, we have to have a
@ -198,6 +205,7 @@ dictionary RTCStatsReportInternal : RTCStatsCollection {
required DOMString pcid;
DOMString localSdp;
DOMString remoteSdp;
sequence<RTCSdpHistoryEntryInternal> sdpHistory = [];
required DOMHighResTimeStamp timestamp;
double callDurationMs;
required unsigned long iceRestarts;

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

@ -1311,6 +1311,14 @@ PeerConnectionImpl::SetLocalDescription(int32_t aAction, const char* aSDP) {
mPrivacyRequested = Some(true);
}
mozilla::dom::RTCSdpHistoryEntryInternal sdpEntry;
sdpEntry.mIsLocal = true;
sdpEntry.mTimestamp = mTimestampMaker.GetNow();
sdpEntry.mSdp = NS_ConvertASCIItoUTF16(aSDP);
if (!mSdpHistory.AppendElement(sdpEntry, fallible)) {
mozalloc_handle_oom(0);
}
mLocalRequestedSDP = aSDP;
bool wasRestartingIce = mJsepSession->IsIceRestarting();
@ -1394,6 +1402,14 @@ PeerConnectionImpl::SetRemoteDescription(int32_t action, const char* aSDP) {
STAMP_TIMECARD(mTimeCard, "Set Remote Description");
mozilla::dom::RTCSdpHistoryEntryInternal sdpEntry;
sdpEntry.mIsLocal = false;
sdpEntry.mTimestamp = mTimestampMaker.GetNow();
sdpEntry.mSdp = NS_ConvertASCIItoUTF16(aSDP);
if (!mSdpHistory.AppendElement(sdpEntry, fallible)) {
mozalloc_handle_oom(0);
}
mRemoteRequestedSDP = aSDP;
bool wasRestartingIce = mJsepSession->IsIceRestarting();
JsepSdpType sdpType;
@ -2803,6 +2819,9 @@ RefPtr<dom::RTCStatsReportPromise> PeerConnectionImpl::GetStats(
NS_ConvertASCIItoUTF16(localDescription.c_str()));
report->mRemoteSdp.Construct(
NS_ConvertASCIItoUTF16(remoteDescription.c_str()));
if (!report->mSdpHistory.AppendElements(mSdpHistory, fallible)) {
mozalloc_handle_oom(0);
}
if (mJsepSession->IsPendingOfferer().isSome()) {
report->mOfferer.Construct(*mJsepSession->IsPendingOfferer());
} else if (mJsepSession->IsCurrentOfferer().isSome()) {

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

@ -528,7 +528,8 @@ class PeerConnectionImpl final
// The SDP sent in from JS
std::string mLocalRequestedSDP;
std::string mRemoteRequestedSDP;
// Only accessed from main
mozilla::dom::Sequence<mozilla::dom::RTCSdpHistoryEntryInternal> mSdpHistory;
std::string mPendingLocalDescription;
std::string mPendingRemoteDescription;
std::string mCurrentLocalDescription;

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

@ -505,6 +505,25 @@ SDPStats.prototype = {
div.appendChild(renderElement("h5", remoteSdpHeading));
div.appendChild(renderElement("pre", this._report.remoteSdp));
div.appendChild(renderElement("h4", getString("sdp_history_heading")));
for (let history of this._report.sdpHistory) {
const historyElem = renderElement("div", null, {
className: "sdp-history",
});
const sdpSide = history.isLocal
? getString("local_sdp_heading")
: getString("remote_sdp_heading");
historyElem.appendChild(
renderElement(
"h5",
formatString("sdp_set_at_timestamp", [sdpSide, history.timestamp])
)
);
const historyDiv = new FoldableSection(historyElem).render();
historyDiv.appendChild(renderElement("pre", history.sdp));
historyElem.appendChild(historyDiv);
div.appendChild(historyElem);
}
return div;
},
};

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

@ -42,13 +42,17 @@ aec_logging_off_state_msg = captured log files can be found in: %1$S
# should not normally be translated and is used as a data label.
peer_connection_id_label = PeerConnection ID
# LOCALIZATION NOTE (sdp_heading, local_sdp_heading, remote_sdp_heading):
# LOCALIZATION NOTE (sdp_heading, local_sdp_heading, remote_sdp_heading, sdp_history_heading):
# "SDP" is an abbreviation for Session Description Protocol, an IETF standard.
# See http://wikipedia.org/wiki/Session_Description_Protocol
sdp_heading = SDP
local_sdp_heading = Local SDP
remote_sdp_heading = Remote SDP
sdp_history_heading = SDP History
# LOCALIZATION NOTE (sdp_set_at_timestamp): the local or remote SDP and when it was set
# %1$S will be replaced by local_sdp_heading or remote sdp_heading and %2$S
# will be a numeric timestamp.
sdp_set_at_timestamp = Set %1$S at timestamp %2$S
# LOCALIZATION NOTE (offer, answer):
# offer and answer describe whether the local sdp is an offer or answer or
# the remote sdp is an offer or answer. These are appended to the local and