mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
Fix connection status error: send packets only when ice status is ready
This commit is contained in:
@@ -222,6 +222,9 @@ int OpenH264Encoder::Encode(
|
||||
|
||||
if (on_encoded_image) {
|
||||
on_encoded_image((char *)encoded_frame_, encoded_frame_size_);
|
||||
if (SAVE_H264_STREAM) {
|
||||
fwrite(encoded_frame_, 1, encoded_frame_size_, file_h264_);
|
||||
}
|
||||
} else {
|
||||
OnEncodedImage((char *)encoded_frame_, encoded_frame_size_);
|
||||
}
|
||||
|
||||
@@ -126,8 +126,7 @@ int PeerConnection::Init(PeerConnectionParams params,
|
||||
on_connection_status_(ConnectionStatus::Connecting);
|
||||
} else if ("disconnected" == ice_status) {
|
||||
on_connection_status_(ConnectionStatus::Disconnected);
|
||||
} else if ("completed" == ice_status || "ready" == ice_status ||
|
||||
"connected" == ice_status) {
|
||||
} else if ("ready" == ice_status) {
|
||||
ice_ready_ = true;
|
||||
on_connection_status_(ConnectionStatus::Connected);
|
||||
b_force_i_frame_ = true;
|
||||
@@ -508,7 +507,7 @@ int PeerConnection::SendVideoData(const char *data, size_t size) {
|
||||
int ret = video_encoder_->Encode(
|
||||
(uint8_t *)data, size, [this](char *encoded_frame, size_t size) -> int {
|
||||
for (auto &ice_trans : ice_transmission_list_) {
|
||||
// LOG_ERROR("H264 frame size: [{}]", size);
|
||||
LOG_ERROR("H264 frame size: [{}]", size);
|
||||
ice_trans.second->SendData(IceTransmission::DATA_TYPE::VIDEO,
|
||||
encoded_frame, size);
|
||||
}
|
||||
@@ -529,8 +528,8 @@ int PeerConnection::SendAudioData(const char *data, size_t size) {
|
||||
[this](char *encoded_audio_buffer, size_t size) -> int {
|
||||
for (auto &ice_trans : ice_transmission_list_) {
|
||||
// LOG_ERROR("opus frame size: [{}]", size);
|
||||
ice_trans.second->SendData(IceTransmission::DATA_TYPE::AUDIO,
|
||||
encoded_audio_buffer, size);
|
||||
// ice_trans.second->SendData(IceTransmission::DATA_TYPE::AUDIO,
|
||||
// encoded_audio_buffer, size);
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user