mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 15:15:28 +00:00
Use proper mid in candidates instead of ICE stream name
This commit is contained in:
@ -41,6 +41,7 @@ public:
|
||||
string typeString() const;
|
||||
Role role() const;
|
||||
string roleString() const;
|
||||
string mid() const;
|
||||
std::optional<string> fingerprint() const;
|
||||
std::optional<uint16_t> sctpPort() const;
|
||||
|
||||
|
@ -97,6 +97,8 @@ Description::Role Description::role() const { return mRole; }
|
||||
|
||||
string Description::roleString() const { return roleToString(mRole); }
|
||||
|
||||
string Description::mid() const { return mMid; }
|
||||
|
||||
std::optional<string> Description::fingerprint() const { return mFingerprint; }
|
||||
|
||||
std::optional<uint16_t> Description::sctpPort() const { return mSctpPort; }
|
||||
|
@ -35,7 +35,7 @@ using std::weak_ptr;
|
||||
|
||||
IceTransport::IceTransport(const Configuration &config, Description::Role role,
|
||||
candidate_callback candidateCallback, ready_callback ready)
|
||||
: mRole(role), mState(State::Disconnected), mNiceAgent(nullptr, nullptr),
|
||||
: mRole(role), mMid("0"), mState(State::Disconnected), mNiceAgent(nullptr, nullptr),
|
||||
mMainLoop(nullptr, nullptr), mCandidateCallback(std::move(candidateCallback)),
|
||||
mReadyCallback(ready) {
|
||||
|
||||
@ -109,7 +109,7 @@ IceTransport::IceTransport(const Configuration &config, Description::Role role,
|
||||
G_CALLBACK(GatheringDoneCallback), this);
|
||||
|
||||
mStreamId = nice_agent_add_stream(mNiceAgent.get(), 1);
|
||||
if (mStreamId == 0)
|
||||
if (!mStreamId)
|
||||
throw std::runtime_error("Failed to add a stream");
|
||||
|
||||
nice_agent_set_stream_name(mNiceAgent.get(), mStreamId, "application");
|
||||
@ -139,6 +139,7 @@ Description IceTransport::getLocalDescription(Description::Type type) const {
|
||||
void IceTransport::setRemoteDescription(const Description &description) {
|
||||
mRole = description.role() == Description::Role::Active ? Description::Role::Passive
|
||||
: Description::Role::Active;
|
||||
mMid = description.mid();
|
||||
|
||||
if (nice_agent_parse_remote_sdp(mNiceAgent.get(), string(description).c_str()))
|
||||
throw std::runtime_error("Failed to parse remote SDP");
|
||||
@ -185,7 +186,7 @@ void IceTransport::outgoing(message_ptr message) {
|
||||
}
|
||||
|
||||
void IceTransport::processCandidate(const string &candidate) {
|
||||
mCandidateCallback(Candidate(candidate, getStreamName()));
|
||||
mCandidateCallback(Candidate(candidate, mMid));
|
||||
}
|
||||
|
||||
void IceTransport::processGatheringDone() { mCandidateCallback(nullopt); }
|
||||
@ -197,11 +198,6 @@ void IceTransport::changeState(uint32_t state) {
|
||||
}
|
||||
}
|
||||
|
||||
string IceTransport::getStreamName() const {
|
||||
const gchar *stream = nice_agent_get_stream_name(mNiceAgent.get(), mStreamId);
|
||||
return string(stream);
|
||||
}
|
||||
|
||||
void IceTransport::CandidateCallback(NiceAgent *agent, NiceCandidate *candidate,
|
||||
gpointer userData) {
|
||||
auto iceTransport = static_cast<rtc::IceTransport *>(userData);
|
||||
|
@ -68,13 +68,12 @@ private:
|
||||
void incoming(const byte *data, int size);
|
||||
void outgoing(message_ptr message);
|
||||
|
||||
string getStreamName() const;
|
||||
|
||||
void changeState(uint32_t state);
|
||||
void processCandidate(const string &candidate);
|
||||
void processGatheringDone();
|
||||
|
||||
Description::Role mRole;
|
||||
string mMid;
|
||||
State mState;
|
||||
|
||||
uint32_t mStreamId = 0;
|
||||
|
Reference in New Issue
Block a user