diff --git a/talk/examples/peerconnection/client/conductor.cc b/talk/examples/peerconnection/client/conductor.cc index bf0d6c9ad..f30516fc7 100644 --- a/talk/examples/peerconnection/client/conductor.cc +++ b/talk/examples/peerconnection/client/conductor.cc @@ -283,7 +283,7 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { std::string type; std::string json_object; - GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type); + rtc::GetStringFromJsonObject(jmessage, kSessionDescriptionTypeName, &type); if (!type.empty()) { if (type == "offer-loopback") { // This is a loopback call. @@ -297,7 +297,8 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { } std::string sdp; - if (!GetStringFromJsonObject(jmessage, kSessionDescriptionSdpName, &sdp)) { + if (!rtc::GetStringFromJsonObject(jmessage, kSessionDescriptionSdpName, + &sdp)) { LOG(WARNING) << "Can't parse received session description message."; return; } @@ -319,10 +320,11 @@ void Conductor::OnMessageFromPeer(int peer_id, const std::string& message) { std::string sdp_mid; int sdp_mlineindex = 0; std::string sdp; - if (!GetStringFromJsonObject(jmessage, kCandidateSdpMidName, &sdp_mid) || - !GetIntFromJsonObject(jmessage, kCandidateSdpMlineIndexName, - &sdp_mlineindex) || - !GetStringFromJsonObject(jmessage, kCandidateSdpName, &sdp)) { + if (!rtc::GetStringFromJsonObject(jmessage, kCandidateSdpMidName, + &sdp_mid) || + !rtc::GetIntFromJsonObject(jmessage, kCandidateSdpMlineIndexName, + &sdp_mlineindex) || + !rtc::GetStringFromJsonObject(jmessage, kCandidateSdpName, &sdp)) { LOG(WARNING) << "Can't parse received message."; return; } diff --git a/webrtc/base/json.cc b/webrtc/base/json.cc index 49a051c01..c692534c6 100644 --- a/webrtc/base/json.cc +++ b/webrtc/base/json.cc @@ -16,6 +16,8 @@ #include +namespace rtc { + bool GetStringFromJson(const Json::Value& in, std::string* out) { if (!in.isString()) { std::ostringstream s; @@ -294,3 +296,5 @@ std::string JsonValueToString(const Json::Value& json) { std::string value = w.write(json); return value.substr(0, value.size() - 1); // trim trailing newline } + +} // namespace rtc diff --git a/webrtc/base/json.h b/webrtc/base/json.h index 9d45ded97..4c0d22243 100644 --- a/webrtc/base/json.h +++ b/webrtc/base/json.h @@ -20,7 +20,7 @@ #include "third_party/jsoncpp/json.h" #endif -// TODO: Move to rtc namespace +namespace rtc { /////////////////////////////////////////////////////////////////////////////// // JSON Helpers @@ -86,4 +86,6 @@ bool GetDoubleFromJsonObject(const Json::Value& in, const std::string& k, // Writes out a Json value as a string. std::string JsonValueToString(const Json::Value& json); +} // namespace rtc + #endif // WEBRTC_BASE_JSON_H_ diff --git a/webrtc/base/json_unittest.cc b/webrtc/base/json_unittest.cc index e7e58227b..fe3cf3bb5 100644 --- a/webrtc/base/json_unittest.cc +++ b/webrtc/base/json_unittest.cc @@ -8,10 +8,14 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include -#include "webrtc/base/gunit.h" #include "webrtc/base/json.h" +#include + +#include "webrtc/base/gunit.h" + +namespace rtc { + static Json::Value in_s("foo"); static Json::Value in_sn("99"); static Json::Value in_si("-99"); @@ -275,3 +279,5 @@ TEST(JsonTest, DoubleVectorToFromArray) { EXPECT_EQ(in[i], outj[i]); } } + +} // namespace rtc