[feat] use decode thread to decode frame

This commit is contained in:
dijunkun
2025-03-26 11:14:12 +08:00
parent dff7948245
commit 28dc9bf62d

View File

@@ -32,6 +32,9 @@ IceTransportController::~IceTransportController() {
if (task_queue_encode_) { if (task_queue_encode_) {
task_queue_encode_->ClearTasks(); task_queue_encode_->ClearTasks();
} }
if (task_queue_decode_) {
task_queue_decode_->ClearTasks();
}
user_data_ = nullptr; user_data_ = nullptr;
video_codec_inited_ = false; video_codec_inited_ = false;
@@ -323,21 +326,28 @@ int IceTransportController::OnReceiveDataRtpPacket(const char* data,
void IceTransportController::OnReceiveCompleteFrame( void IceTransportController::OnReceiveCompleteFrame(
const ReceivedFrame& received_frame) { const ReceivedFrame& received_frame) {
int num_frame_returned = video_decoder_->Decode( task_queue_decode_->PostTask([this, received_frame]() mutable {
received_frame, [this](DecodedFrame decoded_frame) { if (video_decoder_) {
if (on_receive_video_) { int num_frame_returned = video_decoder_->Decode(
XVideoFrame x_video_frame; received_frame, [this](DecodedFrame decoded_frame) {
x_video_frame.data = (const char*)decoded_frame.Buffer(); if (on_receive_video_) {
x_video_frame.width = decoded_frame.Width(); XVideoFrame x_video_frame;
x_video_frame.height = decoded_frame.Height(); x_video_frame.data = (const char*)decoded_frame.Buffer();
x_video_frame.size = decoded_frame.Size(); x_video_frame.width = decoded_frame.Width();
x_video_frame.captured_timestamp = decoded_frame.CapturedTimestamp(); x_video_frame.height = decoded_frame.Height();
x_video_frame.received_timestamp = decoded_frame.ReceivedTimestamp(); x_video_frame.size = decoded_frame.Size();
x_video_frame.decoded_timestamp = decoded_frame.DecodedTimestamp(); x_video_frame.captured_timestamp =
on_receive_video_(&x_video_frame, remote_user_id_.data(), decoded_frame.CapturedTimestamp();
remote_user_id_.size(), user_data_); x_video_frame.received_timestamp =
} decoded_frame.ReceivedTimestamp();
}); x_video_frame.decoded_timestamp =
decoded_frame.DecodedTimestamp();
on_receive_video_(&x_video_frame, remote_user_id_.data(),
remote_user_id_.size(), user_data_);
}
});
}
});
} }
void IceTransportController::OnReceiveCompleteAudio(const char* data, void IceTransportController::OnReceiveCompleteAudio(const char* data,