Skip to content
Permalink
Browse files
Add data passing to the GetStats interface of RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=98003

Patch by Harald Alvestrand <hta@google.com> on 2012-10-03
Reviewed by Adam Barth.

Source/Platform:

* Platform.gypi:
* chromium/public/WebRTCStatsRequest.h:
(WebKit):
(WebRTCStatsRequest):
* chromium/public/WebRTCStatsResponse.h: Added.
(WebCore):
(WebKit):
(WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::~WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::operator=):

Source/WebCore:

Added an RTCStatsResponseBase interface to platform, and let the
RTCStatsRequestImpl class produce an implementation of it that's returned
to WebCore.

Tested by extension of the RTCPeerConnection-stats.html test.

* Modules/mediastream/RTCStatsElement.cpp:
(WebCore::RTCStatsElement::addStatistic):
(WebCore):
* Modules/mediastream/RTCStatsElement.h:
(RTCStatsElement):
* Modules/mediastream/RTCStatsReport.cpp:
(WebCore):
(WebCore::RTCStatsReport::addElement):
(WebCore::RTCStatsReport::addStatistic):
* Modules/mediastream/RTCStatsReport.h:
(RTCStatsReport):
* Modules/mediastream/RTCStatsRequestImpl.cpp:
(WebCore::RTCStatsRequestImpl::createResponse):
(WebCore):
(WebCore::RTCStatsRequestImpl::requestSucceeded):
* Modules/mediastream/RTCStatsRequestImpl.h:
(RTCStatsRequestImpl):
* Modules/mediastream/RTCStatsResponse.cpp:
(WebCore::RTCStatsResponse::create):
(WebCore::RTCStatsResponse::addReport):
(WebCore):
(WebCore::RTCStatsResponse::addElement):
(WebCore::RTCStatsResponse::addStatistic):
* Modules/mediastream/RTCStatsResponse.h:
(RTCStatsResponse):
* WebCore.gypi:
* platform/chromium/support/WebRTCStatsRequest.cpp:
(WebKit::WebRTCStatsRequest::response):
(WebKit):
(WebKit::WebRTCStatsRequest::requestSucceeded):
* platform/chromium/support/WebRTCStatsResponse.cpp: Added.
(WebKit):
(WebKit::WebRTCStatsResponse::WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::assign):
(WebKit::WebRTCStatsResponse::reset):
(WebKit::WebRTCStatsResponse::operator WTF::PassRefPtr<WebCore::RTCStatsResponseBase>):
(WebKit::WebRTCStatsResponse::addReport):
(WebKit::WebRTCStatsResponse::addElement):
(WebKit::WebRTCStatsResponse::addStatistic):
* platform/mediastream/RTCStatsRequest.h:
(WebCore):
(RTCStatsRequest):
* platform/mediastream/RTCStatsResponseBase.h: Added.
(WebCore):
(RTCStatsResponseBase):
(WebCore::RTCStatsResponseBase::~RTCStatsResponseBase):

Tools:

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

LayoutTests:

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

Canonical link: https://commits.webkit.org/116257@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130260 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alvestrand authored and webkit-commit-queue committed Oct 3, 2012
1 parent d355be1 commit d3ee7a732c69ab53d2969e2780a7b95ef91f8cc3
@@ -1,3 +1,13 @@
2012-10-03 Harald Alvestrand <hta@google.com>

Add data passing to the GetStats interface of RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=98003

Reviewed by Adam Barth.

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

2012-10-02 Arko Saha <arko@motorola.com>

Microdata: itemprop names must not override builtin properties.
@@ -4,10 +4,17 @@ 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 pc.getStats(statsHandler1) did not throw exception.
PASS statsHandler1 was called
PASS status is non-null.
PASS result.length is 0
PASS getUserMedia({audio:true, video:true}, gotStream) did not throw exception.
PASS Got a stream.
PASS pc.getStats(statsHandler2) did not throw exception.
PASS statsHandler2 was called
PASS result.length is >= 2
PASS local.length is 1
PASS local[0].stat("type") is "audio"
PASS successfullyParsed is true

TEST COMPLETE
@@ -8,18 +8,53 @@
description("Tests the RTCPeerConnection stats interface.");

var pc = null;
var result;
var local;

function statsHandler(status)
function getUserMedia(dictionary, callback) {
try {
navigator.webkitGetUserMedia(dictionary, callback, error);
} catch (e) {
testFailed('webkitGetUserMedia threw exception :' + e);
finishJSTest();
}
}

function error() {
testFailed('Stream generation failed.');
finishJSTest();
}

function statsHandler1(status)
{
testPassed("statsHandler was called");
testPassed("statsHandler1 was called");
shouldBeNonNull('status');
result = status.result();
shouldBe('result.length', '0');
shouldNotThrow('getUserMedia({audio:true, video:true}, gotStream)');
}

function gotStream(s) {
testPassed('Got a stream.');
stream = s;

pc.addStream(stream);
shouldNotThrow('pc.getStats(statsHandler2)');
}

function statsHandler2(status)
{
testPassed("statsHandler2 was called");
result = status.result();
shouldBeGreaterThanOrEqual('result.length', '2');
local = result[0].local();
shouldBe('local.length', '1');
shouldBe('local[0].stat("type")', '"audio"');
finishJSTest();
}

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

window.jsTestIsAsync = true;
window.successfullyParsed = true;
@@ -1,3 +1,22 @@
2012-10-03 Harald Alvestrand <hta@google.com>

Add data passing to the GetStats interface of RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=98003

Reviewed by Adam Barth.

* Platform.gypi:
* chromium/public/WebRTCStatsRequest.h:
(WebKit):
(WebRTCStatsRequest):
* chromium/public/WebRTCStatsResponse.h: Added.
(WebCore):
(WebKit):
(WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::~WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::operator=):

2012-10-02 Terry Anderson <tdanderson@chromium.org>

[chromium] Add field to WebRenderingStats to track if we have impl-thread scrolled
@@ -112,6 +112,8 @@
'chromium/public/WebRTCPeerConnectionHandlerClient.h',
'chromium/public/WebRTCSessionDescription.h',
'chromium/public/WebRTCSessionDescriptionRequest.h',
'chromium/public/WebRTCStatsRequest.h',
'chromium/public/WebRTCStatsResponse.h',
'chromium/public/WebRTCVoidRequest.h',
'chromium/public/WebRect.h',
'chromium/public/WebReferrerPolicy.h',
@@ -41,6 +41,29 @@ class RTCStatsRequest;

namespace WebKit {

class WebRTCStatsResponse;

// The WebRTCStatsRequest class represents a JavaScript call on
// RTCPeerConnection.getStats(). The user of this API will use
// the calls on this class and WebRTCStatsResponse to fill in the
// data that will be returned via a callback to the user in an
// RTCStatsResponse structure.
//
// The typical usage pattern is:
// WebRTCStatsRequest request = <from somewhere>
// WebRTCStatsResponse response = request.createResponse();
//
// For each item on which statistics are going to be reported:
// size_t reportIndex = response.addReport();
// Add local information:
// size_t elementIndex = response.addElement(reportIndex, true, dateNow());
// For each statistic being reported on:
// response.addStatistic(reportIndex, true, elementIndex,
// "name of statistic", "statistic value");
// Remote information (typically RTCP-derived) is added in the same way.
// When finished adding information:
// request.requestSucceeded(response);

class WebRTCStatsRequest {
public:
WebRTCStatsRequest() { }
@@ -57,7 +80,9 @@ class WebRTCStatsRequest {

WEBKIT_EXPORT void reset();

WEBKIT_EXPORT void requestSucceeded() const;
WEBKIT_EXPORT void requestSucceeded(const WebRTCStatsResponse&) const;

WEBKIT_EXPORT WebRTCStatsResponse createResponse() const;

#if WEBKIT_IMPLEMENTATION
WebRTCStatsRequest(const WTF::PassRefPtr<WebCore::RTCStatsRequest>&);
@@ -0,0 +1,70 @@
/*
* 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 WebRTCStatsResponse_h
#define WebRTCStatsResponse_h

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

namespace WebCore {
class RTCStatsResponseBase;
}

namespace WebKit {

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

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

WEBKIT_EXPORT void assign(const WebRTCStatsResponse&);

WEBKIT_EXPORT void reset();

WEBKIT_EXPORT size_t addReport();
WEBKIT_EXPORT size_t addElement(size_t report, bool isLocal, long timestamp);
WEBKIT_EXPORT void addStatistic(size_t report, bool isLocal, size_t element, WebString name, WebString value);

#if WEBKIT_IMPLEMENTATION
WebRTCStatsResponse(const WTF::PassRefPtr<WebCore::RTCStatsResponseBase>&);

operator WTF::PassRefPtr<WebCore::RTCStatsResponseBase>() const;
#endif

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

} // namespace WebKit

#endif // WebRTCStatsResponse_h
@@ -1,3 +1,63 @@
2012-10-03 Harald Alvestrand <hta@google.com>

Add data passing to the GetStats interface of RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=98003

Reviewed by Adam Barth.

Added an RTCStatsResponseBase interface to platform, and let the
RTCStatsRequestImpl class produce an implementation of it that's returned
to WebCore.

Tested by extension of the RTCPeerConnection-stats.html test.

* Modules/mediastream/RTCStatsElement.cpp:
(WebCore::RTCStatsElement::addStatistic):
(WebCore):
* Modules/mediastream/RTCStatsElement.h:
(RTCStatsElement):
* Modules/mediastream/RTCStatsReport.cpp:
(WebCore):
(WebCore::RTCStatsReport::addElement):
(WebCore::RTCStatsReport::addStatistic):
* Modules/mediastream/RTCStatsReport.h:
(RTCStatsReport):
* Modules/mediastream/RTCStatsRequestImpl.cpp:
(WebCore::RTCStatsRequestImpl::createResponse):
(WebCore):
(WebCore::RTCStatsRequestImpl::requestSucceeded):
* Modules/mediastream/RTCStatsRequestImpl.h:
(RTCStatsRequestImpl):
* Modules/mediastream/RTCStatsResponse.cpp:
(WebCore::RTCStatsResponse::create):
(WebCore::RTCStatsResponse::addReport):
(WebCore):
(WebCore::RTCStatsResponse::addElement):
(WebCore::RTCStatsResponse::addStatistic):
* Modules/mediastream/RTCStatsResponse.h:
(RTCStatsResponse):
* WebCore.gypi:
* platform/chromium/support/WebRTCStatsRequest.cpp:
(WebKit::WebRTCStatsRequest::response):
(WebKit):
(WebKit::WebRTCStatsRequest::requestSucceeded):
* platform/chromium/support/WebRTCStatsResponse.cpp: Added.
(WebKit):
(WebKit::WebRTCStatsResponse::WebRTCStatsResponse):
(WebKit::WebRTCStatsResponse::assign):
(WebKit::WebRTCStatsResponse::reset):
(WebKit::WebRTCStatsResponse::operator WTF::PassRefPtr<WebCore::RTCStatsResponseBase>):
(WebKit::WebRTCStatsResponse::addReport):
(WebKit::WebRTCStatsResponse::addElement):
(WebKit::WebRTCStatsResponse::addStatistic):
* platform/mediastream/RTCStatsRequest.h:
(WebCore):
(RTCStatsRequest):
* platform/mediastream/RTCStatsResponseBase.h: Added.
(WebCore):
(RTCStatsResponseBase):
(WebCore::RTCStatsResponseBase::~RTCStatsResponseBase):

2012-10-02 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Add API to get the web view that initiated a custom URI request to WebKit2 GTK+
@@ -47,6 +47,11 @@ String RTCStatsElement::stat(const String& name) const
return m_stats.get(name);
}

void RTCStatsElement::addStatistic(const String& name, const String& value)
{
m_stats.add(name, value);
}

} // namespace WebCore

#endif // ENABLE(MEDIA_STREAM)
@@ -37,6 +37,7 @@ class RTCStatsElement : public RefCounted<RTCStatsElement> {
static PassRefPtr<RTCStatsElement> create(long timestamp);
long timestamp() const { return m_timestamp; }
String stat(const String& name) const;
void addStatistic(const String& name, const String& value);

private:
explicit RTCStatsElement(long timestamp);
@@ -39,6 +39,27 @@ RTCStatsReport::RTCStatsReport()
{
}

size_t RTCStatsReport::addElement(bool isLocal, long timestamp)
{
if (isLocal) {
m_local.append(RTCStatsElement::create(timestamp));
return m_local.size() - 1;
}
m_remote.append(RTCStatsElement::create(timestamp));
return m_remote.size() - 1;
}

void RTCStatsReport::addStatistic(bool isLocal, size_t element, String name, String value)
{
if (isLocal) {
ASSERT(element >= 0 && element < m_local.size());
m_local[element]->addStatistic(name, value);
} else {
ASSERT(element >= 0 && element < m_remote.size());
m_remote[element]->addStatistic(name, value);
}
}

} // namespace WebCore

#endif // ENABLE(MEDIA_STREAM)
@@ -40,6 +40,9 @@ class RTCStatsReport : public RefCounted<RTCStatsReport> {
const Vector<RefPtr<RTCStatsElement> >& local() const { return m_local; }
const Vector<RefPtr<RTCStatsElement> >& remote() const { return m_remote; }

size_t addElement(bool isLocal, long timestamp);
void addStatistic(bool isLocal, size_t element, String name, String value);

private:
RTCStatsReport();

@@ -51,13 +51,16 @@ RTCStatsRequestImpl::~RTCStatsRequestImpl()
{
}

void RTCStatsRequestImpl::requestSucceeded()
PassRefPtr<RTCStatsResponseBase> RTCStatsRequestImpl::createResponse()
{
return RTCStatsResponse::create();
}

void RTCStatsRequestImpl::requestSucceeded(PassRefPtr<RTCStatsResponseBase> response)
{
if (!m_successCallback)
return;
// FIXME: Fill in content of stats parameter.
RefPtr<RTCStatsResponse> stats = RTCStatsResponse::create();
m_successCallback->handleEvent(stats.get());
m_successCallback->handleEvent(static_cast<RTCStatsResponse*>(response.get()));
clear();
}

@@ -29,6 +29,7 @@

#include "ActiveDOMObject.h"
#include "RTCStatsRequest.h"
#include "RTCStatsResponse.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/WTFString.h>
@@ -42,7 +43,8 @@ class RTCStatsRequestImpl : public RTCStatsRequest, public ActiveDOMObject {
static PassRefPtr<RTCStatsRequestImpl> create(ScriptExecutionContext*, PassRefPtr<RTCStatsCallback>);
virtual ~RTCStatsRequestImpl();

virtual void requestSucceeded();
virtual PassRefPtr<RTCStatsResponseBase> createResponse();
virtual void requestSucceeded(PassRefPtr<RTCStatsResponseBase>);

// ActiveDOMObject
virtual void stop() OVERRIDE;

0 comments on commit d3ee7a7

Please sign in to comment.