Bug 1339906 - pt 5 - add writable field to webidl for RTCIceCandidatePairStats and implement readable and writeable fields. r=drno, r=qDot
MozReview-Commit-ID: 6IODhX5mtnP
--- a/dom/media/webrtc/WebrtcGlobal.h
+++ b/dom/media/webrtc/WebrtcGlobal.h
@@ -202,16 +202,17 @@ struct ParamTraits<mozilla::dom::RTCIceC
typedef mozilla::dom::RTCIceCandidatePairStats paramType;
static void Write(Message* aMsg, const paramType& aParam)
{
WriteParam(aMsg, aParam.mTransportId);
WriteParam(aMsg, aParam.mLocalCandidateId);
WriteParam(aMsg, aParam.mPriority);
WriteParam(aMsg, aParam.mNominated);
+ WriteParam(aMsg, aParam.mWritable);
WriteParam(aMsg, aParam.mReadable);
WriteParam(aMsg, aParam.mRemoteCandidateId);
WriteParam(aMsg, aParam.mSelected);
WriteParam(aMsg, aParam.mState);
WriteParam(aMsg, aParam.mBytesSent);
WriteParam(aMsg, aParam.mBytesReceived);
WriteParam(aMsg, aParam.mLastPacketSentTimestamp);
WriteParam(aMsg, aParam.mLastPacketReceivedTimestamp);
@@ -219,16 +220,17 @@ struct ParamTraits<mozilla::dom::RTCIceC
}
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
{
if (!ReadParam(aMsg, aIter, &(aResult->mTransportId)) ||
!ReadParam(aMsg, aIter, &(aResult->mLocalCandidateId)) ||
!ReadParam(aMsg, aIter, &(aResult->mPriority)) ||
!ReadParam(aMsg, aIter, &(aResult->mNominated)) ||
+ !ReadParam(aMsg, aIter, &(aResult->mWritable)) ||
!ReadParam(aMsg, aIter, &(aResult->mReadable)) ||
!ReadParam(aMsg, aIter, &(aResult->mRemoteCandidateId)) ||
!ReadParam(aMsg, aIter, &(aResult->mSelected)) ||
!ReadParam(aMsg, aIter, &(aResult->mState)) ||
!ReadParam(aMsg, aIter, &(aResult->mBytesSent)) ||
!ReadParam(aMsg, aIter, &(aResult->mBytesReceived)) ||
!ReadParam(aMsg, aIter, &(aResult->mLastPacketSentTimestamp)) ||
!ReadParam(aMsg, aIter, &(aResult->mLastPacketReceivedTimestamp)) ||
--- a/dom/webidl/RTCStatsReport.webidl
+++ b/dom/webidl/RTCStatsReport.webidl
@@ -124,18 +124,19 @@ enum RTCStatsIceCandidatePairState {
};
dictionary RTCIceCandidatePairStats : RTCStats {
DOMString transportId;
DOMString localCandidateId;
DOMString remoteCandidateId;
RTCStatsIceCandidatePairState state;
unsigned long long priority;
+ boolean nominated;
+ boolean writable;
boolean readable;
- boolean nominated;
unsigned long long bytesSent;
unsigned long long bytesReceived;
DOMHighResTimeStamp lastPacketSentTimestamp;
DOMHighResTimeStamp lastPacketReceivedTimestamp;
boolean selected;
};
enum RTCStatsIceCandidateType {
--- a/media/mtransport/nricemediastream.cpp
+++ b/media/mtransport/nricemediastream.cpp
@@ -397,16 +397,23 @@ nsresult NrIceMediaStream::GetCandidateP
pair.state = NrIceCandidatePair::State::STATE_CANCELLED;
break;
default:
MOZ_ASSERT(0);
}
pair.priority = p1->priority;
pair.nominated = p1->peer_nominated || p1->nominated;
+ // As discussed with drno: a component's can_send field (set to true
+ // by ICE consent) is a very close approximation for writable and
+ // readable. Note: the component for the local candidate never has
+ // the can_send member set to true, remote for both readable and
+ // writable. (mjf)
+ pair.writable = p1->remote->component->can_send;
+ pair.readable = p1->remote->component->can_send;
pair.selected = p1->remote->component &&
p1->remote->component->active == p1;
pair.codeword = p1->codeword;
pair.bytes_sent = p1->bytes_sent;
pair.bytes_recvd = p1->bytes_recvd;
pair.ms_since_last_send = p1->last_sent.tv_sec*1000
+ p1->last_sent.tv_usec/1000;
pair.ms_since_last_recv = p1->last_recvd.tv_sec*1000
--- a/media/mtransport/nricemediastream.h
+++ b/media/mtransport/nricemediastream.h
@@ -110,16 +110,18 @@ struct NrIceCandidatePair {
State state;
uint64_t priority;
// Set regardless of who nominated it. Does not necessarily mean that it is
// ready to be selected (ie; nominated by peer, but our check has not
// succeeded yet.) Note: since this implementation uses aggressive nomination,
// when we are the controlling agent, this will always be set if the pair is
// in STATE_SUCCEEDED.
bool nominated;
+ bool writable;
+ bool readable;
// Set if this candidate pair has been selected. Note: Since we are using
// aggressive nomination, this could change frequently as ICE runs.
bool selected;
NrIceCandidate local;
NrIceCandidate remote;
// TODO(bcampen@mozilla.com): Is it important to put the foundation in here?
std::string codeword;
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -3588,16 +3588,18 @@ static void RecordIceStats_s(
RTCIceCandidatePairStats s;
s.mId.Construct(codeword);
s.mTransportId.Construct(transportId);
s.mTimestamp.Construct(now);
s.mType.Construct(RTCStatsType::Candidate_pair);
s.mLocalCandidateId.Construct(localCodeword);
s.mRemoteCandidateId.Construct(remoteCodeword);
s.mNominated.Construct(candPair.nominated);
+ s.mWritable.Construct(candPair.writable);
+ s.mReadable.Construct(candPair.readable);
s.mPriority.Construct(candPair.priority);
s.mSelected.Construct(candPair.selected);
s.mBytesSent.Construct(candPair.bytes_sent);
s.mBytesReceived.Construct(candPair.bytes_recvd);
s.mLastPacketSentTimestamp.Construct(candPair.ms_since_last_send);
s.mLastPacketReceivedTimestamp.Construct(candPair.ms_since_last_recv);
s.mState.Construct(RTCStatsIceCandidatePairState(candPair.state));
report->mIceCandidatePairStats.Value().AppendElement(s, fallible);