• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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
13  * distribution.
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.
17  *
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.
29  */
30 
31 #ifndef WebRTCStatsRequest_h
32 #define WebRTCStatsRequest_h
33 
34 #include "WebCommon.h"
35 #include "WebPrivatePtr.h"
36 #include "WebString.h"
37 
38 namespace WebCore {
39 class RTCStatsRequest;
40 }
41 
42 namespace blink {
43 
44 class WebMediaStreamTrack;
45 class WebMediaStream;
46 class WebRTCStatsResponse;
47 
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.
53 //
54 // The typical usage pattern is:
55 // WebRTCStatsRequest request = <from somewhere>
56 // WebRTCStatsResponse response = request.createResponse();
57 //
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);
68 
69 class WebRTCStatsRequest {
70 public:
WebRTCStatsRequest()71     WebRTCStatsRequest() { }
WebRTCStatsRequest(const WebRTCStatsRequest & other)72     WebRTCStatsRequest(const WebRTCStatsRequest& other) { assign(other); }
~WebRTCStatsRequest()73     ~WebRTCStatsRequest() { reset(); }
74 
75     WebRTCStatsRequest& operator=(const WebRTCStatsRequest& other)
76     {
77         assign(other);
78         return *this;
79     }
80 
81     BLINK_PLATFORM_EXPORT void assign(const WebRTCStatsRequest&);
82 
83     BLINK_PLATFORM_EXPORT void reset();
84 
85     // This function returns true if a selector argument was given to getStats.
86     BLINK_PLATFORM_EXPORT bool hasSelector() const;
87 
88     // The component() accessor give the information
89     // required to look up a MediaStreamTrack implementation.
90     // It is only useful to call it when hasSelector() returns true.
91     BLINK_PLATFORM_EXPORT const WebMediaStreamTrack component() const;
92 
93     BLINK_PLATFORM_EXPORT void requestSucceeded(const WebRTCStatsResponse&) const;
94 
95     BLINK_PLATFORM_EXPORT WebRTCStatsResponse createResponse() const;
96 
97 #if INSIDE_BLINK
98     BLINK_PLATFORM_EXPORT WebRTCStatsRequest(const WTF::PassRefPtr<WebCore::RTCStatsRequest>&);
99 #endif
100 
101 private:
102     WebPrivatePtr<WebCore::RTCStatsRequest> m_private;
103 };
104 
105 } // namespace blink
106 
107 #endif // WebRTCStatsRequest_h
108