Skip to content

Commit

Permalink
fix: Fix black screen issue in AgoraVideoView caused by incorrect res…
Browse files Browse the repository at this point in the history
…ize handling (#2052)

The `resize` value from `OnVideoFrameReceived` became invalid after the
recent `iris` refactor(>= 4.3.2). We now manage the resize check
internally to prevent black screens in `AgoraVideoView`.
  • Loading branch information
littleGnAl authored Oct 21, 2024
1 parent f4ffd34 commit e9d6bcf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions shared/darwin/TextureRenderer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ @interface TextureRender ()
namespace {
class RendererDelegate : public agora::iris::VideoFrameObserverDelegate {
public:
RendererDelegate(void *renderer) : renderer_(renderer) { }
RendererDelegate(void *renderer) : renderer_(renderer), pre_width_(0), pre_height_(0) { }

void OnVideoFrameReceived(const void *videoFrame,
const IrisRtcVideoFrameConfig &config, bool resize) override {
Expand All @@ -36,11 +36,15 @@ void OnVideoFrameReceived(const void *videoFrame,
return;
}

int tmpWidth = vf->width;
int tmpHeight = vf->height;
bool is_resize = pre_width_ != tmpWidth || pre_height_ != tmpHeight;
pre_width_ = tmpWidth;
pre_height_ = tmpHeight;

CVPixelBufferRef _Nullable pixelBuffer = reinterpret_cast<CVPixelBufferRef>(vf->pixelBuffer);
if (pixelBuffer) {
if (resize) {
int tmpWidth = vf->width;
int tmpHeight = vf->height;
if (is_resize) {
dispatch_async(dispatch_get_main_queue(), ^{
[renderer.channel invokeMethod:@"onSizeChanged"
arguments:@{@"width": @(tmpWidth),
Expand Down Expand Up @@ -69,6 +73,8 @@ void OnVideoFrameReceived(const void *videoFrame,

public:
void *renderer_;
int pre_width_;
int pre_height_;
};
}

Expand Down

0 comments on commit e9d6bcf

Please sign in to comment.