[feat] add callback to notify the travsesal mode

This commit is contained in:
dijunkun
2024-07-30 17:31:44 +08:00
parent af49ebe63d
commit 54179722e5
6 changed files with 57 additions and 7 deletions

View File

@@ -222,6 +222,24 @@ int IceTransmission::InitIceTransmission(
[](NiceAgent *agent, guint stream_id, guint component_id,
const char *lfoundation, const char *rfoundation, gpointer user_ptr) {
LOG_INFO("new selected pair: [{}] [{}]", lfoundation, rfoundation);
NiceCandidate *local = nullptr;
NiceCandidate *remote = nullptr;
nice_agent_get_selected_pair(agent, stream_id, component_id, &local,
&remote);
if (user_ptr) {
IceTransmission *ice_transmission_obj =
static_cast<IceTransmission *>(user_ptr);
if (local->type == NICE_CANDIDATE_TYPE_RELAYED &&
remote->type == NICE_CANDIDATE_TYPE_RELAYED) {
LOG_INFO("Traversal using relay server");
ice_transmission_obj->traversal_type_ = TraversalType::TRelay;
} else {
LOG_INFO("Traversal using p2p");
ice_transmission_obj->traversal_type_ = TraversalType::TP2P;
}
ice_transmission_obj->on_receive_net_status_report_(
ice_transmission_obj->traversal_type_, 0, 0, nullptr);
}
},
[](NiceAgent *agent, guint stream_id, guint component_id, guint size,
gchar *buffer, gpointer user_ptr) {