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
This commit is contained in:
braveyao@webrtc.org 2015-02-27 09:51:25 +00:00
parent abbdd520b0
commit c68e0c9dfe
2 changed files with 54 additions and 53 deletions

View File

@ -28,6 +28,7 @@
#include "talk/examples/peerconnection/client/conductor.h" #include "talk/examples/peerconnection/client/conductor.h"
#include <utility> #include <utility>
#include <vector>
#include "talk/app/webrtc/videosourceinterface.h" #include "talk/app/webrtc/videosourceinterface.h"
#include "talk/examples/peerconnection/client/defaults.h" #include "talk/examples/peerconnection/client/defaults.h"
@ -103,7 +104,7 @@ bool Conductor::InitializePeerConnection() {
return false; return false;
} }
if (!CreatePeerConnection(DTLS_ON)) { if (!CreatePeerConnection(DTLS_ON)) {
main_wnd_->MessageBox("Error", main_wnd_->MessageBox("Error",
"CreatePeerConnection failed", true); "CreatePeerConnection failed", true);
DeletePeerConnection(); DeletePeerConnection();
@ -113,14 +114,14 @@ bool Conductor::InitializePeerConnection() {
} }
bool Conductor::ReinitializePeerConnectionForLoopback() { bool Conductor::ReinitializePeerConnectionForLoopback() {
loopback_ = true; loopback_ = true;
rtc::scoped_refptr<webrtc::StreamCollectionInterface> streams( rtc::scoped_refptr<webrtc::StreamCollectionInterface> streams(
peer_connection_->local_streams()); peer_connection_->local_streams());
peer_connection_ = NULL; peer_connection_ = NULL;
if (CreatePeerConnection(DTLS_OFF)) { if (CreatePeerConnection(DTLS_OFF)) {
for (size_t i = 0; i < streams->count(); ++i) for (size_t i = 0; i < streams->count(); ++i)
peer_connection_->AddStream(streams->at(i)); peer_connection_->AddStream(streams->at(i));
peer_connection_->CreateOffer(this, NULL); peer_connection_->CreateOffer(this, NULL);
} }
return peer_connection_.get() != NULL; return peer_connection_.get() != NULL;
} }
@ -129,23 +130,23 @@ bool Conductor::CreatePeerConnection(bool dtls) {
ASSERT(peer_connection_factory_.get() != NULL); ASSERT(peer_connection_factory_.get() != NULL);
ASSERT(peer_connection_.get() == NULL); ASSERT(peer_connection_.get() == NULL);
webrtc::PeerConnectionInterface::IceServers servers; webrtc::PeerConnectionInterface::IceServers servers;
webrtc::PeerConnectionInterface::IceServer server; webrtc::PeerConnectionInterface::IceServer server;
server.uri = GetPeerConnectionString(); server.uri = GetPeerConnectionString();
servers.push_back(server); servers.push_back(server);
webrtc::FakeConstraints constraints; webrtc::FakeConstraints constraints;
if (dtls) { if (dtls) {
constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
"true"); "true");
} }
peer_connection_ = peer_connection_ =
peer_connection_factory_->CreatePeerConnection(servers, peer_connection_factory_->CreatePeerConnection(servers,
&constraints, &constraints,
NULL, NULL,
NULL, NULL,
this); this);
return peer_connection_.get() != NULL; return peer_connection_.get() != NULL;
} }
@ -189,12 +190,12 @@ void Conductor::OnRemoveStream(webrtc::MediaStreamInterface* stream) {
void Conductor::OnIceCandidate(const webrtc::IceCandidateInterface* candidate) { void Conductor::OnIceCandidate(const webrtc::IceCandidateInterface* candidate) {
LOG(INFO) << __FUNCTION__ << " " << candidate->sdp_mline_index(); LOG(INFO) << __FUNCTION__ << " " << candidate->sdp_mline_index();
// For loopback test. To save some connecting delay. // For loopback test. To save some connecting delay.
if (loopback_) { if (loopback_) {
if (!peer_connection_->AddIceCandidate(candidate)) { if (!peer_connection_->AddIceCandidate(candidate)) {
LOG(WARNING) << "Failed to apply the received candidate"; LOG(WARNING) << "Failed to apply the received candidate";
} }
return; return;
} }
Json::StyledWriter writer; Json::StyledWriter writer;
@ -279,15 +280,15 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) {
GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type); GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type);
if (!type.empty()) { if (!type.empty()) {
if (type == "offer-loopback") { if (type == "offer-loopback") {
// This is a loopback call. // This is a loopback call.
// Recreate the peerconnection with DTLS disabled. // Recreate the peerconnection with DTLS disabled.
if (!ReinitializePeerConnectionForLoopback()) { if (!ReinitializePeerConnectionForLoopback()) {
LOG(LS_ERROR) << "Failed to initialize our PeerConnection instance"; LOG(LS_ERROR) << "Failed to initialize our PeerConnection instance";
DeletePeerConnection(); DeletePeerConnection();
client_->SignOut(); client_->SignOut();
} }
return; return;
} }
std::string sdp; std::string sdp;
@ -518,21 +519,21 @@ void Conductor::UIThreadCallback(int msg_id, void* data) {
} }
void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) { void Conductor::OnSuccess(webrtc::SessionDescriptionInterface* desc) {
peer_connection_->SetLocalDescription( peer_connection_->SetLocalDescription(
DummySetSessionDescriptionObserver::Create(), desc); DummySetSessionDescriptionObserver::Create(), desc);
std::string sdp; std::string sdp;
desc->ToString(&sdp); desc->ToString(&sdp);
// For loopback test. To save some connecting delay. // For loopback test. To save some connecting delay.
if (loopback_) { if (loopback_) {
// Replace message type from "offer" to "answer" // Replace message type from "offer" to "answer"
webrtc::SessionDescriptionInterface* session_description( webrtc::SessionDescriptionInterface* session_description(
webrtc::CreateSessionDescription("answer", sdp)); webrtc::CreateSessionDescription("answer", sdp));
peer_connection_->SetRemoteDescription( peer_connection_->SetRemoteDescription(
DummySetSessionDescriptionObserver::Create(), session_description); DummySetSessionDescriptionObserver::Create(), session_description);
return; return;
} }
Json::StyledWriter writer; Json::StyledWriter writer;
Json::Value jmessage; Json::Value jmessage;

View File

@ -25,8 +25,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ #ifndef TALK_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_
#define PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ #define TALK_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_
#pragma once #pragma once
#include <deque> #include <deque>
@ -143,4 +143,4 @@ class Conductor
std::string server_; std::string server_;
}; };
#endif // PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ #endif // TALK_EXAMPLES_PEERCONNECTION_CLIENT_CONDUCTOR_H_