Skip to content
Permalink
Browse files
Implement the GetStats interface on PeerConnection
https://bugs.webkit.org/show_bug.cgi?id=95193

Source/Platform:

Patch by Harald Tveit Alvestrand <harald@alvestrand.no> on 2012-09-26
Reviewed by Adam Barth.

* chromium/public/WebRTCPeerConnectionHandler.h:
(WebKit):
(WebRTCPeerConnectionHandler):
(WebKit::WebRTCPeerConnectionHandler::getStats):
* chromium/public/WebRTCStatsRequest.h: added.
(WebCore):
(WebKit):
(WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::~WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::operator=):

Source/WebCore:

Specification:
http://dev.w3.org/2011/webrtc/editor/webrtc-20120920.html

Patch by Harald Tveit Alvestrand <harald@alvestrand.no> on 2012-09-26
Reviewed by Adam Barth.

The implementation consists of a pure virtual platform object
(RTCStatsRequest) that is implemented in WebCore, and stores
its information in a straightforward data hierarchy.
This patch adds the call path and the storage structures.
It does not add filling in data.

Test: fast/mediastream/RTCPeerConnection-stats.html

* CMakeLists.txt:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::getStats):
(WebCore):
* Modules/mediastream/RTCPeerConnection.h:
(WebCore):
(RTCPeerConnection):
* Modules/mediastream/RTCPeerConnection.idl:
* Modules/mediastream/RTCStatsCallback.h: Added.
(WebCore):
(RTCStatsCallback):
(WebCore::RTCStatsCallback::~RTCStatsCallback):
* Modules/mediastream/RTCStatsCallback.idl: Added.
* Modules/mediastream/RTCStatsElement.cpp: Added.
(WebCore):
(WebCore::RTCStatsElement::create):
(WebCore::RTCStatsElement::RTCStatsElement):
(WebCore::RTCStatsElement::stat):
* Modules/mediastream/RTCStatsElement.h: Added.
(WebCore):
(RTCStatsElement):
* Modules/mediastream/RTCStatsElement.idl: Added.
* Modules/mediastream/RTCStatsReport.cpp: Added.
(WebCore):
(WebCore::RTCStatsReport::create):
(WebCore::RTCStatsReport::RTCStatsReport):
* Modules/mediastream/RTCStatsReport.h: Added.
(WebCore):
(RTCStatsReport):
(WebCore::RTCStatsReport::local):
(WebCore::RTCStatsReport::remote):
* Modules/mediastream/RTCStatsReport.idl: Added.
* Modules/mediastream/RTCStatsRequestImpl.cpp: Added.
(WebCore):
(WebCore::RTCStatsRequestImpl::create):
(WebCore::RTCStatsRequestImpl::RTCStatsRequestImpl):
(WebCore::RTCStatsRequestImpl::~RTCStatsRequestImpl):
(WebCore::RTCStatsRequestImpl::requestSucceeded):
(WebCore::RTCStatsRequestImpl::stop):
(WebCore::RTCStatsRequestImpl::clear):
* Modules/mediastream/RTCStatsRequestImpl.h: Added.
(WebCore):
(RTCStatsRequestImpl):
* Modules/mediastream/RTCStatsResponse.cpp: Added.
(WebCore):
(WebCore::RTCStatsResponse::create):
(WebCore::RTCStatsResponse::RTCStatsResponse):
* Modules/mediastream/RTCStatsResponse.h: Added.
(WebCore):
(RTCStatsResponse):
(WebCore::RTCStatsResponse::result):
* Modules/mediastream/RTCStatsResponse.idl: Added.
* WebCore.gypi:
* platform/chromium/support/WebRTCStatsRequest.cpp: Copied from Source/Platform/chromium/public/WebRTCPeerConnectionHandler.h.
(WebKit):
(WebKit::WebRTCStatsRequest::WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::assign):
(WebKit::WebRTCStatsRequest::reset):
(WebKit::WebRTCStatsRequest::requestSucceeded):
* platform/mediastream/RTCPeerConnectionHandler.h:
(WebCore):
(RTCPeerConnectionHandler):
* platform/mediastream/RTCStatsRequest.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.
(WebCore):
(RTCStatsRequest):
(WebCore::RTCStatsRequest::~RTCStatsRequest):
(WebCore::RTCStatsRequest::RTCStatsRequest):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
(WebCore::RTCPeerConnectionHandlerChromium::getStats):
(WebCore):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
(RTCPeerConnectionHandlerChromium):

Tools:

Patch by Harald Tveit Alvestrand <harald@alvestrand.no> on 2012-09-26
Reviewed by Adam Barth.

* DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.cpp:
(RTCStatsRequestSucceededTask):
(RTCStatsRequestSucceededTask::RTCStatsRequestSucceededTask):
(MockWebRTCPeerConnectionHandler::getStats):
* DumpRenderTree/chromium/MockWebRTCPeerConnectionHandler.h:
(MockWebRTCPeerConnectionHandler):

LayoutTests:

Patch by Harald Tveit Alvestrand <harald@alvestrand.no> on 2012-09-26
Reviewed by Adam Barth.

* fast/mediastream/RTCPeerConnection-stats-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-stats.html: Added.

Canonical link: https://commits.webkit.org/115670@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@129654 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alvestrand authored and webkit-commit-queue committed Sep 26, 2012
1 parent 529e347 commit 92db9031d0ae9771ca3ccf2f51d52298a41b8a23
Showing 35 changed files with 1,080 additions and 0 deletions.
@@ -1,3 +1,13 @@
2012-09-26 Harald Tveit Alvestrand <harald@alvestrand.no>

Implement the GetStats interface on PeerConnection
https://bugs.webkit.org/show_bug.cgi?id=95193

Reviewed by Adam Barth.

* fast/mediastream/RTCPeerConnection-stats-expected.txt: Added.
* fast/mediastream/RTCPeerConnection-stats.html: Added.

2012-09-26 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>

[WK2][WTR] Policy client: dumping from decidePolicyForResponse callback
@@ -0,0 +1,14 @@
Tests the RTCPeerConnection stats interface.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS pc = new webkitRTCPeerConnection(null) did not throw exception.
PASS pc.getStats(statsHandler) did not throw exception.
PASS statsHandler was called
PASS status is non-null.
PASS result.length is 0
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,29 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests the RTCPeerConnection stats interface.");

var pc = null;

function statsHandler(status)
{
testPassed("statsHandler was called");
shouldBeNonNull('status');
result = status.result();
shouldBe('result.length', '0');
finishJSTest();
}

shouldNotThrow('pc = new webkitRTCPeerConnection(null)');
shouldNotThrow('pc.getStats(statsHandler)');

window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
@@ -1,3 +1,22 @@
2012-09-26 Harald Tveit Alvestrand <harald@alvestrand.no>

Implement the GetStats interface on PeerConnection
https://bugs.webkit.org/show_bug.cgi?id=95193

Reviewed by Adam Barth.

* chromium/public/WebRTCPeerConnectionHandler.h:
(WebKit):
(WebRTCPeerConnectionHandler):
(WebKit::WebRTCPeerConnectionHandler::getStats):
* chromium/public/WebRTCStatsRequest.h: added.
(WebCore):
(WebKit):
(WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::~WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::operator=):

2012-09-25 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r129517.
@@ -39,6 +39,7 @@ class WebRTCICECandidate;
class WebRTCPeerConnectionHandlerClient;
class WebRTCSessionDescription;
class WebRTCSessionDescriptionRequest;
class WebRTCStatsRequest;
class WebRTCVoidRequest;

class WebRTCPeerConnectionHandler {
@@ -57,6 +58,8 @@ class WebRTCPeerConnectionHandler {
virtual bool addICECandidate(const WebRTCICECandidate&) = 0;
virtual bool addStream(const WebMediaStreamDescriptor&, const WebMediaConstraints&) = 0;
virtual void removeStream(const WebMediaStreamDescriptor&) = 0;
// FIXME: Remove default implementation when clients have changed.
virtual void getStats(const WebRTCStatsRequest&) { }
virtual void stop() = 0;
};

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef WebRTCStatsRequest_h
#define WebRTCStatsRequest_h

#include "WebCommon.h"
#include "WebPrivatePtr.h"
#include "WebString.h"

namespace WebCore {
class RTCStatsRequest;
}

namespace WebKit {

class WebRTCStatsRequest {
public:
WebRTCStatsRequest() { }
WebRTCStatsRequest(const WebRTCStatsRequest& other) { assign(other); }
~WebRTCStatsRequest() { reset(); }

WebRTCStatsRequest& operator=(const WebRTCStatsRequest& other)
{
assign(other);
return *this;
}

WEBKIT_EXPORT void assign(const WebRTCStatsRequest&);

WEBKIT_EXPORT void reset();

WEBKIT_EXPORT void requestSucceeded() const;

#if WEBKIT_IMPLEMENTATION
WebRTCStatsRequest(const WTF::PassRefPtr<WebCore::RTCStatsRequest>&);
#endif

private:
WebPrivatePtr<WebCore::RTCStatsRequest> m_private;
};

} // namespace WebKit

#endif // WebRTCStatsRequest_h
@@ -228,6 +228,10 @@ SET(WebCore_IDL_FILES
Modules/mediastream/RTCPeerConnection.idl
Modules/mediastream/RTCSessionDescription.idl
Modules/mediastream/RTCSessionDescriptionCallback.idl
Modules/mediastream/RTCStatsCallback.idl
Modules/mediastream/RTCStatsElement.idl
Modules/mediastream/RTCStatsReport.idl
Modules/mediastream/RTCStatsResponse.idl
Modules/mediastream/SessionDescription.idl

Modules/navigatorcontentutils/NavigatorContentUtils.idl
@@ -861,6 +865,10 @@ SET(WebCore_SOURCES
Modules/mediastream/RTCPeerConnection.cpp
Modules/mediastream/RTCSessionDescription.cpp
Modules/mediastream/RTCSessionDescriptionRequestImpl.cpp
Modules/mediastream/RTCStatsElement.cpp
Modules/mediastream/RTCStatsReport.cpp
Modules/mediastream/RTCStatsRequestImpl.cpp
Modules/mediastream/RTCStatsResponse.cpp
Modules/mediastream/RTCVoidRequestImpl.cpp
Modules/mediastream/SessionDescription.cpp
Modules/mediastream/UserMediaController.cpp
@@ -1,3 +1,94 @@
2012-09-26 Harald Tveit Alvestrand <harald@alvestrand.no>

Implement the GetStats interface on PeerConnection
https://bugs.webkit.org/show_bug.cgi?id=95193

Specification:
http://dev.w3.org/2011/webrtc/editor/webrtc-20120920.html

Reviewed by Adam Barth.

The implementation consists of a pure virtual platform object
(RTCStatsRequest) that is implemented in WebCore, and stores
its information in a straightforward data hierarchy.
This patch adds the call path and the storage structures.
It does not add filling in data.

Test: fast/mediastream/RTCPeerConnection-stats.html

* CMakeLists.txt:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::getStats):
(WebCore):
* Modules/mediastream/RTCPeerConnection.h:
(WebCore):
(RTCPeerConnection):
* Modules/mediastream/RTCPeerConnection.idl:
* Modules/mediastream/RTCStatsCallback.h: Added.
(WebCore):
(RTCStatsCallback):
(WebCore::RTCStatsCallback::~RTCStatsCallback):
* Modules/mediastream/RTCStatsCallback.idl: Added.
* Modules/mediastream/RTCStatsElement.cpp: Added.
(WebCore):
(WebCore::RTCStatsElement::create):
(WebCore::RTCStatsElement::RTCStatsElement):
(WebCore::RTCStatsElement::stat):
* Modules/mediastream/RTCStatsElement.h: Added.
(WebCore):
(RTCStatsElement):
* Modules/mediastream/RTCStatsElement.idl: Added.
* Modules/mediastream/RTCStatsReport.cpp: Added.
(WebCore):
(WebCore::RTCStatsReport::create):
(WebCore::RTCStatsReport::RTCStatsReport):
* Modules/mediastream/RTCStatsReport.h: Added.
(WebCore):
(RTCStatsReport):
(WebCore::RTCStatsReport::local):
(WebCore::RTCStatsReport::remote):
* Modules/mediastream/RTCStatsReport.idl: Added.
* Modules/mediastream/RTCStatsRequestImpl.cpp: Added.
(WebCore):
(WebCore::RTCStatsRequestImpl::create):
(WebCore::RTCStatsRequestImpl::RTCStatsRequestImpl):
(WebCore::RTCStatsRequestImpl::~RTCStatsRequestImpl):
(WebCore::RTCStatsRequestImpl::requestSucceeded):
(WebCore::RTCStatsRequestImpl::stop):
(WebCore::RTCStatsRequestImpl::clear):
* Modules/mediastream/RTCStatsRequestImpl.h: Added.
(WebCore):
(RTCStatsRequestImpl):
* Modules/mediastream/RTCStatsResponse.cpp: Added.
(WebCore):
(WebCore::RTCStatsResponse::create):
(WebCore::RTCStatsResponse::RTCStatsResponse):
* Modules/mediastream/RTCStatsResponse.h: Added.
(WebCore):
(RTCStatsResponse):
(WebCore::RTCStatsResponse::result):
* Modules/mediastream/RTCStatsResponse.idl: Added.
* WebCore.gypi:
* platform/chromium/support/WebRTCStatsRequest.cpp: Copied from Source/Platform/chromium/public/WebRTCPeerConnectionHandler.h.
(WebKit):
(WebKit::WebRTCStatsRequest::WebRTCStatsRequest):
(WebKit::WebRTCStatsRequest::assign):
(WebKit::WebRTCStatsRequest::reset):
(WebKit::WebRTCStatsRequest::requestSucceeded):
* platform/mediastream/RTCPeerConnectionHandler.h:
(WebCore):
(RTCPeerConnectionHandler):
* platform/mediastream/RTCStatsRequest.h: Copied from Source/WebCore/platform/mediastream/RTCPeerConnectionHandler.h.
(WebCore):
(RTCStatsRequest):
(WebCore::RTCStatsRequest::~RTCStatsRequest):
(WebCore::RTCStatsRequest::RTCStatsRequest):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
(WebCore::RTCPeerConnectionHandlerChromium::getStats):
(WebCore):
* platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
(RTCPeerConnectionHandlerChromium):

2012-09-26 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com>

[WK2][WTR] Policy client: dumping from decidePolicyForResponse callback
@@ -639,6 +639,14 @@ webcore_built_sources += \
DerivedSources/WebCore/JSRTCSessionDescription.h \
DerivedSources/WebCore/JSRTCSessionDescriptionCallback.cpp \
DerivedSources/WebCore/JSRTCSessionDescriptionCallback.h \
DerivedSources/WebCore/JSRTCStatsCallback.cpp \
DerivedSources/WebCore/JSRTCStatsCallback.h \
DerivedSources/WebCore/JSRTCStatsElement.cpp \
DerivedSources/WebCore/JSRTCStatsElement.h \
DerivedSources/WebCore/JSRTCStatsReport.cpp \
DerivedSources/WebCore/JSRTCStatsReport.h \
DerivedSources/WebCore/JSRTCStatsResponse.cpp \
DerivedSources/WebCore/JSRTCStatsResponse.h \
DerivedSources/WebCore/JSScreen.cpp \
DerivedSources/WebCore/JSScreen.h \
DerivedSources/WebCore/JSScriptProfile.cpp \
@@ -1236,6 +1244,10 @@ dom_binding_idls += \
$(WebCore)/Modules/mediastream/RTCPeerConnection.idl \
$(WebCore)/Modules/mediastream/RTCSessionDescription.idl \
$(WebCore)/Modules/mediastream/RTCSessionDescriptionCallback.idl \
$(WebCore)/Modules/mediastream/RTCStatsCallback.idl \
$(WebCore)/Modules/mediastream/RTCStatsElement.idl \
$(WebCore)/Modules/mediastream/RTCStatsReport.idl \
$(WebCore)/Modules/mediastream/RTCStatsResponse.idl \
$(WebCore)/Modules/mediastream/SessionDescription.idl \
$(WebCore)/Modules/navigatorcontentutils/NavigatorContentUtils.idl \
$(WebCore)/Modules/notifications/Notification.idl \
@@ -48,6 +48,8 @@
#include "RTCSessionDescriptionCallback.h"
#include "RTCSessionDescriptionDescriptor.h"
#include "RTCSessionDescriptionRequestImpl.h"
#include "RTCStatsCallback.h"
#include "RTCStatsRequestImpl.h"
#include "RTCVoidRequestImpl.h"
#include "ScriptExecutionContext.h"
#include "VoidCallback.h"
@@ -379,6 +381,13 @@ MediaStreamList* RTCPeerConnection::remoteStreams() const
return m_remoteStreams.get();
}

void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, PassRefPtr<MediaStreamTrack> selector)
{
RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(scriptExecutionContext(), successCallback);
// FIXME: Add passing selector as part of the statsRequest.
m_peerHandler->getStats(statsRequest.release());
}

void RTCPeerConnection::close(ExceptionCode& ec)
{
if (m_readyState == ReadyStateClosing || m_readyState == ReadyStateClosed) {
@@ -47,10 +47,12 @@
namespace WebCore {

class MediaConstraints;
class MediaStreamTrack;
class RTCConfiguration;
class RTCErrorCallback;
class RTCSessionDescription;
class RTCSessionDescriptionCallback;
class RTCStatsCallback;
class VoidCallback;

class RTCPeerConnection : public RefCounted<RTCPeerConnection>, public RTCPeerConnectionHandlerClient, public EventTarget, public ActiveDOMObject {
@@ -84,6 +86,8 @@ class RTCPeerConnection : public RefCounted<RTCPeerConnection>, public RTCPeerCo

void removeStream(MediaStream*, ExceptionCode&);

void getStats(PassRefPtr<RTCStatsCallback> successCallback, PassRefPtr<MediaStreamTrack> selector);

void close(ExceptionCode&);

DEFINE_ATTRIBUTE_EVENT_LISTENER(negotiationneeded);
@@ -72,6 +72,8 @@ module mediastream {
[StrictTypeChecking] void removeStream(in MediaStream stream)
raises(DOMException);

void getStats(in [Callback] RTCStatsCallback successCallback, in [Optional=DefaultIsUndefined] MediaStreamTrack selector);

void close()
raises(DOMException);

0 comments on commit 92db903

Please sign in to comment.