mirror of
				https://github.com/kunkundi/crossdesk.git
				synced 2025-10-26 20:25:34 +08:00 
			
		
		
		
	[fix] fix send error when ice state change from ready to connected
This commit is contained in:
		| @@ -51,8 +51,8 @@ int IceAgent::CreateIceAgent(nice_cb_state_changed_t on_state_changed, | ||||
|     agent_ = nice_agent_new_full( | ||||
|         g_main_loop_get_context(gloop_), NICE_COMPATIBILITY_RFC5245, | ||||
|         (NiceAgentOption)(trickle_ice_ ? NICE_AGENT_OPTION_ICE_TRICKLE | | ||||
|                                              NICE_AGENT_OPTION_RELIABLE | ||||
|                                        : NICE_AGENT_OPTION_RELIABLE)); | ||||
|                                              NICE_AGENT_OPTION_NONE | ||||
|                                        : NICE_AGENT_OPTION_NONE)); | ||||
|  | ||||
|     if (agent_ == nullptr) { | ||||
|       LOG_ERROR("Failed to create agent_"); | ||||
| @@ -250,6 +250,6 @@ int IceAgent::Send(const char *data, size_t size) { | ||||
|   //   return -1; | ||||
|   // } | ||||
|  | ||||
|   nice_agent_send(agent_, stream_id_, 1, size, data); | ||||
|   int ret = nice_agent_send(agent_, stream_id_, 1, size, data); | ||||
|   return 0; | ||||
| } | ||||
| @@ -54,7 +54,10 @@ int IceTransmission::InitIceTransmission( | ||||
|           return -1; | ||||
|         } | ||||
|  | ||||
|         if (state_ != NICE_COMPONENT_STATE_READY) { | ||||
|         if (state_ != NICE_COMPONENT_STATE_CONNECTED && | ||||
|             state_ != NICE_COMPONENT_STATE_READY) { | ||||
|           LOG_ERROR("Ice is not connected, state = [{}]", | ||||
|                     nice_component_state_to_string(state_)); | ||||
|           return -2; | ||||
|         } | ||||
|  | ||||
| @@ -78,8 +81,10 @@ int IceTransmission::InitIceTransmission( | ||||
|           return -1; | ||||
|         } | ||||
|  | ||||
|         if (state_ != NICE_COMPONENT_STATE_READY) { | ||||
|           LOG_ERROR("Ice is not ready"); | ||||
|         if (state_ != NICE_COMPONENT_STATE_CONNECTED && | ||||
|             state_ != NICE_COMPONENT_STATE_READY) { | ||||
|           LOG_ERROR("Ice is not connected, state = [{}]", | ||||
|                     nice_component_state_to_string(state_)); | ||||
|           return -2; | ||||
|         } | ||||
|  | ||||
| @@ -103,7 +108,10 @@ int IceTransmission::InitIceTransmission( | ||||
|           return -1; | ||||
|         } | ||||
|  | ||||
|         if (state_ != NICE_COMPONENT_STATE_READY) { | ||||
|         if (state_ != NICE_COMPONENT_STATE_CONNECTED && | ||||
|             state_ != NICE_COMPONENT_STATE_READY) { | ||||
|           LOG_ERROR("Ice is not connected, state = [{}]", | ||||
|                     nice_component_state_to_string(state_)); | ||||
|           return -2; | ||||
|         } | ||||
|  | ||||
| @@ -120,7 +128,10 @@ int IceTransmission::InitIceTransmission( | ||||
|           return -1; | ||||
|         } | ||||
|  | ||||
|         if (state_ != NICE_COMPONENT_STATE_READY) { | ||||
|         if (state_ != NICE_COMPONENT_STATE_CONNECTED && | ||||
|             state_ != NICE_COMPONENT_STATE_READY) { | ||||
|           LOG_ERROR("Ice is not connected, state = [{}]", | ||||
|                     nice_component_state_to_string(state_)); | ||||
|           return -2; | ||||
|         } | ||||
|  | ||||
| @@ -137,7 +148,10 @@ int IceTransmission::InitIceTransmission( | ||||
|           return -1; | ||||
|         } | ||||
|  | ||||
|         if (state_ != NICE_COMPONENT_STATE_READY) { | ||||
|         if (state_ != NICE_COMPONENT_STATE_CONNECTED && | ||||
|             state_ != NICE_COMPONENT_STATE_READY) { | ||||
|           LOG_ERROR("Ice is not connected, state = [{}]", | ||||
|                     nice_component_state_to_string(state_)); | ||||
|           return -2; | ||||
|         } | ||||
|  | ||||
| @@ -345,7 +359,13 @@ int IceTransmission::SendAnswer() { | ||||
| } | ||||
|  | ||||
| int IceTransmission::SendData(DATA_TYPE type, const char *data, size_t size) { | ||||
|   if (NiceComponentState::NICE_COMPONENT_STATE_READY == state_) { | ||||
|   if (state_ != NICE_COMPONENT_STATE_CONNECTED && | ||||
|       state_ != NICE_COMPONENT_STATE_READY) { | ||||
|     LOG_ERROR("Ice is not connected, state = [{}]", | ||||
|               nice_component_state_to_string(state_)); | ||||
|     return -2; | ||||
|   } | ||||
|  | ||||
|   std::vector<RtpPacket> packets; | ||||
|  | ||||
|   if (DATA_TYPE::VIDEO == type) { | ||||
| @@ -370,13 +390,19 @@ int IceTransmission::SendData(DATA_TYPE type, const char *data, size_t size) { | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|   } | ||||
|  | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
| int IceTransmission::SendVideoData(VideoFrameType frame_type, const char *data, | ||||
|                                    size_t size) { | ||||
|   if (NiceComponentState::NICE_COMPONENT_STATE_READY == state_) { | ||||
|   if (state_ != NICE_COMPONENT_STATE_CONNECTED && | ||||
|       state_ != NICE_COMPONENT_STATE_READY) { | ||||
|     LOG_ERROR("Ice is not connected, state = [{}]", | ||||
|               nice_component_state_to_string(state_)); | ||||
|     return -2; | ||||
|   } | ||||
|  | ||||
|   std::vector<RtpPacket> packets; | ||||
|  | ||||
|   if (rtp_video_sender_) { | ||||
| @@ -387,7 +413,7 @@ int IceTransmission::SendVideoData(VideoFrameType frame_type, const char *data, | ||||
|     } | ||||
|     rtp_video_sender_->Enqueue(packets); | ||||
|   } | ||||
|   } | ||||
|  | ||||
|   return 0; | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user