Cleanup: Move json.h into rtc namespace.
This should fix the TODO in that header. BUG=None TEST=ninja -C out/Debug still compiles everything. R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/47919004 Patch from Thiago Farina <tfarina@chromium.org>. Cr-Commit-Position: refs/heads/master@{#8921}
This commit is contained in:
parent
0dd58026a8
commit
cb76b89572
@ -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,
|
||||
if (!rtc::GetStringFromJsonObject(jmessage, kCandidateSdpMidName,
|
||||
&sdp_mid) ||
|
||||
!rtc::GetIntFromJsonObject(jmessage, kCandidateSdpMlineIndexName,
|
||||
&sdp_mlineindex) ||
|
||||
!GetStringFromJsonObject(jmessage, kCandidateSdpName, &sdp)) {
|
||||
!rtc::GetStringFromJsonObject(jmessage, kCandidateSdpName, &sdp)) {
|
||||
LOG(WARNING) << "Can't parse received message.";
|
||||
return;
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
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
|
||||
|
@ -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_
|
||||
|
@ -8,10 +8,14 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include "webrtc/base/gunit.h"
|
||||
#include "webrtc/base/json.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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
|
||||
|
Loading…
x
Reference in New Issue
Block a user