OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "bindings/core/v8/ScriptState.h" | 39 #include "bindings/core/v8/ScriptState.h" |
40 #include "bindings/core/v8/ScriptValue.h" | 40 #include "bindings/core/v8/ScriptValue.h" |
41 #include "bindings/core/v8/V8ThrowException.h" | 41 #include "bindings/core/v8/V8ThrowException.h" |
42 #include "bindings/modules/v8/RTCIceCandidateInitOrRTCIceCandidate.h" | 42 #include "bindings/modules/v8/RTCIceCandidateInitOrRTCIceCandidate.h" |
43 #include "bindings/modules/v8/V8RTCCertificate.h" | 43 #include "bindings/modules/v8/V8RTCCertificate.h" |
44 #include "core/dom/DOMException.h" | 44 #include "core/dom/DOMException.h" |
45 #include "core/dom/DOMTimeStamp.h" | 45 #include "core/dom/DOMTimeStamp.h" |
46 #include "core/dom/Document.h" | 46 #include "core/dom/Document.h" |
47 #include "core/dom/ExceptionCode.h" | 47 #include "core/dom/ExceptionCode.h" |
48 #include "core/dom/ExecutionContext.h" | 48 #include "core/dom/ExecutionContext.h" |
| 49 #include "core/frame/HostsUsingFeatures.h" |
49 #include "core/frame/LocalFrame.h" | 50 #include "core/frame/LocalFrame.h" |
50 #include "core/frame/UseCounter.h" | 51 #include "core/frame/UseCounter.h" |
51 #include "core/html/VoidCallback.h" | 52 #include "core/html/VoidCallback.h" |
52 #include "core/loader/FrameLoader.h" | 53 #include "core/loader/FrameLoader.h" |
53 #include "core/loader/FrameLoaderClient.h" | 54 #include "core/loader/FrameLoaderClient.h" |
54 #include "modules/crypto/CryptoResultImpl.h" | 55 #include "modules/crypto/CryptoResultImpl.h" |
55 #include "modules/mediastream/MediaConstraintsImpl.h" | 56 #include "modules/mediastream/MediaConstraintsImpl.h" |
56 #include "modules/mediastream/MediaStreamEvent.h" | 57 #include "modules/mediastream/MediaStreamEvent.h" |
57 #include "modules/peerconnection/RTCAnswerOptions.h" | 58 #include "modules/peerconnection/RTCAnswerOptions.h" |
58 #include "modules/peerconnection/RTCDTMFSender.h" | 59 #include "modules/peerconnection/RTCDTMFSender.h" |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 init.protocol = protocolString; | 978 init.protocol = protocolString; |
978 | 979 |
979 RTCDataChannel* channel = RTCDataChannel::create(getExecutionContext(), m_pe
erHandler.get(), label, init, exceptionState); | 980 RTCDataChannel* channel = RTCDataChannel::create(getExecutionContext(), m_pe
erHandler.get(), label, init, exceptionState); |
980 if (exceptionState.hadException()) | 981 if (exceptionState.hadException()) |
981 return nullptr; | 982 return nullptr; |
982 RTCDataChannel::ReadyState handlerState = channel->getHandlerState(); | 983 RTCDataChannel::ReadyState handlerState = channel->getHandlerState(); |
983 if (handlerState != RTCDataChannel::ReadyStateConnecting) { | 984 if (handlerState != RTCDataChannel::ReadyStateConnecting) { |
984 // There was an early state transition. Don't miss it! | 985 // There was an early state transition. Don't miss it! |
985 channel->didChangeReadyState(handlerState); | 986 channel->didChangeReadyState(handlerState); |
986 } | 987 } |
| 988 m_hasDataChannels = true; |
| 989 |
987 return channel; | 990 return channel; |
988 } | 991 } |
989 | 992 |
990 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) | 993 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) |
991 { | 994 { |
992 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo
calStreams.end(); ++iter) { | 995 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo
calStreams.end(); ++iter) { |
993 if ((*iter)->getTrackById(trackId)) | 996 if ((*iter)->getTrackById(trackId)) |
994 return true; | 997 return true; |
995 } | 998 } |
996 return false; | 999 return false; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 void RTCPeerConnection::didAddRemoteDataChannel(WebRTCDataChannelHandler* handle
r) | 1102 void RTCPeerConnection::didAddRemoteDataChannel(WebRTCDataChannelHandler* handle
r) |
1100 { | 1103 { |
1101 DCHECK(!m_closed); | 1104 DCHECK(!m_closed); |
1102 DCHECK(getExecutionContext()->isContextThread()); | 1105 DCHECK(getExecutionContext()->isContextThread()); |
1103 | 1106 |
1104 if (m_signalingState == SignalingStateClosed) | 1107 if (m_signalingState == SignalingStateClosed) |
1105 return; | 1108 return; |
1106 | 1109 |
1107 RTCDataChannel* channel = RTCDataChannel::create(getExecutionContext(), wrap
Unique(handler)); | 1110 RTCDataChannel* channel = RTCDataChannel::create(getExecutionContext(), wrap
Unique(handler)); |
1108 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne
l, false, false, channel)); | 1111 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne
l, false, false, channel)); |
| 1112 m_hasDataChannels = true; |
1109 } | 1113 } |
1110 | 1114 |
1111 void RTCPeerConnection::releasePeerConnectionHandler() | 1115 void RTCPeerConnection::releasePeerConnectionHandler() |
1112 { | 1116 { |
1113 stop(); | 1117 stop(); |
1114 } | 1118 } |
1115 | 1119 |
1116 void RTCPeerConnection::closePeerConnection() | 1120 void RTCPeerConnection::closePeerConnection() |
1117 { | 1121 { |
1118 DCHECK(m_signalingState != RTCPeerConnection::SignalingStateClosed); | 1122 DCHECK(m_signalingState != RTCPeerConnection::SignalingStateClosed); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 | 1167 |
1164 void RTCPeerConnection::changeIceGatheringState(ICEGatheringState iceGatheringSt
ate) | 1168 void RTCPeerConnection::changeIceGatheringState(ICEGatheringState iceGatheringSt
ate) |
1165 { | 1169 { |
1166 m_iceGatheringState = iceGatheringState; | 1170 m_iceGatheringState = iceGatheringState; |
1167 } | 1171 } |
1168 | 1172 |
1169 bool RTCPeerConnection::setIceConnectionState(ICEConnectionState iceConnectionSt
ate) | 1173 bool RTCPeerConnection::setIceConnectionState(ICEConnectionState iceConnectionSt
ate) |
1170 { | 1174 { |
1171 if (m_iceConnectionState != ICEConnectionStateClosed && m_iceConnectionState
!= iceConnectionState) { | 1175 if (m_iceConnectionState != ICEConnectionStateClosed && m_iceConnectionState
!= iceConnectionState) { |
1172 m_iceConnectionState = iceConnectionState; | 1176 m_iceConnectionState = iceConnectionState; |
| 1177 if (m_iceConnectionState == ICEConnectionStateConnected) |
| 1178 recordRapporMetrics(); |
| 1179 |
1173 return true; | 1180 return true; |
1174 } | 1181 } |
1175 return false; | 1182 return false; |
1176 } | 1183 } |
1177 | 1184 |
1178 void RTCPeerConnection::changeIceConnectionState(ICEConnectionState iceConnectio
nState) | 1185 void RTCPeerConnection::changeIceConnectionState(ICEConnectionState iceConnectio
nState) |
1179 { | 1186 { |
1180 if (m_iceConnectionState != ICEConnectionStateClosed) { | 1187 if (m_iceConnectionState != ICEConnectionStateClosed) { |
1181 scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatech
ange), | 1188 scheduleDispatchEvent(Event::create(EventTypeNames::iceconnectionstatech
ange), |
1182 WTF::bind(&RTCPeerConnection::setIceConnectionState, wrapPersistent(
this), iceConnectionState)); | 1189 WTF::bind(&RTCPeerConnection::setIceConnectionState, wrapPersistent(
this), iceConnectionState)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 HeapVector<Member<EventWrapper>>::iterator it = events.begin(); | 1225 HeapVector<Member<EventWrapper>>::iterator it = events.begin(); |
1219 for (; it != events.end(); ++it) { | 1226 for (; it != events.end(); ++it) { |
1220 if ((*it)->setup()) { | 1227 if ((*it)->setup()) { |
1221 dispatchEvent((*it)->m_event.release()); | 1228 dispatchEvent((*it)->m_event.release()); |
1222 } | 1229 } |
1223 } | 1230 } |
1224 | 1231 |
1225 events.clear(); | 1232 events.clear(); |
1226 } | 1233 } |
1227 | 1234 |
| 1235 void RTCPeerConnection::recordRapporMetrics() |
| 1236 { |
| 1237 Document* document = toDocument(getExecutionContext()); |
| 1238 for (const auto& stream : m_localStreams) { |
| 1239 if (stream->getAudioTracks().size() > 0) |
| 1240 HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Fea
ture::RTCPeerConnectionAudio); |
| 1241 if (stream->getVideoTracks().size() > 0) |
| 1242 HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Fea
ture::RTCPeerConnectionVideo); |
| 1243 } |
| 1244 |
| 1245 for (const auto& stream : m_remoteStreams) { |
| 1246 if (stream->getAudioTracks().size() > 0) |
| 1247 HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Fea
ture::RTCPeerConnectionAudio); |
| 1248 if (stream->getVideoTracks().size() > 0) |
| 1249 HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Fea
ture::RTCPeerConnectionVideo); |
| 1250 } |
| 1251 |
| 1252 if (m_hasDataChannels) |
| 1253 HostsUsingFeatures::countAnyWorld(*document, HostsUsingFeatures::Feature
::RTCPeerConnectionDataChannel); |
| 1254 |
| 1255 } |
| 1256 |
1228 DEFINE_TRACE(RTCPeerConnection) | 1257 DEFINE_TRACE(RTCPeerConnection) |
1229 { | 1258 { |
1230 visitor->trace(m_localStreams); | 1259 visitor->trace(m_localStreams); |
1231 visitor->trace(m_remoteStreams); | 1260 visitor->trace(m_remoteStreams); |
1232 visitor->trace(m_dispatchScheduledEventRunner); | 1261 visitor->trace(m_dispatchScheduledEventRunner); |
1233 visitor->trace(m_scheduledEvents); | 1262 visitor->trace(m_scheduledEvents); |
1234 EventTargetWithInlineData::trace(visitor); | 1263 EventTargetWithInlineData::trace(visitor); |
1235 ActiveDOMObject::trace(visitor); | 1264 ActiveDOMObject::trace(visitor); |
1236 } | 1265 } |
1237 | 1266 |
1238 } // namespace blink | 1267 } // namespace blink |
OLD | NEW |