Skip to content

Commit

Permalink
Fix missing RTC_OBJC_TYPE macros (#100)
Browse files Browse the repository at this point in the history
* RTCVideoRendererAdapter

* RTCDisplayLinkTimer

* RTCNetworkMonitor

* RTCMTLVideoView

* RTCMTLRGBRenderer

* progress

* fix

* ObjCAudioDeviceDelegate

* remaining types

* fix macos

* revert prefix

* prefix string references

* fix RTCMTLVideoView symbols
  • Loading branch information
hiroshihorie authored Oct 11, 2023
1 parent fcab26b commit d5afc4b
Show file tree
Hide file tree
Showing 77 changed files with 247 additions and 242 deletions.
7 changes: 6 additions & 1 deletion sdk/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,12 @@ if (is_ios || is_mac) {
"objc/components/network/RTCNetworkMonitor.mm",
]

configs += [ ":used_from_extension" ]
configs += [
"..:common_objc",
":used_from_extension",
]

public_configs = [ ":common_config_objc" ]

frameworks = [ "Network.framework" ]

Expand Down
2 changes: 1 addition & 1 deletion sdk/objc/api/RTCVideoRendererAdapter+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface RTCVideoRendererAdapter ()
@interface RTC_OBJC_TYPE(RTCVideoRendererAdapter) ()

/**
* The Objective-C video renderer passed to this adapter during construction.
Expand Down
4 changes: 3 additions & 1 deletion sdk/objc/api/RTCVideoRendererAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#import <Foundation/Foundation.h>

#import "RTCMacros.h"

NS_ASSUME_NONNULL_BEGIN

/*
Expand All @@ -18,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
* adapter adapts calls made to that interface to the RTCVideoRenderer supplied
* during construction.
*/
@interface RTCVideoRendererAdapter : NSObject
@interface RTC_OBJC_TYPE (RTCVideoRendererAdapter): NSObject

- (instancetype)init NS_UNAVAILABLE;

Expand Down
19 changes: 9 additions & 10 deletions sdk/objc/api/RTCVideoRendererAdapter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@

namespace webrtc {

class VideoRendererAdapter
: public rtc::VideoSinkInterface<webrtc::VideoFrame> {
class VideoRendererAdapter : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
public:
VideoRendererAdapter(RTCVideoRendererAdapter* adapter) {
VideoRendererAdapter(RTC_OBJC_TYPE(RTCVideoRendererAdapter) * adapter) {
adapter_ = adapter;
size_ = CGSizeZero;
}

void OnFrame(const webrtc::VideoFrame& nativeVideoFrame) override {
RTC_OBJC_TYPE(RTCVideoFrame)* videoFrame = NativeToObjCVideoFrame(nativeVideoFrame);

CGSize current_size = (videoFrame.rotation % 180 == 0)
? CGSizeMake(videoFrame.width, videoFrame.height)
: CGSizeMake(videoFrame.height, videoFrame.width);
CGSize current_size = (videoFrame.rotation % 180 == 0) ?
CGSizeMake(videoFrame.width, videoFrame.height) :
CGSizeMake(videoFrame.height, videoFrame.width);

if (!CGSizeEqualToSize(size_, current_size)) {
size_ = current_size;
Expand All @@ -40,12 +39,12 @@ void OnFrame(const webrtc::VideoFrame& nativeVideoFrame) override {
}

private:
__weak RTCVideoRendererAdapter *adapter_;
__weak RTC_OBJC_TYPE(RTCVideoRendererAdapter) * adapter_;
CGSize size_;
};
}
} // namespace webrtc

@implementation RTCVideoRendererAdapter {
@implementation RTC_OBJC_TYPE (RTCVideoRendererAdapter) {
std::unique_ptr<webrtc::VideoRendererAdapter> _adapter;
}

Expand All @@ -60,7 +59,7 @@ - (instancetype)initWithNativeRenderer:(id<RTC_OBJC_TYPE(RTCVideoRenderer)>)vide
return self;
}

- (rtc::VideoSinkInterface<webrtc::VideoFrame> *)nativeVideoRenderer {
- (rtc::VideoSinkInterface<webrtc::VideoFrame>*)nativeVideoRenderer {
return _adapter.get();
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/objc/api/peerconnection/RTCAudioDeviceModule+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface RTCAudioDeviceModule ()
@interface RTC_OBJC_TYPE(RTCAudioDeviceModule) ()

- (instancetype)initWithNativeModule:(rtc::scoped_refptr<webrtc::AudioDeviceModule> )module
workerThread:(rtc::Thread *)workerThread;
Expand Down
4 changes: 2 additions & 2 deletions sdk/objc/api/peerconnection/RTCAudioDeviceModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ RTC_OBJC_EXPORT
// Executes low-level API's in sequence to switch the device
// Use outputDevice / inputDevice property unless you need to know if setting the device is
// successful.
- (BOOL)trySetOutputDevice:(nullable RTCIODevice *)device;
- (BOOL)trySetInputDevice:(nullable RTCIODevice *)device;
- (BOOL)trySetOutputDevice:(nullable RTC_OBJC_TYPE(RTCIODevice) *)device;
- (BOOL)trySetInputDevice:(nullable RTC_OBJC_TYPE(RTCIODevice) *)device;

- (BOOL)setDevicesUpdatedHandler: (nullable RTCOnAudioDevicesDidUpdate) handler;

Expand Down
20 changes: 10 additions & 10 deletions sdk/objc/api/peerconnection/RTCAudioDeviceModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (instancetype)initWithNativeModule:(rtc::scoped_refptr<webrtc::AudioDeviceModu
});
}

- (RTCIODevice *)outputDevice {
- (RTC_OBJC_TYPE(RTCIODevice) *)outputDevice {
return _workerThread->BlockingCall([self] {

NSArray<RTC_OBJC_TYPE(RTCIODevice) *> *devices = [self _outputDevices];
Expand All @@ -92,11 +92,11 @@ - (RTCIODevice *)outputDevice {
});
}

- (void)setOutputDevice: (RTCIODevice *)device {
- (void)setOutputDevice: (RTC_OBJC_TYPE(RTCIODevice) *)device {
[self trySetOutputDevice: device];
}

- (BOOL)trySetOutputDevice: (RTCIODevice *)device {
- (BOOL)trySetOutputDevice: (RTC_OBJC_TYPE(RTCIODevice) *)device {

return _workerThread->BlockingCall([self, device] {

Expand All @@ -108,7 +108,7 @@ - (BOOL)trySetOutputDevice: (RTCIODevice *)device {
}

if (device != nil) {
index = [devices indexOfObjectPassingTest:^BOOL(RTCIODevice *e, NSUInteger i, BOOL *stop) {
index = [devices indexOfObjectPassingTest:^BOOL(RTC_OBJC_TYPE(RTCIODevice) *e, NSUInteger i, BOOL *stop) {
return (*stop = [e.deviceId isEqualToString:device.deviceId]);
}];
if (index == NSNotFound) {
Expand All @@ -129,7 +129,7 @@ - (BOOL)trySetOutputDevice: (RTCIODevice *)device {
});
}

- (RTCIODevice *)inputDevice {
- (RTC_OBJC_TYPE(RTCIODevice) *)inputDevice {

return _workerThread->BlockingCall([self] {

Expand All @@ -145,11 +145,11 @@ - (RTCIODevice *)inputDevice {
});
}

- (void)setInputDevice: (RTCIODevice *)device {
- (void)setInputDevice: (RTC_OBJC_TYPE(RTCIODevice) *)device {
[self trySetInputDevice: device];
}

- (BOOL)trySetInputDevice: (RTCIODevice *)device {
- (BOOL)trySetInputDevice: (RTC_OBJC_TYPE(RTCIODevice) *)device {

return _workerThread->BlockingCall([self, device] {

Expand All @@ -161,7 +161,7 @@ - (BOOL)trySetInputDevice: (RTCIODevice *)device {
}

if (device != nil) {
index = [devices indexOfObjectPassingTest:^BOOL(RTCIODevice *e, NSUInteger i, BOOL *stop) {
index = [devices indexOfObjectPassingTest:^BOOL(RTC_OBJC_TYPE(RTCIODevice) *e, NSUInteger i, BOOL *stop) {
return (*stop = [e.deviceId isEqualToString:device.deviceId]);
}];
if (index == NSNotFound) {
Expand Down Expand Up @@ -261,7 +261,7 @@ - (BOOL)setDevicesUpdatedHandler: (nullable RTCOnAudioDevicesDidUpdate) handler
_native->PlayoutDeviceName(i, name, guid);
NSString *strGUID = [[NSString alloc] initWithCString:guid encoding:NSUTF8StringEncoding];
NSString *strName = [[NSString alloc] initWithCString:name encoding:NSUTF8StringEncoding];
RTCIODevice *device = [[RTCIODevice alloc] initWithType:RTCIODeviceTypeOutput deviceId:strGUID name:strName];
RTC_OBJC_TYPE(RTCIODevice) *device = [[RTC_OBJC_TYPE(RTCIODevice) alloc] initWithType:RTCIODeviceTypeOutput deviceId:strGUID name:strName];
[result addObject: device];
}
}
Expand All @@ -283,7 +283,7 @@ - (BOOL)setDevicesUpdatedHandler: (nullable RTCOnAudioDevicesDidUpdate) handler
_native->RecordingDeviceName(i, name, guid);
NSString *strGUID = [[NSString alloc] initWithCString:guid encoding:NSUTF8StringEncoding];
NSString *strName = [[NSString alloc] initWithCString:name encoding:NSUTF8StringEncoding];
RTCIODevice *device = [[RTCIODevice alloc] initWithType:RTCIODeviceTypeInput deviceId:strGUID name:strName];
RTC_OBJC_TYPE(RTCIODevice) *device = [[RTC_OBJC_TYPE(RTCIODevice) alloc] initWithType:RTCIODeviceTypeInput deviceId:strGUID name:strName];
[result addObject: device];
}
}
Expand Down
6 changes: 3 additions & 3 deletions sdk/objc/api/peerconnection/RTCAudioTrack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
class AudioSinkConverter : public rtc::RefCountInterface, public webrtc::AudioTrackSinkInterface {
private:
os_unfair_lock *lock_;
__weak RTCAudioTrack *audio_track_;
__weak RTC_OBJC_TYPE(RTCAudioTrack) *audio_track_;
int64_t total_frames_ = 0;
bool attached_ = false;

public:
AudioSinkConverter(RTCAudioTrack *audioTrack, os_unfair_lock *lock) {
AudioSinkConverter(RTC_OBJC_TYPE(RTCAudioTrack) *audioTrack, os_unfair_lock *lock) {
RTC_LOG(LS_INFO) << "RTCAudioTrack.AudioSinkConverter init";
audio_track_ = audioTrack;
lock_ = lock;
Expand Down Expand Up @@ -274,7 +274,7 @@ - (void)didCaptureSampleBuffer:(CMSampleBufferRef)sampleBuffer {
NSArray *renderers = [_renderers allObjects];
os_unfair_lock_unlock(&_lock);

for (id<RTCAudioRenderer> renderer in renderers) {
for (id<RTC_OBJC_TYPE(RTCAudioRenderer)> renderer in renderers) {
[renderer renderSampleBuffer:sampleBuffer];
}
}
Expand Down
10 changes: 5 additions & 5 deletions sdk/objc/api/peerconnection/RTCEncodedImage+Private.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ explicit ObjCEncodedImageBuffer(NSData *data) : data_(data) {}

NSData *data_;
};
}
} // namespace

// A simple wrapper around webrtc::EncodedImageBufferInterface to make it usable with associated
// objects.
@interface RTCWrappedEncodedImageBuffer : NSObject
@interface RTC_OBJC_TYPE (RTCWrappedEncodedImageBuffer): NSObject
@property(nonatomic) rtc::scoped_refptr<webrtc::EncodedImageBufferInterface> buffer;
- (instancetype)initWithEncodedImageBuffer:
(rtc::scoped_refptr<webrtc::EncodedImageBufferInterface>)buffer;
@end
@implementation RTCWrappedEncodedImageBuffer
@implementation RTC_OBJC_TYPE (RTCWrappedEncodedImageBuffer)
@synthesize buffer = _buffer;
- (instancetype)initWithEncodedImageBuffer:
(rtc::scoped_refptr<webrtc::EncodedImageBufferInterface>)buffer {
Expand All @@ -59,7 +59,7 @@ @implementation RTC_OBJC_TYPE (RTCEncodedImage)
(Private)

- (rtc::scoped_refptr<webrtc::EncodedImageBufferInterface>)encodedData {
RTCWrappedEncodedImageBuffer *wrappedBuffer =
RTC_OBJC_TYPE(RTCWrappedEncodedImageBuffer) *wrappedBuffer =
objc_getAssociatedObject(self, @selector(encodedData));
return wrappedBuffer.buffer;
}
Expand All @@ -68,7 +68,7 @@ - (void)setEncodedData:(rtc::scoped_refptr<webrtc::EncodedImageBufferInterface>)
return objc_setAssociatedObject(
self,
@selector(encodedData),
[[RTCWrappedEncodedImageBuffer alloc] initWithEncodedImageBuffer:buffer],
[[RTC_OBJC_TYPE(RTCWrappedEncodedImageBuffer) alloc] initWithEncodedImageBuffer:buffer],
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/objc/api/peerconnection/RTCIODevice+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface RTCIODevice ()
@interface RTC_OBJC_TYPE(RTCIODevice) ()

- (instancetype)initWithType:(RTCIODeviceType)type
deviceId:(NSString *)deviceId
Expand Down
2 changes: 1 addition & 1 deletion sdk/objc/api/peerconnection/RTCIODevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

NSString *const kDefaultDeviceId = @"default";

@implementation RTCIODevice
@implementation RTC_OBJC_TYPE(RTCIODevice)

@synthesize type = _type;
@synthesize deviceId = _deviceId;
Expand Down
2 changes: 1 addition & 1 deletion sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ RTC_OBJC_EXPORT
audioProcessingModule:
(nullable id<RTC_OBJC_TYPE(RTCAudioProcessingModule)>)audioProcessingModule;

@property(nonatomic, readonly) RTCAudioDeviceModule *audioDeviceModule;
@property(nonatomic, readonly) RTC_OBJC_TYPE(RTCAudioDeviceModule) *audioDeviceModule;

- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType;

Expand Down
21 changes: 11 additions & 10 deletions sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ @implementation RTC_OBJC_TYPE (RTCPeerConnectionFactory) {
std::unique_ptr<rtc::Thread> _workerThread;
std::unique_ptr<rtc::Thread> _signalingThread;
rtc::scoped_refptr<webrtc::AudioDeviceModule> _nativeAudioDeviceModule;
RTCDefaultAudioProcessingModule *_defaultAudioProcessingModule;
RTC_OBJC_TYPE(RTCDefaultAudioProcessingModule) *_defaultAudioProcessingModule;

BOOL _hasStartedAecDump;
}
Expand Down Expand Up @@ -133,16 +133,16 @@ - (instancetype)init {

- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpSenderCapabilitiesFor:(RTCRtpMediaType)mediaType {

webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpSenderCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]);
webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpSenderCapabilities([RTC_OBJC_TYPE(RTCRtpReceiver) nativeMediaTypeForMediaType: mediaType]);

return [[RTCRtpCapabilities alloc] initWithNativeCapabilities: capabilities];
return [[RTC_OBJC_TYPE(RTCRtpCapabilities) alloc] initWithNativeCapabilities: capabilities];
}

- (RTC_OBJC_TYPE(RTCRtpCapabilities) *)rtpReceiverCapabilitiesFor:(RTCRtpMediaType)mediaType {

webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpReceiverCapabilities([RTCRtpReceiver nativeMediaTypeForMediaType: mediaType]);
webrtc::RtpCapabilities capabilities = _nativeFactory->GetRtpReceiverCapabilities([RTC_OBJC_TYPE(RTCRtpReceiver) nativeMediaTypeForMediaType: mediaType]);

return [[RTCRtpCapabilities alloc] initWithNativeCapabilities: capabilities];
return [[RTC_OBJC_TYPE(RTCRtpCapabilities) alloc] initWithNativeCapabilities: capabilities];
}

- (instancetype)
Expand All @@ -164,10 +164,10 @@ - (instancetype)init {
}
rtc::scoped_refptr<webrtc::AudioDeviceModule> audio_device_module = [self createAudioDeviceModule:bypassVoiceProcessing];

if ([audioProcessingModule isKindOfClass:[RTCDefaultAudioProcessingModule class]]) {
_defaultAudioProcessingModule = (RTCDefaultAudioProcessingModule *)audioProcessingModule;
if ([audioProcessingModule isKindOfClass:[RTC_OBJC_TYPE(RTCDefaultAudioProcessingModule) class]]) {
_defaultAudioProcessingModule = (RTC_OBJC_TYPE(RTCDefaultAudioProcessingModule) *)audioProcessingModule;
} else {
_defaultAudioProcessingModule = [[RTCDefaultAudioProcessingModule alloc] init];
_defaultAudioProcessingModule = [[RTC_OBJC_TYPE(RTCDefaultAudioProcessingModule) alloc] init];
}

NSLog(@"AudioProcessingModule: %@", _defaultAudioProcessingModule);
Expand Down Expand Up @@ -273,8 +273,9 @@ - (instancetype)initWithNativeAudioEncoderFactory:
bypassVoiceProcessing == YES);
});

_audioDeviceModule = [[RTCAudioDeviceModule alloc] initWithNativeModule: _nativeAudioDeviceModule
workerThread: _workerThread.get()];
_audioDeviceModule =
[[RTC_OBJC_TYPE(RTCAudioDeviceModule) alloc] initWithNativeModule:_nativeAudioDeviceModule
workerThread:_workerThread.get()];

media_deps.adm = _nativeAudioDeviceModule;
media_deps.task_queue_factory = dependencies.task_queue_factory.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

NS_ASSUME_NONNULL_BEGIN

@interface RTCPeerConnectionFactoryBuilder (DefaultComponents)
@interface RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) (DefaultComponents)

+ (RTCPeerConnectionFactoryBuilder *)defaultBuilder;
+ (RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) *)defaultBuilder;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#import "sdk/objc/native/api/audio_device_module.h"
#endif

@implementation RTCPeerConnectionFactoryBuilder (DefaultComponents)
@implementation RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) (DefaultComponents)

+ (RTCPeerConnectionFactoryBuilder *)defaultBuilder {
RTCPeerConnectionFactoryBuilder *builder = [[RTCPeerConnectionFactoryBuilder alloc] init];
+ (RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) *)defaultBuilder {
RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) *builder = [[RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) alloc] init];
auto audioEncoderFactory = webrtc::CreateBuiltinAudioEncoderFactory();
[builder setAudioEncoderFactory:audioEncoderFactory];

Expand Down
4 changes: 2 additions & 2 deletions sdk/objc/api/peerconnection/RTCPeerConnectionFactoryBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class AudioProcessing;

NS_ASSUME_NONNULL_BEGIN

@interface RTCPeerConnectionFactoryBuilder : NSObject
@interface RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) : NSObject

+ (RTCPeerConnectionFactoryBuilder *)builder;
+ (RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) *)builder;

- (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)createPeerConnectionFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_processing/include/audio_processing.h"

@implementation RTCPeerConnectionFactoryBuilder {
@implementation RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) {
std::unique_ptr<webrtc::VideoEncoderFactory> _videoEncoderFactory;
std::unique_ptr<webrtc::VideoDecoderFactory> _videoDecoderFactory;
rtc::scoped_refptr<webrtc::AudioEncoderFactory> _audioEncoderFactory;
Expand All @@ -27,8 +27,8 @@ @implementation RTCPeerConnectionFactoryBuilder {
rtc::scoped_refptr<webrtc::AudioProcessing> _audioProcessingModule;
}

+ (RTCPeerConnectionFactoryBuilder *)builder {
return [[RTCPeerConnectionFactoryBuilder alloc] init];
+ (RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) *)builder {
return [[RTC_OBJC_TYPE(RTCPeerConnectionFactoryBuilder) alloc] init];
}

- (RTC_OBJC_TYPE(RTCPeerConnectionFactory) *)createPeerConnectionFactory {
Expand Down
Loading

0 comments on commit d5afc4b

Please sign in to comment.