Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing RTC_OBJC_TYPE macros #100

Merged
merged 13 commits into from
Oct 11, 2023
Prev Previous commit
Next Next commit
RTCMTLRGBRenderer
  • Loading branch information
hiroshihorie committed Oct 4, 2023
commit c9acfa7ea71d558951ebb163cad4759623d7e92b
3 changes: 2 additions & 1 deletion sdk/objc/components/renderer/metal/RTCMTLRGBRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
#import <Foundation/Foundation.h>

#import "RTCMTLRenderer.h"
#import "RTCMacros.h"

/** @abstract RGB/BGR renderer.
* @discussion This renderer handles both kCVPixelFormatType_32BGRA and
* kCVPixelFormatType_32ARGB.
*/
NS_AVAILABLE(10_11, 9_0)
@interface RTCMTLRGBRenderer : RTCMTLRenderer
@interface RTC_OBJC_TYPE (RTCMTLRGBRenderer): RTCMTLRenderer

@end
30 changes: 18 additions & 12 deletions sdk/objc/components/renderer/metal/RTCMTLRGBRenderer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@
} Vertex;

typedef struct {
float4 position[[position]];
float4 position [[position]];
float2 texcoord;
} VertexIO;

vertex VertexIO vertexPassthrough(constant Vertex *verticies[[buffer(0)]],
uint vid[[vertex_id]]) {
vertex VertexIO vertexPassthrough(constant Vertex * verticies [[buffer(0)]],
uint vid [[vertex_id]]) {
VertexIO out;
constant Vertex &v = verticies[vid];
out.position = float4(float2(v.position), 0.0, 1.0);
out.texcoord = v.texcoord;
return out;
}

fragment half4 fragmentColorConversion(VertexIO in[[stage_in]],
texture2d<half, access::sample> texture[[texture(0)]],
constant bool &isARGB[[buffer(0)]]) {
fragment half4 fragmentColorConversion(VertexIO in [[stage_in]],
texture2d<half, access::sample> texture [[texture(0)]],
constant bool &isARGB [[buffer(0)]]) {
constexpr sampler s(address::clamp_to_edge, filter::linear);

half4 out = texture.sample(s, in.texcoord);
Expand All @@ -56,7 +56,7 @@ fragment half4 fragmentColorConversion(VertexIO in[[stage_in]],
return out;
});

@implementation RTCMTLRGBRenderer {
@implementation RTC_OBJC_TYPE (RTCMTLRGBRenderer) {
// Textures.
CVMetalTextureCacheRef _textureCache;
id<MTLTexture> _texture;
Expand All @@ -73,8 +73,8 @@ - (BOOL)addRenderingDestination:(__kindof MTKView *)view {
}

- (BOOL)initializeTextureCache {
CVReturn status = CVMetalTextureCacheCreate(kCFAllocatorDefault, nil, [self currentMetalDevice],
nil, &_textureCache);
CVReturn status = CVMetalTextureCacheCreate(
kCFAllocatorDefault, nil, [self currentMetalDevice], nil, &_textureCache);
if (status != kCVReturnSuccess) {
RTCLogError(@"Metal: Failed to initialize metal texture cache. Return status is %d", status);
return NO;
Expand Down Expand Up @@ -130,9 +130,15 @@ - (BOOL)setupTexturesForFrame:(nonnull RTC_OBJC_TYPE(RTCVideoFrame) *)frame {
return NO;
}

CVReturn result = CVMetalTextureCacheCreateTextureFromImage(
kCFAllocatorDefault, _textureCache, pixelBuffer, nil, mtlPixelFormat,
width, height, 0, &textureOut);
CVReturn result = CVMetalTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
_textureCache,
pixelBuffer,
nil,
mtlPixelFormat,
width,
height,
0,
&textureOut);
if (result == kCVReturnSuccess) {
gpuTexture = CVMetalTextureGetTexture(textureOut);
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/objc/components/renderer/metal/RTCMTLVideoView.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@interface RTC_OBJC_TYPE (RTCMTLVideoView)
()<MTKViewDelegate> @property(nonatomic) RTCMTLI420Renderer *rendererI420;
@property(nonatomic) RTCMTLNV12Renderer *rendererNV12;
@property(nonatomic) RTCMTLRGBRenderer *rendererRGB;
@property(nonatomic) RTC_OBJC_TYPE(RTCMTLRGBRenderer) * rendererRGB;
@property(nonatomic) MTKView *metalView;
@property(atomic) RTC_OBJC_TYPE(RTCVideoFrame) * videoFrame;
@property(nonatomic) CGSize videoFrameSize;
Expand Down Expand Up @@ -107,7 +107,7 @@ + (RTCMTLI420Renderer *)createI420Renderer {
return [[RTCMTLI420RendererClass alloc] init];
}

+ (RTCMTLRGBRenderer *)createRGBRenderer {
+ (RTC_OBJC_TYPE(RTCMTLRGBRenderer) *)createRGBRenderer {
return [[RTCMTLRGBRendererClass alloc] init];
}

Expand Down