[feat] use 'const DecodedFrame*' instead of 'const DecodedFrame&' in Decode() method

This commit is contained in:
dijunkun
2025-04-25 17:30:29 +08:00
parent ab74361fd3
commit 1a34c6bc1d
10 changed files with 22 additions and 22 deletions

View File

@@ -76,7 +76,7 @@ int AomAv1Decoder::Init() {
int AomAv1Decoder::Decode(
std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame &)> on_receive_decoded_frame) {
std::function<void(const DecodedFrame *)> on_receive_decoded_frame) {
const uint8_t *data = received_frame->Buffer();
size_t size = received_frame->Size();
@@ -157,7 +157,7 @@ int AomAv1Decoder::Decode(
fwrite((unsigned char *)decoded_frame_->Buffer(), 1, decoded_frame_->Size(),
file_nv12_);
#endif
on_receive_decoded_frame(*decoded_frame_);
on_receive_decoded_frame(decoded_frame_);
return 0;
}

View File

@@ -24,7 +24,7 @@ class AomAv1Decoder : public VideoDecoder {
int Decode(
std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame &)> on_receive_decoded_frame);
std::function<void(const DecodedFrame *)> on_receive_decoded_frame);
std::string GetDecoderName() { return "AomAv1"; }

View File

@@ -117,7 +117,7 @@ int Dav1dAv1Decoder::Init() {
int Dav1dAv1Decoder::Decode(
std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame &)> on_receive_decoded_frame) {
std::function<void(const DecodedFrame *)> on_receive_decoded_frame) {
const uint8_t *data = received_frame->Buffer();
size_t size = received_frame->Size();
@@ -209,7 +209,7 @@ int Dav1dAv1Decoder::Decode(
fwrite((unsigned char *)decoded_frame_->Buffer(), 1, decoded_frame_->Size(),
file_nv12_);
#endif
on_receive_decoded_frame(*decoded_frame_);
on_receive_decoded_frame(decoded_frame_);
return 0;
}

View File

@@ -22,7 +22,7 @@ class Dav1dAv1Decoder : public VideoDecoder {
int Decode(
std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame &)> on_receive_decoded_frame);
std::function<void(const DecodedFrame *)> on_receive_decoded_frame);
std::string GetDecoderName() { return "Dav1dAv1"; }

View File

@@ -79,7 +79,7 @@ int NvidiaVideoDecoder::Init() {
int NvidiaVideoDecoder::Decode(
std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame &)> on_receive_decoded_frame) {
std::function<void(const DecodedFrame *)> on_receive_decoded_frame) {
if (!decoder) {
return -1;
}
@@ -120,7 +120,7 @@ int NvidiaVideoDecoder::Decode(
fwrite((unsigned char *)decoded_frame_->Buffer(), 1,
decoded_frame_->Size(), file_nv12_);
#endif
on_receive_decoded_frame(*decoded_frame_);
on_receive_decoded_frame(decoded_frame_);
}
}
}

View File

@@ -15,7 +15,7 @@ class NvidiaVideoDecoder : public VideoDecoder {
int Init();
int Decode(std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame&)> on_receive_decoded_frame);
std::function<void(const DecodedFrame*)> on_receive_decoded_frame);
std::string GetDecoderName() { return "NvidiaH264"; }

View File

@@ -114,7 +114,7 @@ int OpenH264Decoder::Init() {
int OpenH264Decoder::Decode(
std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame &)> on_receive_decoded_frame) {
std::function<void(const DecodedFrame *)> on_receive_decoded_frame) {
if (!openh264_decoder_) {
return -1;
}
@@ -204,7 +204,7 @@ int OpenH264Decoder::Decode(
fwrite((unsigned char *)decoded_frame_->Buffer(), 1,
decoded_frame_->Size(), nv12_stream_);
#endif
on_receive_decoded_frame(*decoded_frame_);
on_receive_decoded_frame(decoded_frame_);
}
}

View File

@@ -25,7 +25,7 @@ class OpenH264Decoder : public VideoDecoder {
int Init();
int Decode(std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame&)> on_receive_decoded_frame);
std::function<void(const DecodedFrame*)> on_receive_decoded_frame);
std::string GetDecoderName() { return "OpenH264"; }

View File

@@ -23,7 +23,7 @@ class VideoDecoder {
virtual int Decode(
std::unique_ptr<ReceivedFrame> received_frame,
std::function<void(const DecodedFrame&)> on_receive_decoded_frame) = 0;
std::function<void(const DecodedFrame*)> on_receive_decoded_frame) = 0;
virtual std::string GetDecoderName() = 0;

View File

@@ -319,19 +319,19 @@ void IceTransportController::OnReceiveCompleteFrame(
uint64_t t = clock_->CurrentTime();
if (video_decoder_) {
int num_frame_returned = video_decoder_->Decode(
std::move(received_frame), [this](const DecodedFrame& decoded_frame) {
if (on_receive_video_) {
std::move(received_frame), [this](const DecodedFrame* decoded_frame) {
if (on_receive_video_ && decoded_frame) {
XVideoFrame x_video_frame;
x_video_frame.data = (const char*)decoded_frame.Buffer();
x_video_frame.width = decoded_frame.DecodedWidth();
x_video_frame.height = decoded_frame.DecodedHeight();
x_video_frame.size = decoded_frame.Size();
x_video_frame.data = (const char*)decoded_frame->Buffer();
x_video_frame.width = decoded_frame->DecodedWidth();
x_video_frame.height = decoded_frame->DecodedHeight();
x_video_frame.size = decoded_frame->Size();
x_video_frame.captured_timestamp =
decoded_frame.CapturedTimestamp();
decoded_frame->CapturedTimestamp();
x_video_frame.received_timestamp =
decoded_frame.ReceivedTimestamp();
decoded_frame->ReceivedTimestamp();
x_video_frame.decoded_timestamp =
decoded_frame.DecodedTimestamp();
decoded_frame->DecodedTimestamp();
if (on_receive_video_) {
on_receive_video_(&x_video_frame, remote_user_id_.data(),