Skip to content

Commit

Permalink
Workaround: Render PixelBuffer in RTCMTLVideoView (#58)
Browse files Browse the repository at this point in the history
* workaround for iOS also

* comment
  • Loading branch information
hiroshihorie authored and cloudwebrtc committed Jun 6, 2023
1 parent 4c181eb commit a34fb56
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions sdk/objc/components/renderer/metal/RTCMTLVideoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -271,18 +271,15 @@ - (void)renderFrame:(nullable RTC_OBJC_TYPE(RTCVideoFrame) *)frame {
return;
}

#if TARGET_OS_IPHONE
self.videoFrame = frame;
#elif TARGET_OS_OSX
// Rendering native CVPixelBuffer is not supported on OS X.
// Workaround to support RTCCVPixelBuffer rendering.
// RTCMTLRGBRenderer seems to be broken at the moment.
BOOL useI420 = NO;
if ([frame.buffer isKindOfClass:[RTC_OBJC_TYPE(RTCCVPixelBuffer) class]]) {
RTC_OBJC_TYPE(RTCCVPixelBuffer) *buffer = (RTC_OBJC_TYPE(RTCCVPixelBuffer) *)frame.buffer;
const OSType pixelFormat = CVPixelBufferGetPixelFormatType(buffer.pixelBuffer);
useI420 = pixelFormat == kCVPixelFormatType_32BGRA || pixelFormat == kCVPixelFormatType_32ARGB;
}
self.videoFrame = useI420 ? [frame newI420VideoFrame] : frame;
#endif
}

#pragma mark - Cross platform
Expand Down

0 comments on commit a34fb56

Please sign in to comment.