| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 namespace WebCore { | 64 namespace WebCore { |
| 65 | 65 |
| 66 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
ary& configuration, ExceptionCode& ec) | 66 PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Diction
ary& configuration, ExceptionCode& ec) |
| 67 { | 67 { |
| 68 if (configuration.isUndefinedOrNull()) | 68 if (configuration.isUndefinedOrNull()) |
| 69 return 0; | 69 return 0; |
| 70 | 70 |
| 71 ArrayValue iceServers; | 71 ArrayValue iceServers; |
| 72 bool ok = configuration.get("iceServers", iceServers); | 72 bool ok = configuration.get("iceServers", iceServers); |
| 73 if (!ok || iceServers.isUndefinedOrNull()) { | 73 if (!ok || iceServers.isUndefinedOrNull()) { |
| 74 ec = TYPE_MISMATCH_ERR; | 74 ec = TypeMismatchError; |
| 75 return 0; | 75 return 0; |
| 76 } | 76 } |
| 77 | 77 |
| 78 size_t numberOfServers; | 78 size_t numberOfServers; |
| 79 ok = iceServers.length(numberOfServers); | 79 ok = iceServers.length(numberOfServers); |
| 80 if (!ok) { | 80 if (!ok) { |
| 81 ec = TYPE_MISMATCH_ERR; | 81 ec = TypeMismatchError; |
| 82 return 0; | 82 return 0; |
| 83 } | 83 } |
| 84 | 84 |
| 85 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); | 85 RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create(); |
| 86 | 86 |
| 87 for (size_t i = 0; i < numberOfServers; ++i) { | 87 for (size_t i = 0; i < numberOfServers; ++i) { |
| 88 Dictionary iceServer; | 88 Dictionary iceServer; |
| 89 ok = iceServers.get(i, iceServer); | 89 ok = iceServers.get(i, iceServer); |
| 90 if (!ok) { | 90 if (!ok) { |
| 91 ec = TYPE_MISMATCH_ERR; | 91 ec = TypeMismatchError; |
| 92 return 0; | 92 return 0; |
| 93 } | 93 } |
| 94 | 94 |
| 95 String urlString, username, credential; | 95 String urlString, username, credential; |
| 96 ok = iceServer.get("url", urlString); | 96 ok = iceServer.get("url", urlString); |
| 97 if (!ok) { | 97 if (!ok) { |
| 98 ec = TYPE_MISMATCH_ERR; | 98 ec = TypeMismatchError; |
| 99 return 0; | 99 return 0; |
| 100 } | 100 } |
| 101 KURL url(KURL(), urlString); | 101 KURL url(KURL(), urlString); |
| 102 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("stun")
)) { | 102 if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("stun")
)) { |
| 103 ec = TYPE_MISMATCH_ERR; | 103 ec = TypeMismatchError; |
| 104 return 0; | 104 return 0; |
| 105 } | 105 } |
| 106 | 106 |
| 107 iceServer.get("username", username); | 107 iceServer.get("username", username); |
| 108 iceServer.get("credential", credential); | 108 iceServer.get("credential", credential); |
| 109 | 109 |
| 110 rtcConfiguration->appendServer(RTCIceServer::create(url, username, crede
ntial)); | 110 rtcConfiguration->appendServer(RTCIceServer::create(url, username, crede
ntial)); |
| 111 } | 111 } |
| 112 | 112 |
| 113 return rtcConfiguration.release(); | 113 return rtcConfiguration.release(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 162 } |
| 163 | 163 |
| 164 RTCPeerConnection::~RTCPeerConnection() | 164 RTCPeerConnection::~RTCPeerConnection() |
| 165 { | 165 { |
| 166 stop(); | 166 stop(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su
ccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& med
iaConstraints, ExceptionCode& ec) | 169 void RTCPeerConnection::createOffer(PassRefPtr<RTCSessionDescriptionCallback> su
ccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& med
iaConstraints, ExceptionCode& ec) |
| 170 { | 170 { |
| 171 if (m_signalingState == SignalingStateClosed) { | 171 if (m_signalingState == SignalingStateClosed) { |
| 172 ec = INVALID_STATE_ERR; | 172 ec = InvalidStateError; |
| 173 return; | 173 return; |
| 174 } | 174 } |
| 175 | 175 |
| 176 if (!successCallback) { | 176 if (!successCallback) { |
| 177 ec = TYPE_MISMATCH_ERR; | 177 ec = TypeMismatchError; |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 | 180 |
| 181 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); | 181 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); |
| 182 if (ec) | 182 if (ec) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ
estImpl::create(scriptExecutionContext(), successCallback, errorCallback); | 185 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ
estImpl::create(scriptExecutionContext(), successCallback, errorCallback); |
| 186 m_peerHandler->createOffer(request.release(), constraints); | 186 m_peerHandler->createOffer(request.release(), constraints); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s
uccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& me
diaConstraints, ExceptionCode& ec) | 189 void RTCPeerConnection::createAnswer(PassRefPtr<RTCSessionDescriptionCallback> s
uccessCallback, PassRefPtr<RTCErrorCallback> errorCallback, const Dictionary& me
diaConstraints, ExceptionCode& ec) |
| 190 { | 190 { |
| 191 if (m_signalingState == SignalingStateClosed) { | 191 if (m_signalingState == SignalingStateClosed) { |
| 192 ec = INVALID_STATE_ERR; | 192 ec = InvalidStateError; |
| 193 return; | 193 return; |
| 194 } | 194 } |
| 195 | 195 |
| 196 if (!successCallback) { | 196 if (!successCallback) { |
| 197 ec = TYPE_MISMATCH_ERR; | 197 ec = TypeMismatchError; |
| 198 return; | 198 return; |
| 199 } | 199 } |
| 200 | 200 |
| 201 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); | 201 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); |
| 202 if (ec) | 202 if (ec) |
| 203 return; | 203 return; |
| 204 | 204 |
| 205 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ
estImpl::create(scriptExecutionContext(), successCallback, errorCallback); | 205 RefPtr<RTCSessionDescriptionRequestImpl> request = RTCSessionDescriptionRequ
estImpl::create(scriptExecutionContext(), successCallback, errorCallback); |
| 206 m_peerHandler->createAnswer(request.release(), constraints.release()); | 206 m_peerHandler->createAnswer(request.release(), constraints.release()); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr
pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCErr
orCallback> errorCallback, ExceptionCode& ec) | 209 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr
pSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCErr
orCallback> errorCallback, ExceptionCode& ec) |
| 210 { | 210 { |
| 211 if (m_signalingState == SignalingStateClosed) { | 211 if (m_signalingState == SignalingStateClosed) { |
| 212 ec = INVALID_STATE_ERR; | 212 ec = InvalidStateError; |
| 213 return; | 213 return; |
| 214 } | 214 } |
| 215 | 215 |
| 216 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; | 216 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; |
| 217 if (!sessionDescription) { | 217 if (!sessionDescription) { |
| 218 ec = TYPE_MISMATCH_ERR; | 218 ec = TypeMismatchError; |
| 219 return; | 219 return; |
| 220 } | 220 } |
| 221 | 221 |
| 222 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut
ionContext(), successCallback, errorCallback); | 222 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut
ionContext(), successCallback, errorCallback); |
| 223 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we
bSessionDescription()); | 223 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we
bSessionDescription()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionC
ode& ec) | 226 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionC
ode& ec) |
| 227 { | 227 { |
| 228 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->loca
lDescription(); | 228 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->loca
lDescription(); |
| 229 if (webSessionDescription.isNull()) | 229 if (webSessionDescription.isNull()) |
| 230 return 0; | 230 return 0; |
| 231 | 231 |
| 232 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr
eate(webSessionDescription); | 232 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr
eate(webSessionDescription); |
| 233 return sessionDescription.release(); | 233 return sessionDescription.release(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p
rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCEr
rorCallback> errorCallback, ExceptionCode& ec) | 236 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p
rpSessionDescription, PassRefPtr<VoidCallback> successCallback, PassRefPtr<RTCEr
rorCallback> errorCallback, ExceptionCode& ec) |
| 237 { | 237 { |
| 238 if (m_signalingState == SignalingStateClosed) { | 238 if (m_signalingState == SignalingStateClosed) { |
| 239 ec = INVALID_STATE_ERR; | 239 ec = InvalidStateError; |
| 240 return; | 240 return; |
| 241 } | 241 } |
| 242 | 242 |
| 243 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; | 243 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; |
| 244 if (!sessionDescription) { | 244 if (!sessionDescription) { |
| 245 ec = TYPE_MISMATCH_ERR; | 245 ec = TypeMismatchError; |
| 246 return; | 246 return; |
| 247 } | 247 } |
| 248 | 248 |
| 249 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut
ionContext(), successCallback, errorCallback); | 249 RefPtr<RTCVoidRequestImpl> request = RTCVoidRequestImpl::create(scriptExecut
ionContext(), successCallback, errorCallback); |
| 250 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w
ebSessionDescription()); | 250 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w
ebSessionDescription()); |
| 251 } | 251 } |
| 252 | 252 |
| 253 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception
Code& ec) | 253 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception
Code& ec) |
| 254 { | 254 { |
| 255 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->remo
teDescription(); | 255 WebKit::WebRTCSessionDescription webSessionDescription = m_peerHandler->remo
teDescription(); |
| 256 if (webSessionDescription.isNull()) | 256 if (webSessionDescription.isNull()) |
| 257 return 0; | 257 return 0; |
| 258 | 258 |
| 259 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio
nDescription); | 259 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio
nDescription); |
| 260 return desc.release(); | 260 return desc.release(); |
| 261 } | 261 } |
| 262 | 262 |
| 263 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict
ionary& mediaConstraints, ExceptionCode& ec) | 263 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict
ionary& mediaConstraints, ExceptionCode& ec) |
| 264 { | 264 { |
| 265 if (m_signalingState == SignalingStateClosed) { | 265 if (m_signalingState == SignalingStateClosed) { |
| 266 ec = INVALID_STATE_ERR; | 266 ec = InvalidStateError; |
| 267 return; | 267 return; |
| 268 } | 268 } |
| 269 | 269 |
| 270 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration
, ec); | 270 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration
, ec); |
| 271 if (ec) | 271 if (ec) |
| 272 return; | 272 return; |
| 273 | 273 |
| 274 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); | 274 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); |
| 275 if (ec) | 275 if (ec) |
| 276 return; | 276 return; |
| 277 | 277 |
| 278 bool valid = m_peerHandler->updateIce(configuration, constraints); | 278 bool valid = m_peerHandler->updateIce(configuration, constraints); |
| 279 if (!valid) | 279 if (!valid) |
| 280 ec = SYNTAX_ERR; | 280 ec = SyntaxError; |
| 281 } | 281 } |
| 282 | 282 |
| 283 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception
Code& ec) | 283 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, Exception
Code& ec) |
| 284 { | 284 { |
| 285 if (m_signalingState == SignalingStateClosed) { | 285 if (m_signalingState == SignalingStateClosed) { |
| 286 ec = INVALID_STATE_ERR; | 286 ec = InvalidStateError; |
| 287 return; | 287 return; |
| 288 } | 288 } |
| 289 | 289 |
| 290 if (!iceCandidate) { | 290 if (!iceCandidate) { |
| 291 ec = TYPE_MISMATCH_ERR; | 291 ec = TypeMismatchError; |
| 292 return; | 292 return; |
| 293 } | 293 } |
| 294 | 294 |
| 295 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate()); | 295 bool valid = m_peerHandler->addIceCandidate(iceCandidate->webCandidate()); |
| 296 if (!valid) | 296 if (!valid) |
| 297 ec = SYNTAX_ERR; | 297 ec = SyntaxError; |
| 298 } | 298 } |
| 299 | 299 |
| 300 String RTCPeerConnection::signalingState() const | 300 String RTCPeerConnection::signalingState() const |
| 301 { | 301 { |
| 302 switch (m_signalingState) { | 302 switch (m_signalingState) { |
| 303 case SignalingStateStable: | 303 case SignalingStateStable: |
| 304 return ASCIILiteral("stable"); | 304 return ASCIILiteral("stable"); |
| 305 case SignalingStateHaveLocalOffer: | 305 case SignalingStateHaveLocalOffer: |
| 306 return ASCIILiteral("have-local-offer"); | 306 return ASCIILiteral("have-local-offer"); |
| 307 case SignalingStateHaveRemoteOffer: | 307 case SignalingStateHaveRemoteOffer: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 return ASCIILiteral("closed"); | 352 return ASCIILiteral("closed"); |
| 353 } | 353 } |
| 354 | 354 |
| 355 ASSERT_NOT_REACHED(); | 355 ASSERT_NOT_REACHED(); |
| 356 return String(); | 356 return String(); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti
onary& mediaConstraints, ExceptionCode& ec) | 359 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti
onary& mediaConstraints, ExceptionCode& ec) |
| 360 { | 360 { |
| 361 if (m_signalingState == SignalingStateClosed) { | 361 if (m_signalingState == SignalingStateClosed) { |
| 362 ec = INVALID_STATE_ERR; | 362 ec = InvalidStateError; |
| 363 return; | 363 return; |
| 364 } | 364 } |
| 365 | 365 |
| 366 RefPtr<MediaStream> stream = prpStream; | 366 RefPtr<MediaStream> stream = prpStream; |
| 367 if (!stream) { | 367 if (!stream) { |
| 368 ec = TYPE_MISMATCH_ERR; | 368 ec = TypeMismatchError; |
| 369 return; | 369 return; |
| 370 } | 370 } |
| 371 | 371 |
| 372 if (m_localStreams.contains(stream)) | 372 if (m_localStreams.contains(stream)) |
| 373 return; | 373 return; |
| 374 | 374 |
| 375 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); | 375 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); |
| 376 if (ec) | 376 if (ec) |
| 377 return; | 377 return; |
| 378 | 378 |
| 379 m_localStreams.append(stream); | 379 m_localStreams.append(stream); |
| 380 | 380 |
| 381 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); | 381 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); |
| 382 if (!valid) | 382 if (!valid) |
| 383 ec = SYNTAX_ERR; | 383 ec = SyntaxError; |
| 384 } | 384 } |
| 385 | 385 |
| 386 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio
nCode& ec) | 386 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio
nCode& ec) |
| 387 { | 387 { |
| 388 if (m_signalingState == SignalingStateClosed) { | 388 if (m_signalingState == SignalingStateClosed) { |
| 389 ec = INVALID_STATE_ERR; | 389 ec = InvalidStateError; |
| 390 return; | 390 return; |
| 391 } | 391 } |
| 392 | 392 |
| 393 if (!prpStream) { | 393 if (!prpStream) { |
| 394 ec = TYPE_MISMATCH_ERR; | 394 ec = TypeMismatchError; |
| 395 return; | 395 return; |
| 396 } | 396 } |
| 397 | 397 |
| 398 RefPtr<MediaStream> stream = prpStream; | 398 RefPtr<MediaStream> stream = prpStream; |
| 399 | 399 |
| 400 size_t pos = m_localStreams.find(stream); | 400 size_t pos = m_localStreams.find(stream); |
| 401 if (pos == notFound) | 401 if (pos == notFound) |
| 402 return; | 402 return; |
| 403 | 403 |
| 404 m_localStreams.remove(pos); | 404 m_localStreams.remove(pos); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 434 void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P
assRefPtr<MediaStreamTrack> selector) | 434 void RTCPeerConnection::getStats(PassRefPtr<RTCStatsCallback> successCallback, P
assRefPtr<MediaStreamTrack> selector) |
| 435 { | 435 { |
| 436 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(scrip
tExecutionContext(), successCallback, selector); | 436 RefPtr<RTCStatsRequestImpl> statsRequest = RTCStatsRequestImpl::create(scrip
tExecutionContext(), successCallback, selector); |
| 437 // FIXME: Add passing selector as part of the statsRequest. | 437 // FIXME: Add passing selector as part of the statsRequest. |
| 438 m_peerHandler->getStats(statsRequest.release()); | 438 m_peerHandler->getStats(statsRequest.release()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co
nst Dictionary& options, ExceptionCode& ec) | 441 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co
nst Dictionary& options, ExceptionCode& ec) |
| 442 { | 442 { |
| 443 if (m_signalingState == SignalingStateClosed) { | 443 if (m_signalingState == SignalingStateClosed) { |
| 444 ec = INVALID_STATE_ERR; | 444 ec = InvalidStateError; |
| 445 return 0; | 445 return 0; |
| 446 } | 446 } |
| 447 | 447 |
| 448 WebKit::WebRTCDataChannelInit init; | 448 WebKit::WebRTCDataChannelInit init; |
| 449 options.get("ordered", init.ordered); | 449 options.get("ordered", init.ordered); |
| 450 options.get("negotiated", init.negotiated); | 450 options.get("negotiated", init.negotiated); |
| 451 | 451 |
| 452 unsigned short value = 0; | 452 unsigned short value = 0; |
| 453 if (options.get("id", value)) | 453 if (options.get("id", value)) |
| 454 init.id = value; | 454 init.id = value; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 473 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo
calStreams.end(); ++iter) { | 473 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo
calStreams.end(); ++iter) { |
| 474 if ((*iter)->getTrackById(trackId)) | 474 if ((*iter)->getTrackById(trackId)) |
| 475 return true; | 475 return true; |
| 476 } | 476 } |
| 477 return false; | 477 return false; |
| 478 } | 478 } |
| 479 | 479 |
| 480 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt
reamTrack> prpTrack, ExceptionCode& ec) | 480 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt
reamTrack> prpTrack, ExceptionCode& ec) |
| 481 { | 481 { |
| 482 if (m_signalingState == SignalingStateClosed) { | 482 if (m_signalingState == SignalingStateClosed) { |
| 483 ec = INVALID_STATE_ERR; | 483 ec = InvalidStateError; |
| 484 return 0; | 484 return 0; |
| 485 } | 485 } |
| 486 | 486 |
| 487 if (!prpTrack) { | 487 if (!prpTrack) { |
| 488 ec = TypeError; | 488 ec = TypeError; |
| 489 return 0; | 489 return 0; |
| 490 } | 490 } |
| 491 | 491 |
| 492 RefPtr<MediaStreamTrack> track = prpTrack; | 492 RefPtr<MediaStreamTrack> track = prpTrack; |
| 493 | 493 |
| 494 if (!hasLocalStreamWithTrackId(track->id())) { | 494 if (!hasLocalStreamWithTrackId(track->id())) { |
| 495 ec = SYNTAX_ERR; | 495 ec = SyntaxError; |
| 496 return 0; | 496 return 0; |
| 497 } | 497 } |
| 498 | 498 |
| 499 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(scriptExecutionCont
ext(), m_peerHandler.get(), track.release(), ec); | 499 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(scriptExecutionCont
ext(), m_peerHandler.get(), track.release(), ec); |
| 500 if (ec) | 500 if (ec) |
| 501 return 0; | 501 return 0; |
| 502 return dtmfSender.release(); | 502 return dtmfSender.release(); |
| 503 } | 503 } |
| 504 | 504 |
| 505 void RTCPeerConnection::close(ExceptionCode& ec) | 505 void RTCPeerConnection::close(ExceptionCode& ec) |
| 506 { | 506 { |
| 507 if (m_signalingState == SignalingStateClosed) { | 507 if (m_signalingState == SignalingStateClosed) { |
| 508 ec = INVALID_STATE_ERR; | 508 ec = InvalidStateError; |
| 509 return; | 509 return; |
| 510 } | 510 } |
| 511 | 511 |
| 512 m_peerHandler->stop(); | 512 m_peerHandler->stop(); |
| 513 | 513 |
| 514 changeIceConnectionState(IceConnectionStateClosed); | 514 changeIceConnectionState(IceConnectionStateClosed); |
| 515 changeIceGatheringState(IceGatheringStateComplete); | 515 changeIceGatheringState(IceGatheringStateComplete); |
| 516 changeSignalingState(SignalingStateClosed); | 516 changeSignalingState(SignalingStateClosed); |
| 517 } | 517 } |
| 518 | 518 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 events.swap(m_scheduledEvents); | 666 events.swap(m_scheduledEvents); |
| 667 | 667 |
| 668 Vector<RefPtr<Event> >::iterator it = events.begin(); | 668 Vector<RefPtr<Event> >::iterator it = events.begin(); |
| 669 for (; it != events.end(); ++it) | 669 for (; it != events.end(); ++it) |
| 670 dispatchEvent((*it).release()); | 670 dispatchEvent((*it).release()); |
| 671 | 671 |
| 672 events.clear(); | 672 events.clear(); |
| 673 } | 673 } |
| 674 | 674 |
| 675 } // namespace WebCore | 675 } // namespace WebCore |
| OLD | NEW |