Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / libjingle / source / talk / app / webrtc / webrtcsession.cc
index 0de46e7..b2951eb 100644 (file)
@@ -786,7 +786,7 @@ bool WebRtcSession::ProcessIceMessage(const IceCandidateInterface* candidate) {
     return false;
   }
 
-  return UseCandidatesInSessionDescription(remote_desc_.get());
+  return UseCandidate(candidate);
 }
 
 bool WebRtcSession::GetTrackIdBySsrc(uint32 ssrc, std::string* id) {
@@ -866,6 +866,18 @@ void WebRtcSession::SetAudioSend(uint32 ssrc, bool enable,
     voice_channel_->SetChannelOptions(options);
 }
 
+void WebRtcSession::SetAudioPlayoutVolume(uint32 ssrc, double volume) {
+  ASSERT(signaling_thread()->IsCurrent());
+  ASSERT(volume >= 0 && volume <= 10);
+  if (!voice_channel_) {
+    LOG(LS_ERROR) << "SetAudioPlayoutVolume: No audio channel exists.";
+    return;
+  }
+
+  if (!voice_channel_->SetOutputScaling(ssrc, volume, volume))
+    ASSERT(false);
+}
+
 bool WebRtcSession::SetCaptureDevice(uint32 ssrc,
                                      cricket::VideoCapturer* camera) {
   ASSERT(signaling_thread()->IsCurrent());
@@ -1142,12 +1154,20 @@ void WebRtcSession::OnTransportWritable(cricket::Transport* transport) {
   // TODO(bemasc): Expose more API from Transport to detect when
   // candidate selection starts or stops, due to success or failure.
   if (transport->all_channels_writable()) {
+    // By the time |SignalTransportWritable| arrives, the excess channels may
+    // already have been pruned, so that the Transport is Completed.  The
+    // specification requires that transitions from Checking to Completed pass
+    // through Connected.  This check enforces that requirement.
+    // (Direct transitions from Connected and Disconnected to Completed are
+    // allowed.)
     if (ice_connection_state_ ==
-            PeerConnectionInterface::kIceConnectionChecking ||
-        ice_connection_state_ ==
-            PeerConnectionInterface::kIceConnectionDisconnected) {
+            PeerConnectionInterface::kIceConnectionChecking) {
       SetIceConnectionState(PeerConnectionInterface::kIceConnectionConnected);
     }
+
+    SetIceConnectionState(transport->completed() ?
+        PeerConnectionInterface::kIceConnectionCompleted :
+        PeerConnectionInterface::kIceConnectionConnected);
   } else if (transport->HasChannels()) {
     // If the current state is Connected or Completed, then there were writable
     // channels but now there are not, so the next state must be Disconnected.
@@ -1161,6 +1181,16 @@ void WebRtcSession::OnTransportWritable(cricket::Transport* transport) {
   }
 }
 
+void WebRtcSession::OnTransportCompleted(cricket::Transport* transport) {
+  ASSERT(signaling_thread()->IsCurrent());
+  SetIceConnectionState(PeerConnectionInterface::kIceConnectionCompleted);
+}
+
+void WebRtcSession::OnTransportFailed(cricket::Transport* transport) {
+  ASSERT(signaling_thread()->IsCurrent());
+  SetIceConnectionState(PeerConnectionInterface::kIceConnectionFailed);
+}
+
 void WebRtcSession::OnTransportProxyCandidatesReady(
     cricket::TransportProxy* proxy, const cricket::Candidates& candidates) {
   ASSERT(signaling_thread()->IsCurrent());