OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_PEERCONNECTION_TRACKER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_PEERCONNECTION_TRACKER_H_ |
6 #define CONTENT_RENDERER_MEDIA_PEERCONNECTION_TRACKER_H_ | 6 #define CONTENT_RENDERER_MEDIA_PEERCONNECTION_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "content/public/renderer/render_process_observer.h" | 11 #include "content/public/renderer/render_process_observer.h" |
12 #include "third_party/WebKit/public/platform/WebMediaStream.h" | 12 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
13 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandlerClient.h
" | 13 #include "third_party/WebKit/public/platform/WebRTCPeerConnectionHandlerClient.h
" |
14 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" | 14 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" |
15 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" | 15 #include "third_party/libjingle/source/talk/app/webrtc/peerconnectioninterface.h
" |
16 | 16 |
17 namespace WebKit { | 17 namespace blink { |
18 class WebFrame; | 18 class WebFrame; |
19 class WebRTCICECandidate; | 19 class WebRTCICECandidate; |
20 class WebString; | 20 class WebString; |
21 class WebRTCSessionDescription; | 21 class WebRTCSessionDescription; |
22 } // namespace WebKit | 22 } // namespace blink |
23 | 23 |
24 namespace webrtc { | 24 namespace webrtc { |
25 class DataChannelInterface; | 25 class DataChannelInterface; |
26 } // namespace webrtc | 26 } // namespace webrtc |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 class RTCMediaConstraints; | 29 class RTCMediaConstraints; |
30 class RTCPeerConnectionHandler; | 30 class RTCPeerConnectionHandler; |
31 | 31 |
32 // This class collects data about each peer connection, | 32 // This class collects data about each peer connection, |
(...skipping 30 matching lines...) Expand all Loading... |
63 // This should be called once and only once for each PeerConnection. | 63 // This should be called once and only once for each PeerConnection. |
64 // The |pc_handler| is the handler object associated with the PeerConnection, | 64 // The |pc_handler| is the handler object associated with the PeerConnection, |
65 // the |servers| are the server configurations used to establish the | 65 // the |servers| are the server configurations used to establish the |
66 // connection, the |constraints| are the media constraints used to initialize | 66 // connection, the |constraints| are the media constraints used to initialize |
67 // the PeerConnection, the |frame| is the WebFrame object representing the | 67 // the PeerConnection, the |frame| is the WebFrame object representing the |
68 // page in which the PeerConnection is created. | 68 // page in which the PeerConnection is created. |
69 void RegisterPeerConnection( | 69 void RegisterPeerConnection( |
70 RTCPeerConnectionHandler* pc_handler, | 70 RTCPeerConnectionHandler* pc_handler, |
71 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, | 71 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, |
72 const RTCMediaConstraints& constraints, | 72 const RTCMediaConstraints& constraints, |
73 const WebKit::WebFrame* frame); | 73 const blink::WebFrame* frame); |
74 | 74 |
75 // Sends an update when a PeerConnection has been destroyed. | 75 // Sends an update when a PeerConnection has been destroyed. |
76 virtual void UnregisterPeerConnection(RTCPeerConnectionHandler* pc_handler); | 76 virtual void UnregisterPeerConnection(RTCPeerConnectionHandler* pc_handler); |
77 | 77 |
78 // Sends an update when createOffer/createAnswer has been called. | 78 // Sends an update when createOffer/createAnswer has been called. |
79 // The |pc_handler| is the handler object associated with the PeerConnection, | 79 // The |pc_handler| is the handler object associated with the PeerConnection, |
80 // the |constraints| is the media constraints used to create the offer/answer. | 80 // the |constraints| is the media constraints used to create the offer/answer. |
81 virtual void TrackCreateOffer(RTCPeerConnectionHandler* pc_handler, | 81 virtual void TrackCreateOffer(RTCPeerConnectionHandler* pc_handler, |
82 const RTCMediaConstraints& constraints); | 82 const RTCMediaConstraints& constraints); |
83 virtual void TrackCreateAnswer(RTCPeerConnectionHandler* pc_handler, | 83 virtual void TrackCreateAnswer(RTCPeerConnectionHandler* pc_handler, |
84 const RTCMediaConstraints& constraints); | 84 const RTCMediaConstraints& constraints); |
85 | 85 |
86 // Sends an update when setLocalDescription or setRemoteDescription is called. | 86 // Sends an update when setLocalDescription or setRemoteDescription is called. |
87 virtual void TrackSetSessionDescription( | 87 virtual void TrackSetSessionDescription( |
88 RTCPeerConnectionHandler* pc_handler, | 88 RTCPeerConnectionHandler* pc_handler, |
89 const WebKit::WebRTCSessionDescription& desc, Source source); | 89 const blink::WebRTCSessionDescription& desc, Source source); |
90 | 90 |
91 // Sends an update when Ice candidates are updated. | 91 // Sends an update when Ice candidates are updated. |
92 virtual void TrackUpdateIce( | 92 virtual void TrackUpdateIce( |
93 RTCPeerConnectionHandler* pc_handler, | 93 RTCPeerConnectionHandler* pc_handler, |
94 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, | 94 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, |
95 const RTCMediaConstraints& options); | 95 const RTCMediaConstraints& options); |
96 | 96 |
97 // Sends an update when an Ice candidate is added. | 97 // Sends an update when an Ice candidate is added. |
98 virtual void TrackAddIceCandidate( | 98 virtual void TrackAddIceCandidate( |
99 RTCPeerConnectionHandler* pc_handler, | 99 RTCPeerConnectionHandler* pc_handler, |
100 const WebKit::WebRTCICECandidate& candidate, Source source); | 100 const blink::WebRTCICECandidate& candidate, Source source); |
101 | 101 |
102 // Sends an update when a media stream is added. | 102 // Sends an update when a media stream is added. |
103 virtual void TrackAddStream( | 103 virtual void TrackAddStream( |
104 RTCPeerConnectionHandler* pc_handler, | 104 RTCPeerConnectionHandler* pc_handler, |
105 const WebKit::WebMediaStream& stream, Source source); | 105 const blink::WebMediaStream& stream, Source source); |
106 | 106 |
107 // Sends an update when a media stream is removed. | 107 // Sends an update when a media stream is removed. |
108 virtual void TrackRemoveStream( | 108 virtual void TrackRemoveStream( |
109 RTCPeerConnectionHandler* pc_handler, | 109 RTCPeerConnectionHandler* pc_handler, |
110 const WebKit::WebMediaStream& stream, Source source); | 110 const blink::WebMediaStream& stream, Source source); |
111 | 111 |
112 // Sends an update when a DataChannel is created. | 112 // Sends an update when a DataChannel is created. |
113 virtual void TrackCreateDataChannel( | 113 virtual void TrackCreateDataChannel( |
114 RTCPeerConnectionHandler* pc_handler, | 114 RTCPeerConnectionHandler* pc_handler, |
115 const webrtc::DataChannelInterface* data_channel, Source source); | 115 const webrtc::DataChannelInterface* data_channel, Source source); |
116 | 116 |
117 // Sends an update when a PeerConnection has been stopped. | 117 // Sends an update when a PeerConnection has been stopped. |
118 virtual void TrackStop(RTCPeerConnectionHandler* pc_handler); | 118 virtual void TrackStop(RTCPeerConnectionHandler* pc_handler); |
119 | 119 |
120 // Sends an update when the signaling state of a PeerConnection has changed. | 120 // Sends an update when the signaling state of a PeerConnection has changed. |
121 virtual void TrackSignalingStateChange( | 121 virtual void TrackSignalingStateChange( |
122 RTCPeerConnectionHandler* pc_handler, | 122 RTCPeerConnectionHandler* pc_handler, |
123 WebKit::WebRTCPeerConnectionHandlerClient::SignalingState state); | 123 blink::WebRTCPeerConnectionHandlerClient::SignalingState state); |
124 | 124 |
125 // Sends an update when the Ice connection state | 125 // Sends an update when the Ice connection state |
126 // of a PeerConnection has changed. | 126 // of a PeerConnection has changed. |
127 virtual void TrackIceConnectionStateChange( | 127 virtual void TrackIceConnectionStateChange( |
128 RTCPeerConnectionHandler* pc_handler, | 128 RTCPeerConnectionHandler* pc_handler, |
129 WebKit::WebRTCPeerConnectionHandlerClient::ICEConnectionState state); | 129 blink::WebRTCPeerConnectionHandlerClient::ICEConnectionState state); |
130 | 130 |
131 // Sends an update when the Ice gathering state | 131 // Sends an update when the Ice gathering state |
132 // of a PeerConnection has changed. | 132 // of a PeerConnection has changed. |
133 virtual void TrackIceGatheringStateChange( | 133 virtual void TrackIceGatheringStateChange( |
134 RTCPeerConnectionHandler* pc_handler, | 134 RTCPeerConnectionHandler* pc_handler, |
135 WebKit::WebRTCPeerConnectionHandlerClient::ICEGatheringState state); | 135 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state); |
136 | 136 |
137 // Sends an update when the SetSessionDescription or CreateOffer or | 137 // Sends an update when the SetSessionDescription or CreateOffer or |
138 // CreateAnswer callbacks are called. | 138 // CreateAnswer callbacks are called. |
139 virtual void TrackSessionDescriptionCallback( | 139 virtual void TrackSessionDescriptionCallback( |
140 RTCPeerConnectionHandler* pc_handler, Action action, | 140 RTCPeerConnectionHandler* pc_handler, Action action, |
141 const std::string& type, const std::string& value); | 141 const std::string& type, const std::string& value); |
142 | 142 |
143 // Sends an update when onRenegotiationNeeded is called. | 143 // Sends an update when onRenegotiationNeeded is called. |
144 virtual void TrackOnRenegotiationNeeded(RTCPeerConnectionHandler* pc_handler); | 144 virtual void TrackOnRenegotiationNeeded(RTCPeerConnectionHandler* pc_handler); |
145 | 145 |
146 // Sends an update when a DTMFSender is created. | 146 // Sends an update when a DTMFSender is created. |
147 virtual void TrackCreateDTMFSender( | 147 virtual void TrackCreateDTMFSender( |
148 RTCPeerConnectionHandler* pc_handler, | 148 RTCPeerConnectionHandler* pc_handler, |
149 const WebKit::WebMediaStreamTrack& track); | 149 const blink::WebMediaStreamTrack& track); |
150 | 150 |
151 private: | 151 private: |
152 // Assign a local ID to a peer connection so that the browser process can | 152 // Assign a local ID to a peer connection so that the browser process can |
153 // uniquely identify a peer connection in the renderer process. | 153 // uniquely identify a peer connection in the renderer process. |
154 int GetNextLocalID(); | 154 int GetNextLocalID(); |
155 | 155 |
156 // IPC Message handler for getting all stats. | 156 // IPC Message handler for getting all stats. |
157 void OnGetAllStats(); | 157 void OnGetAllStats(); |
158 | 158 |
159 void SendPeerConnectionUpdate(RTCPeerConnectionHandler* pc_handler, | 159 void SendPeerConnectionUpdate(RTCPeerConnectionHandler* pc_handler, |
160 const std::string& callback_type, | 160 const std::string& callback_type, |
161 const std::string& value); | 161 const std::string& value); |
162 | 162 |
163 // This map stores the local ID assigned to each RTCPeerConnectionHandler. | 163 // This map stores the local ID assigned to each RTCPeerConnectionHandler. |
164 typedef std::map<RTCPeerConnectionHandler*, int> PeerConnectionIdMap; | 164 typedef std::map<RTCPeerConnectionHandler*, int> PeerConnectionIdMap; |
165 PeerConnectionIdMap peer_connection_id_map_; | 165 PeerConnectionIdMap peer_connection_id_map_; |
166 | 166 |
167 // This keeps track of the next available local ID. | 167 // This keeps track of the next available local ID. |
168 int next_lid_; | 168 int next_lid_; |
169 | 169 |
170 DISALLOW_COPY_AND_ASSIGN(PeerConnectionTracker); | 170 DISALLOW_COPY_AND_ASSIGN(PeerConnectionTracker); |
171 }; | 171 }; |
172 | 172 |
173 } // namespace content | 173 } // namespace content |
174 | 174 |
175 #endif // CONTENT_RENDERER_MEDIA_PEERCONNECTION_TRACKER_H_ | 175 #endif // CONTENT_RENDERER_MEDIA_PEERCONNECTION_TRACKER_H_ |
OLD | NEW |