2 * Copyright 2013 The WebRTC Project Authors. All rights reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #include "webrtc/p2p/base/transportdescription.h"
13 #include "webrtc/p2p/base/constants.h"
14 #include "webrtc/base/stringutils.h"
18 bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role) {
19 const char* const roles[] = {
20 CONNECTIONROLE_ACTIVE_STR,
21 CONNECTIONROLE_PASSIVE_STR,
22 CONNECTIONROLE_ACTPASS_STR,
23 CONNECTIONROLE_HOLDCONN_STR
26 for (size_t i = 0; i < ARRAY_SIZE(roles); ++i) {
27 if (_stricmp(roles[i], role_str.c_str()) == 0) {
28 *role = static_cast<ConnectionRole>(CONNECTIONROLE_ACTIVE + i);
35 bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str) {
37 case cricket::CONNECTIONROLE_ACTIVE:
38 *role_str = cricket::CONNECTIONROLE_ACTIVE_STR;
40 case cricket::CONNECTIONROLE_ACTPASS:
41 *role_str = cricket::CONNECTIONROLE_ACTPASS_STR;
43 case cricket::CONNECTIONROLE_PASSIVE:
44 *role_str = cricket::CONNECTIONROLE_PASSIVE_STR;
46 case cricket::CONNECTIONROLE_HOLDCONN:
47 *role_str = cricket::CONNECTIONROLE_HOLDCONN_STR;
55 } // namespace cricket