mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 23:25:33 +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;
|
string typeString() const;
|
||||||
Role role() const;
|
Role role() const;
|
||||||
string roleString() const;
|
string roleString() const;
|
||||||
|
string mid() const;
|
||||||
std::optional<string> fingerprint() const;
|
std::optional<string> fingerprint() const;
|
||||||
std::optional<uint16_t> sctpPort() 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::roleString() const { return roleToString(mRole); }
|
||||||
|
|
||||||
|
string Description::mid() const { return mMid; }
|
||||||
|
|
||||||
std::optional<string> Description::fingerprint() const { return mFingerprint; }
|
std::optional<string> Description::fingerprint() const { return mFingerprint; }
|
||||||
|
|
||||||
std::optional<uint16_t> Description::sctpPort() const { return mSctpPort; }
|
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,
|
IceTransport::IceTransport(const Configuration &config, Description::Role role,
|
||||||
candidate_callback candidateCallback, ready_callback ready)
|
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)),
|
mMainLoop(nullptr, nullptr), mCandidateCallback(std::move(candidateCallback)),
|
||||||
mReadyCallback(ready) {
|
mReadyCallback(ready) {
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ IceTransport::IceTransport(const Configuration &config, Description::Role role,
|
|||||||
G_CALLBACK(GatheringDoneCallback), this);
|
G_CALLBACK(GatheringDoneCallback), this);
|
||||||
|
|
||||||
mStreamId = nice_agent_add_stream(mNiceAgent.get(), 1);
|
mStreamId = nice_agent_add_stream(mNiceAgent.get(), 1);
|
||||||
if (mStreamId == 0)
|
if (!mStreamId)
|
||||||
throw std::runtime_error("Failed to add a stream");
|
throw std::runtime_error("Failed to add a stream");
|
||||||
|
|
||||||
nice_agent_set_stream_name(mNiceAgent.get(), mStreamId, "application");
|
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) {
|
void IceTransport::setRemoteDescription(const Description &description) {
|
||||||
mRole = description.role() == Description::Role::Active ? Description::Role::Passive
|
mRole = description.role() == Description::Role::Active ? Description::Role::Passive
|
||||||
: Description::Role::Active;
|
: Description::Role::Active;
|
||||||
|
mMid = description.mid();
|
||||||
|
|
||||||
if (nice_agent_parse_remote_sdp(mNiceAgent.get(), string(description).c_str()))
|
if (nice_agent_parse_remote_sdp(mNiceAgent.get(), string(description).c_str()))
|
||||||
throw std::runtime_error("Failed to parse remote SDP");
|
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) {
|
void IceTransport::processCandidate(const string &candidate) {
|
||||||
mCandidateCallback(Candidate(candidate, getStreamName()));
|
mCandidateCallback(Candidate(candidate, mMid));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IceTransport::processGatheringDone() { mCandidateCallback(nullopt); }
|
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,
|
void IceTransport::CandidateCallback(NiceAgent *agent, NiceCandidate *candidate,
|
||||||
gpointer userData) {
|
gpointer userData) {
|
||||||
auto iceTransport = static_cast<rtc::IceTransport *>(userData);
|
auto iceTransport = static_cast<rtc::IceTransport *>(userData);
|
||||||
|
@ -68,13 +68,12 @@ private:
|
|||||||
void incoming(const byte *data, int size);
|
void incoming(const byte *data, int size);
|
||||||
void outgoing(message_ptr message);
|
void outgoing(message_ptr message);
|
||||||
|
|
||||||
string getStreamName() const;
|
|
||||||
|
|
||||||
void changeState(uint32_t state);
|
void changeState(uint32_t state);
|
||||||
void processCandidate(const string &candidate);
|
void processCandidate(const string &candidate);
|
||||||
void processGatheringDone();
|
void processGatheringDone();
|
||||||
|
|
||||||
Description::Role mRole;
|
Description::Role mRole;
|
||||||
|
string mMid;
|
||||||
State mState;
|
State mState;
|
||||||
|
|
||||||
uint32_t mStreamId = 0;
|
uint32_t mStreamId = 0;
|
||||||
|
Reference in New Issue
Block a user