зеркало из https://github.com/mozilla/gecko-dev.git
Bug 906990 - Part 7: Populate candidate pairs in RTCStatsReport. r=jib
This commit is contained in:
Родитель
16d187a8a7
Коммит
5d64fba8c5
|
@ -1077,6 +1077,7 @@ PeerConnectionObserver.prototype = {
|
||||||
appendStats(dict.mediaStreamStats, report);
|
appendStats(dict.mediaStreamStats, report);
|
||||||
appendStats(dict.transportStats, report);
|
appendStats(dict.transportStats, report);
|
||||||
appendStats(dict.iceComponentStats, report);
|
appendStats(dict.iceComponentStats, report);
|
||||||
|
appendStats(dict.iceCandidatePairStats, report);
|
||||||
appendStats(dict.iceCandidateStats, report);
|
appendStats(dict.iceCandidateStats, report);
|
||||||
appendStats(dict.codecStats, report);
|
appendStats(dict.codecStats, report);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,13 @@
|
||||||
|
|
||||||
enum RTCStatsType {
|
enum RTCStatsType {
|
||||||
"inboundrtp",
|
"inboundrtp",
|
||||||
"outboundrtp"
|
"outboundrtp",
|
||||||
|
"session",
|
||||||
|
"track",
|
||||||
|
"transport",
|
||||||
|
"candidatepair",
|
||||||
|
"localcandidate",
|
||||||
|
"remotecandidate"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary RTCStats {
|
dictionary RTCStats {
|
||||||
|
@ -70,6 +76,26 @@ dictionary RTCIceComponentStats : RTCStats {
|
||||||
boolean activeConnection;
|
boolean activeConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum RTCStatsIceCandidatePairState {
|
||||||
|
"frozen",
|
||||||
|
"waiting",
|
||||||
|
"inprogress",
|
||||||
|
"failed",
|
||||||
|
"succeeded",
|
||||||
|
"cancelled"
|
||||||
|
};
|
||||||
|
|
||||||
|
dictionary RTCIceCandidatePairStats : RTCStats {
|
||||||
|
DOMString componentId;
|
||||||
|
DOMString localCandidateId;
|
||||||
|
DOMString remoteCandidateId;
|
||||||
|
RTCStatsIceCandidatePairState state;
|
||||||
|
unsigned long long mozPriority;
|
||||||
|
boolean readable;
|
||||||
|
boolean nominated;
|
||||||
|
boolean selected;
|
||||||
|
};
|
||||||
|
|
||||||
enum RTCStatsIceCandidateType {
|
enum RTCStatsIceCandidateType {
|
||||||
"host",
|
"host",
|
||||||
"serverreflexive",
|
"serverreflexive",
|
||||||
|
@ -105,6 +131,7 @@ dictionary RTCStatsReportInternal {
|
||||||
sequence<RTCMediaStreamStats> mediaStreamStats;
|
sequence<RTCMediaStreamStats> mediaStreamStats;
|
||||||
sequence<RTCTransportStats> transportStats;
|
sequence<RTCTransportStats> transportStats;
|
||||||
sequence<RTCIceComponentStats> iceComponentStats;
|
sequence<RTCIceComponentStats> iceComponentStats;
|
||||||
|
sequence<RTCIceCandidatePairStats> iceCandidatePairStats;
|
||||||
sequence<RTCIceCandidateStats> iceCandidateStats;
|
sequence<RTCIceCandidateStats> iceCandidateStats;
|
||||||
sequence<RTCCodecStats> codecStats;
|
sequence<RTCCodecStats> codecStats;
|
||||||
};
|
};
|
||||||
|
|
|
@ -506,7 +506,7 @@ PeerConnectionImpl::CreateRemoteSourceStreamInfo(nsRefPtr<RemoteSourceStreamInfo
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<mozilla::SourceMediaStream*>(stream->GetStream())->SetPullEnabled(true);
|
static_cast<SourceMediaStream*>(stream->GetStream())->SetPullEnabled(true);
|
||||||
|
|
||||||
nsRefPtr<RemoteSourceStreamInfo> remote;
|
nsRefPtr<RemoteSourceStreamInfo> remote;
|
||||||
remote = new RemoteSourceStreamInfo(stream.forget(), mMedia);
|
remote = new RemoteSourceStreamInfo(stream.forget(), mMedia);
|
||||||
|
@ -756,7 +756,7 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::RefPtr<DtlsIdentity> const
|
RefPtr<DtlsIdentity> const
|
||||||
PeerConnectionImpl::GetIdentity() {
|
PeerConnectionImpl::GetIdentity() {
|
||||||
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
||||||
return mIdentity;
|
return mIdentity;
|
||||||
|
@ -822,7 +822,7 @@ PeerConnectionImpl::EnsureDataConnection(uint16_t aNumstreams)
|
||||||
// and we increase the number of streams dynamically as needed.
|
// and we increase the number of streams dynamically as needed.
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
mDataConnection = new mozilla::DataChannelConnection(this);
|
mDataConnection = new DataChannelConnection(this);
|
||||||
if (!mDataConnection->Init(5000, aNumstreams, true)) {
|
if (!mDataConnection->Init(5000, aNumstreams, true)) {
|
||||||
CSFLogError(logTag,"%s DataConnection Init Failed",__FUNCTION__);
|
CSFLogError(logTag,"%s DataConnection Init Failed",__FUNCTION__);
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -897,9 +897,9 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
|
||||||
MOZ_ASSERT(aRetval);
|
MOZ_ASSERT(aRetval);
|
||||||
|
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
nsRefPtr<mozilla::DataChannel> dataChannel;
|
nsRefPtr<DataChannel> dataChannel;
|
||||||
mozilla::DataChannelConnection::Type theType =
|
DataChannelConnection::Type theType =
|
||||||
static_cast<mozilla::DataChannelConnection::Type>(aType);
|
static_cast<DataChannelConnection::Type>(aType);
|
||||||
|
|
||||||
nsresult rv = EnsureDataConnection(WEBRTC_DATACHANNEL_STREAMS_DEFAULT);
|
nsresult rv = EnsureDataConnection(WEBRTC_DATACHANNEL_STREAMS_DEFAULT);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -908,8 +908,8 @@ PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
|
||||||
dataChannel = mDataConnection->Open(
|
dataChannel = mDataConnection->Open(
|
||||||
NS_ConvertUTF16toUTF8(aLabel), NS_ConvertUTF16toUTF8(aProtocol), theType,
|
NS_ConvertUTF16toUTF8(aLabel), NS_ConvertUTF16toUTF8(aProtocol), theType,
|
||||||
!outOfOrderAllowed,
|
!outOfOrderAllowed,
|
||||||
aType == mozilla::DataChannelConnection::PARTIAL_RELIABLE_REXMIT ? aMaxNum :
|
aType == DataChannelConnection::PARTIAL_RELIABLE_REXMIT ? aMaxNum :
|
||||||
(aType == mozilla::DataChannelConnection::PARTIAL_RELIABLE_TIMED ? aMaxTime : 0),
|
(aType == DataChannelConnection::PARTIAL_RELIABLE_TIMED ? aMaxTime : 0),
|
||||||
nullptr, nullptr, aExternalNegotiated, aStream
|
nullptr, nullptr, aExternalNegotiated, aStream
|
||||||
);
|
);
|
||||||
NS_ENSURE_TRUE(dataChannel,NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(dataChannel,NS_ERROR_FAILURE);
|
||||||
|
@ -987,7 +987,7 @@ static void NotifyDataChannel_m(nsRefPtr<nsIDOMDataChannel> aChannel,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
PeerConnectionImpl::NotifyDataChannel(already_AddRefed<mozilla::DataChannel> aChannel)
|
PeerConnectionImpl::NotifyDataChannel(already_AddRefed<DataChannel> aChannel)
|
||||||
{
|
{
|
||||||
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
||||||
MOZ_ASSERT(aChannel.get());
|
MOZ_ASSERT(aChannel.get());
|
||||||
|
@ -1110,7 +1110,7 @@ PeerConnectionImpl::GetTimeSinceEpoch(DOMHighResTimeStamp *result) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PeerConnectionImpl::GetStats(mozilla::dom::MediaStreamTrack *aSelector) {
|
PeerConnectionImpl::GetStats(MediaStreamTrack *aSelector) {
|
||||||
PC_AUTO_ENTER_API_CALL(true);
|
PC_AUTO_ENTER_API_CALL(true);
|
||||||
|
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
|
@ -1118,7 +1118,6 @@ PeerConnectionImpl::GetStats(mozilla::dom::MediaStreamTrack *aSelector) {
|
||||||
DOMHighResTimeStamp now;
|
DOMHighResTimeStamp now;
|
||||||
nsresult rv = GetTimeSinceEpoch(&now);
|
nsresult rv = GetTimeSinceEpoch(&now);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsRefPtr<PeerConnectionImpl> pc(this);
|
nsRefPtr<PeerConnectionImpl> pc(this);
|
||||||
RUN_ON_THREAD(mSTSThread,
|
RUN_ON_THREAD(mSTSThread,
|
||||||
WrapRunnable(pc,
|
WrapRunnable(pc,
|
||||||
|
@ -1399,7 +1398,7 @@ PeerConnectionImpl::ShutdownMedia()
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
// End of call to be recorded in Telemetry
|
// End of call to be recorded in Telemetry
|
||||||
if (!mStartTime.IsNull()){
|
if (!mStartTime.IsNull()){
|
||||||
mozilla::TimeDuration timeDelta = mozilla::TimeStamp::Now() - mStartTime;
|
TimeDuration timeDelta = TimeStamp::Now() - mStartTime;
|
||||||
Telemetry::Accumulate(Telemetry::WEBRTC_CALL_DURATION, timeDelta.ToSeconds());
|
Telemetry::Accumulate(Telemetry::WEBRTC_CALL_DURATION, timeDelta.ToSeconds());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1633,6 +1632,65 @@ void PeerConnectionImpl::GetStats_s(
|
||||||
if (!report) {
|
if (!report) {
|
||||||
result = NS_ERROR_FAILURE;
|
result = NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (mMedia) {
|
||||||
|
RefPtr<NrIceMediaStream> mediaStream(
|
||||||
|
mMedia->ice_media_stream(trackId));
|
||||||
|
if (mediaStream) {
|
||||||
|
std::vector<NrIceCandidatePair> candPairs;
|
||||||
|
mediaStream->GetCandidatePairs(&candPairs);
|
||||||
|
report->mIceCandidatePairStats.Construct();
|
||||||
|
report->mIceCandidateStats.Construct();
|
||||||
|
NS_ConvertASCIItoUTF16 componentId(mediaStream->name().c_str());
|
||||||
|
for (auto p = candPairs.begin(); p != candPairs.end(); ++p) {
|
||||||
|
RTCIceCandidatePairStats s;
|
||||||
|
NS_ConvertASCIItoUTF16 codeword(p->codeword.c_str());
|
||||||
|
const nsString localCodeword(
|
||||||
|
NS_ConvertASCIItoUTF16("local_") + codeword);
|
||||||
|
const nsString remoteCodeword(
|
||||||
|
NS_ConvertASCIItoUTF16("remote_") + codeword);
|
||||||
|
s.mId.Construct(codeword);
|
||||||
|
s.mComponentId.Construct(componentId);
|
||||||
|
s.mTimestamp.Construct(now);
|
||||||
|
s.mType.Construct(RTCStatsType::Candidatepair);
|
||||||
|
|
||||||
|
// Not quite right; we end up with duplicate candidates. Will fix.
|
||||||
|
s.mLocalCandidateId.Construct(localCodeword);
|
||||||
|
s.mRemoteCandidateId.Construct(remoteCodeword);
|
||||||
|
s.mNominated.Construct(p->nominated);
|
||||||
|
s.mMozPriority.Construct(p->priority);
|
||||||
|
s.mSelected.Construct(p->selected);
|
||||||
|
s.mState.Construct(RTCStatsIceCandidatePairState(p->state));
|
||||||
|
report->mIceCandidatePairStats.Value().AppendElement(s);
|
||||||
|
|
||||||
|
{
|
||||||
|
RTCIceCandidateStats local;
|
||||||
|
local.mId.Construct(s.mLocalCandidateId.Value());
|
||||||
|
local.mTimestamp.Construct(now);
|
||||||
|
local.mType.Construct(RTCStatsType::Localcandidate);
|
||||||
|
local.mCandidateType.Construct(
|
||||||
|
RTCStatsIceCandidateType(p->local.type));
|
||||||
|
local.mIpAddress.Construct(
|
||||||
|
NS_ConvertASCIItoUTF16(p->local.host.c_str()));
|
||||||
|
local.mPortNumber.Construct(p->local.port);
|
||||||
|
report->mIceCandidateStats.Value().AppendElement(local);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
RTCIceCandidateStats remote;
|
||||||
|
remote.mId.Construct(s.mRemoteCandidateId.Value());
|
||||||
|
remote.mTimestamp.Construct(now);
|
||||||
|
remote.mType.Construct(RTCStatsType::Remotecandidate);
|
||||||
|
remote.mCandidateType.Construct(
|
||||||
|
RTCStatsIceCandidateType(p->remote.type));
|
||||||
|
remote.mIpAddress.Construct(
|
||||||
|
NS_ConvertASCIItoUTF16(p->remote.host.c_str()));
|
||||||
|
remote.mPortNumber.Construct(p->remote.port);
|
||||||
|
report->mIceCandidateStats.Value().AppendElement(remote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nsRefPtr<PeerConnectionImpl> pc(this);
|
nsRefPtr<PeerConnectionImpl> pc(this);
|
||||||
RUN_ON_THREAD(mThread,
|
RUN_ON_THREAD(mThread,
|
||||||
WrapRunnable(pc,
|
WrapRunnable(pc,
|
||||||
|
@ -1646,7 +1704,7 @@ void PeerConnectionImpl::GetStats_s(
|
||||||
void PeerConnectionImpl::OnStatsReport_m(
|
void PeerConnectionImpl::OnStatsReport_m(
|
||||||
uint32_t trackId,
|
uint32_t trackId,
|
||||||
nsresult result,
|
nsresult result,
|
||||||
nsAutoPtr<mozilla::dom::RTCStatsReportInternal> report) {
|
nsAutoPtr<RTCStatsReportInternal> report) {
|
||||||
PeerConnectionObserver* pco = mPCObserver.MayGet();
|
PeerConnectionObserver* pco = mPCObserver.MayGet();
|
||||||
if (pco) {
|
if (pco) {
|
||||||
JSErrorResult rv;
|
JSErrorResult rv;
|
||||||
|
@ -1696,7 +1754,7 @@ PeerConnectionImpl::GetSdpParseErrors() {
|
||||||
void
|
void
|
||||||
PeerConnectionImpl::startCallTelem() {
|
PeerConnectionImpl::startCallTelem() {
|
||||||
// Start time for calls
|
// Start time for calls
|
||||||
mStartTime = mozilla::TimeStamp::Now();
|
mStartTime = TimeStamp::Now();
|
||||||
|
|
||||||
// Increment session call counter
|
// Increment session call counter
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
|
@ -1709,7 +1767,7 @@ PeerConnectionImpl::startCallTelem() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PeerConnectionImpl::GetLocalStreams(nsTArray<nsRefPtr<mozilla::DOMMediaStream > >& result)
|
PeerConnectionImpl::GetLocalStreams(nsTArray<nsRefPtr<DOMMediaStream > >& result)
|
||||||
{
|
{
|
||||||
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
|
@ -1725,7 +1783,7 @@ PeerConnectionImpl::GetLocalStreams(nsTArray<nsRefPtr<mozilla::DOMMediaStream >
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
PeerConnectionImpl::GetRemoteStreams(nsTArray<nsRefPtr<mozilla::DOMMediaStream > >& result)
|
PeerConnectionImpl::GetRemoteStreams(nsTArray<nsRefPtr<DOMMediaStream > >& result)
|
||||||
{
|
{
|
||||||
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
PC_AUTO_ENTER_API_CALL_NO_CHECK();
|
||||||
#ifdef MOZILLA_INTERNAL_API
|
#ifdef MOZILLA_INTERNAL_API
|
||||||
|
|
Загрузка…
Ссылка в новой задаче