Deprecate Candidate::set_id(), offer generate_id() instead
Bug: none Change-Id: I68df28a24446667c1bcde04120795fce54252feb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/339940 Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41762}
This commit is contained in:
parent
a75459d122
commit
bde80e3c0e
@ -64,6 +64,10 @@ Candidate::Candidate(const Candidate&) = default;
|
|||||||
|
|
||||||
Candidate::~Candidate() = default;
|
Candidate::~Candidate() = default;
|
||||||
|
|
||||||
|
void Candidate::generate_id() {
|
||||||
|
id_ = rtc::CreateRandomString(8);
|
||||||
|
}
|
||||||
|
|
||||||
bool Candidate::is_local() const {
|
bool Candidate::is_local() const {
|
||||||
return type_ == LOCAL_PORT_TYPE;
|
return type_ == LOCAL_PORT_TYPE;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,8 +63,12 @@ class RTC_EXPORT Candidate {
|
|||||||
Candidate(const Candidate&);
|
Candidate(const Candidate&);
|
||||||
~Candidate();
|
~Candidate();
|
||||||
|
|
||||||
|
// 8 character long randomized ID string for logging purposes.
|
||||||
const std::string& id() const { return id_; }
|
const std::string& id() const { return id_; }
|
||||||
void set_id(absl::string_view id) { Assign(id_, id); }
|
// Generates a new, 8 character long, id.
|
||||||
|
void generate_id();
|
||||||
|
// TODO(tommi): Callers should use generate_id(). Remove.
|
||||||
|
[[deprecated]] void set_id(absl::string_view id) { Assign(id_, id); }
|
||||||
|
|
||||||
int component() const { return component_; }
|
int component() const { return component_; }
|
||||||
void set_component(int component) { component_ = component; }
|
void set_component(int component) { component_ = component; }
|
||||||
|
|||||||
@ -20,9 +20,11 @@ namespace cricket {
|
|||||||
TEST(CandidateTest, Id) {
|
TEST(CandidateTest, Id) {
|
||||||
Candidate c;
|
Candidate c;
|
||||||
EXPECT_EQ(c.id().size(), 8u);
|
EXPECT_EQ(c.id().size(), 8u);
|
||||||
std::string new_id = "12345678";
|
std::string current_id = c.id();
|
||||||
c.set_id(new_id);
|
// Generate a new ID.
|
||||||
EXPECT_EQ(new_id, c.id());
|
c.generate_id();
|
||||||
|
EXPECT_EQ(c.id().size(), 8u);
|
||||||
|
EXPECT_NE(current_id, c.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CandidateTest, Component) {
|
TEST(CandidateTest, Component) {
|
||||||
|
|||||||
@ -1689,10 +1689,9 @@ void Connection::MaybeUpdateLocalCandidate(StunRequest* request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uint32_t priority = priority_attr->value();
|
const uint32_t priority = priority_attr->value();
|
||||||
std::string id = rtc::CreateRandomString(8);
|
|
||||||
|
|
||||||
// Create a peer-reflexive candidate based on the local candidate.
|
// Create a peer-reflexive candidate based on the local candidate.
|
||||||
local_candidate_.set_id(id);
|
local_candidate_.generate_id();
|
||||||
local_candidate_.set_type(PRFLX_PORT_TYPE);
|
local_candidate_.set_type(PRFLX_PORT_TYPE);
|
||||||
// Set the related address and foundation attributes before changing the
|
// Set the related address and foundation attributes before changing the
|
||||||
// address.
|
// address.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user