From c68e0c9dfe92fe546ab40d32660f3f1b8b5d4bf4 Mon Sep 17 00:00:00 2001 From: "braveyao@webrtc.org" Date: Fri, 27 Feb 2015 09:51:25 +0000 Subject: [PATCH] Fix cpplint warning in the previous cl to peerconnection client example. BUG=3872 TEST=Manual Test + AutoTest R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/40949004 Cr-Commit-Position: refs/heads/master@{#8525} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8525 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../peerconnection/client/conductor.cc | 101 +++++++++--------- .../peerconnection/client/conductor.h | 6 +- 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/talk/examples/peerconnection/client/conductor.cc b/talk/examples/peerconnection/client/conductor.cc index 3fca75857..7df20909a 100644 --- a/talk/examples/peerconnection/client/conductor.cc +++ b/talk/examples/peerconnection/client/conductor.cc @@ -28,6 +28,7 @@ #include "talk/examples/peerconnection/client/conductor.h" #include +#include #include "talk/app/webrtc/videosourceinterface.h" #include "talk/examples/peerconnection/client/defaults.h" @@ -103,7 +104,7 @@ bool Conductor::InitializePeerConnection() { return false; } - if (!CreatePeerConnection(DTLS_ON)) { + if (!CreatePeerConnection(DTLS_ON)) { main_wnd_->MessageBox("Error", "CreatePeerConnection failed", true); DeletePeerConnection(); @@ -113,14 +114,14 @@ bool Conductor::InitializePeerConnection() { } bool Conductor::ReinitializePeerConnectionForLoopback() { - loopback_ = true; - rtc::scoped_refptr streams( - peer_connection_->local_streams()); - peer_connection_ = NULL; + loopback_ = true; + rtc::scoped_refptr streams( + peer_connection_->local_streams()); + peer_connection_ = NULL; if (CreatePeerConnection(DTLS_OFF)) { - for (size_t i = 0; i < streams->count(); ++i) - peer_connection_->AddStream(streams->at(i)); - peer_connection_->CreateOffer(this, NULL); + for (size_t i = 0; i < streams->count(); ++i) + peer_connection_->AddStream(streams->at(i)); + peer_connection_->CreateOffer(this, NULL); } return peer_connection_.get() != NULL; } @@ -129,23 +130,23 @@ bool Conductor::CreatePeerConnection(bool dtls) { ASSERT(peer_connection_factory_.get() != NULL); ASSERT(peer_connection_.get() == NULL); - webrtc::PeerConnectionInterface::IceServers servers; - webrtc::PeerConnectionInterface::IceServer server; - server.uri = GetPeerConnectionString(); - servers.push_back(server); - + webrtc::PeerConnectionInterface::IceServers servers; + webrtc::PeerConnectionInterface::IceServer server; + server.uri = GetPeerConnectionString(); + servers.push_back(server); + webrtc::FakeConstraints constraints; if (dtls) { - constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, - "true"); - } - - peer_connection_ = - peer_connection_factory_->CreatePeerConnection(servers, - &constraints, - NULL, - NULL, - this); + constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, + "true"); + } + + peer_connection_ = + peer_connection_factory_->CreatePeerConnection(servers, + &constraints, + NULL, + NULL, + this); return peer_connection_.get() != NULL; } @@ -189,12 +190,12 @@ void Conductor::OnRemoveStream(webrtc::MediaStreamInterface* stream) { void Conductor::OnIceCandidate(const webrtc::IceCandidateInterface* candidate) { LOG(INFO) << __FUNCTION__ << " " << candidate->sdp_mline_index(); - // For loopback test. To save some connecting delay. - if (loopback_) { - if (!peer_connection_->AddIceCandidate(candidate)) { - LOG(WARNING) << "Failed to apply the received candidate"; - } - return; + // For loopback test. To save some connecting delay. + if (loopback_) { + if (!peer_connection_->AddIceCandidate(candidate)) { + LOG(WARNING) << "Failed to apply the received candidate"; + } + return; } Json::StyledWriter writer; @@ -279,15 +280,15 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type); if (!type.empty()) { - if (type == "offer-loopback") { - // This is a loopback call. - // Recreate the peerconnection with DTLS disabled. - if (!ReinitializePeerConnectionForLoopback()) { + if (type == "offer-loopback") { + // This is a loopback call. + // Recreate the peerconnection with DTLS disabled. + if (!ReinitializePeerConnectionForLoopback()) { LOG(LS_ERROR) << "Failed to initialize our PeerConnection instance"; DeletePeerConnection(); - client_->SignOut(); - } - return; + client_->SignOut(); + } + return; } std::string sdp; @@ -518,21 +519,21 @@ void Conductor::UIThreadCallback(int msg_id, void* data) { } void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) { - peer_connection_->SetLocalDescription( - DummySetSessionDescriptionObserver::Create(), desc); - + peer_connection_->SetLocalDescription( + DummySetSessionDescriptionObserver::Create(), desc); + std::string sdp; - desc->ToString(&sdp); - - // For loopback test. To save some connecting delay. - if (loopback_) { - // Replace message type from "offer" to "answer" - webrtc::SessionDescriptionInterface* session_description( - webrtc::CreateSessionDescription("answer", sdp)); - peer_connection_->SetRemoteDescription( - DummySetSessionDescriptionObserver::Create(), session_description); - return; - } + desc->ToString(&sdp); + + // For loopback test. To save some connecting delay. + if (loopback_) { + // Replace message type from "offer" to "answer" + webrtc::SessionDescriptionInterface* session_description( + webrtc::CreateSessionDescription("answer", sdp)); + peer_connection_->SetRemoteDescription( + DummySetSessionDescriptionObserver::Create(), session_description); + return; + } Json::StyledWriter writer; Json::Value jmessage; diff --git a/talk/examples/peerconnection/client/conductor.h b/talk/examples/peerconnection/client/conductor.h index d99c98a78..43303a34f 100644 --- a/talk/examples/peerconnection/client/conductor.h +++ b/talk/examples/peerconnection/client/conductor.h @@ -25,8 +25,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ -#define PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ +#ifndef TALK_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_ +#define TALK_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_ #pragma once #include @@ -143,4 +143,4 @@ class Conductor std::string server_; }; -#endif // PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ +#endif // TALK_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_