2 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef WebRTCStatsRequest_h
32 #define WebRTCStatsRequest_h
34 #include "WebCommon.h"
35 #include "WebPrivatePtr.h"
36 #include "WebString.h"
39 class RTCStatsRequest;
44 class WebMediaStreamTrack;
46 class WebRTCStatsResponse;
48 // The WebRTCStatsRequest class represents a JavaScript call on
49 // RTCPeerConnection.getStats(). The user of this API will use
50 // the calls on this class and WebRTCStatsResponse to fill in the
51 // data that will be returned via a callback to the user in an
52 // RTCStatsResponse structure.
54 // The typical usage pattern is:
55 // WebRTCStatsRequest request = <from somewhere>
56 // WebRTCStatsResponse response = request.createResponse();
58 // For each item on which statistics are going to be reported:
59 // size_t reportIndex = response.addReport();
60 // Add local information:
61 // size_t elementIndex = response.addElement(reportIndex, true, dateNow());
62 // For each statistic being reported on:
63 // response.addStatistic(reportIndex, true, elementIndex,
64 // "name of statistic", "statistic value");
65 // Remote information (typically RTCP-derived) is added in the same way.
66 // When finished adding information:
67 // request.requestSucceeded(response);
69 class WebRTCStatsRequest {
71 WebRTCStatsRequest() { }
72 WebRTCStatsRequest(const WebRTCStatsRequest& other) { assign(other); }
73 ~WebRTCStatsRequest() { reset(); }
75 WebRTCStatsRequest& operator=(const WebRTCStatsRequest& other)
81 BLINK_PLATFORM_EXPORT void assign(const WebRTCStatsRequest&);
83 BLINK_PLATFORM_EXPORT void reset();
85 // This function returns true if a selector argument was given to getStats.
86 BLINK_PLATFORM_EXPORT bool hasSelector() const;
88 // The stream() and component() accessors give the two pieces of information
89 // required to look up a MediaStreamTrack implementation.
90 // It is only useful to call them when hasSelector() returns true.
91 BLINK_PLATFORM_EXPORT const WebMediaStream stream() const;
93 BLINK_PLATFORM_EXPORT const WebMediaStreamTrack component() const;
95 BLINK_PLATFORM_EXPORT void requestSucceeded(const WebRTCStatsResponse&) const;
97 BLINK_PLATFORM_EXPORT WebRTCStatsResponse createResponse() const;
100 BLINK_PLATFORM_EXPORT WebRTCStatsRequest(const WTF::PassRefPtr<WebCore::RTCStatsRequest>&);
104 WebPrivatePtr<WebCore::RTCStatsRequest> m_private;
109 #endif // WebRTCStatsRequest_h