mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Fix turn config error
This commit is contained in:
@@ -22,7 +22,7 @@ int IceAgent::CreateIceAgent(juice_cb_state_changed_t on_state_changed,
|
||||
juice_cb_candidate_t on_candidate,
|
||||
juice_cb_gathering_done_t on_gathering_done,
|
||||
juice_cb_recv_t on_recv, void *user_ptr) {
|
||||
juice_set_log_level(JUICE_LOG_LEVEL_DEBUG);
|
||||
// juice_set_log_level(JUICE_LOG_LEVEL_DEBUG);
|
||||
|
||||
juice_set_log_handler([](juice_log_level_t level, const char *message) {
|
||||
if (JUICE_LOG_LEVEL_VERBOSE == level) {
|
||||
@@ -42,35 +42,32 @@ int IceAgent::CreateIceAgent(juice_cb_state_changed_t on_state_changed,
|
||||
}
|
||||
});
|
||||
|
||||
juice_config_t config;
|
||||
memset(&config, 0, sizeof(config));
|
||||
memset(&config_, 0, sizeof(config_));
|
||||
|
||||
// STUN server example
|
||||
config.stun_server_host = stun_ip_.c_str();
|
||||
config.stun_server_port = stun_port_;
|
||||
config_.stun_server_host = stun_ip_.c_str();
|
||||
config_.stun_server_port = stun_port_;
|
||||
|
||||
if (!turn_ip_.empty() && -1 != turn_port_ && !turn_username_.empty() &&
|
||||
!turn_password_.empty()) {
|
||||
juice_turn_server_t turn_server;
|
||||
memset(&turn_server, 0, sizeof(turn_server));
|
||||
turn_server.host = turn_ip_.c_str();
|
||||
turn_server.port = turn_port_;
|
||||
turn_server.username = turn_username_.c_str();
|
||||
turn_server.password = turn_password_.c_str();
|
||||
config.turn_servers = &turn_server;
|
||||
config.turn_servers_count = 1;
|
||||
memset(&turn_server_, 0, sizeof(turn_server_));
|
||||
turn_server_.host = turn_ip_.c_str();
|
||||
turn_server_.port = turn_port_;
|
||||
turn_server_.username = turn_username_.c_str();
|
||||
turn_server_.password = turn_password_.c_str();
|
||||
config_.turn_servers = &turn_server_;
|
||||
config_.turn_servers_count = 1;
|
||||
}
|
||||
|
||||
config.cb_state_changed = on_state_changed;
|
||||
config.cb_candidate = on_candidate;
|
||||
config.cb_gathering_done = on_gathering_done;
|
||||
config.cb_recv = on_recv;
|
||||
config.user_ptr = user_ptr;
|
||||
config_.cb_state_changed = on_state_changed;
|
||||
config_.cb_candidate = on_candidate;
|
||||
config_.cb_gathering_done = on_gathering_done;
|
||||
config_.cb_recv = on_recv;
|
||||
config_.user_ptr = user_ptr;
|
||||
|
||||
// config.local_port_range_begin = 40000;
|
||||
// config.local_port_range_end = 50000;
|
||||
config_.local_port_range_begin = 40000;
|
||||
config_.local_port_range_end = 50000;
|
||||
|
||||
agent_ = juice_create(&config);
|
||||
agent_ = juice_create(&config_);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ class IceAgent {
|
||||
juice_agent_t* agent_ = nullptr;
|
||||
char local_sdp_[JUICE_MAX_SDP_STRING_LEN];
|
||||
juice_state_t state_;
|
||||
juice_config_t config_;
|
||||
juice_turn_server_t turn_server_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -48,8 +48,6 @@ int NvidiaVideoEncoder::Init() {
|
||||
init_params.encodeWidth = frame_width_;
|
||||
init_params.encodeHeight = frame_height_;
|
||||
init_params.encodeConfig->profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;
|
||||
init_params.encodeConfig->encodeCodecConfig.h264Config.level =
|
||||
NV_ENC_LEVEL::NV_ENC_LEVEL_H264_31;
|
||||
init_params.encodeConfig->gopLength = keyFrameInterval_;
|
||||
init_params.encodeConfig->frameIntervalP = 1;
|
||||
init_params.encodeConfig->rcParams.rateControlMode =
|
||||
@@ -59,9 +57,13 @@ int NvidiaVideoEncoder::Init() {
|
||||
// init_params.encodeConfig->rcParams.minQP.qpIntra = 10;
|
||||
init_params.encodeConfig->rcParams.enableMaxQP = 1;
|
||||
init_params.encodeConfig->rcParams.maxQP.qpIntra = 22;
|
||||
init_params.encodeConfig->encodeCodecConfig.h264Config.level =
|
||||
NV_ENC_LEVEL::NV_ENC_LEVEL_H264_31;
|
||||
init_params.encodeConfig->encodeCodecConfig.h264Config.sliceMode = 1;
|
||||
init_params.encodeConfig->encodeCodecConfig.h264Config.sliceModeData =
|
||||
max_payload_size_;
|
||||
// init_params.encodeConfig->encodeCodecConfig.h264Config.disableSPSPPS = 1;
|
||||
// init_params.encodeConfig->encodeCodecConfig.h264Config.repeatSPSPPS = 1;
|
||||
|
||||
encoder_->CreateEncoder(&init_params);
|
||||
|
||||
@@ -82,7 +84,7 @@ int NvidiaVideoEncoder::Encode(
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (0 == seq_++ % (300)) {
|
||||
if (0 == seq_++ % 300) {
|
||||
ForceIdr();
|
||||
}
|
||||
|
||||
@@ -149,5 +151,7 @@ void NvidiaVideoEncoder::ForceIdr() {
|
||||
reconfig_params.forceIDR = 1;
|
||||
reconfig_params.resetEncoder = 1;
|
||||
|
||||
encoder_->Reconfigure(&reconfig_params);
|
||||
if (!encoder_->Reconfigure(&reconfig_params)) {
|
||||
LOG_ERROR("Failed to force I frame");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user