mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[feat] add callback to notify the travsesal mode
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -31,6 +31,8 @@ class IceTransmission {
|
||||
kVideoFrameDelta = 4,
|
||||
};
|
||||
|
||||
enum TraversalType { TP2P = 0, TRelay = 1 };
|
||||
|
||||
public:
|
||||
IceTransmission(bool trickle_ice, bool offer_peer,
|
||||
std::string &transmission_id, std::string &user_id,
|
||||
@@ -66,6 +68,13 @@ class IceTransmission {
|
||||
on_receive_data_ = on_receive_data;
|
||||
}
|
||||
|
||||
void SetOnReceiveNetStatusReportFunc(
|
||||
std::function<void(TraversalType, const unsigned short,
|
||||
const unsigned short, void *)>
|
||||
on_receive_net_status_report) {
|
||||
on_receive_net_status_report_ = on_receive_net_status_report;
|
||||
}
|
||||
|
||||
int JoinTransmission();
|
||||
|
||||
int SetTransmissionId(const std::string &transmission_id);
|
||||
@@ -109,6 +118,7 @@ class IceTransmission {
|
||||
std::string remote_user_id_;
|
||||
std::string remote_ice_username_ = "";
|
||||
NiceComponentState state_ = NICE_COMPONENT_STATE_DISCONNECTED;
|
||||
TraversalType traversal_type_ = TraversalType::TP2P;
|
||||
|
||||
private:
|
||||
std::unique_ptr<IceAgent> ice_agent_ = nullptr;
|
||||
@@ -121,6 +131,9 @@ class IceTransmission {
|
||||
std::function<void(const char *, size_t, const char *, size_t)>
|
||||
on_receive_data_ = nullptr;
|
||||
std::function<void(std::string)> on_ice_status_change_ = nullptr;
|
||||
std::function<void(TraversalType, const unsigned short, const unsigned short,
|
||||
void *)>
|
||||
on_receive_net_status_report_ = nullptr;
|
||||
|
||||
private:
|
||||
std::unique_ptr<RtpCodec> video_rtp_codec_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user