mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
[fix] fix crash duo to invalid target resolution
This commit is contained in:
@@ -212,17 +212,16 @@ int IceTransportController::SendVideo(const XVideoFrame* video_frame) {
|
|||||||
new_frame.height = video_frame_copy->height;
|
new_frame.height = video_frame_copy->height;
|
||||||
new_frame.size = video_frame_copy->size;
|
new_frame.size = video_frame_copy->size;
|
||||||
new_frame.captured_timestamp = video_frame_copy->captured_timestamp;
|
new_frame.captured_timestamp = video_frame_copy->captured_timestamp;
|
||||||
if (target_width_.has_value() && target_height_.has_value()) {
|
if (target_width_.has_value() && target_height_.has_value() &&
|
||||||
if (target_width_.value() < video_frame_copy->width &&
|
target_width_.value() < video_frame_copy->width &&
|
||||||
target_height_.value() < video_frame_copy->height) {
|
target_height_.value() < video_frame_copy->height) {
|
||||||
resolution_adapter_->ResolutionDowngrade(
|
resolution_adapter_->ResolutionDowngrade(
|
||||||
video_frame_copy.get(), target_width_.value(),
|
video_frame_copy.get(), target_width_.value(),
|
||||||
target_height_.value(), &new_frame);
|
target_height_.value(), &new_frame);
|
||||||
} else {
|
} else {
|
||||||
new_frame.data = new char[video_frame_copy->size];
|
new_frame.data = new char[video_frame_copy->size];
|
||||||
memcpy((void*)new_frame.data, (void*)video_frame_copy->data,
|
memcpy((void*)new_frame.data, video_frame_copy->data,
|
||||||
video_frame_copy->size);
|
video_frame_copy->size);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RawFrame raw_frame((const uint8_t*)new_frame.data, new_frame.size,
|
RawFrame raw_frame((const uint8_t*)new_frame.data, new_frame.size,
|
||||||
@@ -600,23 +599,21 @@ void IceTransportController::PostUpdates(webrtc::NetworkControlUpdate update) {
|
|||||||
if (target_bitrate != target_bitrate_ && video_encoder_) {
|
if (target_bitrate != target_bitrate_ && video_encoder_) {
|
||||||
target_bitrate_ = target_bitrate;
|
target_bitrate_ = target_bitrate;
|
||||||
int width, height, target_width, target_height;
|
int width, height, target_width, target_height;
|
||||||
int valid = video_encoder_->GetResolution(&width, &height);
|
if (!video_encoder_->GetResolution(&width, &height)) {
|
||||||
if (valid != 0) {
|
if (0 == resolution_adapter_->GetResolution(target_bitrate_, width,
|
||||||
width = source_width_;
|
height, &target_width,
|
||||||
height = source_height_;
|
&target_height)) {
|
||||||
}
|
if (target_width != target_width_ ||
|
||||||
if (0 == resolution_adapter_->GetResolution(target_bitrate_, width,
|
target_height != target_height_) {
|
||||||
height, &target_width,
|
target_width_ = target_width;
|
||||||
&target_height)) {
|
target_height_ = target_height;
|
||||||
if (target_width != target_width_ || target_height != target_height_) {
|
|
||||||
target_width_ = target_width;
|
|
||||||
target_height_ = target_height;
|
|
||||||
|
|
||||||
b_force_i_frame_ = true;
|
b_force_i_frame_ = true;
|
||||||
|
}
|
||||||
|
} else if (target_width_.has_value() && target_height_.has_value()) {
|
||||||
|
target_width_.reset();
|
||||||
|
target_height_.reset();
|
||||||
}
|
}
|
||||||
} else if (target_width_.has_value() && target_height_.has_value()) {
|
|
||||||
target_width_.reset();
|
|
||||||
target_height_.reset();
|
|
||||||
}
|
}
|
||||||
video_encoder_->SetTargetBitrate(target_bitrate_);
|
video_encoder_->SetTargetBitrate(target_bitrate_);
|
||||||
// LOG_WARN("Set target bitrate [{}]bps", target_bitrate_);
|
// LOG_WARN("Set target bitrate [{}]bps", target_bitrate_);
|
||||||
|
|||||||
Reference in New Issue
Block a user