Skip to content

Commit

Permalink
Update libjingle to 42594198.
Browse files Browse the repository at this point in the history
TBR=ronghuawu@google.com

Review URL: https://webrtc-codereview.appspot.com/1108005

git-svn-id: http://libjingle.googlecode.com/svn/trunk@280 dd674b97-3498-5ee5-1854-bdd07cd0ff33
  • Loading branch information
sergeyu@google.com committed Feb 15, 2013
1 parent 15d8da0 commit f2bee8b
Show file tree
Hide file tree
Showing 26 changed files with 1,393 additions and 163 deletions.
13 changes: 8 additions & 5 deletions talk/app/webrtc/mediastreamsignaling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static bool FindConstraint(const MediaConstraintsInterface* constraints,

static bool ParseConstraints(
const MediaConstraintsInterface* constraints,
cricket::MediaSessionOptions* options) {
cricket::MediaSessionOptions* options, bool is_answer) {
std::string value;
size_t mandatory_constraints_satisfied = 0;

Expand All @@ -104,7 +104,7 @@ static bool ParseConstraints(
(value == MediaConstraintsInterface::kValueTrue);
} else {
// kOfferToReceiveAudio is non mandatory true according to spec.
options->has_audio |= true;
options->has_audio = true;
}

if (FindConstraint(constraints,
Expand All @@ -117,7 +117,10 @@ static bool ParseConstraints(
options->has_video |=
(value == MediaConstraintsInterface::kValueTrue);
} else {
// kOfferToReceiveVideo is non mandatory false according to spec.
// kOfferToReceiveVideo is non mandatory false according to spec. But
// if it is an answer and video is offered, we should still accept video
// per default.
options->has_video |= is_answer ? true : false;
}

if (FindConstraint(constraints,
Expand Down Expand Up @@ -306,7 +309,7 @@ bool MediaStreamSignaling::GetOptionsForOffer(
const MediaConstraintsInterface* constraints,
cricket::MediaSessionOptions* options) {
UpdateSessionOptions();
if (!ParseConstraints(constraints, &options_)) {
if (!ParseConstraints(constraints, &options_, false)) {
return false;
}
options_.bundle_enabled = EvaluateNeedForBundle(options_);
Expand All @@ -322,7 +325,7 @@ bool MediaStreamSignaling::GetOptionsForAnswer(
// Copy the |options_| to not let the flag MediaSessionOptions::has_audio and
// MediaSessionOptions::has_video affect subsequent offers.
cricket::MediaSessionOptions current_options = options_;
if (!ParseConstraints(constraints, &current_options)) {
if (!ParseConstraints(constraints, &current_options, true)) {
return false;
}
current_options.bundle_enabled = EvaluateNeedForBundle(current_options);
Expand Down
42 changes: 36 additions & 6 deletions talk/app/webrtc/peerconnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ enum {
MSG_SET_SESSIONDESCRIPTION_SUCCESS,
MSG_SET_SESSIONDESCRIPTION_FAILED,
MSG_GETSTATS,
MSG_ICECHANGE,
MSG_ICECONNECTIONCHANGE,
MSG_ICEGATHERINGCHANGE,
MSG_ICECANDIDATE,
MSG_ICECOMPLETE,
};
Expand Down Expand Up @@ -238,6 +239,8 @@ PeerConnection::PeerConnection(PeerConnectionFactory* factory)
observer_(NULL),
signaling_state_(kStable),
ice_state_(kIceNew),
ice_connection_state_(kIceConnectionNew),
ice_gathering_state_(kIceGatheringNew),
local_media_streams_(StreamCollection::Create()) {
}

Expand Down Expand Up @@ -296,7 +299,7 @@ bool PeerConnection::DoInitialize(

// Register PeerConnection as receiver of local ice candidates.
// All the callbacks will be posted to the application from PeerConnection.
session_->RegisterObserver(this);
session_->RegisterIceObserver(this);
session_->SignalState.connect(this, &PeerConnection::OnSessionStateChange);
return true;
}
Expand Down Expand Up @@ -374,6 +377,16 @@ PeerConnectionInterface::IceState PeerConnection::ice_state() {
return ice_state_;
}

PeerConnectionInterface::IceConnectionState
PeerConnection::ice_connection_state() {
return ice_connection_state_;
}

PeerConnectionInterface::IceGatheringState
PeerConnection::ice_gathering_state() {
return ice_gathering_state_;
}

talk_base::scoped_refptr<DataChannelInterface>
PeerConnection::CreateDataChannel(
const std::string& label,
Expand Down Expand Up @@ -578,8 +591,12 @@ void PeerConnection::OnMessage(talk_base::Message* msg) {
delete param;
break;
}
case MSG_ICECHANGE: {
observer_->OnIceChange();
case MSG_ICECONNECTIONCHANGE: {
observer_->OnIceConnectionChange(ice_connection_state_);
break;
}
case MSG_ICEGATHERINGCHANGE: {
observer_->OnIceGatheringChange(ice_gathering_state_);
break;
}
case MSG_ICECANDIDATE: {
Expand Down Expand Up @@ -614,8 +631,16 @@ void PeerConnection::OnAddDataChannel(DataChannelInterface* data_channel) {
data_channel));
}

void PeerConnection::OnIceChange() {
signaling_thread()->Post(this, MSG_ICECHANGE);
void PeerConnection::OnIceConnectionChange(
PeerConnectionInterface::IceConnectionState new_state) {
ice_connection_state_ = new_state;
signaling_thread()->Post(this, MSG_ICECONNECTIONCHANGE);
}

void PeerConnection::OnIceGatheringChange(
PeerConnectionInterface::IceGatheringState new_state) {
ice_gathering_state_ = new_state;
signaling_thread()->Post(this, MSG_ICEGATHERINGCHANGE);
}

void PeerConnection::OnIceCandidate(const IceCandidateInterface* candidate) {
Expand All @@ -639,7 +664,12 @@ void PeerConnection::OnIceComplete() {
void PeerConnection::ChangeSignalingState(
PeerConnectionInterface::SignalingState signaling_state) {
signaling_state_ = signaling_state;
observer_->OnSignalingChange(signaling_state_);
observer_->OnStateChange(PeerConnectionObserver::kSignalingState);
if (signaling_state == kClosed) {
ice_connection_state_ = kIceConnectionClosed;
observer_->OnIceConnectionChange(ice_connection_state_);
}
}

} // namespace webrtc
14 changes: 10 additions & 4 deletions talk/app/webrtc/peerconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration>
// the PeerConnection functionality.
class PeerConnection : public PeerConnectionInterface,
public RemoteMediaStreamObserver,
public IceCandidateObserver,
public IceObserver,
public talk_base::MessageHandler,
public sigslot::has_slots<> {
public:
Expand Down Expand Up @@ -80,7 +80,10 @@ class PeerConnection : public PeerConnectionInterface,
virtual ReadyState ready_state() { return signaling_state(); }
virtual SignalingState signaling_state();

// TODO(bemasc): Remove ice_state() when callers are removed.
virtual IceState ice_state();
virtual IceConnectionState ice_connection_state();
virtual IceGatheringState ice_gathering_state();

virtual const SessionDescriptionInterface* local_description() const;
virtual const SessionDescriptionInterface* remote_description() const;
Expand Down Expand Up @@ -110,8 +113,9 @@ class PeerConnection : public PeerConnectionInterface,
virtual void OnRemoveStream(MediaStreamInterface* stream);
virtual void OnAddDataChannel(DataChannelInterface* data_channel);

// Implements IceCandidateObserver
virtual void OnIceChange();
// Implements IceObserver
virtual void OnIceConnectionChange(IceConnectionState new_state);
virtual void OnIceGatheringChange(IceGatheringState new_state);
virtual void OnIceCandidate(const IceCandidateInterface* candidate);
virtual void OnIceComplete();

Expand Down Expand Up @@ -142,8 +146,10 @@ class PeerConnection : public PeerConnectionInterface,
talk_base::scoped_refptr<PeerConnectionFactory> factory_;
PeerConnectionObserver* observer_;
SignalingState signaling_state_;
// TODO(ronghuawu): Implement ice_state.
// TODO(bemasc): Remove ice_state_.
IceState ice_state_;
IceConnectionState ice_connection_state_;
IceGatheringState ice_gathering_state_;
talk_base::scoped_refptr<StreamCollection> local_media_streams_;

talk_base::scoped_ptr<cricket::PortAllocator> port_allocator_;
Expand Down
61 changes: 58 additions & 3 deletions talk/app/webrtc/peerconnection_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,26 @@ class PeerConnectionTestClientBase
return peer_connection()->local_streams();
}

webrtc::PeerConnectionInterface::SignalingState signaling_state() {
return peer_connection()->signaling_state();
}

webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state() {
return peer_connection()->ice_connection_state();
}

webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() {
return peer_connection()->ice_gathering_state();
}

// PeerConnectionObserver callbacks.
virtual void OnError() {}
virtual void OnMessage(const std::string&) {}
virtual void OnSignalingMessage(const std::string& /*msg*/) {}
virtual void OnStateChange(StateType /*state_changed*/) {}
virtual void OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) {
EXPECT_EQ(peer_connection_->signaling_state(), new_state);
}
virtual void OnAddStream(webrtc::MediaStreamInterface* media_stream) {
for (size_t i = 0; i < media_stream->video_tracks()->count(); ++i) {
const std::string id = media_stream->video_tracks()->at(i)->id();
Expand All @@ -329,10 +344,16 @@ class PeerConnectionTestClientBase
}
virtual void OnRemoveStream(webrtc::MediaStreamInterface* media_stream) {}
virtual void OnRenegotiationNeeded() {}
virtual void OnIceChange() {}
virtual void OnIceConnectionChange(
webrtc::PeerConnectionInterface::IceConnectionState new_state) {
EXPECT_EQ(peer_connection_->ice_connection_state(), new_state);
}
virtual void OnIceGatheringChange(
webrtc::PeerConnectionInterface::IceGatheringState new_state) {
EXPECT_EQ(peer_connection_->ice_gathering_state(), new_state);
}
virtual void OnIceCandidate(
const webrtc::IceCandidateInterface* /*candidate*/) {}
virtual void OnIceComplete() {}

protected:
explicit PeerConnectionTestClientBase(const std::string& id)
Expand Down Expand Up @@ -796,6 +817,40 @@ class P2PTestConductor : public testing::Test {
!receiving_client_->can_receive_video()) {
video_frame_count = -1;
}

if (audio_frame_count != -1 || video_frame_count != -1) {
// Audio or video is expected to flow, so both sides should get to the
// Connected state.
// Note: These tests have been observed to fail under heavy load at
// shorter timeouts, so they may be flaky.
EXPECT_EQ_WAIT(
webrtc::PeerConnectionInterface::kIceConnectionConnected,
initiating_client_->ice_connection_state(),
kMaxWaitForFramesMs);
EXPECT_EQ_WAIT(
webrtc::PeerConnectionInterface::kIceConnectionConnected,
receiving_client_->ice_connection_state(),
kMaxWaitForFramesMs);
}

if (initiating_client_->can_receive_audio() ||
initiating_client_->can_receive_video()) {
// The initiating client can receive media, so it must produce candidates
// that will serve as destinations for that media.
// TODO(bemasc): Understand why the state is not already Complete here, as
// seems to be the case for the receiving client. This may indicate a bug
// in the ICE gathering system.
EXPECT_NE(webrtc::PeerConnectionInterface::kIceGatheringNew,
initiating_client_->ice_gathering_state());
}
if (receiving_client_->can_receive_audio() ||
receiving_client_->can_receive_video()) {
// The receiving client can receive media, so it must produce candidates
// that will serve as destinations for that media.
EXPECT_EQ(webrtc::PeerConnectionInterface::kIceGatheringComplete,
receiving_client_->ice_gathering_state());
}

EXPECT_TRUE_WAIT(FramesNotPending(audio_frame_count, video_frame_count),
kMaxWaitForFramesMs);
}
Expand Down
9 changes: 6 additions & 3 deletions talk/app/webrtc/peerconnectionfactory_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,16 @@ class NullPeerConnectionObserver : public PeerConnectionObserver {
virtual void OnError() {}
virtual void OnMessage(const std::string& msg) {}
virtual void OnSignalingMessage(const std::string& msg) {}
virtual void OnStateChange(StateType state_changed) {}
virtual void OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) {}
virtual void OnAddStream(MediaStreamInterface* stream) {}
virtual void OnRemoveStream(MediaStreamInterface* stream) {}
virtual void OnRenegotiationNeeded() {}
virtual void OnIceChange() {}
virtual void OnIceConnectionChange(
PeerConnectionInterface::IceConnectionState new_state) {}
virtual void OnIceGatheringChange(
PeerConnectionInterface::IceGatheringState new_state) {}
virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) {}
virtual void OnIceComplete() {}
};

} // namespace
Expand Down
Loading

0 comments on commit f2bee8b

Please sign in to comment.